git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jerry Zhang <jerry@skydio.com>
Cc: git@vger.kernel.org, ross@skydio.com, abe@skydio.com,
	brian.kubisiak@skydio.com
Subject: Re: [PATCH] git-apply: silence errors for success cases
Date: Wed, 21 Apr 2021 16:53:29 -0700	[thread overview]
Message-ID: <xmqqwnsvw5xi.fsf@gitster.g> (raw)
In-Reply-To: <xmqqtuo0z8mc.fsf@gitster.g> (Junio C. Hamano's message of "Tue, 20 Apr 2021 19:14:51 -0700")

Junio C Hamano <gitster@pobox.com> writes:

> Jerry Zhang <jerry@skydio.com> writes:
>
>> Certain invocations of "git apply --3way"
>> will print error messages even though git
>> is able to fall back on apply_fragments and
>> apply the patch successfully with a return
>> value of 0. To fix, return early from
>> try_threeway() in the following cases:
>
> I suspect that this is a recent breakage after we swapped the order
> of 3way fallback.  It used to be that we tried the straight
> application first (while suppressing the error messages) and then
> fell back on 3way (while fully exposing the error messages).

The other side of the coin is that we should say, before falling
back to non-3way codepath, that we saw 3way application failed, and
falling back to the straight patch, if we don't say so already with
the recent change, just like we used to say the opposite after seeing
the patch application to fail and then fell back to 3way.

In other words, we may have said, under the verbose mode, that we
are falling back to threeway only after seeing apply-fragments
failed, but if we are doing 3-way first, telling that we are doing
three-way application in try_threeway() function is actively wrong.
The message was there only because try_threeway() was a fallback and
sometimes did not happen even when the user asked to do --3way (hence
deserved a message).  Now we always try 3way first when the user asked,
the extra message should be given only after try_threeway() failed
and should talk about falling back to the straight application.

IOW, a fix something along this line, perhaps, is needed to complete
the "swap the order between 3way and direct application" series we
earlier worked on.


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

diff --git i/apply.c w/apply.c
index 8c5b29809b..6634305e9e 100644
--- i/apply.c
+++ w/apply.c
@@ -3570,7 +3570,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);
@@ -3637,6 +3637,9 @@ 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->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;





  reply	other threads:[~2021-04-21 23:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-21  0:47 [PATCH] git-apply: silence errors for success cases Jerry Zhang
2021-04-21  2:14 ` Junio C Hamano
2021-04-21 23:53   ` Junio C Hamano [this message]
2021-07-28  3:14     ` [PATCH V2] " Jerry Zhang
2021-12-11  2:05       ` Jerry Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqwnsvw5xi.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=abe@skydio.com \
    --cc=brian.kubisiak@skydio.com \
    --cc=git@vger.kernel.org \
    --cc=jerry@skydio.com \
    --cc=ross@skydio.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).