commit 8ffaaa7349471fab7aa615df5febf6f3d1a868ac10dc3ec62e8157642619bd50 from: Stefan Sperling date: Sun May 25 16:22:15 2025 UTC ignore arbitrary amounts of leading slashes in ignore patterns, not just one commit - 7b9e559456eea8c3e5f6906fda555e0b9eb18ef299643e294fbf9482c1b9768a commit + 8ffaaa7349471fab7aa615df5febf6f3d1a868ac10dc3ec62e8157642619bd50 blob - 66a76497a4866830081bf2bad7c7be6c53d7c8181304b0f3cd4e806656199dbe blob + 12193888cf5f46ed8f21c9ea2c6a4d95d4765de78a342cb49ee187b323cff008 --- lib/worktree.c +++ lib/worktree.c @@ -3817,9 +3817,9 @@ match_path(const char *pattern, size_t pattern_len, co size_t len = pattern_len; /* - * For gitignore(7) compatibility, ignore leading slashes + * For gitignore(5) compatibility, ignore leading slashes. */ - if (len > 0 && pat[0] == '/') { + while (len > 0 && pat[0] == '/') { pat++; len--; } blob - b7a4dfc043a346d11b91e0aad900c506330af9b2cafd9841bc15dda285c18b9e blob + 62e96cdd44a4f3da491a3ac9c686ac7d9e3c85191e2c27a17ce78456f3d43650 --- regress/cmdline/status.sh +++ regress/cmdline/status.sh @@ -736,7 +736,7 @@ test_status_gitignore_leading_slashes() { echo "unversioned file" > $testroot/wt/epsilon/nu/baz echo "/foo" > $testroot/wt/.gitignore - echo "/nu" >> $testroot/wt/.gitignore + echo "//////////////////////////nu" >> $testroot/wt/.gitignore echo '? .gitignore' > $testroot/stdout.expected echo '? epsilon/bar' >> $testroot/stdout.expected