{"thread":{"id":"40012","subject":"[PATCH] git-am: add am.threeWay config variable","startedAt":"2015-08-04T14:19:26Z","lastAt":"2015-08-19T09:45:38Z","messageCount":5,"participants":["Paul Tan","Johannes Schindelin","Matthieu Moy"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"267470","messageId":"1438697966-4958-1-git-send-email-pyokagan@gmail.com","threadId":"40012","inReplyTo":null,"subject":"[PATCH] git-am: add am.threeWay config variable","fromName":"Paul Tan","fromEmail":"pyokagan@gmail.com","sentAt":"2015-08-04T14:19:26Z","receivedAt":"2015-08-04T14:19:26Z","isPatch":true,"sender":{"key":"pyokagan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/109479?v=4"},"body":"From: Remi Lespinet <remi.lespinet@ensimag.grenoble-inp.fr>\n\nAdd 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>\nSigned-off-by: Paul Tan <pyokagan@gmail.com>\n---\nI tweaked Remi's patch so it is implemented on top of builtin/am.c. Hopefully\nthere will be no regressions this time ;)\n\n Documentation/config.txt |  8 ++++++++\n Documentation/git-am.txt |  7 +++++--\n builtin/am.c             |  2 ++\n t/t4150-am.sh            | 19 +++++++++++++++++++\n 4 files changed, 34 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 315f271..fb3fc57 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/builtin/am.c b/builtin/am.c\nindex 84d57d4..1399c8d 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -152,6 +152,8 @@ static void am_state_init(struct am_state *state, const char *dir)\n \n \tstate->prec = 4;\n \n+\tgit_config_get_bool(\"am.threeway\", &state->threeway);\n+\n \tstate->utf8 = 1;\n \n \tgit_config_get_bool(\"am.messageid\", &state->message_id);\ndiff --git a/t/t4150-am.sh b/t/t4150-am.sh\nindex e9b6f81..dd627c4 100755\n--- a/t/t4150-am.sh\n+++ b/t/t4150-am.sh\n@@ -551,6 +551,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-- \n2.5.0.280.gd88bd6e\n"},{"id":"267607","messageId":"ee65e46e4a342e4646ae78baf12fbe3b@www.dscho.org","threadId":"40012","inReplyTo":"1438697966-4958-1-git-send-email-pyokagan@gmail.com","subject":"Re: [PATCH] git-am: add am.threeWay config variable","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2015-08-07T09:18:27Z","receivedAt":"2015-08-07T09:18:27Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn 2015-08-04 16:19, Paul Tan wrote:\n> From: Remi Lespinet <remi.lespinet@ensimag.grenoble-inp.fr>\n> \n> Add the am.threeWay configuration variable to use the -3 or --3way\n> option of git am by default. When am.threeway is set and not desired\n> for a specific git am command, the --no-3way option can be used to\n> override it.\n> \n> Signed-off-by: Remi Lespinet <remi.lespinet@ensimag.grenoble-inp.fr>\n> Signed-off-by: Paul Tan <pyokagan@gmail.com>\n> ---\n> I tweaked Remi's patch so it is implemented on top of builtin/am.c. Hopefully\n> there will be no regressions this time ;)\n\nThe diff looks obviously correct to me (and yes, I also looked at the context... :-)).\n\nCiao,\nDscho\n"},{"id":"268250","messageId":"vpqfv3h9bvf.fsf@anie.imag.fr","threadId":"40012","inReplyTo":"1438697966-4958-1-git-send-email-pyokagan@gmail.com","subject":"Re: [PATCH] git-am: add am.threeWay config variable","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2015-08-18T09:36:36Z","receivedAt":"2015-08-18T09:36:36Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Paul Tan <pyokagan@gmail.com> writes:\n\n> From: Remi Lespinet <remi.lespinet@ensimag.grenoble-inp.fr>\n>\n> Add the am.threeWay configuration variable to use the -3 or --3way\n> option of git am by default. When am.threeway is set and not desired\n> for a specific git am command, the --no-3way option can be used to\n> override it.\n>\n> Signed-off-by: Remi Lespinet <remi.lespinet@ensimag.grenoble-inp.fr>\n> Signed-off-by: Paul Tan <pyokagan@gmail.com>\n> ---\n> I tweaked Remi's patch so it is implemented on top of builtin/am.c. Hopefully\n> there will be no regressions this time ;)\n\nThanks for doing this.\n\nI don't remember the details of the regression we had with the shell\nversion, but that would probably deserve an additional test to enforce\nthe \"Hopefully there will be no regressions\" part of your message.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"268293","messageId":"CACRoPnTY8mALN8KbjR0CHeaKOkm2oSLRL9=4X1tU1LmHiJTeNg@mail.gmail.com","threadId":"40012","inReplyTo":"vpqfv3h9bvf.fsf@anie.imag.fr","subject":"Re: [PATCH] git-am: add am.threeWay config variable","fromName":"Paul Tan","fromEmail":"pyokagan@gmail.com","sentAt":"2015-08-19T08:33:36Z","receivedAt":"2015-08-19T08:33:36Z","isPatch":true,"sender":{"key":"pyokagan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/109479?v=4"},"body":"On Tue, Aug 18, 2015 at 5:36 PM, Matthieu Moy\n<Matthieu.Moy@grenoble-inp.fr> wrote:\n> I don't remember the details of the regression we had with the shell\n> version, but that would probably deserve an additional test to enforce\n> the \"Hopefully there will be no regressions\" part of your message.\n\nActually, technically, I think this patch by its own would reintroduce\nthe regression ;)\n\nThe reason is that the bug was caused by the overall structure of the\ngit-am.sh code, and not the patch itself[1].\n\nThis is fixed in another patch series[2] on top of this patch which\nalso implements a test for \"git am --3way\".\n\n[1] http://thread.gmane.org/gmane.comp.version-control.git/274577\n[2] http://thread.gmane.org/gmane.comp.version-control.git/275322\n\nThanks,\nPaul\n"},{"id":"268294","messageId":"vpq4mjv7gsd.fsf@anie.imag.fr","threadId":"40012","inReplyTo":"CACRoPnTY8mALN8KbjR0CHeaKOkm2oSLRL9=4X1tU1LmHiJTeNg@mail.gmail.com","subject":"Re: [PATCH] git-am: add am.threeWay config variable","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2015-08-19T09:45:38Z","receivedAt":"2015-08-19T09:45:38Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Paul Tan <pyokagan@gmail.com> writes:\n\n> On Tue, Aug 18, 2015 at 5:36 PM, Matthieu Moy\n> <Matthieu.Moy@grenoble-inp.fr> wrote:\n>> I don't remember the details of the regression we had with the shell\n>> version, but that would probably deserve an additional test to enforce\n>> the \"Hopefully there will be no regressions\" part of your message.\n>\n> Actually, technically, I think this patch by its own would reintroduce\n> the regression ;)\n>\n> The reason is that the bug was caused by the overall structure of the\n> git-am.sh code, and not the patch itself[1].\n>\n> This is fixed in another patch series[2] on top of this patch which\n> also implements a test for \"git am --3way\".\n\nOK, perfect. I had missed that. Thanks again.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"}]}