File tree Expand file tree Collapse file tree 2 files changed +22
-4
lines changed Expand file tree Collapse file tree 2 files changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -128,15 +128,18 @@ fall_back_3way () {
128
128
mkdir " $dotest /patch-merge-tmp-dir"
129
129
130
130
# First see if the patch records the index info that we can use.
131
- git apply --build-fake-ancestor " $dotest /patch-merge-tmp-index" \
132
- " $dotest /patch" &&
131
+ cmd=" git apply $git_apply_opt --build-fake-ancestor" &&
132
+ cmd=" $cmd " ' "$dotest/patch-merge-tmp-index" "$dotest/patch"' &&
133
+ eval " $cmd " &&
133
134
GIT_INDEX_FILE=" $dotest /patch-merge-tmp-index" \
134
135
git write-tree > " $dotest /patch-merge-base+" ||
135
136
cannot_fallback " $( gettext " Repository lacks necessary blobs to fall back on 3-way merge." ) "
136
137
137
138
say Using index info to reconstruct a base tree...
138
- if GIT_INDEX_FILE=" $dotest /patch-merge-tmp-index" \
139
- git apply --cached < " $dotest /patch"
139
+
140
+ cmd=' GIT_INDEX_FILE="$dotest/patch-merge-tmp-index"'
141
+ cmd=" $cmd git apply --cached $git_apply_opt " ' <"$dotest/patch"'
142
+ if eval " $cmd "
140
143
then
141
144
mv " $dotest /patch-merge-base+" " $dotest /patch-merge-base"
142
145
mv " $dotest /patch-merge-tmp-index" " $dotest /patch-merge-index"
Original file line number Diff line number Diff line change @@ -123,6 +123,7 @@ test_expect_success setup '
123
123
git commit -m "added another file" &&
124
124
125
125
git format-patch --stdout master >lorem-move.patch &&
126
+ git format-patch --no-prefix --stdout master >lorem-zero.patch &&
126
127
127
128
git checkout -b rename &&
128
129
git mv file renamed &&
@@ -286,6 +287,20 @@ test_expect_success 'am -3 falls back to 3-way merge' '
286
287
git diff --exit-code lorem
287
288
'
288
289
290
+ test_expect_success ' am -3 -p0 can read --no-prefix patch' '
291
+ rm -fr .git/rebase-apply &&
292
+ git reset --hard &&
293
+ git checkout -b lorem3 master2 &&
294
+ sed -n -e "3,\$p" msg >file &&
295
+ head -n 9 msg >>file &&
296
+ git add file &&
297
+ test_tick &&
298
+ git commit -m "copied stuff" &&
299
+ git am -3 -p0 lorem-zero.patch &&
300
+ ! test -d .git/rebase-apply &&
301
+ git diff --exit-code lorem
302
+ '
303
+
289
304
test_expect_success ' am can rename a file' '
290
305
grep "^rename from" rename.patch &&
291
306
rm -fr .git/rebase-apply &&
You can’t perform that action at this time.
0 commit comments