git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* GIT_INDEX_FILE relative paths are relative to the work tree
@ 2015-11-27 15:17 Jack O'Connor
  2015-11-27 15:35 ` Duy Nguyen
  0 siblings, 1 reply; 2+ messages in thread
From: Jack O'Connor @ 2015-11-27 15:17 UTC (permalink / raw)
  To: git

When I use a relative path in the GIT_INDEX_FILE environment variable,
git interprets that path relative to the the work tree. This can be
confusing if my cwd is some subdirectory of my project; in that case
an index file is created in the project root rather than in my cwd. It
can also be confusing if I'm using --git-dir and --work-tree, in which
case the path is interpreted relative to the latter.

Is this behavior intentional? If so, I think it would be worth
mentioning in the documentation for GIT_INDEX_FILE. But I can't think
of a case where I would ever want an index file to end up inside my
work tree.

This also comes up in http://stackoverflow.com/a/7645492/823869. Using
absolute paths is a workaround.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: GIT_INDEX_FILE relative paths are relative to the work tree
  2015-11-27 15:17 GIT_INDEX_FILE relative paths are relative to the work tree Jack O'Connor
@ 2015-11-27 15:35 ` Duy Nguyen
  0 siblings, 0 replies; 2+ messages in thread
From: Duy Nguyen @ 2015-11-27 15:35 UTC (permalink / raw)
  To: Jack O'Connor; +Cc: git

On Fri, Nov 27, 2015 at 4:17 PM, Jack O'Connor <oconnor663@gmail.com> wrote:
> When I use a relative path in the GIT_INDEX_FILE environment variable,
> git interprets that path relative to the the work tree. This can be
> confusing if my cwd is some subdirectory of my project; in that case
> an index file is created in the project root rather than in my cwd. It
> can also be confusing if I'm using --git-dir and --work-tree, in which
> case the path is interpreted relative to the latter.
>
> Is this behavior intentional? If so, I think it would be worth
> mentioning in the documentation for GIT_INDEX_FILE. But I can't think
> of a case where I would ever want an index file to end up inside my
> work tree.

It would be more intuitive if $GIT_INDEX_FILE is relative to user's
current directory, not some random work tree root. And mentioning it
as such is not sufficient, we may be able to access the index file
without a work tree. This variable is so old that I'm afraid changing
its behavior will break stuff, so probably best to document "relative
$GIT_INDEX_FILE is undefined behavior"

> This also comes up in http://stackoverflow.com/a/7645492/823869. Using
> absolute paths is a workaround.



-- 
Duy

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-11-27 15:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-27 15:17 GIT_INDEX_FILE relative paths are relative to the work tree Jack O'Connor
2015-11-27 15:35 ` Duy Nguyen

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).