Skip to content

Commit 4056afb

Browse files
committed
am -3: allow nonstandard -p<num> option
When falling back to 3-way merge, we run "git apply" to synthesize the fake ancestor tree by parsing the incoming patch, and another "git apply" to apply the patch to the fake ancestor tree. Both invocation need to be aware of the custom -p<num> setting to parse patches that were prepared with non-standard src/dst prefix. Signed-off-by: Junio C Hamano <[email protected]>
1 parent d0482e8 commit 4056afb

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

git-am.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,18 @@ fall_back_3way () {
127127
mkdir "$dotest/patch-merge-tmp-dir"
128128

129129
# 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" &&
132133
GIT_INDEX_FILE="$dotest/patch-merge-tmp-index" \
133134
git write-tree >"$dotest/patch-merge-base+" ||
134135
cannot_fallback "$(gettext "Repository lacks necessary blobs to fall back on 3-way merge.")"
135136

136137
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"
139142
then
140143
mv "$dotest/patch-merge-base+" "$dotest/patch-merge-base"
141144
mv "$dotest/patch-merge-tmp-index" "$dotest/patch-merge-index"

0 commit comments

Comments
 (0)