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

Re: git rev-parse --show-toplevel inside `.git` returns 0 and prints nothing

From
Jeff King <peff@peff.net>
Date
Nov 19, 2019, 07:37 UTC
Message-ID
<20191119073754.GA30634@sigill.intra.peff.net>
In-Reply-To
<CA+dzEBmekzDVdqy=4GDF+Wm8e-YTPEdbh0oVowZNQYO67vEhEg@mail.gmail.com>
On Mon, Nov 18, 2019 at 08:13:02PM -0800, Anthony Sottile wrote:
Show 13 quoted lines
> > I think the reason this hasn't come up until now is callers are expected
> > to use require_work_tree() or "rev-parse --is-inside-work-tree" first.
> >
> > It would probably make sense for the rev-parse documentation to also
> > clarify what "the top-level directory" is.
> >
> > -Peff
> 
> I realize I forgot to include the X to my Y :) -- this was a totally
> silly case that I got as a bug report:
> https://github.com/pre-commit/pre-commit/issues/1219
> 
> I *expected* an error case but didn't get one
Yes, and I do agree that an error is the right thing.

Would that have helped your pre-commit script? I guess it would have barfed at that point. :) It sounds like it should be checking first that it has a working tree.

-Peff
Previous: Anthony SottileNext: Jeff King
Message 5 of 6 in “git rev-parse --show-toplevel inside `.git` returns 0 and prints nothing”
  1. Anthony SottileNov 18, 2019
  2. Junio C HamanoNov 19, 2019
  3. Jeff KingNov 19, 2019
  4. Anthony SottileNov 19, 2019
  5. Jeff KingNov 19, 2019
  6. Jeff KingNov 19, 2019

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.