rebase -m: Fix incorrect short-logs of already applied commits.
When a topic branch is rebased, some of whose commits are already cherry-picked upstream: o--X--A--B--Y <- master \ A--B--Z <- topic then 'git rebase -m master' would report: Already applied: 0001 Y Already applied: 0002 Y With this fix it reports the expected: Already applied: 0001 A Already applied: 0002 B As an added bonus, this change also avoids 'echo' of a commit message, which might contain escapements. Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Sixt committed
Sep 1, 2007 at 09:25 UTC
7afa845edc09d2818af5fe67a0eb45ec579d1260
2 files changed
+52
-5
git-rebase.sh
+8
-5
@@ -59,20 +59,23 @@ continue_merge () {
59
die "$RESOLVEMSG"
60
fi
61
62
+ cmt=`cat $dotest/current`
63
if ! git diff-index --quiet HEAD
64
then
64
- if ! git-commit -C "`cat $dotest/current`"
65
+ if ! git-commit -C "$cmt"
66
then
67
echo "Commit failed, please do not call \"git commit\""
68
echo "directly, but instead do one of the following: "
69
die "$RESOLVEMSG"
70
fi
70
- printf "Committed: %0${prec}d" $msgnum
71
+ printf "Committed: %0${prec}d " $msgnum
72
+ git rev-list --pretty=oneline -1 HEAD | \
73
+ sed 's/^[a-f0-9]\+ //'
74
else
72
- printf "Already applied: %0${prec}d" $msgnum
75
+ printf "Already applied: %0${prec}d " $msgnum
76
+ git rev-list --pretty=oneline -1 "$cmt" | \
77
+ sed 's/^[a-f0-9]\+ //'
78
fi
74
- echo ' '`git rev-list --pretty=oneline -1 HEAD | \
75
- sed 's/^[a-f0-9]\+ //'`
79
80
prev_head=`git rev-parse HEAD^0`
81
# save the resulting commit so we can read-tree on it later
t/t3406-rebase-message.sh
new
+44
@@ -0,0 +1,44 @@
1
+#!/bin/sh
2
+
3
+test_description='messages from rebase operation'
4
+
5
+. ./test-lib.sh
6
+
7
+quick_one () {
8
+ echo "$1" >"file$1" &&
9
+ git add "file$1" &&
10
+ test_tick &&
11
+ git commit -m "$1"
12
+}
13
+
14
+test_expect_success setup '
15
+ quick_one O &&
16
+ git branch topic &&
17
+ quick_one X &&
18
+ quick_one A &&
19
+ quick_one B &&
20
+ quick_one Y &&
21
+
22
+ git checkout topic &&
23
+ quick_one A &&
24
+ quick_one B &&
25
+ quick_one Z
26
+
27
+'
28
+
29
+cat >expect <<\EOF
30
+Already applied: 0001 A
31
+Already applied: 0002 B
32
+Committed: 0003 Z
33
+EOF
34
+
35
+test_expect_success 'rebase -m' '
36
+
37
+ git rebase -m master >report &&
38
+ sed -n -e "/^Already applied: /p" \
39
+ -e "/^Committed: /p" report >actual &&
40
+ diff -u expect actual
41
+
42
+'
43
+
44
+test_done