threads / discuss / 12760

"git rev-parse --git-dir" fails from inside .git/<any-subdir>

Subject: "git rev-parse --git-dir" fails from inside .git/<any-subdir>

## tl;dr

One message between Mar 18, 2008 and Mar 18, 2008.

replies: 0people: 1as markdown or json

Jean-Luc Herren· Mar 18, 2008, 23:38 UTC · lore
Hello list!

I noticed that "git rev-parse --git-dir" doesn't work properly when called from inside a sub-directory of .git. It seems setup_git_directory_gently() is the problem, because it simply calls chdir("..") until "." is a valid git directory and it then sets GIT_DIR = ".". But this relative path only works as long as you stay in the directory that setup_git_directory_gently() has put you in. It won't work when git-sh-setup uses GIT_DIR=$(git rev-parse --git-dir).

This causes "git repack -a -f" to fail with "Nothing new to pack." from inside .git/objects/pack, which would be handy to test different parameters and compare the resulting pack files.

I don't know whether setup_git_directory_gently() or rather builtin-rev-parse.c needs to be changed, I'll let someone else do this as I don't know the code base well enough.

jlh

← back to recent threads