File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -128,15 +128,18 @@ fall_back_3way () {
128128 mkdir " $dotest /patch-merge-tmp-dir"
129129
130130 # 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 " &&
133134 GIT_INDEX_FILE=" $dotest /patch-merge-tmp-index" \
134135 git write-tree > " $dotest /patch-merge-base+" ||
135136 cannot_fallback " $( gettext " Repository lacks necessary blobs to fall back on 3-way merge." ) "
136137
137138 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 "
140143 then
141144 mv " $dotest /patch-merge-base+" " $dotest /patch-merge-base"
142145 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 '
123123 git commit -m "added another file" &&
124124
125125 git format-patch --stdout master >lorem-move.patch &&
126+ git format-patch --no-prefix --stdout master >lorem-zero.patch &&
126127
127128 git checkout -b rename &&
128129 git mv file renamed &&
@@ -286,6 +287,20 @@ test_expect_success 'am -3 falls back to 3-way merge' '
286287 git diff --exit-code lorem
287288'
288289
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+
289304test_expect_success ' am can rename a file' '
290305 grep "^rename from" rename.patch &&
291306 rm -fr .git/rebase-apply &&
You can’t perform that action at this time.
0 commit comments