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

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/

Previous: K JayatheerthNext: JAYATHEERTH K
Message 4 of 19 in “add: fix pathspec handling when literal filenames match wildcard”
  1. 0/1 add: fix pathspec handling when literal filenames match wildcardK Jayatheerth, Apr 12, 2025
  2. 1/1 add: fix handling literal filenames and wildcardsK Jayatheerth, Apr 12, 2025
  3. t3706: Add test for wildcard vs literal pathspecK Jayatheerth, Apr 12, 2025
  4. Lucas Seiki OshiroApr 14, 2025
  5. JAYATHEERTH KApr 14, 2025
  6. Junio C HamanoApr 14, 2025
  7. brian m. carlsonApr 15, 2025
  8. JAYATHEERTH KApr 16, 2025
  9. Junio C HamanoApr 16, 2025
  10. JAYATHEERTH KApr 16, 2025
  11. Lucas Seiki OshiroApr 16, 2025
  12. Junio C HamanoApr 16, 2025
  13. JAYATHEERTH KApr 19, 2025
  14. Lucas Seiki OshiroApr 19, 2025
  15. JAYATHEERTH KApr 22, 2025
  16. JAYATHEERTH KApr 16, 2025
  17. JAYATHEERTH KApr 16, 2025
  18. Lucas Seiki OshiroApr 12, 2025
  19. JAYATHEERTH KApr 12, 2025

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.