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

Re: Q about git rev-parse {--is-inside-work-tree, --show-cdup}

From
Jeff King <peff@peff.net>
Date
Dec 3, 2010, 21:50 UTC
Message-ID
<20101203215032.GB3972@sigill.intra.peff.net>
In-Reply-To
<7v4oauo8fj.fsf@alter.siamese.dyndns.org>
On Fri, Dec 03, 2010 at 01:25:36PM -0800, Junio C Hamano wrote:
Show 10 quoted lines
> > 1. Wouldn't it be useful, if "git rev-parse" (1) had an option "-q" that
> > simply indicates whether "--is-inside-work-tree" is true by means of the
> > return code? Actually it has an option "-q" but that doesn't work with
> > "--is-inside-work-tree".
> 
> That would break existing scripts that expect "-q" to squelch only the
> error output, no?  I think the risk of breaking existing scripts that
> other people wrote over time that you (and I) haven't seen outweighs any
> benefit (i.e. "if test $(rev-parse...) = true" vs "if rev-parse...") you
> are seeing here.

Right now "-q" doesn't do _anything_ for --is-inside-work-tree, AFAICT. It is a useless no-op. So I don't know if we are breaking anybody. What does somebody doing "git rev-parse -q --is-inside-work-tree" expect to happen?

I don't see why they would expect it to suppress error output. Usually "-q" is about "suppress non-essential output, but keep errors coming". If you wanted to suppress errors, you would use "2>/dev/null".

That being said, in my original reply I only half-thought about Dirk's problem, and considered more the number of times "git rev-parse -q" has annoyed me in the past by doing nothing[1], and just assumed this was another such case. It really isn't that hard to just check $(git rev-parse) in this instance.

-Peff

[1] I wish I could remember my exact case. It's something that I remember coming up no more than once every month or two, but that annoys me every time, because it doesn't do what I expect.

-Peff
Previous: Junio C HamanoNext: Dirk Süsserott
Message 4 of 6 in “Q about git rev-parse {--is-inside-work-tree, --show-cdup}”
  1. Dirk SüsserottDec 3, 2010
  2. Jeff KingDec 3, 2010
  3. Junio C HamanoDec 3, 2010
  4. Jeff KingDec 3, 2010
  5. Dirk SüsserottDec 4, 2010
  6. Andreas SchwabDec 4, 2010

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.