rebase: honor --rerere-autoupdate
Rebase accepts '--rerere-autoupdate' as an option but only honors it if '-m' is also given. Fix it for a non-interactive rebase by passing on the option to 'git am' and 'git cherry-pick'. Rework the tests so that they can be used for each rebase flavor and extend them. Reported-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Phillip Wood committed
Aug 2, 2017 at 11:44 UTC
5fb415b57f93330b5ceb743ac36d99da10ac00b1
2 files changed
+57
-28
git-rebase--am.sh
+2
-1
@@ -45,7 +45,7 @@ then
45
# itself well to recording empty patches. fortunately, cherry-pick
46
# makes this easy
47
git cherry-pick ${gpg_sign_opt:+"$gpg_sign_opt"} --allow-empty \
48
- --right-only "$revisions" \
48
+ $allow_rerere_autoupdate --right-only "$revisions" \
49
${restrict_revision+^$restrict_revision}
50
ret=$?
51
else
@@ -82,6 +82,7 @@ else
82
fi
83
84
git am $git_am_opt --rebasing --resolvemsg="$resolvemsg" \
85
+ $allow_rerere_autoupdate \
86
${gpg_sign_opt:+"$gpg_sign_opt"} <"$GIT_DIR/rebased-patches"
87
ret=$?
88
t/t3418-rebase-continue.sh
+55
-27
@@ -40,25 +40,6 @@ test_expect_success 'non-interactive rebase --continue works with touched file'
40
git rebase --continue
41
'
42
43
-test_expect_success 'non-interactive rebase --continue with rerere enabled' '
44
- test_config rerere.enabled true &&
45
- test_when_finished "test_might_fail git rebase --abort" &&
46
- git reset --hard commit-new-file-F2-on-topic-branch &&
47
- git checkout master &&
48
- rm -fr .git/rebase-* &&
49
-
50
- test_must_fail git rebase --onto master master topic &&
51
- echo "Resolved" >F2 &&
52
- git add F2 &&
53
- cp F2 F2.expected &&
54
- git rebase --continue &&
55
-
56
- git reset --hard commit-new-file-F2-on-topic-branch &&
57
- git checkout master &&
58
- test_must_fail git rebase --onto master master topic &&
59
- test_cmp F2.expected F2
60
-'
61
-
43
test_expect_success 'rebase --continue can not be used with other options' '
44
test_must_fail git rebase -v --continue &&
45
test_must_fail git rebase --continue -v
@@ -93,25 +74,72 @@ test_expect_success 'rebase --continue remembers merge strategy and options' '
74
test -f funny.was.run
75
'
76
96
-test_expect_success 'rebase --continue remembers --rerere-autoupdate' '
77
+test_expect_success 'setup rerere database' '
78
rm -fr .git/rebase-* &&
79
git reset --hard commit-new-file-F3-on-topic-branch &&
80
git checkout master &&
81
test_commit "commit-new-file-F3" F3 3 &&
101
- git config rerere.enabled true &&
82
+ test_config rerere.enabled true &&
83
test_must_fail git rebase -m master topic &&
84
echo "Resolved" >F2 &&
85
+ cp F2 expected-F2 &&
86
git add F2 &&
87
test_must_fail git rebase --continue &&
88
echo "Resolved" >F3 &&
89
+ cp F3 expected-F3 &&
90
git add F3 &&
91
git rebase --continue &&
109
- git reset --hard topic@{1} &&
110
- test_must_fail git rebase -m --rerere-autoupdate master &&
111
- test "$(cat F2)" = "Resolved" &&
112
- test_must_fail git rebase --continue &&
113
- test "$(cat F3)" = "Resolved" &&
114
- git rebase --continue
92
+ git reset --hard topic@{1}
93
'
94
95
+prepare () {
96
+ rm -fr .git/rebase-* &&
97
+ git reset --hard commit-new-file-F3-on-topic-branch &&
98
+ git checkout master &&
99
+ test_config rerere.enabled true
100
+}
101
+
102
+test_rerere_autoupdate () {
103
+ action=$1 &&
104
+ test_expect_success "rebase $action --continue remembers --rerere-autoupdate" '
105
+ prepare &&
106
+ test_must_fail git rebase $action --rerere-autoupdate master topic &&
107
+ test_cmp expected-F2 F2 &&
108
+ git diff-files --quiet &&
109
+ test_must_fail git rebase --continue &&
110
+ test_cmp expected-F3 F3 &&
111
+ git diff-files --quiet &&
112
+ git rebase --continue
113
+ '
114
+
115
+ test_expect_success "rebase $action --continue honors rerere.autoUpdate" '
116
+ prepare &&
117
+ test_config rerere.autoupdate true &&
118
+ test_must_fail git rebase $action master topic &&
119
+ test_cmp expected-F2 F2 &&
120
+ git diff-files --quiet &&
121
+ test_must_fail git rebase --continue &&
122
+ test_cmp expected-F3 F3 &&
123
+ git diff-files --quiet &&
124
+ git rebase --continue
125
+ '
126
+
127
+ test_expect_success "rebase $action --continue remembers --no-rerere-autoupdate" '
128
+ prepare &&
129
+ test_config rerere.autoupdate true &&
130
+ test_must_fail git rebase $action --no-rerere-autoupdate master topic &&
131
+ test_cmp expected-F2 F2 &&
132
+ test_must_fail git diff-files --quiet &&
133
+ git add F2 &&
134
+ test_must_fail git rebase --continue &&
135
+ test_cmp expected-F3 F3 &&
136
+ test_must_fail git diff-files --quiet &&
137
+ git add F3 &&
138
+ git rebase --continue
139
+ '
140
+}
141
+
142
+test_rerere_autoupdate
143
+test_rerere_autoupdate -m
144
+
145
test_done