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

Bug? of gitignore pattern matching

From
美美纱Misha <mishanyo1001@gmail.com>
Date
Jul 7, 2020, 12:19 UTC
Message-ID
<CAMZHuz-Z2HGynUY0R5YDjkN1E12ZtD8h7OsZ9W6mawsxWQODgQ@mail.gmail.com>
In document of gitignore I found
An asterisk "*" matches anything except a slash.

This description well meets what if the asterisk is at the begging or in the middle of the pattern.

``` ~/Code/github/test on  master! 20:01:11 $ git check-ignore -v data/a/b/1

~/Code/github/test on  master! 20:01:18 $ git check-ignore -v data/a/b/2 .gitignore:2:data/**/2 data/a/b/2

~/Code/github/test on  master! 20:01:19 $ git check-ignore -v data/a/b/3 .gitignore:3:data/***/3 data/a/b/3

~/Code/github/test on  master! 20:01:20 $ cat .gitignore data/*/1 data/**/2 data/***/3

~/Code/github/test on  master! 20:01:21 $ vim .gitignore

~/Code/github/test on  master! 20:01:46 $ git check-ignore -v a/b/3 .gitignore:3:***/3 a/b/3

~/Code/github/test on  master! 20:01:51 $ git check-ignore -v a/b/2 .gitignore:2:**/2 a/b/2

~/Code/github/test on  master! 20:01:53 $ git check-ignore -v a/b/1

~/Code/github/test on  master! 20:01:54 $ cat .gitignore */1 **/2 ***/3

```

``` ~/Code/github/test on  master! 20:00:13 $ git check-ignore -v data/1/a/b .gitignore:1:data/1/* data/1/a/b

~/Code/github/test on  master! 20:00:22 $ git check-ignore -v data/2/a/b .gitignore:2:data/2/** data/2/a/b

~/Code/github/test on  master! 20:00:25 $ git check-ignore -v data/3/a/b .gitignore:3:data/3/*** data/3/a/b

~/Code/github/test on  master! 20:00:26 $ cat .gitignore data/1/* data/2/** data/3/*** ```

But if this asterisk is at the end of the ignore pattern. Seems that "*" equals to "**"

-----
And there is another question

Other consecutive asterisks are considered regular asterisks and will match according to the previous rules.

And it seems that triple asterisks act like double ones. What do regular asterisks mean, I used to believe they work as a single asterisk before testing. Maybe there is some ambiguity?

Best, Yanxiang Gao

Message 1 of 1 in “Bug? of gitignore pattern matching”
  1. 美纱MishaJul 7, 2020

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.