Re: [PATCH 2/4] .gitignore: remove dangling file

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

 



On Tue, Dec 1, 2020 at 8:26 PM Jeff King <peff@xxxxxxxx> wrote:

> I was curious how hard it would be to find unused ones, and it is not
> too bad:
>
>   find * -type f |
>   git check-ignore --stdin -v |
>   perl -e '
>     my $ignore_file = shift;
>     while (<>) {
>       /^\Q$ignore_file\E:(\d+)/ and $seen{$1} = 1;
>     }
>     open(my $fh, "<", $ignore_file);
>     while (<$fh>) {
>       print "$. $_" unless $seen{$.};
>     }
>   ' .gitignore

Or to use a more modern language:

find * -type f |
  git check-ignore --stdin -v |
  ruby -e '
    $ignore_file = ARGV.first
    $seen = {}
    $stdin.each do |e|
      e =~ /^#{Regexp.quote($ignore_file)}:(\d+)/ and $seen[$1.to_i - 1] = true
    end
    ARGF.each_with_index do |e, i|
      print "#{i} #{e}" unless $seen[i]
    end
  ' .gitignore

-- 
Felipe Contreras



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

  Powered by Linux