On Sat, Jul 28, 2018 at 11:57 AM Jeff King <p...@peff.net> wrote:
> > +static int has_duplicate_icase_entries(struct index_state *istate)
> > +{
> > +     struct string_list list = STRING_LIST_INIT_NODUP;
> > +     int i;
> > +     int found = 0;
> > +
> > +     for (i = 0; i < istate->cache_nr; i++)
> > +             string_list_append(&list, istate->cache[i]->name);
> > +
> > +     list.cmp = strcasecmp;
> > +     string_list_sort(&list);
> > +
> > +     for (i = 1; i < list.nr; i++) {
> > +             if (strcasecmp(list.items[i-1].string,
> > +                            list.items[i].string))
> > +                     continue;
> > +             found = 1;
> > +             break;
> > +     }
> > +     string_list_clear(&list, 0);
> > +
> > +     return found;
> > +}
>
> strcasecmp() will only catch a subset of the cases. We really need to
> follow the same folding rules that the filesystem would.

True. But that's how we handle case insensitivity internally. If a
filesytem has more sophisticated folding rules then git will not work
well on that one anyway.

> For the case of clone, I actually wonder if we could detect during the
> checkout step that a file already exists. Since we know that the
> directory we started with was empty, then if it does, either:
>
>   - there's some funny case-folding going on that means two paths in the
>     repository map to the same name in the filesystem; or
>
>   - somebody else is writing to the directory at the same time as us

This is exactly what my first patch does (minus the sparse checkout
part).  But without knowing the exact folding rules, I don't think we
can locate this "somebody else" who wrote the first path. So if N
paths are treated the same by this filesystem, we could only report
N-1 of them.

If we want to report just one path when this happens though, then this
works quite well.
-- 
Duy

Reply via email to