{"thread":{"id":"39529","subject":"[PATCH v5 3/3] git-am: add am.threeWay config variable","startedAt":"2015-06-04T23:24:42Z","lastAt":"2015-06-08T11:36:11Z","messageCount":4,"participants":["Remi Lespinet","Matthieu Moy"],"isPatch":true,"patchVersion":5,"patchTotal":3},"messages":[{"id":"262986","messageId":"1433460284-20240-1-git-send-email-remi.lespinet@ensimag.grenoble-inp.fr","threadId":"39529","inReplyTo":null,"subject":"[PATCH v5 1/3] git-am.sh: fix initialization of the threeway variable","fromName":"Remi Lespinet","fromEmail":"remi.lespinet@ensimag.grenoble-inp.fr","sentAt":"2015-06-04T23:24:42Z","receivedAt":"2015-06-04T23:24:42Z","isPatch":true,"sender":{"key":"remi.lespinet@ensimag.grenoble-inp.fr","avatar":"https://avatars.githubusercontent.com/u/11941160?v=4"},"body":"Initialization for the threeway variable was missing. This caused\na behavior change for command lines like:\n\n\tthreeway=t git am ...\n\nThis commit adds initialization for this variable.\n\nSigned-off-by: Remi Lespinet <remi.lespinet@ensimag.grenoble-inp.fr>\n---\n git-am.sh | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/git-am.sh b/git-am.sh\nindex 761befb..c460dd0 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -378,6 +378,7 @@ committer_date_is_author_date=\n ignore_date=\n allow_rerere_autoupdate=\n gpg_sign_opt=\n+threeway=\n \n if test \"$(git config --bool --get am.messageid)\" = true\n then\n-- \n1.9.1\n"},{"id":"262987","messageId":"1433460284-20240-2-git-send-email-remi.lespinet@ensimag.grenoble-inp.fr","threadId":"39529","inReplyTo":"1433460284-20240-1-git-send-email-remi.lespinet@ensimag.grenoble-inp.fr","subject":"[PATCH v5 2/3] t4150-am: refactor am -3 tests","fromName":"Remi Lespinet","fromEmail":"remi.lespinet@ensimag.grenoble-inp.fr","sentAt":"2015-06-04T23:24:43Z","receivedAt":"2015-06-04T23:24:43Z","isPatch":true,"sender":{"key":"remi.lespinet@ensimag.grenoble-inp.fr","avatar":"https://avatars.githubusercontent.com/u/11941160?v=4"},"body":"Create a setup for git am -3 in a separate test instead of creating\nthis setup each time.\n\nThis prepares for the next commit which will use this setup as well.\n\nSigned-off-by: Remi Lespinet <remi.lespinet@ensimag.grenoble-inp.fr>\n---\n t/t4150-am.sh | 32 ++++++++++++++------------------\n 1 file changed, 14 insertions(+), 18 deletions(-)\n\ndiff --git a/t/t4150-am.sh b/t/t4150-am.sh\nindex 306e6f3..6ced98c 100755\n--- a/t/t4150-am.sh\n+++ b/t/t4150-am.sh\n@@ -274,15 +274,21 @@ test_expect_success 'am --keep-non-patch really keeps the non-patch part' '\n \tgrep \"^\\[foo\\] third\" actual\n '\n \n+test_expect_success 'setup am -3' '\n+\trm -fr .git/rebase-apply &&\n+\tgit reset --hard &&\n+\tgit checkout -b base3way master2 &&\n+\tsed -n -e \"3,\\$p\" msg >file &&\n+\thead -n 9 msg >>file &&\n+\tgit add file &&\n+\ttest_tick &&\n+\tgit commit -m \"copied stuff\"\n+'\n+\n test_expect_success 'am -3 falls back to 3-way merge' '\n \trm -fr .git/rebase-apply &&\n \tgit reset --hard &&\n-\tgit checkout -b lorem2 master2 &&\n-\tsed -n -e \"3,\\$p\" msg >file &&\n-\thead -n 9 msg >>file &&\n-\tgit add file &&\n-\ttest_tick &&\n-\tgit commit -m \"copied stuff\" &&\n+\tgit checkout -b lorem2 base3way &&\n \tgit am -3 lorem-move.patch &&\n \ttest_path_is_missing .git/rebase-apply &&\n \tgit diff --exit-code lorem\n@@ -291,12 +297,7 @@ test_expect_success 'am -3 falls back to 3-way merge' '\n test_expect_success 'am -3 -p0 can read --no-prefix patch' '\n \trm -fr .git/rebase-apply &&\n \tgit reset --hard &&\n-\tgit checkout -b lorem3 master2 &&\n-\tsed -n -e \"3,\\$p\" msg >file &&\n-\thead -n 9 msg >>file &&\n-\tgit add file &&\n-\ttest_tick &&\n-\tgit commit -m \"copied stuff\" &&\n+\tgit checkout -b lorem3 base3way &&\n \tgit am -3 -p0 lorem-zero.patch &&\n \ttest_path_is_missing .git/rebase-apply &&\n \tgit diff --exit-code lorem\n@@ -338,12 +339,7 @@ test_expect_success 'am -3 can rename a file after falling back to 3-way merge'\n test_expect_success 'am -3 -q is quiet' '\n \trm -fr .git/rebase-apply &&\n \tgit checkout -f lorem2 &&\n-\tgit reset master2 --hard &&\n-\tsed -n -e \"3,\\$p\" msg >file &&\n-\thead -n 9 msg >>file &&\n-\tgit add file &&\n-\ttest_tick &&\n-\tgit commit -m \"copied stuff\" &&\n+\tgit reset base3way --hard &&\n \tgit am -3 -q lorem-move.patch >output.out 2>&1 &&\n \t! test -s output.out\n '\n-- \n1.9.1\n"},{"id":"262985","messageId":"1433460284-20240-3-git-send-email-remi.lespinet@ensimag.grenoble-inp.fr","threadId":"39529","inReplyTo":"1433460284-20240-1-git-send-email-remi.lespinet@ensimag.grenoble-inp.fr","subject":"[PATCH v5 3/3] git-am: add am.threeWay config variable","fromName":"Remi Lespinet","fromEmail":"remi.lespinet@ensimag.grenoble-inp.fr","sentAt":"2015-06-04T23:24:44Z","receivedAt":"2015-06-04T23:24:44Z","isPatch":true,"sender":{"key":"remi.lespinet@ensimag.grenoble-inp.fr","avatar":"https://avatars.githubusercontent.com/u/11941160?v=4"},"body":"Add the am.threeWay configuration variable to use the -3 or --3way\noption of git am by default. When am.threeway is set and not desired\nfor a specific git am command, the --no-3way option can be used to\noverride it.\n\nSigned-off-by: Remi Lespinet <remi.lespinet@ensimag.grenoble-inp.fr>\n---\n Only one change compared to previous version:\n \n \"git-config(1)\" replaced by \"linkgit:git-config[1]\"\n\n Documentation/config.txt |  8 ++++++++\n Documentation/git-am.txt |  7 +++++--\n git-am.sh                |  9 +++++++++\n t/t4150-am.sh            | 19 +++++++++++++++++++\n 4 files changed, 41 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex d44bc85..36b75d9 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -769,6 +769,14 @@ am.keepcr::\n \tby giving '--no-keep-cr' from the command line.\n \tSee linkgit:git-am[1], linkgit:git-mailsplit[1].\n \n+am.threeWay::\n+\tBy default, `git am` will fail if the patch does not apply cleanly. When\n+\tset to true, this setting tells `git am` to fall back on 3-way merge if\n+\tthe patch records the identity of blobs it is supposed to apply to and\n+\twe have those blobs available locally (equivalent to giving the `--3way`\n+\toption from the command line). Defaults to `false`.\n+\tSee linkgit:git-am[1].\n+\n apply.ignoreWhitespace::\n \tWhen set to 'change', tells 'git apply' to ignore changes in\n \twhitespace, in the same way as the '--ignore-space-change'\ndiff --git a/Documentation/git-am.txt b/Documentation/git-am.txt\nindex 0d8ba48..dbea6e7 100644\n--- a/Documentation/git-am.txt\n+++ b/Documentation/git-am.txt\n@@ -10,7 +10,7 @@ SYNOPSIS\n --------\n [verse]\n 'git am' [--signoff] [--keep] [--[no-]keep-cr] [--[no-]utf8]\n-\t [--3way] [--interactive] [--committer-date-is-author-date]\n+\t [--[no-]3way] [--interactive] [--committer-date-is-author-date]\n \t [--ignore-date] [--ignore-space-change | --ignore-whitespace]\n \t [--whitespace=<option>] [-C<n>] [-p<n>] [--directory=<dir>]\n \t [--exclude=<path>] [--include=<path>] [--reject] [-q | --quiet]\n@@ -90,10 +90,13 @@ default.   You can use `--no-utf8` to override this.\n \n -3::\n --3way::\n+--no-3way::\n \tWhen the patch does not apply cleanly, fall back on\n \t3-way merge if the patch records the identity of blobs\n \tit is supposed to apply to and we have those blobs\n-\tavailable locally.\n+\tavailable locally. `--no-3way` can be used to override\n+\tam.threeWay configuration variable. For more information,\n+\tsee am.threeWay in linkgit:git-config[1].\n \n --ignore-space-change::\n --ignore-whitespace::\ndiff --git a/git-am.sh b/git-am.sh\nindex c460dd0..75e701a 100755\n--- a/git-am.sh\n+++ b/git-am.sh\n@@ -390,6 +390,11 @@ then\n     keepcr=t\n fi\n \n+if test \"$(git config --bool --get am.threeWay)\" = true\n+then\n+    threeway=t\n+fi\n+\n while test $# != 0\n do\n \tcase \"$1\" in\n@@ -401,6 +406,8 @@ it will be removed. Please do not use it anymore.\"\n \t\t;;\n \t-3|--3way)\n \t\tthreeway=t ;;\n+\t--no-3way)\n+\t\tthreeway=f ;;\n \t-s|--signoff)\n \t\tsign=t ;;\n \t-u|--utf8)\n@@ -658,6 +665,8 @@ fi\n if test \"$(cat \"$dotest/threeway\")\" = t\n then\n \tthreeway=t\n+else\n+\tthreeway=f\n fi\n git_apply_opt=$(cat \"$dotest/apply-opt\")\n if test \"$(cat \"$dotest/sign\")\" = t\ndiff --git a/t/t4150-am.sh b/t/t4150-am.sh\nindex 6ced98c..b822a39 100755\n--- a/t/t4150-am.sh\n+++ b/t/t4150-am.sh\n@@ -303,6 +303,25 @@ test_expect_success 'am -3 -p0 can read --no-prefix patch' '\n \tgit diff --exit-code lorem\n '\n \n+test_expect_success 'am with config am.threeWay falls back to 3-way merge' '\n+\trm -fr .git/rebase-apply &&\n+\tgit reset --hard &&\n+\tgit checkout -b lorem4 base3way &&\n+\ttest_config am.threeWay 1 &&\n+\tgit am lorem-move.patch &&\n+\ttest_path_is_missing .git/rebase-apply &&\n+\tgit diff --exit-code lorem\n+'\n+\n+test_expect_success 'am with config am.threeWay overridden by --no-3way' '\n+\trm -fr .git/rebase-apply &&\n+\tgit reset --hard &&\n+\tgit checkout -b lorem5 base3way &&\n+\ttest_config am.threeWay 1 &&\n+\ttest_must_fail git am --no-3way lorem-move.patch &&\n+\ttest_path_is_dir .git/rebase-apply\n+'\n+\n test_expect_success 'am can rename a file' '\n \tgrep \"^rename from\" rename.patch &&\n \trm -fr .git/rebase-apply &&\n-- \n1.9.1\n"},{"id":"263188","messageId":"vpqwpzectzo.fsf@anie.imag.fr","threadId":"39529","inReplyTo":"1433460284-20240-2-git-send-email-remi.lespinet@ensimag.grenoble-inp.fr","subject":"Re: [PATCH v5 2/3] t4150-am: refactor am -3 tests","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2015-06-08T11:36:11Z","receivedAt":"2015-06-08T11:36:11Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Remi Lespinet <remi.lespinet@ensimag.grenoble-inp.fr> writes:\n\n> +test_expect_success 'setup am -3' '\n> +\trm -fr .git/rebase-apply &&\n\nI don't think you need this 'rm -fr' since you're going to repeat it at\nthe beginning of individual tests. But it doesn't harm to keep it just\nin case.\n\nWith or without this 'rm -fr', the series looks good to me. Thanks.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"}]}