git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Philippe Blain <levraiphilippeblain@gmail.com>
To: Junio C Hamano <gitster@pobox.com>,
	Philippe Blain via GitGitGadget <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] sequencer: allow disabling conflict advice
Date: Sat, 9 Mar 2024 12:22:23 -0500	[thread overview]
Message-ID: <6ef490d2-ce0a-f8bd-8079-6b4ef3e37eda@gmail.com> (raw)
In-Reply-To: <xmqqwmqiudna.fsf@gitster.g>

Hi Junio,

Le 2024-03-03 à 17:57, Junio C Hamano a écrit :
> "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()".

That's true and makes the changes simpler, thank you for the suggestion.
I'll do that in v2.

Philippe.

  reply	other threads:[~2024-03-09 17:22 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
2024-03-09 17:22   ` Philippe Blain [this message]
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

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

  git send-email \
    --in-reply-to=6ef490d2-ce0a-f8bd-8079-6b4ef3e37eda@gmail.com \
    --to=levraiphilippeblain@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=gitster@pobox.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.
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 NNTP newsgroup(s).