diff mbox series

[V2] git-apply: modify prints to account for --3way changes

Message ID 20210427194005.14318-1-jerry@skydio.com (mailing list archive)
State Accepted
Commit 526705fd3d14a38646a12235ee385dcc0ffc7321
Headers show
Series [V2] git-apply: modify prints to account for --3way changes | expand

Commit Message

Jerry Zhang April 27, 2021, 7:40 p.m. UTC
"git apply" specifically calls out when it
is falling back to 3way merge application.
Since the order changed to preferring 3way
and falling back to direct application,
continue that behavior by printing whenever
3way fails and git has to fall back.

Signed-off-by: Jerry Zhang <jerry@skydio.com>
---
V1 -> V2:
- Moved --quiet flag to separate patch

 apply.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Junio C Hamano April 28, 2021, 7:32 a.m. UTC | #1
Jerry Zhang <jerry@skydio.com> writes:

> Subject: Re: [PATCH V2] git-apply: modify prints to account for --3way changes

Sorry that I missed this in the previous round, but what do you mean
by "prints" here?

> "git apply" specifically calls out when it is falling back to 3way
> merge application.  Since the order changed to preferring 3way and
> falling back to direct application, continue that behavior by
> printing whenever 3way fails and git has to fall back.

I am guessing it is safe to s/modify prints/adjust messages/ after
reading this explanation.

> Signed-off-by: Jerry Zhang <jerry@skydio.com>
> ---
> V1 -> V2:
> - Moved --quiet flag to separate patch
>
>  apply.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/apply.c b/apply.c
> index a36d4002ca..7aa49e2048 100644
> --- a/apply.c
> +++ b/apply.c
> @@ -3572,7 +3572,7 @@ static int try_threeway(struct apply_state *state,
>  		 read_blob_object(&buf, &pre_oid, patch->old_mode))
>  		return error(_("repository lacks the necessary blob to perform 3-way merge."));
>  
> -	if (state->apply_verbosity > verbosity_silent)
> +	if (state->apply_verbosity > verbosity_silent && patch->direct_to_threeway)
>  		fprintf(stderr, _("Performing three-way merge...\n"));
>  
>  	img = strbuf_detach(&buf, &len);
> @@ -3639,6 +3639,10 @@ static int apply_data(struct apply_state *state, struct patch *patch,
>  		return -1;
>  
>  	if (!state->threeway || try_threeway(state, &image, patch, st, ce) < 0) {
> +		if (state->apply_verbosity > verbosity_silent &&
> +		    state->threeway && !patch->direct_to_threeway)
> +			fprintf(stderr, _("Falling back to direct application...\n"));
> +
>  		/* Note: with --reject, apply_fragments() returns 0 */
>  		if (patch->direct_to_threeway || apply_fragments(state, &image, patch) < 0)
>  			return -1;
Jerry Zhang April 28, 2021, 6:26 p.m. UTC | #2
On Wed, Apr 28, 2021 at 12:32 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> Jerry Zhang <jerry@skydio.com> writes:
>
> > Subject: Re: [PATCH V2] git-apply: modify prints to account for --3way changes
>
> Sorry that I missed this in the previous round, but what do you mean
> by "prints" here?
>
> > "git apply" specifically calls out when it is falling back to 3way
> > merge application.  Since the order changed to preferring 3way and
> > falling back to direct application, continue that behavior by
> > printing whenever 3way fails and git has to fall back.
>
> I am guessing it is safe to s/modify prints/adjust messages/ after
> reading this explanation.
Sure, do you want  a new patch for that?
>
> > Signed-off-by: Jerry Zhang <jerry@skydio.com>
> > ---
> > V1 -> V2:
> > - Moved --quiet flag to separate patch
> >
> >  apply.c | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/apply.c b/apply.c
> > index a36d4002ca..7aa49e2048 100644
> > --- a/apply.c
> > +++ b/apply.c
> > @@ -3572,7 +3572,7 @@ static int try_threeway(struct apply_state *state,
> >                read_blob_object(&buf, &pre_oid, patch->old_mode))
> >               return error(_("repository lacks the necessary blob to perform 3-way merge."));
> >
> > -     if (state->apply_verbosity > verbosity_silent)
> > +     if (state->apply_verbosity > verbosity_silent && patch->direct_to_threeway)
> >               fprintf(stderr, _("Performing three-way merge...\n"));
> >
> >       img = strbuf_detach(&buf, &len);
> > @@ -3639,6 +3639,10 @@ static int apply_data(struct apply_state *state, struct patch *patch,
> >               return -1;
> >
> >       if (!state->threeway || try_threeway(state, &image, patch, st, ce) < 0) {
> > +             if (state->apply_verbosity > verbosity_silent &&
> > +                 state->threeway && !patch->direct_to_threeway)
> > +                     fprintf(stderr, _("Falling back to direct application...\n"));
> > +
> >               /* Note: with --reject, apply_fragments() returns 0 */
> >               if (patch->direct_to_threeway || apply_fragments(state, &image, patch) < 0)
> >                       return -1;
Junio C Hamano April 29, 2021, 12:58 a.m. UTC | #3
Jerry Zhang <jerry@skydio.com> writes:

> On Wed, Apr 28, 2021 at 12:32 AM Junio C Hamano <gitster@pobox.com> wrote:
>>
>> Jerry Zhang <jerry@skydio.com> writes:
>>
>> > Subject: Re: [PATCH V2] git-apply: modify prints to account for --3way changes
>>
>> Sorry that I missed this in the previous round, but what do you mean
>> by "prints" here?
>>
>> > "git apply" specifically calls out when it is falling back to 3way
>> > merge application.  Since the order changed to preferring 3way and
>> > falling back to direct application, continue that behavior by
>> > printing whenever 3way fails and git has to fall back.
>>
>> I am guessing it is safe to s/modify prints/adjust messages/ after
>> reading this explanation.
> Sure, do you want  a new patch for that?

It's not what *I* want ;-).  

If what you sent is not sufficiently clear to help readers, you
would want to update, no?
diff mbox series

Patch

diff --git a/apply.c b/apply.c
index a36d4002ca..7aa49e2048 100644
--- a/apply.c
+++ b/apply.c
@@ -3572,7 +3572,7 @@  static int try_threeway(struct apply_state *state,
 		 read_blob_object(&buf, &pre_oid, patch->old_mode))
 		return error(_("repository lacks the necessary blob to perform 3-way merge."));
 
-	if (state->apply_verbosity > verbosity_silent)
+	if (state->apply_verbosity > verbosity_silent && patch->direct_to_threeway)
 		fprintf(stderr, _("Performing three-way merge...\n"));
 
 	img = strbuf_detach(&buf, &len);
@@ -3639,6 +3639,10 @@  static int apply_data(struct apply_state *state, struct patch *patch,
 		return -1;
 
 	if (!state->threeway || try_threeway(state, &image, patch, st, ce) < 0) {
+		if (state->apply_verbosity > verbosity_silent &&
+		    state->threeway && !patch->direct_to_threeway)
+			fprintf(stderr, _("Falling back to direct application...\n"));
+
 		/* Note: with --reject, apply_fragments() returns 0 */
 		if (patch->direct_to_threeway || apply_fragments(state, &image, patch) < 0)
 			return -1;