Re: [PATCH v4 08/10] dir: simplify untracked cache "ident" field

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

 



On Tue, Dec 29, 2015 at 11:32 PM, Junio C Hamano <gitster@xxxxxxxxx> wrote:
> Christian Couder <christian.couder@xxxxxxxxx> writes:
>
>> -static int ident_in_untracked(const struct untracked_cache *uc)
>> +static int ident_current_location_in_untracked(const struct untracked_cache *uc)
>>  {
>> -     const char *end = uc->ident.buf + uc->ident.len;
>> -     const char *p   = uc->ident.buf;
>> +     struct strbuf cur_loc = STRBUF_INIT;
>> +     int res = 0;
>>
>> -     for (p = uc->ident.buf; p < end; p += strlen(p) + 1)
>> -             if (!strcmp(p, get_ident_string()))
>> -                     return 1;
>> -     return 0;
>> +     /*
>> +      * Previous git versions may have saved many strings in the
>> +      * "ident" field, but it is insane to manage many locations,
>> +      * so just take care of the first one.
>> +      */
>> +
>> +     strbuf_addf(&cur_loc, "Location %s, system ", get_git_work_tree());
>> +
>> +     if (starts_with(uc->ident.buf, cur_loc.buf))
>> +             res = 1;
>> +
>> +     strbuf_release(&cur_loc);
>> +
>> +     return res;
>>  }
>
> The ", system " part looks funny.  I think I know what you are
> trying to do, though.
>
> If the path to the working tree has ", system " as a substring,
> I wonder if funny things may happen with this starts_with()?

Yeah, I think in the next iteration I will do what Torsten suggests.
It looks like the only sane solution, other than just not using the
"ident" field anymore and relying only on config variables like the
example I give in my reply to Torsten.
--
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]