Re: gitignore + commit with excludes = bug
- From
Matheus Tavares Bernardino <matheus.bernardino@usp.br>
- Date
- May 10, 2021, 19:37 UTC
- Message-ID
- <CAHd-oW7veyN+qetv-Mf-qPa+bcah=JCz6mSRAzunVgaFRxdbnA@mail.gmail.com>
- In-Reply-To
- <CABPp-BFpeoENLADH-e6dCc0PyEVQyHueY6PV8AZYbD+a3iceXA@mail.gmail.com>
On Mon, May 10, 2021 at 4:27 PM Elijah Newren <newren@gmail.com> wrote:
Show 18 quoted lines
> > Thanks for tracking this down. Your analysis and patch look correct > to me, but perhaps we could simplify the code a bit. Instead of > looping twice, perhaps insert the following code above the if-checks: > > + /* > + * We can have a bunch of exclusion rules: > + * .gitignore > + * *.log > + * !settings.log > + * and we're trying to see if the path matches one of these, > + * but note that the last one is a "negated exclusion rule", > + * for the excludes to match this pathspec, it needs to not > + * match the negated exclusion. > + */ > + int retval = (item->magic & PATHSPEC_EXCLUDE) ? 0 : 1; > > and then change all the "return 1" statements to "return retval".
Hmm, but then wouldn't something like `git add ignored :^ignored` also trigger the warning, as we see 'ignored' first, and return 1 before seeing ':^ignored'?