git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
JHJean-Luc Herren <jlh@gmx.ch>
Date
Mar 18, 2008, 23:38 UTC
Message-ID
<47E05274.3070908@gmx.ch>
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
Message 1 of 1 in “"git rev-parse --git-dir" fails from inside .git/<any-subdir>”
  1. Jean-Luc HerrenMar 18, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.