Skip to content

Commit

Permalink
bring in all ~140 tests for git pattern matching, git-ignore styile (#…
Browse files Browse the repository at this point in the history
…301)

Note that character classes are still missing.
  • Loading branch information
Byron committed Apr 7, 2022
1 parent dbe7305 commit f9ab830
Showing 1 changed file with 145 additions and 0 deletions.
145 changes: 145 additions & 0 deletions git-glob/tests/fixtures/make_baseline.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
#!/bin/bash
set -eu -o pipefail


git init -q
git config commit.gpgsign false
git config core.autocrlf false

while read -r pattern nomatch; do
echo $pattern $nomatch
done <<EOF
"a*b*c"
"abc*abc*abc"
"some/**/needle.txt"
"some/**/**/needle.txt"
"/**/test"
"/**/test"
"/**/test"
"**/.*"
"**/.*"
".*/**"
".*/**"
"a[0-9]b"
"a[!0-9]b"
"a[!0-9]b"
"[!-]" "-"
"*hello.txt"
"*hello.txt"
"*some/path/to/hello.txt"
"*some/path/to/hello.txt"
"a"
"./foo"
"**/foo"
"**/foo/bar"
"/*.c"
"*.c"
"**/m4/ltoptions.m4"
"a[^0-9]b"
"a[^0-9]b"
"[^-]"
"some/*/needle.txt"
"some/*/needle.txt"
"some/*/needle.txt"
".*/**"
"foo/**"
EOF

while read -r pattern match; do
echo $pattern $match
done <<EOF
"a" "a"
"a*b" "a_b"
"a*b*c" "abc"
"a*b*c" "a_b_c"
"a*b*c" "a___b___c"
"abc*abc*abc" "abcabcabcabcabcabcabc"
"a*a*a*a*a*a*a*a*a" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"a*b[xyz]c*d" "abxcdbxcddd"
"*.rs" ".rs"
"☃" "☃"
"some/**/needle.txt" "some/needle.txt"
"some/**/needle.txt" "some/one/needle.txt"
"some/**/needle.txt" "some/one/two/needle.txt"
"some/**/needle.txt" "some/other/needle.txt"
"**" "abcde"
"**" ""
"**" ".asdf"
"**" "/x/.asdf"
"some/**/**/needle.txt" "some/needle.txt"
"some/**/**/needle.txt" "some/one/needle.txt"
"some/**/**/needle.txt" "some/one/two/needle.txt"
"some/**/**/needle.txt" "some/other/needle.txt"
"**/test" "one/two/test"
"**/test" "one/test"
"**/test" "test"
"/**/test" "/one/two/test"
"/**/test" "/one/test"
"/**/test" "/test"
"**/.*" ".abc"
"**/.*" "abc/.abc"
"**/foo/bar" "foo/bar"
".*/**" ".abc/abc"
"test/**" "test/"
"test/**" "test/one"
"test/**" "test/one/two"
"some/*/needle.txt" "some/one/needle.txt"
"a[0-9]b" "a0b"
"a[0-9]b" "a9b"
"a[!0-9]b" "a_b"
"[a-z123]" "1"
"[1a-z23]" "1"
"[123a-z]" "1"
"[abc-]" "-"
"[-abc]" "-"
"[-a-c]" "b"
"[a-c-]" "b"
"[-]" "-"
"a[^0-9]b" "a_b"
"*hello.txt" "hello.txt"
"*hello.txt" "gareth_says_hello.txt"
"*hello.txt" "some/path/to/hello.txt"
"*hello.txt" "some\\path\\to\\hello.txt"
"*hello.txt" "/an/absolute/path/to/hello.txt"
"*some/path/to/hello.txt" "some/path/to/hello.txt"
"*some/path/to/hello.txt" "a/bigger/some/path/to/hello.txt"
"_[[]_[]]_[?]_[*]_!_" "_[_]_?_*_!_"
"aBcDeFg" "aBcDeFg" CASEI
"aBcDeFg" "abcdefg" CASEI
"aBcDeFg" "ABCDEFG" CASEI
"aBcDeFg" "AbCdEfG" CASEI
"a,b" "a,b"
" " " "
"{a,b}" "a"
"{a,b}" "b"
"{**/src/**,foo}" "abc/src/bar"
"{**/src/**,foo}" "foo"
"{[}],foo}" "}"
"{foo}" "foo"
"{}" ""
"{,}" ""
"{*.foo,*.bar,*.wat}" "test.foo"
"{*.foo,*.bar,*.wat}" "test.bar"
"{*.foo,*.bar,*.wat}" "test.wat"
"abc/def" "abc/def"
# unix only
"abc?def" "abc/def"
# windows only
"abc?def" "abc\\def"
"abc*def" "abc/def"
"abc[/]def" "abc/def"
# unix only
"abc\\def" "abc/def"
# windows only
"abc\\def" "abc/def"
"\\[" "["
"\\?" "?"
"\\*" "*"
"\\[a-z]" "\\a"
"\\?" "\\a"
"\\*" "\\\\"
# unix only
"\\a" "a"
# windows only
"\\a" "/a"
EOF

0 comments on commit f9ab830

Please sign in to comment.