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

Re: GIT_INDEX_FILE relative path breaks in subdir

From
Joey Hess <id@joeyh.name>
Date
May 22, 2016, 19:04 UTC
Message-ID
<20160522190404.GA20998@kitenet.net>
In-Reply-To
<20160517182645.GA27396@kitenet.net>

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
Previous: Joey HessNext: Junio C Hamano
Message 4 of 9 in “GIT_INDEX_FILE relative path breaks in subdir”
  1. Joey HessMay 17, 2016
  2. Junio C HamanoMay 17, 2016
  3. Joey HessMay 17, 2016
  4. Joey HessMay 22, 2016
  5. Junio C HamanoMay 23, 2016
  6. Joey HessMay 23, 2016
  7. Junio C HamanoMay 23, 2016
  8. Joey HessMay 23, 2016
  9. Junio C HamanoMay 23, 2016

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.