git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 27, 2021, 07:46 UTC
Message-ID
<xmqqczugdvan.fsf@gitster.g>
In-Reply-To
<20210427011314.28156-1-jerry@skydio.com>
Jerry Zhang <jerry@skydio.com> writes:
Show 6 quoted lines
> "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.
That makes sense.
> Add a --quiet flag to "git apply" so the user
> can turn down the verbosity.
It makes sense, too.

But aren't they a different change that should belong to a separate patch? After all, the first point is to give the same kind of fallback warning/report as we used to before we swapped the fallback order, and no users needed extra "more silent" setting to deal with the fallback warning messages. Allowing to set the verbosity even lower may be desirable, but that is an independent new feature, isn't it?

I wonder if it is the more correct approach to replace OPT__VERBOSE() with OPT_VERBOSITY() here, instead of adding a separate OPT_SET_INT() like you did.

Thanks.
Show 38 quoted lines
> Signed-off-by: Jerry Zhang <jerry@skydio.com>
> ---
>  apply.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/apply.c b/apply.c
> index 8532b48e4f..2abf2e8a61 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;
> @@ -5050,6 +5054,8 @@ int apply_parse_options(int argc, const char **argv,
>  		OPT_BOOL(0, "allow-overlap", &state->allow_overlap,
>  			N_("allow overlapping hunks")),
>  		OPT__VERBOSE(&state->apply_verbosity, N_("be verbose")),
> +		OPT_SET_INT('q', "quiet", &state->apply_verbosity,
> +			N_("be quiet"), -1),
>  		OPT_BIT(0, "inaccurate-eof", options,
>  			N_("tolerate incorrectly detected missing new-line at the end of file"),
>  			APPLY_OPT_INACCURATE_EOF),
Previous: Jerry ZhangNext: Jerry Zhang
Message 2 of 7 in “git-apply: modify prints to account for --3way changes”
  1. git-apply: modify prints to account for --3way changesJerry Zhang, Apr 27, 2021
  2. Junio C HamanoApr 27, 2021
  3. git-apply: modify prints to account for --3way changesJerry Zhang, Apr 27, 2021
  4. Junio C HamanoApr 28, 2021
  5. Jerry ZhangApr 28, 2021
  6. Junio C HamanoApr 29, 2021
  7. git-apply: adjust messages to account for --3way changesJerry Zhang, Apr 29, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.