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

Re: [PATCH 3/3] Teach cat-file a --quiet option

From
Junio C Hamano <junkio@cox.net>
Date
Apr 22, 2007, 09:20 UTC
Message-ID
<7vd51wpxz2.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20070422081106.GI17480@spearce.org>
"Shawn O. Pearce" <spearce@spearce.org> writes:
> What's also annoying is cat-file today prints an error with -e if
> you use the "branch:path" syntax, but not if you supply the 40 byte
> hex SHA-1 of the blob in question.

I _think_ the intent of -e or any other "silently check" option is to signal "status" with exit code, while still indicating an error with the message.

For the particular example of "cat-file -e", whose purpose is to accept an object name string and report if such an object exists in the repository:

	$ git cat-file -e 45354a57ee7e3e42c7137db6c94fa968c6babe8d; echo $?
        0
	$ git cat-file -e 45354a57ee7e3e42c7137db6c94fa968c6babe8e; echo $?
        1
	$ git cat-file -e HEAD:NO-SUCH-PATH
	fatal: Not a valid object name HEAD:NO-SUCH-PATH

The input of the above two _look_ like valid object names and they return Ok/Bad because the user is asking "is there such an object?".

Technically speaking, with the last case, the user did not give a correctly formatted object name (treeish colon needs to be followed by a path that exists in the treeish to be considered a valid object name), so it can be argued that complaining is the right thing to do, but that is too literal to the law and I would agree that it probably is on the wrong side of the borderline.

Previous: Shawn O. PearceNext: Shawn O. Pearce
Message 4 of 6 in “Teach cat-file a --quiet option”
  1. 3/3 Teach cat-file a --quiet optionShawn O. Pearce, Apr 22, 2007
  2. Junio C HamanoApr 22, 2007
  3. Shawn O. PearceApr 22, 2007
  4. Junio C HamanoApr 22, 2007
  5. Shawn O. PearceApr 22, 2007
  6. Junio C HamanoApr 22, 2007

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.