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

Re: `git rev-parse --is-inside-work-tree` and $GIT_WORK_TREE

From
John Keeping <john@keeping.me.uk>
Date
Mar 29, 2016, 12:33 UTC
Message-ID
<20160329123306.GD1578@serenity.lan>
In-Reply-To
<CAPZ477PD7SkRg7T_Y_n27Hjw5TeW6Sh0-vtoP6-4xUDraC7OiA@mail.gmail.com>
On Tue, Mar 29, 2016 at 06:53:35AM -0500, Elliott Cable wrote:
Show 14 quoted lines
> On Tue, Mar 29, 2016 at 6:42 AM, Elliott Cable <me@ell.io> wrote:
> > So, I find this behaviour a little strange; I can't determine if it's
> > a subtle bug, or intentionally undefined/‘fuzzy’ behaviour ...
> 
> Oh lord, it gets worse ...
> 
> $ cd a-repo
> $ git rev-parse --is-inside-work-tree; git rev-parse --is-inside-git-dir
> true
> false
> $ cd .git
> $ git rev-parse --is-inside-work-tree; git rev-parse --is-inside-git-dir
> false
> true

I believe these are working correctly, the .git directory is not part of the working tree.

> $ export GIT_WORK_TREE="$(git rev-parse --show-toplevel)"   # !!!

Did you check the value of GIT_WORK_TREE here? When I try it's the empty string.

If I set the core.worktree config variable to ".." then rev-parse does find the working tree correctly. I recall some previous discussion about this but I can't find it in the list archives from a quick search.

Show 7 quoted lines
> $ git rev-parse --is-inside-work-tree; git rev-parse --is-inside-git-dir
> true
> false
> $ # !!?!?
> 
> So, basically, if `$GIT_WORK_TREE` is set at all, it appears that the
> `rev-parse --is-inside...` flags don't function reliably at all.

If you set GIT_WORK_TREE you're telling Git to override all of the normal detection logic. What version of Git are you using? When I try this it says:

	fatal: The empty string is not a valid path

If I set GIT_WORK_TREE to the correct value for this repository then it behaves the same as with the auto-detection logic.

Previous: Elliott CableNext: Junio C Hamano
Message 3 of 16 in “`git rev-parse --is-inside-work-tree` and $GIT_WORK_TREE”
  1. Elliott CableMar 29, 2016
  2. Elliott CableMar 29, 2016
  3. John KeepingMar 29, 2016
  4. Junio C HamanoMar 29, 2016
  5. Jeff KingMar 29, 2016
  6. Junio C HamanoMar 29, 2016
  7. Jeff KingMar 29, 2016
  8. Jeff KingMar 29, 2016
  9. John KeepingMar 29, 2016
  10. Jeff KingMar 29, 2016
  11. John KeepingMar 29, 2016
  12. John KeepingMar 29, 2016
  13. Jeff KingMar 29, 2016
  14. Junio C HamanoMar 29, 2016
  15. Duy NguyenMar 30, 2016
  16. Elliott CableApr 1, 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.