From 1164db977e3c2dd54a4d90d4aded7ca64791d16b Mon Sep 17 00:00:00 2001 From: Remi Lespinet Date: Thu, 4 Jun 2015 17:04:53 +0200 Subject: [PATCH 1/3] git-am.sh: fix initialization of the threeway variable Initialization for the threeway variable was missing. This caused a behavior change for command lines like: threeway=t git am ... This commit adds initialization for this variable. Signed-off-by: Remi Lespinet Signed-off-by: Junio C Hamano --- git-am.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/git-am.sh b/git-am.sh index a67d0f9898..4696998d4e 100755 --- a/git-am.sh +++ b/git-am.sh @@ -378,6 +378,7 @@ committer_date_is_author_date= ignore_date= allow_rerere_autoupdate= gpg_sign_opt= +threeway= if test "$(git config --bool --get am.messageid)" = true then From 8c8884ce97eed5ab27a8b6f9f54a6f3795eded19 Mon Sep 17 00:00:00 2001 From: Remi Lespinet Date: Thu, 4 Jun 2015 17:04:54 +0200 Subject: [PATCH 2/3] t4150-am: refactor am -3 tests Create a setup for git am -3 in a separate test instead of creating this setup each time. This prepares for the next commit which will use this setup as well. Signed-off-by: Remi Lespinet Signed-off-by: Junio C Hamano --- t/t4150-am.sh | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/t/t4150-am.sh b/t/t4150-am.sh index 306e6f39ac..6ced98cfb4 100755 --- a/t/t4150-am.sh +++ b/t/t4150-am.sh @@ -274,15 +274,21 @@ test_expect_success 'am --keep-non-patch really keeps the non-patch part' ' grep "^\[foo\] third" actual ' -test_expect_success 'am -3 falls back to 3-way merge' ' +test_expect_success 'setup am -3' ' rm -fr .git/rebase-apply && git reset --hard && - git checkout -b lorem2 master2 && + git checkout -b base3way master2 && sed -n -e "3,\$p" msg >file && head -n 9 msg >>file && git add file && test_tick && - git commit -m "copied stuff" && + git commit -m "copied stuff" +' + +test_expect_success 'am -3 falls back to 3-way merge' ' + rm -fr .git/rebase-apply && + git reset --hard && + git checkout -b lorem2 base3way && git am -3 lorem-move.patch && test_path_is_missing .git/rebase-apply && git diff --exit-code lorem @@ -291,12 +297,7 @@ test_expect_success 'am -3 falls back to 3-way merge' ' test_expect_success 'am -3 -p0 can read --no-prefix patch' ' rm -fr .git/rebase-apply && git reset --hard && - git checkout -b lorem3 master2 && - sed -n -e "3,\$p" msg >file && - head -n 9 msg >>file && - git add file && - test_tick && - git commit -m "copied stuff" && + git checkout -b lorem3 base3way && git am -3 -p0 lorem-zero.patch && test_path_is_missing .git/rebase-apply && git diff --exit-code lorem @@ -338,12 +339,7 @@ test_expect_success 'am -3 can rename a file after falling back to 3-way merge' test_expect_success 'am -3 -q is quiet' ' rm -fr .git/rebase-apply && git checkout -f lorem2 && - git reset master2 --hard && - sed -n -e "3,\$p" msg >file && - head -n 9 msg >>file && - git add file && - test_tick && - git commit -m "copied stuff" && + git reset base3way --hard && git am -3 -q lorem-move.patch >output.out 2>&1 && ! test -s output.out ' From d96a275b91bae1800cd43be0651e886e7e042a17 Mon Sep 17 00:00:00 2001 From: Remi Lespinet Date: Thu, 4 Jun 2015 17:04:55 +0200 Subject: [PATCH 3/3] git-am: add am.threeWay config variable Add the am.threeWay configuration variable to use the -3 or --3way option of git am by default. When am.threeway is set and not desired for a specific git am command, the --no-3way option can be used to override it. Signed-off-by: Remi Lespinet Signed-off-by: Junio C Hamano --- Documentation/config.txt | 8 ++++++++ Documentation/git-am.txt | 7 +++++-- git-am.sh | 9 +++++++++ t/t4150-am.sh | 19 +++++++++++++++++++ 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/Documentation/config.txt b/Documentation/config.txt index 2e5ceaf719..77ada666f7 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -761,6 +761,14 @@ am.keepcr:: by giving '--no-keep-cr' from the command line. See linkgit:git-am[1], linkgit:git-mailsplit[1]. +am.threeWay:: + By default, `git am` will fail if the patch does not apply cleanly. When + set to true, this setting tells `git am` to fall back on 3-way merge if + the patch records the identity of blobs it is supposed to apply to and + we have those blobs available locally (equivalent to giving the `--3way` + option from the command line). Defaults to `false`. + See linkgit:git-am[1]. + apply.ignoreWhitespace:: When set to 'change', tells 'git apply' to ignore changes in whitespace, in the same way as the '--ignore-space-change' diff --git a/Documentation/git-am.txt b/Documentation/git-am.txt index 0d8ba48f79..dbea6e7ae9 100644 --- a/Documentation/git-am.txt +++ b/Documentation/git-am.txt @@ -10,7 +10,7 @@ SYNOPSIS -------- [verse] 'git am' [--signoff] [--keep] [--[no-]keep-cr] [--[no-]utf8] - [--3way] [--interactive] [--committer-date-is-author-date] + [--[no-]3way] [--interactive] [--committer-date-is-author-date] [--ignore-date] [--ignore-space-change | --ignore-whitespace] [--whitespace=