{"thread":{"id":"40903","subject":"GIT_INDEX_FILE relative paths are relative to the work tree","startedAt":"2015-11-27T15:17:42Z","lastAt":"2015-11-27T15:35:35Z","messageCount":2,"participants":["Jack O'Connor","Duy Nguyen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"273799","messageId":"CA+6di1=4GwDg1kksJiKrVtDYSy=Sk=opWcg0=Ekwf0-OoQ2X9g@mail.gmail.com","threadId":"40903","inReplyTo":null,"subject":"GIT_INDEX_FILE relative paths are relative to the work tree","fromName":"Jack O'Connor","fromEmail":"oconnor663@gmail.com","sentAt":"2015-11-27T15:17:42Z","receivedAt":"2015-11-27T15:17:42Z","isPatch":false,"sender":{"key":"oconnor663@gmail.com","avatar":"https://gravatar.com/avatar/221557916c71e91c6adf326e4fcc9c8bd71dd4b855a7a2ad670107ff7155330d?d=mp&s=160"},"body":"When I use a relative path in the GIT_INDEX_FILE environment variable,\ngit interprets that path relative to the the work tree. This can be\nconfusing if my cwd is some subdirectory of my project; in that case\nan index file is created in the project root rather than in my cwd. It\ncan also be confusing if I'm using --git-dir and --work-tree, in which\ncase the path is interpreted relative to the latter.\n\nIs this behavior intentional? If so, I think it would be worth\nmentioning in the documentation for GIT_INDEX_FILE. But I can't think\nof a case where I would ever want an index file to end up inside my\nwork tree.\n\nThis also comes up in http://stackoverflow.com/a/7645492/823869. Using\nabsolute paths is a workaround.\n"},{"id":"273800","messageId":"CACsJy8CzGJxXNy1n+=AzOvPXjp983i_L1tg-_G+9i=qVd7FxmA@mail.gmail.com","threadId":"40903","inReplyTo":"CA+6di1=4GwDg1kksJiKrVtDYSy=Sk=opWcg0=Ekwf0-OoQ2X9g@mail.gmail.com","subject":"Re: GIT_INDEX_FILE relative paths are relative to the work tree","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2015-11-27T15:35:35Z","receivedAt":"2015-11-27T15:35:35Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Fri, Nov 27, 2015 at 4:17 PM, Jack O'Connor <oconnor663@gmail.com> wrote:\n> When I use a relative path in the GIT_INDEX_FILE environment variable,\n> git interprets that path relative to the the work tree. This can be\n> confusing if my cwd is some subdirectory of my project; in that case\n> an index file is created in the project root rather than in my cwd. It\n> can also be confusing if I'm using --git-dir and --work-tree, in which\n> case the path is interpreted relative to the latter.\n>\n> Is this behavior intentional? If so, I think it would be worth\n> mentioning in the documentation for GIT_INDEX_FILE. But I can't think\n> of a case where I would ever want an index file to end up inside my\n> work tree.\n\nIt would be more intuitive if $GIT_INDEX_FILE is relative to user's\ncurrent directory, not some random work tree root. And mentioning it\nas such is not sufficient, we may be able to access the index file\nwithout a work tree. This variable is so old that I'm afraid changing\nits behavior will break stuff, so probably best to document \"relative\n$GIT_INDEX_FILE is undefined behavior\"\n\n> This also comes up in http://stackoverflow.com/a/7645492/823869. Using\n> absolute paths is a workaround.\n\n\n\n-- \nDuy\n"}]}