Re: [PATCH] help: always suggest common-cmds if prefix of cmd

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

 



On Thu, Nov 25, 2010 at 5:49 AM, Junio C Hamano <gitster@xxxxxxxxx> wrote:
> Erik Faye-Lund <kusmabite@xxxxxxxxx> writes:
>
>> Indeed. What about this intra-diff? Hopefully it's a bit clearer, as
>> it's closer to the original, just reusing the same logic for the new
>> similar loop... Also makes the final diff smaller, which is nice.
>>
>> diff --git a/help.c b/help.c
>> index dc76a62..d02a019 100644
>> --- a/help.c
>> +++ b/help.c
>> @@ -339,11 +339,10 @@ const char *help_unknown_cmd(const char *cmd)
>>               die ("Uh oh. Your system reports no Git commands at all.");
>>
>>       n = 0;
>> -     do {
>> -             best_similarity = main_cmds.names[n++]->len;
>> -     } while (!best_similarity);
>> -     n++;
>> -     while (n < main_cmds.cnt && best_similarity >= main_cmds.names[n]->len)
>> +     while (n < main_cmds.cnt && !main_cmds.names[n]->len)
>> +             ++n;
>> +     best_similarity = main_cmds.names[n++]->len;
>> +     while (n < main_cmds.cnt && best_similarity == main_cmds.names[n]->len)
>>               ++n;
>
> Perhaps, but it is probably more conventional to write this kind of loop with:
>
>        for (n = 0; ...; n++)
>                ...
>
> no?
>
>>       if (autocorrect && n == 1 && SIMILAR_ENOUGH(best_similarity)) {
>>               const char *assumed = main_cmds.names[0]->name;
>

Sure. I was just trying to match the existing code. But sure, I can
change that if you prefer. I think it makes the end-result slightly
nicer.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[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]