Re: Efficiently detecting paths that differ from each other only in case

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

 



On Fri, Oct 08, 2010 at 01:13:07AM -0500, Dun Peal wrote:

> Etc. I know how to do it by listing paths with ls-files, but my repo
> contains many thousands of files, so I was wondering if there was a
> more efficient way than for every commit:
> 
> 1. Get a list of all paths in the repo from ls-files.
> 2. Lowercase all paths.
> 3. Check for repeats.

You can do:

  git ls-files | tr A-Z a-z | sort | uniq -d

but:

  1. It will print only the lowercased version, not all versions.

  2. It doesn't handle filenames with embedded newlines.

You could fix both with something like:

  git ls-files -z | perl -0ne '
    push @{$h{lc($_)}}, $_;
    END {
      print join("\n", @{$h{$_}}) . "\n\n"
        foreach grep { @{$h{$_}} > 1 } keys(%h);
    }
  '

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