From: Jeff King Date: Tue, 28 Apr 2015 05:17:37 +0000 (-0400) Subject: rebase: silence "git checkout" for noop rebase X-Git-Tag: v2.4.2~3^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=22946a942627d67b09a9630a036e48ce2823cd0c;p=git rebase: silence "git checkout" for noop rebase When the branch to be rebased is already up to date, we "git checkout" the branch, print an "up to date" message, and end the rebase early. However, our checkout may print "Switched to branch 'foo'" or "Already on 'foo'", even if the user has asked for "--quiet". We should avoid printing these messages at all, "--quiet" or no. Since the rebase is a noop, this checkout can be seen as optimizing out these other two checkout operations (that happen in a real rebase): 1. Moving to the detached HEAD to start the rebase; we always feed "-q" to checkout there, and instead rely on our own custom message (which respects --quiet). 2. Finishing a rebase, where we move to the final branch. Here we actually use update-ref rather than git-checkout, and produce no messages. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- diff --git a/git-rebase.sh b/git-rebase.sh index 47ca3b990b..ba74d11941 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -581,7 +581,7 @@ then # Lazily switch to the target branch if needed... test -z "$switch_to" || GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $switch_to" \ - git checkout "$switch_to" -- + git checkout -q "$switch_to" -- say "$(eval_gettext "Current branch \$branch_name is up to date.")" finish_rebase exit 0