Joey Hess [off-list ref] writes:
Appears to be a bug in git. Seems that it's assuming GIT_INDEX_FILE is
relative to the top of the worktree and not to the CWD.
I think that has always been the case. You can always specify it as
relative to the top. Of course, you can use absolute.
Junio C Hamano wrote:
Joey Hess [off-list ref] writes:
quoted
Appears to be a bug in git. Seems that it's assuming GIT_INDEX_FILE is
relative to the top of the worktree and not to the CWD.
I think that has always been the case. You can always specify it as
relative to the top. Of course, you can use absolute.
I think it *has* always been that way, but is there anything in the
documentation that indicates this is the case? This could well be best
fixed in the documentation.
Hmm, at least GIT_OBJECT_DIRECTORY also behaves this way.
(OTOH, GIT_DIR does not behave this way).
--
see shy jo
This is actually worse than I thought; when git is being run with a
detached work tree, GIT_INDEX_FILE is treated as a path relative to CWD,
instead of the normal behavior of relative the top of the work tree.
Normal and expected (according to this thread anyway):
joey@darkstar:~/src/other/git/Documentation> input="100644 8a1218a1024a212bb3db30becd860315f9f3ac52 1 frotz"
joey@darkstar:~/src/other/git/Documentation> echo "$input" | GIT_INDEX_FILE=.git/newindex git update-index --index-info
joey@darkstar:~/src/other/git/Documentation> ls ../.git/newindex
../.git/newindex
Fully detached worktree and git dir:
joey@darkstar:/> echo "$input" | GIT_INDEX_FILE=.git/index git --git-dir=/home/joey/src/other/git/.git --work-tree=/home/joey/src/other/git update-index --index-info
fatal: Unable to create '/.git/index.lock': No such file or directory
joey@darkstar:/> echo "$input" | GIT_WORK_TREE=/home/joey/src/other/git GIT_DIR=/home/joey/src/other/git/.git GIT_INDEX_FILE=.git/newindex git update-index --index-info
fatal: Unable to create '/.git/newindex.lock': No such file or directory
Work tree detached via git configuration:
joey@darkstar:~/src/other/git> git config core.worktree /home/joey/src/other/git/tmptree
joey@darkstar:~/src/other/git> mkdir tmptree
joey@darkstar:~/src/other/git> cd tmptree/
joey@darkstar:~/src/other/git/tmptree> mkdir Documentation
joey@darkstar:~/src/other/git/tmptree> cd Documentation/
joey@darkstar:~/src/other/git/tmptree/Documentation> echo "$input" | GIT_INDEX_FILE=.git/index git update-index --index-info
fatal: Unable to create '/home/joey/src/other/git/tmptree/.git/index.lock': No such file or directory
This seems to make it basically impossible for any program that wants to
use GIT_INDEX_FILE to use anything other than an absolute path;
there are too many configurations to keep straight that could change how
git interprets what should be a simple relative path to a file.
--
see shy jo