File tree Expand file tree Collapse file tree 4 files changed +41
-2
lines changed
Expand file tree Collapse file tree 4 files changed +41
-2
lines changed Original file line number Diff line number Diff line change @@ -761,6 +761,14 @@ am.keepcr::
761761 by giving '--no-keep-cr' from the command line.
762762 See linkgit:git-am[1], linkgit:git-mailsplit[1].
763763
764+ am.threeWay::
765+ By default, `git am` will fail if the patch does not apply cleanly. When
766+ set to true, this setting tells `git am` to fall back on 3-way merge if
767+ the patch records the identity of blobs it is supposed to apply to and
768+ we have those blobs available locally (equivalent to giving the `--3way`
769+ option from the command line). Defaults to `false`.
770+ See linkgit:git-am[1].
771+
764772apply.ignoreWhitespace::
765773 When set to 'change', tells 'git apply' to ignore changes in
766774 whitespace, in the same way as the '--ignore-space-change'
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ SYNOPSIS
1010--------
1111[verse]
1212'git am' [--signoff] [--keep] [--[no-]keep-cr] [--[no-]utf8]
13- [--3way] [--interactive] [--committer-date-is-author-date]
13+ [--[no-] 3way] [--interactive] [--committer-date-is-author-date]
1414 [--ignore-date] [--ignore-space-change | --ignore-whitespace]
1515 [--whitespace=<option>] [-C<n>] [-p<n>] [--directory=<dir>]
1616 [--exclude=<path>] [--include=<path>] [--reject] [-q | --quiet]
@@ -90,10 +90,13 @@ default. You can use `--no-utf8` to override this.
9090
9191-3::
9292--3way::
93+ --no-3way::
9394 When the patch does not apply cleanly, fall back on
9495 3-way merge if the patch records the identity of blobs
9596 it is supposed to apply to and we have those blobs
96- available locally.
97+ available locally. `--no-3way` can be used to override
98+ am.threeWay configuration variable. For more information,
99+ see am.threeWay in linkgit:git-config[1].
97100
98101--ignore-space-change::
99102--ignore-whitespace::
Original file line number Diff line number Diff line change @@ -390,6 +390,11 @@ then
390390 keepcr=t
391391fi
392392
393+ if test " $( git config --bool --get am.threeWay) " = true
394+ then
395+ threeway=t
396+ fi
397+
393398while test $# ! = 0
394399do
395400 case " $1 " in
@@ -401,6 +406,8 @@ it will be removed. Please do not use it anymore."
401406 ;;
402407 -3|--3way)
403408 threeway=t ;;
409+ --no-3way)
410+ threeway=f ;;
404411 -s|--signoff)
405412 sign=t ;;
406413 -u|--utf8)
658665if test " $( cat " $dotest /threeway" ) " = t
659666then
660667 threeway=t
668+ else
669+ threeway=f
661670fi
662671git_apply_opt=$( cat " $dotest /apply-opt" )
663672if test " $( cat " $dotest /sign" ) " = t
Original file line number Diff line number Diff line change @@ -303,6 +303,25 @@ test_expect_success 'am -3 -p0 can read --no-prefix patch' '
303303 git diff --exit-code lorem
304304'
305305
306+ test_expect_success ' am with config am.threeWay falls back to 3-way merge' '
307+ rm -fr .git/rebase-apply &&
308+ git reset --hard &&
309+ git checkout -b lorem4 base3way &&
310+ test_config am.threeWay 1 &&
311+ git am lorem-move.patch &&
312+ test_path_is_missing .git/rebase-apply &&
313+ git diff --exit-code lorem
314+ '
315+
316+ test_expect_success ' am with config am.threeWay overridden by --no-3way' '
317+ rm -fr .git/rebase-apply &&
318+ git reset --hard &&
319+ git checkout -b lorem5 base3way &&
320+ test_config am.threeWay 1 &&
321+ test_must_fail git am --no-3way lorem-move.patch &&
322+ test_path_is_dir .git/rebase-apply
323+ '
324+
306325test_expect_success ' am can rename a file' '
307326 grep "^rename from" rename.patch &&
308327 rm -fr .git/rebase-apply &&
You can’t perform that action at this time.
0 commit comments