Re: [PATCH v4 08/10] dir: simplify untracked cache "ident" field
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Dec 29, 2015, 22:32 UTC
- Message-ID
- <xmqqsi2kga1x.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <1451372974-16266-9-git-send-email-chriscool@tuxfamily.org>
Christian Couder <christian.couder@gmail.com> writes:
Show 27 quoted lines
> -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()?