Re: Fwd: Unexpected behavior of ls-files command when using --others --exclude-from, and a .gitignore file which resides in a subdirectory
- From
Jeff King <peff@peff.net>
- Date
- Jan 24, 2024, 01:09 UTC
- Message-ID
- <20240124010924.GB2603087@coredump.intra.peff.net>
- In-Reply-To
- <CAGF1KhWaOrnV8d2f_vajOT0hFK2N_8m7-p_vnZhw92ZdhXfsag@mail.gmail.com>
On Tue, Jan 23, 2024 at 06:40:10AM +0100, Raúl Núñez de Arenas Coronado wrote:
Show 15 quoted lines
> > Do you get different results from that toy repo? If not, then what is > > different about your main repo? Do you perhaps have a stray "*" match > > somewhere in .git/info/exclude, etc? Or are you still providing > > --exclude-from in addition to --exclude-standard? > > The difference lies in how I deal in my computer with ignored files. I > have some files in all my repos which have to be ignored always, so I > have that pattern in my core.excludes file. BUT those files have to be > backed up on my system, just in case my local copy of the repo is lost > for some reason, as they are files I need for development in my > personal machine. > > If I use --exclude-standard, no matter if those files are being > ignored by core.excludes OR .git/info/exclude, they won't appear in > that 'list other files' command output.
Ah, OK. I understand your case better now. Then yes, I think --exclude-per-directory is the right thing for you, since it lets you just trigger parts of the exclusion mechanism, and not all. I would say to ignore the deprecation mention in the manpage. ;)
(I think this also gives an interesting use case arguing for continuing to support those more-specific exclusion options for ls-files).
If you are mostly just using core.excludesFile (and not .git/info/exclude), then I suspect:
git -c core.excludesFile /dev/null ls-files -o --exclude-standard
would work for you, too (but it sounds like you might also be using .git/info/exclude).
-Peff