Re: [PATCH v3] bisect--helper: convert a function in shell to C
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 23, 2016, 16:15 UTC
- Message-ID
- <xmqqy499cgrb.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <alpine.DEB.2.20.1603231238180.4690@virtualbox>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 9 quoted lines
>> + if (one_of(term, "help", "start", "skip", "next", "reset", "visualize", >> + "replay", "log", "run", NULL)) > > If I understood Junio correctly, he meant to line up the second line with > the corresponding level. In this case, as "replay" is a parameter of the > one_of() function, the indentation would look like this instead: > > if (one_of(term, "help", "start", "skip", "next", "reset", "visualize", > "replay", "log", "run", NULL))
Thanks for clarification. It may also make sense to wrap the first line one word earlier.
Show 13 quoted lines
>> + die("can't use the builtin command '%s' as a term", term);
>> +
>> + /* In theory, nothing prevents swapping
>> + * completely good and bad, but this situation
>> + * could be confusing and hasn't been tested
>> + * enough. Forbid it for now.
>> + */
>
> I see quite a few comments that put the closing "*/" on its own line, but
> do not award the same pleasure to the opening "/*". Personally, I much
> prefer the opening "/*" to have an entire line to itself, too, but I guess
> that there is enough precendence in Git's source code to accept both
> forms.We do want to see "/*" and "*/" on their own lines, and new code should definitely do so.
Show 15 quoted lines
>> + if (!strcmp(term, "bad") || !strcmp(term, "new"))
>> + if (strcmp(revision, "bad"))
>> + die("can't change the meaning of term '%s'", term);
>> +
>> + if(!strcmp(term, "good") || !strcmp(term, "old"))
>> + if (strcmp(revision, "good"))
>> + die("can't change the meaning of term '%s'", term);
>
> I am still convinced that
>
> if ((one_of(term, "bad", "new", NULL) && strcmp(orig_term, "bad")) ||
> (one_of(term, "good", "old", NULL) && strcmp(orig_term, "good")))
> die("can't change the meaning of term '%s'", term);
>
> looks so much nicer.... and more importantly, easier to understand what is going on.
Thanks.