git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Csaba Henk <csaba@lowlife.hu>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: [PATCH 2/2] rebase: write a reflog entry when finishing
Date: Fri, 27 May 2011 16:16:14 -0400	[thread overview]
Message-ID: <20110527201614.GB29836@sigill.intra.peff.net> (raw)
In-Reply-To: <BANLkTinyKQJQUHa8tn43=cCJMsVbgaZXjA@mail.gmail.com>

When we finish a rebase, our detached HEAD is at the final
result. We update the original branch ref with this result,
and then point the HEAD symbolic ref at the updated branch.
We write a reflog for the branch update, but not for the
update of HEAD.

Because we're already at the final result on the detached
HEAD, moving to the branch actually doesn't change our
commit sha1 at all. So in that sense, a reflog entry would
be pointless.

However, humans do read reflogs, and an entry saying "rebase
finished: returning to refs/heads/master" can be helpful in
understanding what is going on.

Signed-off-by: Jeff King <peff@peff.net>
---
See the minor test update for an example of how this could break people
or scripts who assume they know what's at which point in the reflog. In
general I think all bets are off with HEAD, because commands do their
work on a detached HEAD, and then provide a nice single-entry result in
the branch reflog (which is why I switched the test to use the more
stable master@{1}).

 git-rebase--interactive.sh    |    4 +++-
 git-rebase.sh                 |    4 +++-
 t/t3404-rebase-interactive.sh |    2 +-
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 41ba96a..65690af 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -510,7 +510,9 @@ do_next () {
 	refs/*)
 		message="$GIT_REFLOG_ACTION: $head_name onto $shortonto" &&
 		git update-ref -m "$message" $head_name $newhead $orig_head &&
-		git symbolic-ref HEAD $head_name
+		git symbolic-ref \
+		  -m "$GIT_REFLOG_ACTION: returning to $head_name" \
+		  HEAD $head_name
 		;;
 	esac && {
 		test ! -f "$state_dir"/verbose ||
diff --git a/git-rebase.sh b/git-rebase.sh
index 57cbe49..d7855ea 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -153,7 +153,9 @@ move_to_original_branch () {
 		message="rebase finished: $head_name onto $onto"
 		git update-ref -m "$message" \
 			$head_name $(git rev-parse HEAD) $orig_head &&
-		git symbolic-ref HEAD $head_name ||
+		git symbolic-ref \
+			-m "rebase finished: returning to $head_name" \
+			HEAD $head_name ||
 		die "Could not move back to $head_name"
 		;;
 	esac
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 7d8147b..47c8371 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -317,7 +317,7 @@ test_expect_success '--continue tries to commit' '
 '
 
 test_expect_success 'verbose flag is heeded, even after --continue' '
-	git reset --hard HEAD@{1} &&
+	git reset --hard master@{1} &&
 	test_tick &&
 	test_must_fail git rebase -v -i --onto new-branch1 HEAD^ &&
 	echo resolved > file1 &&
-- 
1.7.5.3.12.g99e25

  parent reply	other threads:[~2011-05-27 20:16 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-29 15:03 git symbolic-ref vs. reflog (vs. rebase) Csaba Henk
2011-04-29 16:19 ` Junio C Hamano
2011-04-29 17:21   ` Csaba Henk
2011-04-30  4:13     ` Jeff King
2011-05-02  8:46       ` Csaba Henk
2011-05-27 20:13         ` [PATCH 1/2] rebase: create HEAD reflog entry when aborting Jeff King
2011-05-27 20:16         ` Jeff King [this message]
2011-04-29 22:48   ` git symbolic-ref vs. reflog (vs. rebase) Jeff King
2011-04-29 23:00     ` Junio C Hamano
2011-04-30  3:58       ` Jeff King
2011-05-02  8:38       ` Csaba Henk

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=20110527201614.GB29836@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=csaba@lowlife.hu \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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).