Re: [PATCH v15 02/16] path.c: refactor relative_path(), not only strip prefix
- From
Jiang Xin <worldhello.net@gmail.com>
- Date
- Jun 27, 2013, 03:31 UTC
- Message-ID
- <CANYiYbHi=TTuV63SN44YK-vx2+0Vy8c+cHB4z874ouSfmeaAng@mail.gmail.com>
- In-Reply-To
- <7v7ghgwyup.fsf@alter.siamese.dyndns.org>
2013/6/27 Junio C Hamano <gitster@pobox.com>:
Show 21 quoted lines
>> + } else {
>> + i++;
>> + j++;
>> + }
>> + }
>> +
>> + if (
>> + /* "prefix" seems like prefix of "in" */
>> + i >= prefix_len &&
>
> So shouldn't this be "i == prefix_len"?
>
>> + /*
>> + * but "/foo" is not a prefix of "/foobar"
>> + * (i.e. prefix not end with '/')
>> + */
>> + prefix_off < prefix_len) {
>> + if (j >= in_len) {
>
> Again, "j == in_len", isn't it? Or can i and j overrun in_len and
> prefix_len?Yes, better write as ==. But both will pass the test cases. Since this commit has been merged to next, so let it be?
-- Jiang Xin