git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Sam Cates <sam@samcates.com>
Cc: git@vger.kernel.org
Subject: [PATCH] rebase: silence "git checkout" for noop rebase
Date: Tue, 28 Apr 2015 01:17:37 -0400	[thread overview]
Message-ID: <20150428051737.GE24580@peff.net> (raw)
In-Reply-To: <CAFGg4-hsRY9S4ok0-KSUWN7AWS=Eptk4E5B-LZcPFPsKrOP-_A@mail.gmail.com>

On Mon, Apr 27, 2015 at 12:05:41PM -0700, Sam Cates wrote:

> STEPS TO REPRODUCE:
> 1. git checkout master
> 2. git rebase --quiet master topic
> 
> EXPECTED RESULTS:
> The checkout and rebase occur with no output.
> 
> ACTUAL RESULTS:
> The output from the checkout is not suppressed.

Can you be more specific about your setup? What is the relationship
between "master" and "topic"?

If "topic" is already up to date with master, I get:

  $ git rebase --quiet master topic
  Switched to branch 'topic'

(the --quiet does suppress "Current branch topic is up to date").  The
patch below addresses that. But there may be other calls to git-checkout
that would need similar treatment (either unconditional "-q" as below,
or respecting $GIT_QUIET, depending on the individual case).

-- >8 --
Subject: 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 <peff@peff.net>
---
 git-rebase.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/git-rebase.sh b/git-rebase.sh
index 55da9db..90854e3 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -582,7 +582,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
-- 
2.4.0.rc3.477.gc25258d

      reply	other threads:[~2015-04-28  5:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-27 19:05 git-rebase doesn't forward --quiet to git-checkout Sam Cates
2015-04-28  5:17 ` Jeff King [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150428051737.GE24580@peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=sam@samcates.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).