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
Jonathan Nieder <jrnieder@gmail.com>
Date
Mar 20, 2010, 12:35 UTC
Message-ID
<20100320123520.GA29041@progeny.tock>
In-Reply-To
<1269051518-25099-2-git-send-email-bmeyer@rim.com>
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.)

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.

Jonathan
Previous: Benjamin C MeyerNext: Benjamin Meyer
Message 3 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.