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
Jeff King <peff@peff.net>
Date
Mar 29, 2016, 22:16 UTC
Message-ID
<20160329221657.GA31811@sigill.intra.peff.net>
In-Reply-To
<20160329220003.GG1578@serenity.lan>
On Tue, Mar 29, 2016 at 11:00:03PM +0100, John Keeping wrote:
Show 12 quoted lines
> > We seem to get that wrong. I'm also not sure if it would make sense if
> > you explicitly set the two to be equal, like:
> > 
> >   # checking in your own refs?
> >   GIT_WORK_TREE=$(pwd) GIT_DIR=$(pwd) git add refs packed-refs
> > 
> > So the current behavior may just be weird-but-true.
> 
> This case definitely feels wrong:
> 
> 	$ GIT_WORK_TREE=$(cd ..; pwd) GIT_DIR=$(pwd) git rev-parse --is-inside-git-dir
> 	false
Yeah, and not just the is-inside-git-dir test:
  $ echo content >../file
  $ GIT_WORK_TREE=$(cd ..; pwd) GIT_DIR=$(pwd) git add file
  fatal: pathspec 'file' did not match any files

I'd expect that to work, and it doesn't, because we pass ".git/" as the "prefix" to cmd_add(). Which I guess is true, but it feels kind of weird (I think most people who set both variables like that would generally point to some other directory entirely, and we would have a NULL prefix).

The --is-inside-git-dir thing is related, but a different problem. I just got your follow-up mentioning that it doesn't take the prefix into account, which I agree it probably should.

-Peff
Previous: John KeepingNext: Junio C Hamano
Message 13 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.