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

Re: [PATCH] sequencer: allow disabling conflict advice

From
Philippe Blain <levraiphilippeblain@gmail.com>
Date
Mar 9, 2024, 17:22 UTC
Message-ID
<6ef490d2-ce0a-f8bd-8079-6b4ef3e37eda@gmail.com>
In-Reply-To
<xmqqwmqiudna.fsf@gitster.g>
Hi Junio,
Le 2024-03-03 à 17:57, Junio C Hamano a écrit :
Show 72 quoted lines
> "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.
Previous: Junio C HamanoNext: Philippe Blain
Message 4 of 32 in “sequencer: allow disabling conflict advice”
  1. sequencer: allow disabling conflict advicePhilippe Blain via GitGitGadget, Mar 2, 2024
  2. Philippe BlainMar 2, 2024
  3. Junio C HamanoMar 3, 2024
  4. Philippe BlainMar 9, 2024
  5. Philippe BlainMar 9, 2024
  6. Junio C HamanoMar 9, 2024
  7. Junio C HamanoMar 9, 2024
  8. Phillip WoodMar 4, 2024
  9. Phillip WoodMar 4, 2024
  10. Junio C HamanoMar 4, 2024
  11. Philippe BlainMar 9, 2024
  12. Phillip WoodMar 9, 2024
  13. Junio C HamanoMar 9, 2024
  14. Philippe BlainMar 9, 2024
  15. 0/2 Allow disabling advice shown after merge conflictsPhilippe Blain via GitGitGadget, Mar 10, 2024
  16. 1/2 sequencer: allow disabling conflict advicePhilippe Blain via GitGitGadget, Mar 10, 2024
  17. Kristoffer HaugsbakkMar 11, 2024
  18. Philippe BlainMar 16, 2024
  19. 2/2 builtin/am: allow disabling conflict advicePhilippe Blain via GitGitGadget, Mar 10, 2024
  20. phillip.wood123@gmail.comMar 11, 2024
  21. Junio C HamanoMar 11, 2024
  22. Junio C HamanoMar 11, 2024
  23. Philippe BlainMar 16, 2024
  24. Philippe BlainMar 16, 2024
  25. Rubén JustoMar 11, 2024
  26. Philippe BlainMar 16, 2024
  27. 0/2 Allow disabling advice shown after merge conflictsPhilippe Blain via GitGitGadget, Mar 16, 2024
  28. 1/2 sequencer: allow disabling conflict advicePhilippe Blain via GitGitGadget, Mar 16, 2024
  29. 2/2 builtin/am: allow disabling conflict advicePhilippe Blain via GitGitGadget, Mar 16, 2024
  30. Junio C HamanoMar 18, 2024
  31. Phillip WoodMar 25, 2024
  32. Junio C HamanoMar 25, 2024

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.