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