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

Re: [PATCH 2/4] pull: use --quiet rather than 2>/dev/null

From
BMBenjamin Meyer <ben@meyerhome.net>
Date
Mar 20, 2010, 18:59 UTC
Message-ID
<818FE4EC-5AE9-4F05-B9AD-E1753F7ED9E6@meyerhome.net>
In-Reply-To
<20100320123520.GA29041@progeny.tock>
On Mar 20, 2010, at 8:35 AM, Jonathan Nieder wrote:
Show 16 quoted lines
> Benjamin C Meyer wrote:
> 
>> -	for reflog in $(git rev-list -g $remoteref 2>/dev/null)
>> +	for reflog in $(git rev-list --quiet -g $remoteref)
> 
> Are you sure?  My local copy of git-rev-list.1 says
> 
>   --quiet
>        Don’t print anything to standard output. This form is primarily meant
>        to allow the caller to test the exit status to see if a range of
>        objects is fully connected (or not). It is faster than redirecting
>        stdout to /dev/null as the output does not have to be formatted.
> 
> A similar question applies to the other patches in this series: are
> you sure they suppress the right output?  (I haven’t checked, just
> asking.)
Thanks for reviewing the change
Yah looks like I made a mistake there, rev-list --quiet suppresses everything and not just stderr.  When going through this janitor task I noticed that the --quiet is very inconsistent among git commands.  Some suppress error messages, some suppress all messages.  This might be something to improve in the future as even though I kept referring to the documentation this error slipped in.
re-checking the other patches I think they are correct in their usage.  I ran the matching tests, the rebase ones passed, 3903-stash.sh is already failing before my patch and t3904-stash-patch.sh continues passing with the patch.  Other then running the tests in t/ is there anything I should do to verify patches?
Show 22 quoted lines
> Aside: that for loop looks like it could be improved.  Maybe it is worth
> factoring this into a separate function, something like:
> 
> old_upstream() {
> 	remoteref=$1 &&
> 	curr_branch=$2 &&
> 
> 	oldremoteref="$(git rev-parse -q --verify "$remoteref")" &&
> 	{ git rev-list -g "$remoteref" 2>/dev/null || return $?; } |
> 	while read reflog
> 	do
> 		if test -z "$(git rev-list "$curr_branch".."$reflog" | head -n 1)"
> 		then
> 			printf "%s\n" "$reflog"
> 			return 0
> 		fi
> 	done &&
> 	printf "%s\n" "$oldremoteref"
> }
> 
> In other words, we can avoid walking the whole reflog before starting
> to look for an ancestor for the current branch.
That looks like it would speed up that bit of code, but I am still figuring out the internals of git so I can't really comment on if this is the best solution etc.
-Benjamin Meyer
Previous: Jonathan NiederNext: Jonathan Nieder
Message 4 of 9 in “stash: use --quiet rather than using 2>/dev/null”
  1. 1/4 stash: use --quiet rather than using 2>/dev/nullBenjamin C Meyer, Mar 20, 2010
  2. 2/4 pull: use --quiet rather than 2>/dev/nullBenjamin C Meyer, Mar 20, 2010
  3. Jonathan NiederMar 20, 2010
  4. Benjamin MeyerMar 20, 2010
  5. Jonathan NiederMar 21, 2010
  6. Benjamin MeyerMar 21, 2010
  7. Jonathan NiederMar 23, 2010
  8. 3/4 rebase: use --quiet rather than 2>/dev/nullBenjamin C Meyer, Mar 20, 2010
  9. 4/4 rebase-interactive: use --quiet rather than 2>/dev/nullBenjamin C Meyer, Mar 20, 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.