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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Johannes Schindelin <Johannes.Schindelin@xxxxxx> writes:

>> @@ -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.

>> +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.

>> +		/*
>> +		 * 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.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux