Skip to content

Commit 250f0a0

Browse files
committed
Merge branch 'jc/am-3-nonstandard-popt'
* jc/am-3-nonstandard-popt: test: "am -3" can accept non-standard -p<num> am -3: allow nonstandard -p<num> option
2 parents 91527e5 + a61ba26 commit 250f0a0

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

git-am.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff 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"

t/t4150-am.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
289304
test_expect_success 'am can rename a file' '
290305
grep "^rename from" rename.patch &&
291306
rm -fr .git/rebase-apply &&

0 commit comments

Comments
 (0)