rebase: protect against diff.renames configuration
We currently do not disable diff.renames configuration while rebase internally runs "format-patch" to feed "am -3". The end user configuration for "diff" should not affect the result produced by the higher level command that is related to "diff" only because internally it is implemented in terms of it. For that matter, I have a feeling that format-patch should not even look at diff.renames, but we seem to have been doing this for a long time so there is no easy way to fix this thinko. In any case, here is a much straightforward fix for "rebase". [jn: with test case from David] Reported-by: David D. Kilzer <ddkilzer@kilzer.net> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Nov 10, 2008 at 16:15 UTC
840b3ca758a42cb1481259521126ba2b02a5447a
2 files changed
+24
-2
git-rebase.sh
+1
-1
@@ -543,7 +543,7 @@ fi
543
if test -z "$do_merge"
544
then
545
git format-patch -k --stdout --full-index --ignore-if-in-upstream \
546
- $root_flag "$revisions" |
546
+ --no-renames $root_flag "$revisions" |
547
git am $git_am_opt --rebasing --resolvemsg="$RESOLVEMSG" &&
548
move_to_original_branch
549
ret=$?
t/t3400-rebase.sh
+23
-1
@@ -19,7 +19,16 @@ test_expect_success 'prepare repository with topic branches' '
19
echo First >A &&
20
git update-index --add A &&
21
git commit -m "Add A." &&
22
- git checkout -b my-topic-branch &&
22
+ git checkout -b force-3way &&
23
+ echo Dummy >Y &&
24
+ git update-index --add Y &&
25
+ git commit -m "Add Y." &&
26
+ git checkout -b filemove &&
27
+ git reset --soft master &&
28
+ mkdir D &&
29
+ git mv A D/A &&
30
+ git commit -m "Move A." &&
31
+ git checkout -b my-topic-branch master &&
32
echo Second >B &&
33
git update-index --add B &&
34
git commit -m "Add B." &&
@@ -128,6 +137,19 @@ test_expect_success 'rebase a single mode change' '
137
GIT_TRACE=1 git rebase master
138
'
139
140
+test_expect_success 'rebase is not broken by diff.renames' '
141
+ git config diff.renames copies &&
142
+ test_when_finished "git config --unset diff.renames" &&
143
+ git checkout filemove &&
144
+ GIT_TRACE=1 git rebase force-3way
145
+'
146
+
147
+test_expect_success 'setup: recover' '
148
+ test_might_fail git rebase --abort &&
149
+ git reset --hard &&
150
+ git checkout modechange
151
+'
152
+
153
test_expect_success 'Show verbose error when HEAD could not be detached' '
154
>B &&
155
test_must_fail git rebase topic 2>output.err >output.out &&