git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: gitignore + commit with excludes = bug

From
Elijah Newren <newren@gmail.com>
Date
May 10, 2021, 22:34 UTC
Message-ID
<CABPp-BHPr0aJZTRsVPK+Ga2oKZJLa75OkcyHLpZH=sD1pfpNZg@mail.gmail.com>
In-Reply-To
<CAHd-oW7veyN+qetv-Mf-qPa+bcah=JCz6mSRAzunVgaFRxdbnA@mail.gmail.com>

On Mon, May 10, 2021 at 12:37 PM Matheus Tavares Bernardino <matheus.bernardino@usp.br> wrote:

Show 24 quoted lines
>
> On Mon, May 10, 2021 at 4:27 PM Elijah Newren <newren@gmail.com> wrote:
> >
> > 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'?

Oh, right, whoops. Do you want to add this testcase, and a commit message for this (and maybe a comment explaining the double loop)?

Previous: Matheus Tavares BernardinoNext: Matheus Tavares Bernardino
Message 8 of 9 in “gitignore + commit with excludes = bug”
  1. Paul JacksonMay 1, 2021
  2. Philip OakleyMay 4, 2021
  3. Matheus TavaresMay 4, 2021
  4. Paul JacksonMay 9, 2021
  5. Philip OakleyMay 10, 2021
  6. Elijah NewrenMay 10, 2021
  7. Matheus Tavares BernardinoMay 10, 2021
  8. Elijah NewrenMay 10, 2021
  9. Matheus Tavares BernardinoMay 11, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.