Re: [PATCH] t3706: Add test for wildcard vs literal pathspec
- From
Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
- Date
- Apr 14, 2025, 16:51 UTC
- Message-ID
- <FFC5C6BE-9A4B-4EFD-AEC4-E69CE6610054@gmail.com>
- In-Reply-To
- <20250412174051.780148-1-jayatheerthkulkarni2005@gmail.com>
Hi!
Show 20 quoted lines
> +test_expect_success 'setup: create files and initial commit' ' > + mkdir testdir && > + >testdir/f\* && > + >testdir/f\*\* && > + >testdir/foo && > + git add testdir && > + git commit -m "Initial setup with literal wildcard files" > +' > + > +test_expect_success 'clean slate before testing wildcard behavior' ' > + git rm -rf testdir && > + git commit -m "Clean state" > +' > > +test_expect_success 'recreate files to test add behavior' ' > + mkdir testdir && > + >testdir/f\* && > + >testdir/f\*\* && > + >testdir/foo > +'
Two questions:
1. Does this need to be inside a test_expect_success? It seems to me that those two tests cases are actually setup code for the next two.
2. If so, does it need to have all that setup? I could reproduce the bug by only running:
``` git reset touch foo 'f*' 'f**' git add 'f*' git ls-files ```
btw, this works with your code, congrats!
Other idea: `?` is another wildcard for matching only one character. Have you tested if the same bug happens with it?
PS: while I was writing this review I pushed this to my GitHub just to make the CI run the entire test suite since pathspecs are a sensible part of Git.
Take look at this, it seems that your tests aren't passing on Windows: https://github.com/lucasoshiro/git/actions/runs/14450183624/job/40521015897. Perhaps you'll need to change something there. It seems to be related to how Windows handle paths (specially the \ character, which means the same as / in Unix). Personally, I'm not a Windows guy and can't help you further with this. A quick reference on how paths on Windows work is this (and yeah, they are far more complex than in Unix): https://www.fileside.app/blog/2023-03-17_windows-file-paths/