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 @@ -127,15 +127,18 @@ fall_back_3way () {
127
127
mkdir " $dotest /patch-merge-tmp-dir"
128
128
129
129
# First see if the patch records the index info that we can use.
130
- git apply --build-fake-ancestor " $dotest /patch-merge-tmp-index" \
131
- " $dotest /patch" &&
130
+ cmd=" git apply $git_apply_opt --build-fake-ancestor" &&
131
+ cmd=" $cmd " ' "$dotest/patch-merge-tmp-index" "$dotest/patch"' &&
132
+ eval " $cmd " &&
132
133
GIT_INDEX_FILE=" $dotest /patch-merge-tmp-index" \
133
134
git write-tree > " $dotest /patch-merge-base+" ||
134
135
cannot_fallback " $( gettext " Repository lacks necessary blobs to fall back on 3-way merge." ) "
135
136
136
137
say Using index info to reconstruct a base tree...
137
- if GIT_INDEX_FILE=" $dotest /patch-merge-tmp-index" \
138
- git apply --cached < " $dotest /patch"
138
+
139
+ cmd=' GIT_INDEX_FILE="$dotest/patch-merge-tmp-index"'
140
+ cmd=" $cmd git apply --cached $git_apply_opt " ' <"$dotest/patch"'
141
+ if eval " $cmd "
139
142
then
140
143
mv " $dotest /patch-merge-base+" " $dotest /patch-merge-base"
141
144
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 &&
@@ -276,6 +277,20 @@ test_expect_success 'am -3 falls back to 3-way merge' '
276
277
git diff --exit-code lorem
277
278
'
278
279
280
+ test_expect_success ' am -3 -p0 can read --no-prefix patch' '
281
+ rm -fr .git/rebase-apply &&
282
+ git reset --hard &&
283
+ git checkout -b lorem3 master2 &&
284
+ sed -n -e "3,\$p" msg >file &&
285
+ head -n 9 msg >>file &&
286
+ git add file &&
287
+ test_tick &&
288
+ git commit -m "copied stuff" &&
289
+ git am -3 -p0 lorem-zero.patch &&
290
+ ! test -d .git/rebase-apply &&
291
+ git diff --exit-code lorem
292
+ '
293
+
279
294
test_expect_success ' am can rename a file' '
280
295
grep "^rename from" rename.patch &&
281
296
rm -fr .git/rebase-apply &&
You can’t perform that action at this time.
0 commit comments