Pathspec does not accept / does not warn for specific pathspecs

From: Σταύρος Ντέντος <hidden>
Date: 2021-02-26 20:45:40

Hello there,

as I was trying to use git-archive to ... well, archive some
artifacts. So I called:
git archive HEAD -o p.zip --prefix=p/

Then, I noticed that .gitignore files from the repo were packed (and a
couple of others, but we don't care about that right now).
I wanted to exclude all .gitignore files (there is `/.gitignore` and
`/resources/.gitignore`). So I did:
git archive HEAD -o p.zip --prefix=p/ -- ':!.gitignore'

I noticed that the second-level .gitignore file was still included. I
started thinking that this is not a .gitignore pathspec, but it
matches a literal file.
I don't know why at-the-time I accepted that, since, if I write
`.ignoreFile` at a `.gitignore`, it would exclude any `.ignoreFile` at
any level. So I did:
git archive HEAD -o p.zip --prefix=p/ -- ':!/.gitignore'

Which, as expected, did not change anything; and I followed up with:
git archive HEAD -o p.zip --prefix=p/ -- ':!**/.gitignore'

Then, I noticed some weird behavior. The second-level `.gitignore` was
getting ignored, but not the first one!
Someone at the chat indicated that, the `**` was _magically_
interpreted as `*`, which is obvious to me why it won't help. So, they
suggested:
git archive HEAD -o p.zip --prefix=p/ -- ':!(glob)**/.gitignore'

Which lead to **both of the  .gitignores** to be included. And then I
was baffled.
Now I know (I guess) that the pathspec magic was `:!`, and I tried to
match against a `(glob)**/.gitignore`, i.e. `(glob)*/.gitignore`,
which, of course, it doesn't exist in any form.

And I wonder:
Why doesn't `git archive ... -- ` understand `:!.gitignore` as a
.gitignore file would do (minus the `:`)?
Why doesn't `git archive ... -- ` understand `:!**/.gitignore` as a
.gitignore file would do (minus the `:`)?
Is there some reason that `git archive ... -- ` doesn't understand
`:!(glob)**/.gitignore`? It doesn't sound awfully complicated, or
risking a lot of regression (a folder starting with `(`, and
containing valid pathspec long forms IMHO is rare), or
Is there some reason that `git archive ... -- ` doesn't warn me that
`:!(glob)**/.gitignore` is invalid (and maybe I meant
`(exclude,glob)`)?

With regards,
Ntentos Stavros
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help