rebase -i: provide reasonable reflog for the rebased branch
If your rebase succeeded, the HEAD's reflog will still show the whole mess, but "<branchname>@{1}" now shows the state _before_ the rebase, so that you can reset (or compare) the original and the rebased revisions more easily. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
Jun 25, 2007 at 18:58 UTC
68a163c9b483ae352fcfee8c4505d113213daa73
2 files changed
+12
-2
git-rebase--interactive.sh
+8
-2
@@ -151,8 +151,14 @@ do_next () {
151
esac
152
test -s "$TODO" && return
153
154
- HEAD=$(git rev-parse HEAD)
155
- HEADNAME=$(cat "$DOTEST"/head-name)
154
+ comment_for_reflog finish &&
155
+ HEADNAME=$(cat "$DOTEST"/head-name) &&
156
+ OLDHEAD=$(cat "$DOTEST"/head) &&
157
+ SHORTONTO=$(git rev-parse --short $(cat "$DOTEST"/onto)) &&
158
+ NEWHEAD=$(git rev-parse HEAD) &&
159
+ message="$GIT_REFLOG_ACTION: $HEADNAME onto $SHORTONTO)" &&
160
+ git update-ref -m "$message" $HEADNAME $NEWHEAD $OLDHEAD &&
161
+ git symbolic-ref HEAD $HEADNAME &&
162
rm -rf "$DOTEST" &&
163
warn "Successfully rebased and updated $HEADNAME."
164
t/t3404-rebase-interactive.sh
+4
@@ -99,6 +99,10 @@ test_expect_success 'rebase on top of a non-conflicting commit' '
99
test $(git rev-parse I) = $(git rev-parse HEAD~2)
100
'
101
102
+test_expect_success 'reflog for the branch shows state before rebase' '
103
+ test $(git rev-parse branch1@{1}) = $(git rev-parse original-branch1)
104
+'
105
+
106
test_expect_success 'exchange two commits' '
107
FAKE_LINES="2 1" git rebase -i HEAD~2 &&
108
test H = $(git cat-file commit HEAD^ | tail -n 1) &&