{"thread":{"id":"55566","subject":"[PATCH] git-apply: modify prints to account for --3way changes","startedAt":"2021-04-27T01:13:20Z","lastAt":"2021-04-29T02:35:16Z","messageCount":7,"participants":["Jerry Zhang","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"423051","messageId":"20210427011314.28156-1-jerry@skydio.com","threadId":"55566","inReplyTo":null,"subject":"[PATCH] git-apply: modify prints to account for --3way changes","fromName":"Jerry Zhang","fromEmail":"jerry@skydio.com","sentAt":"2021-04-27T01:13:14Z","receivedAt":"2021-04-27T01:13:20Z","isPatch":true,"sender":{"key":"jerry@skydio.com","avatar":"https://avatars.githubusercontent.com/u/81337184?v=4"},"body":"\"git apply\" specifically calls out when it\nis falling back to 3way merge application.\nSince the order changed to preferring 3way\nand falling back to direct application,\ncontinue that behavior by printing whenever\n3way fails and git has to fall back.\n\nAdd a --quiet flag to \"git apply\" so the user\ncan turn down the verbosity.\n\nSigned-off-by: Jerry Zhang <jerry@skydio.com>\n---\n apply.c | 8 +++++++-\n 1 file changed, 7 insertions(+), 1 deletion(-)\n\ndiff --git a/apply.c b/apply.c\nindex 8532b48e4f..2abf2e8a61 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -3572,7 +3572,7 @@ static int try_threeway(struct apply_state *state,\n \t\t read_blob_object(&buf, &pre_oid, patch->old_mode))\n \t\treturn error(_(\"repository lacks the necessary blob to perform 3-way merge.\"));\n \n-\tif (state->apply_verbosity > verbosity_silent)\n+\tif (state->apply_verbosity > verbosity_silent && patch->direct_to_threeway)\n \t\tfprintf(stderr, _(\"Performing three-way merge...\\n\"));\n \n \timg = strbuf_detach(&buf, &len);\n@@ -3639,6 +3639,10 @@ static int apply_data(struct apply_state *state, struct patch *patch,\n \t\treturn -1;\n \n \tif (!state->threeway || try_threeway(state, &image, patch, st, ce) < 0) {\n+\t\tif (state->apply_verbosity > verbosity_silent &&\n+\t\t    state->threeway && !patch->direct_to_threeway)\n+\t\t\tfprintf(stderr, _(\"Falling back to direct application...\\n\"));\n+\n \t\t/* Note: with --reject, apply_fragments() returns 0 */\n \t\tif (patch->direct_to_threeway || apply_fragments(state, &image, patch) < 0)\n \t\t\treturn -1;\n@@ -5050,6 +5054,8 @@ int apply_parse_options(int argc, const char **argv,\n \t\tOPT_BOOL(0, \"allow-overlap\", &state->allow_overlap,\n \t\t\tN_(\"allow overlapping hunks\")),\n \t\tOPT__VERBOSE(&state->apply_verbosity, N_(\"be verbose\")),\n+\t\tOPT_SET_INT('q', \"quiet\", &state->apply_verbosity,\n+\t\t\tN_(\"be quiet\"), -1),\n \t\tOPT_BIT(0, \"inaccurate-eof\", options,\n \t\t\tN_(\"tolerate incorrectly detected missing new-line at the end of file\"),\n \t\t\tAPPLY_OPT_INACCURATE_EOF),\n-- \n2.29.0\n\n"},{"id":"423065","messageId":"xmqqczugdvan.fsf@gitster.g","threadId":"55566","inReplyTo":"20210427011314.28156-1-jerry@skydio.com","subject":"Re: [PATCH] git-apply: modify prints to account for --3way changes","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-04-27T07:46:24Z","receivedAt":"2021-04-27T07:46:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jerry Zhang <jerry@skydio.com> writes:\n\n> \"git apply\" specifically calls out when it\n> is falling back to 3way merge application.\n> Since the order changed to preferring 3way\n> and falling back to direct application,\n> continue that behavior by printing whenever\n> 3way fails and git has to fall back.\n\nThat makes sense.\n\n\n> Add a --quiet flag to \"git apply\" so the user\n> can turn down the verbosity.\n\nIt makes sense, too.\n\nBut aren't they a different change that should belong to a separate\npatch?  After all, the first point is to give the same kind of\nfallback warning/report as we used to before we swapped the fallback\norder, and no users needed extra \"more silent\" setting to deal with\nthe fallback warning messages.  Allowing to set the verbosity even\nlower may be desirable, but that is an independent new feature,\nisn't it?\n\nI wonder if it is the more correct approach to replace\nOPT__VERBOSE() with OPT_VERBOSITY() here, instead of adding a\nseparate OPT_SET_INT() like you did.\n\nThanks.\n\n> Signed-off-by: Jerry Zhang <jerry@skydio.com>\n> ---\n>  apply.c | 8 +++++++-\n>  1 file changed, 7 insertions(+), 1 deletion(-)\n>\n> diff --git a/apply.c b/apply.c\n> index 8532b48e4f..2abf2e8a61 100644\n> --- a/apply.c\n> +++ b/apply.c\n> @@ -3572,7 +3572,7 @@ static int try_threeway(struct apply_state *state,\n>  \t\t read_blob_object(&buf, &pre_oid, patch->old_mode))\n>  \t\treturn error(_(\"repository lacks the necessary blob to perform 3-way merge.\"));\n>  \n> -\tif (state->apply_verbosity > verbosity_silent)\n> +\tif (state->apply_verbosity > verbosity_silent && patch->direct_to_threeway)\n>  \t\tfprintf(stderr, _(\"Performing three-way merge...\\n\"));\n>  \n>  \timg = strbuf_detach(&buf, &len);\n> @@ -3639,6 +3639,10 @@ static int apply_data(struct apply_state *state, struct patch *patch,\n>  \t\treturn -1;\n>  \n>  \tif (!state->threeway || try_threeway(state, &image, patch, st, ce) < 0) {\n> +\t\tif (state->apply_verbosity > verbosity_silent &&\n> +\t\t    state->threeway && !patch->direct_to_threeway)\n> +\t\t\tfprintf(stderr, _(\"Falling back to direct application...\\n\"));\n> +\n>  \t\t/* Note: with --reject, apply_fragments() returns 0 */\n>  \t\tif (patch->direct_to_threeway || apply_fragments(state, &image, patch) < 0)\n>  \t\t\treturn -1;\n> @@ -5050,6 +5054,8 @@ int apply_parse_options(int argc, const char **argv,\n>  \t\tOPT_BOOL(0, \"allow-overlap\", &state->allow_overlap,\n>  \t\t\tN_(\"allow overlapping hunks\")),\n>  \t\tOPT__VERBOSE(&state->apply_verbosity, N_(\"be verbose\")),\n> +\t\tOPT_SET_INT('q', \"quiet\", &state->apply_verbosity,\n> +\t\t\tN_(\"be quiet\"), -1),\n>  \t\tOPT_BIT(0, \"inaccurate-eof\", options,\n>  \t\t\tN_(\"tolerate incorrectly detected missing new-line at the end of file\"),\n>  \t\t\tAPPLY_OPT_INACCURATE_EOF),\n"},{"id":"423125","messageId":"20210427194005.14318-1-jerry@skydio.com","threadId":"55566","inReplyTo":"20210427011314.28156-1-jerry@skydio.com","subject":"[PATCH V2] git-apply: modify prints to account for --3way changes","fromName":"Jerry Zhang","fromEmail":"jerry@skydio.com","sentAt":"2021-04-27T19:40:05Z","receivedAt":"2021-04-27T19:40:19Z","isPatch":true,"sender":{"key":"jerry@skydio.com","avatar":"https://avatars.githubusercontent.com/u/81337184?v=4"},"body":"\"git apply\" specifically calls out when it\nis falling back to 3way merge application.\nSince the order changed to preferring 3way\nand falling back to direct application,\ncontinue that behavior by printing whenever\n3way fails and git has to fall back.\n\nSigned-off-by: Jerry Zhang <jerry@skydio.com>\n---\nV1 -> V2:\n- Moved --quiet flag to separate patch\n\n apply.c | 6 +++++-\n 1 file changed, 5 insertions(+), 1 deletion(-)\n\ndiff --git a/apply.c b/apply.c\nindex a36d4002ca..7aa49e2048 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -3572,7 +3572,7 @@ static int try_threeway(struct apply_state *state,\n \t\t read_blob_object(&buf, &pre_oid, patch->old_mode))\n \t\treturn error(_(\"repository lacks the necessary blob to perform 3-way merge.\"));\n \n-\tif (state->apply_verbosity > verbosity_silent)\n+\tif (state->apply_verbosity > verbosity_silent && patch->direct_to_threeway)\n \t\tfprintf(stderr, _(\"Performing three-way merge...\\n\"));\n \n \timg = strbuf_detach(&buf, &len);\n@@ -3639,6 +3639,10 @@ static int apply_data(struct apply_state *state, struct patch *patch,\n \t\treturn -1;\n \n \tif (!state->threeway || try_threeway(state, &image, patch, st, ce) < 0) {\n+\t\tif (state->apply_verbosity > verbosity_silent &&\n+\t\t    state->threeway && !patch->direct_to_threeway)\n+\t\t\tfprintf(stderr, _(\"Falling back to direct application...\\n\"));\n+\n \t\t/* Note: with --reject, apply_fragments() returns 0 */\n \t\tif (patch->direct_to_threeway || apply_fragments(state, &image, patch) < 0)\n \t\t\treturn -1;\n-- \n2.29.0\n\n"},{"id":"423182","messageId":"xmqq7dkmc19x.fsf@gitster.g","threadId":"55566","inReplyTo":"20210427194005.14318-1-jerry@skydio.com","subject":"Re: [PATCH V2] git-apply: modify prints to account for --3way changes","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-04-28T07:32:26Z","receivedAt":"2021-04-28T07:32:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jerry Zhang <jerry@skydio.com> writes:\n\n> Subject: Re: [PATCH V2] git-apply: modify prints to account for --3way changes\n\nSorry that I missed this in the previous round, but what do you mean\nby \"prints\" here?\n\n> \"git apply\" specifically calls out when it is falling back to 3way\n> merge application.  Since the order changed to preferring 3way and\n> falling back to direct application, continue that behavior by\n> printing whenever 3way fails and git has to fall back.\n\nI am guessing it is safe to s/modify prints/adjust messages/ after\nreading this explanation.\n\n> Signed-off-by: Jerry Zhang <jerry@skydio.com>\n> ---\n> V1 -> V2:\n> - Moved --quiet flag to separate patch\n>\n>  apply.c | 6 +++++-\n>  1 file changed, 5 insertions(+), 1 deletion(-)\n>\n> diff --git a/apply.c b/apply.c\n> index a36d4002ca..7aa49e2048 100644\n> --- a/apply.c\n> +++ b/apply.c\n> @@ -3572,7 +3572,7 @@ static int try_threeway(struct apply_state *state,\n>  \t\t read_blob_object(&buf, &pre_oid, patch->old_mode))\n>  \t\treturn error(_(\"repository lacks the necessary blob to perform 3-way merge.\"));\n>  \n> -\tif (state->apply_verbosity > verbosity_silent)\n> +\tif (state->apply_verbosity > verbosity_silent && patch->direct_to_threeway)\n>  \t\tfprintf(stderr, _(\"Performing three-way merge...\\n\"));\n>  \n>  \timg = strbuf_detach(&buf, &len);\n> @@ -3639,6 +3639,10 @@ static int apply_data(struct apply_state *state, struct patch *patch,\n>  \t\treturn -1;\n>  \n>  \tif (!state->threeway || try_threeway(state, &image, patch, st, ce) < 0) {\n> +\t\tif (state->apply_verbosity > verbosity_silent &&\n> +\t\t    state->threeway && !patch->direct_to_threeway)\n> +\t\t\tfprintf(stderr, _(\"Falling back to direct application...\\n\"));\n> +\n>  \t\t/* Note: with --reject, apply_fragments() returns 0 */\n>  \t\tif (patch->direct_to_threeway || apply_fragments(state, &image, patch) < 0)\n>  \t\t\treturn -1;\n"},{"id":"423210","messageId":"CAMKO5CvLW=XYFby1pBj7FHcXpNTM-qMB8UakDG+N=UXU2Gw7fQ@mail.gmail.com","threadId":"55566","inReplyTo":"xmqq7dkmc19x.fsf@gitster.g","subject":"Re: [PATCH V2] git-apply: modify prints to account for --3way changes","fromName":"Jerry Zhang","fromEmail":"jerry@skydio.com","sentAt":"2021-04-28T18:26:09Z","receivedAt":"2021-04-28T18:26:31Z","isPatch":true,"sender":{"key":"jerry@skydio.com","avatar":"https://avatars.githubusercontent.com/u/81337184?v=4"},"body":"On Wed, Apr 28, 2021 at 12:32 AM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Jerry Zhang <jerry@skydio.com> writes:\n>\n> > Subject: Re: [PATCH V2] git-apply: modify prints to account for --3way changes\n>\n> Sorry that I missed this in the previous round, but what do you mean\n> by \"prints\" here?\n>\n> > \"git apply\" specifically calls out when it is falling back to 3way\n> > merge application.  Since the order changed to preferring 3way and\n> > falling back to direct application, continue that behavior by\n> > printing whenever 3way fails and git has to fall back.\n>\n> I am guessing it is safe to s/modify prints/adjust messages/ after\n> reading this explanation.\nSure, do you want  a new patch for that?\n>\n> > Signed-off-by: Jerry Zhang <jerry@skydio.com>\n> > ---\n> > V1 -> V2:\n> > - Moved --quiet flag to separate patch\n> >\n> >  apply.c | 6 +++++-\n> >  1 file changed, 5 insertions(+), 1 deletion(-)\n> >\n> > diff --git a/apply.c b/apply.c\n> > index a36d4002ca..7aa49e2048 100644\n> > --- a/apply.c\n> > +++ b/apply.c\n> > @@ -3572,7 +3572,7 @@ static int try_threeway(struct apply_state *state,\n> >                read_blob_object(&buf, &pre_oid, patch->old_mode))\n> >               return error(_(\"repository lacks the necessary blob to perform 3-way merge.\"));\n> >\n> > -     if (state->apply_verbosity > verbosity_silent)\n> > +     if (state->apply_verbosity > verbosity_silent && patch->direct_to_threeway)\n> >               fprintf(stderr, _(\"Performing three-way merge...\\n\"));\n> >\n> >       img = strbuf_detach(&buf, &len);\n> > @@ -3639,6 +3639,10 @@ static int apply_data(struct apply_state *state, struct patch *patch,\n> >               return -1;\n> >\n> >       if (!state->threeway || try_threeway(state, &image, patch, st, ce) < 0) {\n> > +             if (state->apply_verbosity > verbosity_silent &&\n> > +                 state->threeway && !patch->direct_to_threeway)\n> > +                     fprintf(stderr, _(\"Falling back to direct application...\\n\"));\n> > +\n> >               /* Note: with --reject, apply_fragments() returns 0 */\n> >               if (patch->direct_to_threeway || apply_fragments(state, &image, patch) < 0)\n> >                       return -1;\n"},{"id":"423224","messageId":"xmqqlf91aoux.fsf@gitster.g","threadId":"55566","inReplyTo":"CAMKO5CvLW=XYFby1pBj7FHcXpNTM-qMB8UakDG+N=UXU2Gw7fQ@mail.gmail.com","subject":"Re: [PATCH V2] git-apply: modify prints to account for --3way changes","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-04-29T00:58:14Z","receivedAt":"2021-04-29T00:58:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jerry Zhang <jerry@skydio.com> writes:\n\n> On Wed, Apr 28, 2021 at 12:32 AM Junio C Hamano <gitster@pobox.com> wrote:\n>>\n>> Jerry Zhang <jerry@skydio.com> writes:\n>>\n>> > Subject: Re: [PATCH V2] git-apply: modify prints to account for --3way changes\n>>\n>> Sorry that I missed this in the previous round, but what do you mean\n>> by \"prints\" here?\n>>\n>> > \"git apply\" specifically calls out when it is falling back to 3way\n>> > merge application.  Since the order changed to preferring 3way and\n>> > falling back to direct application, continue that behavior by\n>> > printing whenever 3way fails and git has to fall back.\n>>\n>> I am guessing it is safe to s/modify prints/adjust messages/ after\n>> reading this explanation.\n> Sure, do you want  a new patch for that?\n\nIt's not what *I* want ;-).  \n\nIf what you sent is not sufficiently clear to help readers, you\nwould want to update, no?\n\n"},{"id":"423230","messageId":"20210429023503.29631-1-jerry@skydio.com","threadId":"55566","inReplyTo":"20210427194005.14318-1-jerry@skydio.com","subject":"[PATCH V3] git-apply: adjust messages to account for --3way changes","fromName":"Jerry Zhang","fromEmail":"jerry@skydio.com","sentAt":"2021-04-29T02:35:03Z","receivedAt":"2021-04-29T02:35:16Z","isPatch":true,"sender":{"key":"jerry@skydio.com","avatar":"https://avatars.githubusercontent.com/u/81337184?v=4"},"body":"\"git apply\" specifically calls out when it\nis falling back to 3way merge application.\nSince the order changed to preferring 3way\nand falling back to direct application,\ncontinue that behavior by printing whenever\n3way fails and git has to fall back.\n\nSigned-off-by: Jerry Zhang <jerry@skydio.com>\n---\nV2->V3 \n- Changed \"modify prints\" to \"adjust messages\"\n\n apply.c | 6 +++++-\n 1 file changed, 5 insertions(+), 1 deletion(-)\n\ndiff --git a/apply.c b/apply.c\nindex 5957430433..0ddde5e8a8 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -3572,7 +3572,7 @@ static int try_threeway(struct apply_state *state,\n \t\t read_blob_object(&buf, &pre_oid, patch->old_mode))\n \t\treturn error(_(\"repository lacks the necessary blob to perform 3-way merge.\"));\n \n-\tif (state->apply_verbosity > verbosity_silent)\n+\tif (state->apply_verbosity > verbosity_silent && patch->direct_to_threeway)\n \t\tfprintf(stderr, _(\"Performing three-way merge...\\n\"));\n \n \timg = strbuf_detach(&buf, &len);\n@@ -3639,6 +3639,10 @@ static int apply_data(struct apply_state *state, struct patch *patch,\n \t\treturn -1;\n \n \tif (!state->threeway || try_threeway(state, &image, patch, st, ce) < 0) {\n+\t\tif (state->apply_verbosity > verbosity_silent &&\n+\t\t    state->threeway && !patch->direct_to_threeway)\n+\t\t\tfprintf(stderr, _(\"Falling back to direct application...\\n\"));\n+\n \t\t/* Note: with --reject, apply_fragments() returns 0 */\n \t\tif (patch->direct_to_threeway || apply_fragments(state, &image, patch) < 0)\n \t\t\treturn -1;\n-- \n2.29.0\n\n"}]}