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

3 messages, 2 authors, 2016-06-15 · open the first message on its own page

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

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:43:06

"Shawn O. Pearce" [off-list ref] 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.

This is especially true if the script is using something like
`cat-file blob HEAD:path/to/file` to look at an optional file's
content.
I am not sure if I agree with this logic.  How is this different
from discarding stderr to /dev/null?

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

From: Shawn O. Pearce <hidden>
Date: 2016-06-15 22:43:06

Junio C Hamano [off-list ref] wrote:
"Shawn O. Pearce" [off-list ref] writes:
quoted
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.

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

From: Shawn O. Pearce <hidden>
Date: 2016-06-15 22:43:06

Junio C Hamano [off-list ref] wrote:
"Shawn O. Pearce" [off-list ref] writes:
quoted
This is especially true if the script is using something like
`cat-file blob HEAD:path/to/file` to look at an optional file's
content.
I am not sure if I agree with this logic.  How is this different
from discarding stderr to /dev/null?
Also, a redirect of stderr to /dev/null kills other error messages
that might be interesting to see on stderr of the caller, like if
a packfile isn't readable...  while my --quiet patch doesn't.j The
--quiet flag only kills errors that occurred because the requested
object doesn't exist.

-- 
Shawn.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help