Re: Clean up stale .gitignore and .gitattribute patterns

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

 



On Fri, Jun 23, 2023 at 10:26:23AM -0700, Junio C Hamano wrote:

> Sebastian Schuberth <sschuberth@xxxxxxxxx> writes:
> 
> > is there a command to easily check patterns in .gitignore and
> > .gitattributes to still match something? I'd like to remove / correct
> > patterns that don't match anything anymore due to (re)moved files.
> 
> I guess "git check-attr --stdin" and "git check-ignore --stdin" will
> be part of the solution to your problem, but I do not know what the
> other parts would be.
> 
> Feeding "ls-files" output to "check-ignore --stdin" feels sort-of
> oxymoron because by definition the output from "ls-files" cannot
> contain any ignored paths.

You can feed "ls-files -o" (since without --exclude-standard it lists
every untracked file in the working tree), but note that this is
inherently incomplete. Any solution like this can only tell you which
ones are unused by what's in your current working tree, not what might
be possible if you ran "make foo" or whatever.

It can be wrong the other way, too. You might have "file.foo" sitting
around from a build last year (or even sightseeing an old commit), even
though support for building ".foo" is long gone from the code base.

So you'd really want to start with a fresh clone, then run any build
commands that might possibly put cruft in the working tree (if that's
even possible on a single platform), and then do your analysis (and see
my other mail in the thread for some hacky scripting there).

-Peff



[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