#!/bin/sh global test_description := ''test globbing (and noglob) of pathspec limiting'' source ./test-lib.sh test_expect_success 'create commits with glob characters' ' test_commit unrelated bar && test_commit vanilla foo && # insert file "f*" in the commit, but in a way that avoids # the name "f*" in the worktree, because it is not allowed # on Windows (the tests below do not depend on the presence # of the file in the worktree) git update-index --add --cacheinfo 100644 "$(git rev-parse HEAD:foo)" "f*" && test_tick && git commit -m star && test_commit bracket "f[o][o]" ' test_expect_success 'vanilla pathspec matches literally' ' echo vanilla >expect && git log --format=%s -- foo >actual && test_cmp expect actual ' test_expect_success 'star pathspec globs' ' cat >expect <<-\EOF && bracket star vanilla EOF git log --format=%s -- "f*" >actual && test_cmp expect actual ' test_expect_success 'star pathspec globs' ' cat >expect <<-\EOF && bracket star vanilla EOF git log --format=%s -- ":(glob)f*" >actual && test_cmp expect actual ' test_expect_success 'bracket pathspec globs and matches literal brackets' ' cat >expect <<-\EOF && bracket vanilla EOF git log --format=%s -- "f[o][o]" >actual && test_cmp expect actual ' test_expect_success 'bracket pathspec globs and matches literal brackets' ' cat >expect <<-\EOF && bracket vanilla EOF git log --format=%s -- ":(glob)f[o][o]" >actual && test_cmp expect actual ' test_expect_success 'no-glob option matches literally (vanilla)' ' echo vanilla >expect && git --literal-pathspecs log --format=%s -- foo >actual && test_cmp expect actual ' test_expect_success 'no-glob option matches literally (vanilla)' ' echo vanilla >expect && git log --format=%s -- ":(literal)foo" >actual && test_cmp expect actual ' test_expect_success 'no-glob option matches literally (star)' ' echo star >expect && git --literal-pathspecs log --format=%s -- "f*" >actual && test_cmp expect actual ' test_expect_success 'no-glob option matches literally (star)' ' echo star >expect && git log --format=%s -- ":(literal)f*" >actual && test_cmp expect actual ' test_expect_success 'no-glob option matches literally (bracket)' ' echo bracket >expect && git --literal-pathspecs log --format=%s -- "f[o][o]" >actual && test_cmp expect actual ' test_expect_success 'no-glob option matches literally (bracket)' ' echo bracket >expect && git log --format=%s -- ":(literal)f[o][o]" >actual && test_cmp expect actual ' test_expect_success 'no-glob option disables :(literal)' ' : >expect && git --literal-pathspecs log --format=%s -- ":(literal)foo" >actual && test_cmp expect actual ' test_expect_success 'no-glob environment variable works' ' echo star >expect && GIT_LITERAL_PATHSPECS=1 git log --format=%s -- "f*" >actual && test_cmp expect actual ' test_expect_success 'blame takes global pathspec flags' ' git --literal-pathspecs blame -- foo && git --icase-pathspecs blame -- foo && git --glob-pathspecs blame -- foo && git --noglob-pathspecs blame -- foo ' test_expect_success 'setup xxx/bar' ' mkdir xxx && test_commit xxx xxx/bar ' test_expect_success '**/ works with :(glob)' ' cat >expect <<-\EOF && xxx unrelated EOF git log --format=%s -- ":(glob)**/bar" >actual && test_cmp expect actual ' test_expect_success '**/ does not work with --noglob-pathspecs' ' : >expect && git --noglob-pathspecs log --format=%s -- "**/bar" >actual && test_cmp expect actual ' test_expect_success '**/ works with :(glob) and --noglob-pathspecs' ' cat >expect <<-\EOF && xxx unrelated EOF git --noglob-pathspecs log --format=%s -- ":(glob)**/bar" >actual && test_cmp expect actual ' test_expect_success '**/ works with --glob-pathspecs' ' cat >expect <<-\EOF && xxx unrelated EOF git --glob-pathspecs log --format=%s -- "**/bar" >actual && test_cmp expect actual ' test_expect_success '**/ does not work with :(literal) and --glob-pathspecs' ' : >expect && git --glob-pathspecs log --format=%s -- ":(literal)**/bar" >actual && test_cmp expect actual ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"test globbing (and noglob) of pathspec limiting">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(SQ <"create commits with glob characters">)} { (SQ <"\n"> <"\ttest_commit unrelated bar &&\n"> <"\ttest_commit vanilla foo &&\n"> <"\t# insert file \"f*\" in the commit, but in a way that avoids\n"> <"\t# the name \"f*\" in the worktree, because it is not allowed\n"> <"\t# on Windows (the tests below do not depend on the presence\n"> <"\t# of the file in the worktree)\n"> <"\tgit update-index --add --cacheinfo 100644 \"$(git rev-parse HEAD:foo)\" \"f*\" &&\n"> <"\ttest_tick &&\n"> <"\tgit commit -m star &&\n"> <"\ttest_commit bracket \"f[o][o]\"\n"> ) } ) (C {(test_expect_success)} {(SQ <"vanilla pathspec matches literally">)} { (SQ <"\n"> <"\techo vanilla >expect &&\n"> <"\tgit log --format=%s -- foo >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"star pathspec globs">)} { (SQ <"\n"> <"\tcat >expect <<-\\EOF &&\n"> <"\tbracket\n"> <"\tstar\n"> <"\tvanilla\n"> <"\tEOF\n"> <"\tgit log --format=%s -- \"f*\" >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"star pathspec globs">)} { (SQ <"\n"> <"\tcat >expect <<-\\EOF &&\n"> <"\tbracket\n"> <"\tstar\n"> <"\tvanilla\n"> <"\tEOF\n"> <"\tgit log --format=%s -- \":(glob)f*\" >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"bracket pathspec globs and matches literal brackets">)} { (SQ <"\n"> <"\tcat >expect <<-\\EOF &&\n"> <"\tbracket\n"> <"\tvanilla\n"> <"\tEOF\n"> <"\tgit log --format=%s -- \"f[o][o]\" >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"bracket pathspec globs and matches literal brackets">)} { (SQ <"\n"> <"\tcat >expect <<-\\EOF &&\n"> <"\tbracket\n"> <"\tvanilla\n"> <"\tEOF\n"> <"\tgit log --format=%s -- \":(glob)f[o][o]\" >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"no-glob option matches literally (vanilla)">)} { (SQ <"\n"> <"\techo vanilla >expect &&\n"> <"\tgit --literal-pathspecs log --format=%s -- foo >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"no-glob option matches literally (vanilla)">)} { (SQ <"\n"> <"\techo vanilla >expect &&\n"> <"\tgit log --format=%s -- \":(literal)foo\" >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"no-glob option matches literally (star)">)} { (SQ <"\n"> <"\techo star >expect &&\n"> <"\tgit --literal-pathspecs log --format=%s -- \"f*\" >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"no-glob option matches literally (star)">)} { (SQ <"\n"> <"\techo star >expect &&\n"> <"\tgit log --format=%s -- \":(literal)f*\" >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"no-glob option matches literally (bracket)">)} { (SQ <"\n"> <"\techo bracket >expect &&\n"> <"\tgit --literal-pathspecs log --format=%s -- \"f[o][o]\" >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"no-glob option matches literally (bracket)">)} { (SQ <"\n"> <"\techo bracket >expect &&\n"> <"\tgit log --format=%s -- \":(literal)f[o][o]\" >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"no-glob option disables :(literal)">)} { (SQ <"\n"> <"\t: >expect &&\n"> <"\tgit --literal-pathspecs log --format=%s -- \":(literal)foo\" >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"no-glob environment variable works">)} { (SQ <"\n"> <"\techo star >expect &&\n"> <"\tGIT_LITERAL_PATHSPECS=1 git log --format=%s -- \"f*\" >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"blame takes global pathspec flags">)} { (SQ <"\n"> <"\tgit --literal-pathspecs blame -- foo &&\n"> <"\tgit --icase-pathspecs blame -- foo &&\n"> <"\tgit --glob-pathspecs blame -- foo &&\n"> <"\tgit --noglob-pathspecs blame -- foo\n"> ) } ) (C {(test_expect_success)} {(SQ <"setup xxx/bar">)} {(SQ <"\n"> <"\tmkdir xxx &&\n"> <"\ttest_commit xxx xxx/bar\n">)} ) (C {(test_expect_success)} {(SQ <"**/ works with :(glob)">)} { (SQ <"\n"> <"\tcat >expect <<-\\EOF &&\n"> <"\txxx\n"> <"\tunrelated\n"> <"\tEOF\n"> <"\tgit log --format=%s -- \":(glob)**/bar\" >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"**/ does not work with --noglob-pathspecs">)} { (SQ <"\n"> <"\t: >expect &&\n"> <"\tgit --noglob-pathspecs log --format=%s -- \"**/bar\" >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"**/ works with :(glob) and --noglob-pathspecs">)} { (SQ <"\n"> <"\tcat >expect <<-\\EOF &&\n"> <"\txxx\n"> <"\tunrelated\n"> <"\tEOF\n"> <"\tgit --noglob-pathspecs log --format=%s -- \":(glob)**/bar\" >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"**/ works with --glob-pathspecs">)} { (SQ <"\n"> <"\tcat >expect <<-\\EOF &&\n"> <"\txxx\n"> <"\tunrelated\n"> <"\tEOF\n"> <"\tgit --glob-pathspecs log --format=%s -- \"**/bar\" >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"**/ does not work with :(literal) and --glob-pathspecs">)} { (SQ <"\n"> <"\t: >expect &&\n"> <"\tgit --glob-pathspecs log --format=%s -- \":(literal)**/bar\" >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_done)}) ] )