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

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

From
Shawn O. Pearce <spearce@spearce.org>
Date
Apr 22, 2007, 08:11 UTC
Message-ID
<20070422081106.GI17480@spearce.org>
In-Reply-To
<7virboq1tx.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> wrote:
Show 5 quoted lines
> "Shawn O. Pearce" <spearce@spearce.org> writes:
> 
> > Sometimes when you get the content of a file in a script you don't
> > want an error message for missing files; instead its OK to treat
> > a missing file the same as one whose content was empty.
...
> I am not sure if I agree with this logic.  How is this different
> from discarding stderr to /dev/null?
 
Its not any different.  But it means I can do:
	open(I,'-|','git','cat-file','--quiet','blob',"HEAD:users/$who");

and not worry about redirection to silence the case of when $who is not in the users subtree of HEAD. Sure, I could redirect that, but then that's something more like:

	if (open(I,'-|')) {
		open STDERR, ">/dev/null";
		exec 'git','cat-file','--quiet','blob',"HEAD:users/$who";
		exit 1;
	}

and uh, why, that's really annoying. And my Perl is rusty enough that I'm not even sure I did that right, I'd have to go look it up danngit. And didn't we just add a --quiet to git-diff? This is different, but not that much different..

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. Again, you have to redirect the one syntax, but not the other, even for just a simple -e. Which makes -e slightly less useful. So I also fixed that...

Anyway... if you really don't like it, drop it, I'll just have to go digging through the Perl manual... ;-)

-- 
Shawn.
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 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.