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

GIT_INDEX_FILE relative path breaks in subdir

From
Joey Hess <id@joeyh.name>
Date
May 17, 2016, 17:18 UTC
Message-ID
<20160517171836.GA12183@kitenet.net>

joey@darkstar:/tmp>git init test Initialized empty Git repository in /tmp/test/.git/ joey@darkstar:/tmp>cd test joey@darkstar:/tmp/test>mkdir sub joey@darkstar:/tmp/test>cd sub joey@darkstar:/tmp/test/sub>GIT_INDEX_FILE=../.git/otherindex git write-tree fatal: Unable to create '/tmp/test/../.git/otherindex.lock': No such file or directory

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.

Workaround: Use absolute path to the index file.

joey@darkstar:/tmp/test/sub>GIT_INDEX_FILE=`pwd`/../.git/otherindex git write-tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904 joey@darkstar:/tmp/test/sub>ls ../.git/otherindex ../.git/otherindex

git version 2.8.1
-- 
see shy jo
Next: Junio C Hamano
Message 1 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.