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

Re: [PATCH v2] sequencer: fix edit handling for cherry-pick and revert messages

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 30, 2021, 18:47 UTC
Message-ID
<xmqq7dloeawf.fsf@gitster.g>
In-Reply-To
<nycvar.QRO.7.76.6.2103301200020.52@tvgsbejvaqbjf.bet>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 8 quoted lines
>> @@ -182,7 +182,7 @@ static int run_sequencer(int argc, const char **argv, struct replay_opts *opts)
>>  				"--signoff", opts->signoff,
>>  				"--no-commit", opts->no_commit,
>>  				"-x", opts->record_origin,
>> -				"--edit", opts->edit,
>> +				"--edit", opts->edit == 1,
>
> Honestly, I'd prefer `> 0` here.

Unless somebody (including Elijah) is trying to soon introduce yet another value to .edit member, I'd agree 100%. If it is a tristate (unspecified, no, yes), I think "is it positive" should be the way to ask "does the user definitely wants it?", "is it zero" should be the way to ask "does the user definitely declines it?" and "is it non-negative" (and "is it negative") the way to ask "does the user care (or not care)?". Using that consistently is good.

Show 7 quoted lines
>> +static int should_edit(struct replay_opts *opts) {
>> +	assert(opts->edit >= -1 && opts->edit <= 1);
>
> Do we really want to introduce more of these useless `assert()`s? I know
> that we stopped converting them to `BUG()`, but I really dislike
> introducing new ones: they have very little effect, being no-ops by
> default in most setups.

Yeah, in a new code in flux where programmers can easily make errors, "if (...) BUG()" may not be a bad thing to add (but then we may want to see if we can make the codepaths involved less error prone), but I agree with your view that assert() is mostly useless. A comment that explains the expectation and why that expectation is there would be more useful.

>> +	if (opts->edit == -1)
>
> Maybe `< 0`, as we do elsewhere for "not specified"?
Yup.
Show 8 quoted lines
>> +		/*
>> +		 * Note that we only handle the case of non-conflicted
>> +		 * commits; continue_single_pick() handles the conflicted
>> +		 * commits itself instead of calling this function.
>> +		 */
>> +		return (opts->action == REPLAY_REVERT && isatty(0)) ? 1 : 0;
>
> Apart from the extra parentheses, that makes sense to me.

I can take it either way (but personally I think this particular one is easier to see as written---this is subjective).

> ...
> The rest looks good, and the comments are _really_ helpful.
Yup, I agree.
Thanks for a review.
Previous: Johannes SchindelinNext: Elijah Newren
Message 10 of 28 in “sequencer: fix edit handling for cherry-pick and revert messages”
  1. sequencer: fix edit handling for cherry-pick and revert messagesElijah Newren via GitGitGadget, Mar 26, 2021
  2. Philip OakleyMar 26, 2021
  3. Elijah NewrenMar 26, 2021
  4. Junio C HamanoMar 28, 2021
  5. Phillip WoodMar 29, 2021
  6. Junio C HamanoMar 29, 2021
  7. Elijah NewrenMar 29, 2021
  8. sequencer: fix edit handling for cherry-pick and revert messagesElijah Newren via GitGitGadget, Mar 30, 2021
  9. Johannes SchindelinMar 30, 2021
  10. Junio C HamanoMar 30, 2021
  11. Elijah NewrenMar 30, 2021
  12. Ævar Arnfjörð BjarmasonMar 31, 2021
  13. Elijah NewrenMar 31, 2021
  14. Junio C HamanoMar 31, 2021
  15. Elijah NewrenApr 1, 2021
  16. Elijah NewrenMar 30, 2021
  17. unifying sequencer's options persisting, was Re: [PATCH v2] sequencer: fix edit handling for cherry-pick and revert messagesJohannes Schindelin, Mar 31, 2021
  18. Phillip WoodApr 2, 2021
  19. Phillip WoodApr 2, 2021
  20. Junio C HamanoApr 2, 2021
  21. Elijah NewrenApr 2, 2021
  22. Junio C HamanoApr 2, 2021
  23. Johannes SchindelinApr 8, 2021
  24. Junio C HamanoApr 8, 2021
  25. Christian CouderApr 8, 2021
  26. Johannes SchindelinApr 9, 2021
  27. sequencer: fix edit handling for cherry-pick and revert messagesElijah Newren via GitGitGadget, Mar 31, 2021
  28. Johannes SchindelinMar 31, 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.