Re: [PATCH] Added support for core.ignorecase when excluding gitignore entries

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

 



On Wed, Jul 15, 2009 at 11:19:05PM -0600, Joshua Jensen wrote:

> This patch allows core.ignorecase=true to work properly with
> gitignore exclusions.

Makes sense, though I can't help but wonder what would happen with a
filesystem that did more than just case (like the utf8 normalization
that happens on HFS).

Should we actually be converting the filesystem names into a canonical
format as they are read? IIRC, Linus posted some patches a few weeks ago
about "git path" versus "filesystem path", but I didn't actually look
too closely.

That seems like the right way forward to fixing these problems in the
long term, but it may make sense to do something like your patch in the
meantime.

> -                        !strcmp(exclude + 1, pathname + pathlen -
> x->patternlen + 1))
> -                        return to_exclude;
> +                    if (ignore_case) {
> +                        if (x->patternlen - 1 <= pathlen &&
> +                            !strcasecmp(exclude + 1, pathname +
> pathlen - x->patternlen + 1))
> +                            return to_exclude;
> +                    } else {
> +                        if (x->patternlen - 1 <= pathlen &&
> +                            !strcmp(exclude + 1, pathname + pathlen
> - x->patternlen + 1))
> +                            return to_exclude;
> +                    }

If your patch is the right route, it might be nice to collapse the
comparison into its own function. You end up cutting and pasting a lot
of the related conditionals and returns (like above, where 2 lines
become 9), so it might make sense to do something like:

  int filename_cmp(const char *a, const char *b, int ignore_case)
  {
    return ignore_case ? strcasecmp(a, b) : strcmp(a, b);
  }

and then just s/strcmp/filename_cmp/ at the appropriate callsites.

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