On Tue, 27 Oct 2015 22:12:51 -0700 (PDT)
ozzloy <ozz...@gmail.com> wrote:

> i am writing a script to test exactly what's staged for the next
> commit. this should work even on root commit, and in orphan branches,
> so using stash by itself doesn't work because there's no HEAD for
> stash to stash on.
> my current solution in those situations is to:
> 0 commit the index
> 1 stash unstaged unignored files
> 2 run tests and save result
> 3 stash pop
> 4 delete HEAD
> 5 return the saved test result
> my concern is that step 0 might modify the index.
> if there's a better way to test the index, i'd be happy to hear it

I have one ide and one question.

The idea: use `git checkout-index` with a relocated work tree
(something like the result of running `mktemp -d /tmp/gitXXXXXX`)
and build there.  This will basically replace step 0 and remove
steps 1,3-5.  Basically, you'd do:

  DIR=`mktemp -d /tmp/gitXXXXXX`
  trap "rm -rf '$DIR'" TERM INT EXIT
  git --work-tree="$DIR" checkout-index --all
  make test -C "$DIR"

The question is: why are you concerned with the state of the file
representing the index at all?  As I've already hinted, the behaviour
of the index file during committing appears to be not documented which
means Git is free to actually update the index when it records a commit.
So what would maintaining the index's file mtime etc would buy you?

You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to