From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: John Keeping <john@keeping.me.uk>, Elliott Cable <me@ell.io>,
git@vger.kernel.org
Subject: Re: `git rev-parse --is-inside-work-tree` and $GIT_WORK_TREE
Date: Tue, 29 Mar 2016 15:41:56 -0400 [thread overview]
Message-ID: <20160329194156.GA9527@sigill.intra.peff.net> (raw)
In-Reply-To: <xmqqshz9z5hu.fsf@gitster.mtv.corp.google.com>
On Tue, Mar 29, 2016 at 08:08:29AM -0700, Junio C Hamano wrote:
> So it is a misconfiguration if you only set GIT_WORK_TREE without
> setting GIT_DIR.
Hmm. I have frequently done this when my cwd is a git repository (e.g.,
a bare one), and it works as you'd expect (find the git-dir in the
current path, then the working tree via $GIT_WORK_TREE).
I always assumed that was the intended behavior, as it is the only one
that makes sense. I suspect I am not alone in having relied on this.
> Also, if you set both and run Git from outside $GIT_WORK_TREE, even
> though Git may try to do its best to give you a reasonable behaviour
> [*1*], it is working by accident not by design (see the statement
> you are making by setting GIT_WORK_TREE in the third bullet above).
>
> IOW, running from outside GIT_WORK_TREE is a misconfiguration.
>
> [Footnote]
>
> *1* Think what should happen when you are outside GIT_WORK_TREE and
> say this:
>
> $ git grep foo
>
> As you are not even inside the working tree, the command would
> not know in which subdirectory you want to find the string foo;
> the "reasonable behaviour" is to work on the whole working tree
> in this case.
Likewise, I always assumed this "reasonable behavior" was intended. When
we setup_git_directory(), we end up in the root of the working tree as
usual. The "prefix" must be empty, as we were not in the work tree at
all, and we do a whole-tree operation.
Those behaviors may not have been fully designed, but as they do the
only reasonable thing (besides dying with an error), and people may have
baked that assumption into their scripts, I think we should avoid
changing them unless there is a compelling reason.
-Peff
next prev parent reply other threads:[~2016-03-29 19:42 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-29 11:42 `git rev-parse --is-inside-work-tree` and $GIT_WORK_TREE Elliott Cable
2016-03-29 11:53 ` Elliott Cable
2016-03-29 12:33 ` John Keeping
2016-03-29 15:08 ` Junio C Hamano
2016-03-29 19:41 ` Jeff King [this message]
2016-03-29 19:56 ` Junio C Hamano
2016-03-29 20:26 ` Jeff King
2016-03-29 20:34 ` Jeff King
2016-03-29 20:52 ` John Keeping
2016-03-29 21:21 ` Jeff King
2016-03-29 22:00 ` John Keeping
2016-03-29 22:14 ` John Keeping
2016-03-29 22:16 ` Jeff King
2016-03-29 22:35 ` Junio C Hamano
2016-03-30 0:53 ` Duy Nguyen
2016-04-01 0:49 ` Elliott Cable
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160329194156.GA9527@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=john@keeping.me.uk \
--cc=me@ell.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 NNTP newsgroup(s).