git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Philippe Blain via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org,  Philippe Blain <levraiphilippeblain@gmail.com>
Subject: Re: [PATCH] sequencer: allow disabling conflict advice
Date: Sun, 03 Mar 2024 14:57:45 -0800	[thread overview]
Message-ID: <xmqqwmqiudna.fsf@gitster.g> (raw)
In-Reply-To: <pull.1682.git.1709396291693.gitgitgadget@gmail.com> (Philippe Blain via GitGitGadget's message of "Sat, 02 Mar 2024 16:18:11 +0000")

"Philippe Blain via GitGitGadget" <gitgitgadget@gmail.com> writes:

>  	if (msg) {
> -		advise("%s\n", msg);
> +		advise_if_enabled(ADVICE_SEQUENCER_CONFLICT, "%s\n", msg);
>  		/*
>  		 * A conflict has occurred but the porcelain
>  		 * (typically rebase --interactive) wants to take care

This hunk is good.  The block removes the CHERRY_PICK_HEAD after
giving this advice and then returns.

> @@ -480,22 +480,25 @@ static void print_advice(struct repository *r, int show_hint,
>  
>  	if (show_hint) {
>  		if (opts->no_commit)
> -			advise(_("after resolving the conflicts, mark the corrected paths\n"
> -				 "with 'git add <paths>' or 'git rm <paths>'"));
> +			advise_if_enabled(ADVICE_SEQUENCER_CONFLICT,
> +					  _("after resolving the conflicts, mark the corrected paths\n"
> +					    "with 'git add <paths>' or 'git rm <paths>'"));
>  		else if (opts->action == REPLAY_PICK)
> -			advise(_("After resolving the conflicts, mark them with\n"
> -				 "\"git add/rm <pathspec>\", then run\n"
> -				 "\"git cherry-pick --continue\".\n"
> -				 "You can instead skip this commit with \"git cherry-pick --skip\".\n"
> -				 "To abort and get back to the state before \"git cherry-pick\",\n"
> -				 "run \"git cherry-pick --abort\"."));
> +			advise_if_enabled(ADVICE_SEQUENCER_CONFLICT,
> +					  _("After resolving the conflicts, mark them with\n"
> +					    "\"git add/rm <pathspec>\", then run\n"
> +					    "\"git cherry-pick --continue\".\n"
> +					    "You can instead skip this commit with \"git cherry-pick --skip\".\n"
> +					    "To abort and get back to the state before \"git cherry-pick\",\n"
> +					    "run \"git cherry-pick --abort\"."));
>  		else if (opts->action == REPLAY_REVERT)
> -			advise(_("After resolving the conflicts, mark them with\n"
> -				 "\"git add/rm <pathspec>\", then run\n"
> -				 "\"git revert --continue\".\n"
> -				 "You can instead skip this commit with \"git revert --skip\".\n"
> -				 "To abort and get back to the state before \"git revert\",\n"
> -				 "run \"git revert --abort\"."));
> +			advise_if_enabled(ADVICE_SEQUENCER_CONFLICT,
> +					  _("After resolving the conflicts, mark them with\n"
> +					    "\"git add/rm <pathspec>\", then run\n"
> +					    "\"git revert --continue\".\n"
> +					    "You can instead skip this commit with \"git revert --skip\".\n"
> +					    "To abort and get back to the state before \"git revert\",\n"
> +					    "run \"git revert --abort\"."));
>  		else
>  			BUG("unexpected pick action in print_advice()");
>  	}

This hunk can be improved.  If I were doing this patch, I probably
would have just done

-	if (show_hint) {
+	if (show_hint && advice_enabled(ADVICE_SEQUENCER_CONFLICT)) {

and nothing else, and doing so would keep the block easier to extend
and maintain in the future.

Because the block is all about "show_hint", we have code to print
advice messages and nothing else in it currently, and more
importantly, we will not add anything other than code to print
advice messages in it.  Because of that, skipping everything when
ADVICE_SEQUENCER_CONFLICT is not enabled will not cause problems
(unlike the earlier hunk---which will break if we added "&&
advice_enabled()" to "if (msg)").  That way, when somebody teaches
this code a new kind of opts->action, they do not have to say
"advice_if_enabled(ADVICE_SEQUENCER_CONFLICT()"; they can just use
"advise()".

> diff --git a/t/t3501-revert-cherry-pick.sh b/t/t3501-revert-cherry-pick.sh
> index aeab689a98d..bc7c878b236 100755
> --- a/t/t3501-revert-cherry-pick.sh
> +++ b/t/t3501-revert-cherry-pick.sh

All changes to the file look good.


  parent reply	other threads:[~2024-03-03 22:58 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-02 16:18 [PATCH] sequencer: allow disabling conflict advice Philippe Blain via GitGitGadget
2024-03-02 16:32 ` Philippe Blain
2024-03-03 22:57 ` Junio C Hamano [this message]
2024-03-09 17:22   ` Philippe Blain
2024-03-09 18:58     ` Philippe Blain
2024-03-09 19:55       ` Junio C Hamano
2024-03-09 23:19         ` Junio C Hamano
2024-03-04 10:12 ` Phillip Wood
2024-03-04 10:27   ` Phillip Wood
2024-03-04 17:56     ` Junio C Hamano
2024-03-09 17:53       ` Philippe Blain
2024-03-09 19:15         ` Phillip Wood
2024-03-09 19:56           ` Junio C Hamano
2024-03-09 18:01   ` Philippe Blain
2024-03-10 19:50 ` [PATCH v2 0/2] Allow disabling advice shown after merge conflicts Philippe Blain via GitGitGadget
2024-03-10 19:51   ` [PATCH v2 1/2] sequencer: allow disabling conflict advice Philippe Blain via GitGitGadget
2024-03-11 10:29     ` Kristoffer Haugsbakk
2024-03-16 19:33       ` Philippe Blain
2024-03-10 19:51   ` [PATCH v2 2/2] builtin/am: " Philippe Blain via GitGitGadget
2024-03-11 10:54     ` phillip.wood123
2024-03-11 17:12       ` Junio C Hamano
2024-03-11 17:49         ` Junio C Hamano
2024-03-16 19:44           ` Philippe Blain
2024-03-16 20:01         ` Philippe Blain
2024-03-11 20:58   ` [PATCH v2 0/2] Allow disabling advice shown after merge conflicts Rubén Justo
2024-03-16 20:33     ` Philippe Blain
2024-03-16 21:16   ` [PATCH v3 " Philippe Blain via GitGitGadget
2024-03-16 21:16     ` [PATCH v3 1/2] sequencer: allow disabling conflict advice Philippe Blain via GitGitGadget
2024-03-16 21:16     ` [PATCH v3 2/2] builtin/am: " Philippe Blain via GitGitGadget
2024-03-18 16:31     ` [PATCH v3 0/2] Allow disabling advice shown after merge conflicts Junio C Hamano
2024-03-25 10:48     ` Phillip Wood
2024-03-25 16:57       ` Junio C Hamano

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=xmqqwmqiudna.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=levraiphilippeblain@gmail.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).