Skip to content

Commit 22946a9

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 282616c commit 22946a9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

git-rebase.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ then
581581
# Lazily switch to the target branch if needed...
582582
test -z "$switch_to" ||
583583
GIT_REFLOG_ACTION="$GIT_REFLOG_ACTION: checkout $switch_to" \
584-
git checkout "$switch_to" --
584+
git checkout -q "$switch_to" --
585585
say "$(eval_gettext "Current branch \$branch_name is up to date.")"
586586
finish_rebase
587587
exit 0

0 commit comments

Comments
 (0)