git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Elliott Cable <me@ell.io>
To: git@vger.kernel.org
Subject: `git rev-parse --is-inside-work-tree` and $GIT_WORK_TREE
Date: Tue, 29 Mar 2016 06:42:44 -0500	[thread overview]
Message-ID: <CAPZ477NxXVNNwDvzaFt7GoUGuJwnOuX3y1N+aPtVRFD3E8dQBA@mail.gmail.com> (raw)

So, I find this behaviour a little strange; I can't determine if it's
a subtle bug, or intentionally undefined/‘fuzzy’ behaviour:

    $ cd a-repo/.git/
    $ pwd
    /path/to/a-repo/.git
    $ git rev-parse --is-inside-work-tree
    false
    $ export GIT_WORK_TREE=/path/to/a-repo
    $ git rev-parse --is-inside-work-tree
    true

i.e. when within the repository (the `.git` directory), and when that
directory is a sub-directory of the working-tree, `rev-parse
--is-inside-work-tree` reports *false* (reasonable enough, I suppose);
but then if `$GIT_WORK_TREE` is set to precisely the directory that
git was *already* assuming was the working-directory, then the same
command, in the same location, reports *true*.

This should probably be made consistent: either `rev-parse
--is-inside-work-tree` should report “true”, even inside the `.git`
dir, as long as that directory is a sub-directory of the working-tree
… or repository-directories / `$GIT_DIR` / `.git` directories should
be excluded from truthy responses to `rev-parse
--is-inside-work-tree`.


⁓ ELLIOTTCABLE — fly safe.
  http://ell.io/tt

             reply	other threads:[~2016-03-29 11:43 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-29 11:42 Elliott Cable [this message]
2016-03-29 11:53 ` `git rev-parse --is-inside-work-tree` and $GIT_WORK_TREE Elliott Cable
2016-03-29 12:33   ` John Keeping
2016-03-29 15:08     ` Junio C Hamano
2016-03-29 19:41       ` Jeff King
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=CAPZ477NxXVNNwDvzaFt7GoUGuJwnOuX3y1N+aPtVRFD3E8dQBA@mail.gmail.com \
    --to=me@ell.io \
    --cc=git@vger.kernel.org \
    /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).