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

Re: Inconsistent results from git rev-parse --show-toplevel

From
Jeff King <peff@peff.net>
Date
Jan 25, 2020, 19:53 UTC
Message-ID
<20200125195319.GA5519@coredump.intra.peff.net>
In-Reply-To
<TU4PR8401MB1117B81EB9240905AA36B1E9F9090@TU4PR8401MB1117.NAMPRD84.PROD.OUTLOOK.COM>
On Sat, Jan 25, 2020 at 07:31:20PM +0000, Crabtree, Andrew wrote:
Show 8 quoted lines
> > From: Junio C Hamano [mailto:gitster@pobox.com] 
> > Because you do not know where the top level is (otherwise you would not be asking "rev-parse --show-toplevel" about it), either is an option for you, 
> > but you can "unset GIT_DIR" to stop telling Git that it should not
> > perform the repository discovery.
> 
> Gotcha, thanks.  Would it make sense to have 'git rev-parse
> --show-toplevel' error out if GIT_DIR is set?  Or update the rev-parse
> documentation with a warning about GIT_DIR? 

No, it shouldn't be an error; setting GIT_DIR means that your current directory is the worktree. That _is_ confusing in some situations, but at this point it's a historical thing that I don't think we want to change. Discussing it in the documentation might be good (it's probably in there somewhere already, but a pointer from --show-toplevel doesn't seem unreasonable).

But the bigger thing, I think, is: who is setting GIT_DIR but not setting GIT_WORK_TREE to match? Because IMHO that's the situation that is causing the confusion.

-Peff
Previous: Crabtree, AndrewNext: Crabtree, Andrew
Message 4 of 8 in “Inconsistent results from git rev-parse --show-toplevel”
  1. Crabtree, AndrewJan 24, 2020
  2. Junio C HamanoJan 24, 2020
  3. Crabtree, AndrewJan 25, 2020
  4. Jeff KingJan 25, 2020
  5. Crabtree, AndrewJan 25, 2020
  6. Jeff KingJan 30, 2020
  7. Crabtree, AndrewJan 30, 2020
  8. Jeff KingFeb 14, 2020

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.