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

Re: something like git-check-ignore but considering only patterns?

From
Britton Kerin <britton.kerin@gmail.com>
Date
Jan 2, 2022, 08:12 UTC
Message-ID
<CAC4O8c95QEnV2=KueE0AOE4Dg+Jh58M2iYiVv=-655667AX85Q@mail.gmail.com>
In-Reply-To
<CABPp-BEQdpO5=j_f2MjgZjhudNZgKhDgV31M_Cy6Agx_U=KweQ@mail.gmail.com>
On Wed, Dec 29, 2021 at 2:15 PM Elijah Newren <newren@gmail.com> wrote:
Show 15 quoted lines
>
> On Wed, Dec 29, 2021 at 12:54 PM Britton Kerin <britton.kerin@gmail.com> wrote:
> >
> > I'd like to query if a file e.g. symLinkToDir/foo.o would be ignored
> > if it were in a real dir instead (don't ask) but in a general way and
> > hopefully without parsing and matching all the .gitignore entries
> > myself.  Is it possible?
>
> How would that even work?  If there is just one gitignore pattern and it was:
>
>     build/*
>
> And you tried to ask (making up a new `--patterns` flag):
>
>     git check-ignore --patterns '*/foo.o'

You're right that it wouldn't make sense for a pattern but I want to ask about a concrete path. I've got a setup that hashes source trees (some of which are large, and some of which sometimes switch between sym links and identical dirs) and some make tricks to cause it to first consider timestamps then hashes in a link-transparent way before commiting to a rebuild. I want to recycle .gitignore (and ~/.gitignore) etc. to filter out built files out of the hash input so it works right for dirs that build into themselves (as most do).

Show 6 quoted lines
> What should the command return?  True?  False?  It kinda depends on
> what that '*' actually is.  If it's "build" then it's ignored.  If
> it's not, then for this example it wouldn't be ignored.  So the best
> answer we would be able to give is "maybe", which isn't particularly
> useful.  Also, typical cases will be much more complex than that.  So
> we can only answer whether specific paths are ignored, not whether

The problem is just that check-ignore won't answer for paths it finds are beyond a link, when what I want to know is just whether a given path matches any of the patterns (and doesn't later get excluded etc.) regardless of other git or filesystem state (except source names and contents of course).

Britton
Previous: Elijah Newren
Message 3 of 3 in “something like git-check-ignore but considering only patterns?”
  1. Britton KerinDec 28, 2021
  2. Elijah NewrenDec 29, 2021
  3. Britton KerinJan 2, 2022

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.