t / t6130-pathspec-noglob.shon commit Merge branch 'rs/pretty-use-prefixcmp' (3ab4c54)
   1#!/bin/sh
   2
   3test_description='test globbing (and noglob) of pathspec limiting'
   4. ./test-lib.sh
   5
   6test_expect_success 'create commits with glob characters' '
   7        test_commit unrelated bar &&
   8        test_commit vanilla foo &&
   9        # insert file "f*" in the commit, but in a way that avoids
  10        # the name "f*" in the worktree, because it is not allowed
  11        # on Windows (the tests below do not depend on the presence
  12        # of the file in the worktree)
  13        git update-index --add --cacheinfo 100644 "$(git rev-parse HEAD:foo)" "f*" &&
  14        test_tick &&
  15        git commit -m star &&
  16        test_commit bracket "f[o][o]"
  17'
  18
  19test_expect_success 'vanilla pathspec matches literally' '
  20        echo vanilla >expect &&
  21        git log --format=%s -- foo >actual &&
  22        test_cmp expect actual
  23'
  24
  25test_expect_success 'star pathspec globs' '
  26        cat >expect <<-\EOF &&
  27        bracket
  28        star
  29        vanilla
  30        EOF
  31        git log --format=%s -- "f*" >actual &&
  32        test_cmp expect actual
  33'
  34
  35test_expect_success 'bracket pathspec globs and matches literal brackets' '
  36        cat >expect <<-\EOF &&
  37        bracket
  38        vanilla
  39        EOF
  40        git log --format=%s -- "f[o][o]" >actual &&
  41        test_cmp expect actual
  42'
  43
  44test_expect_success 'no-glob option matches literally (vanilla)' '
  45        echo vanilla >expect &&
  46        git --literal-pathspecs log --format=%s -- foo >actual &&
  47        test_cmp expect actual
  48'
  49
  50test_expect_success 'no-glob option matches literally (star)' '
  51        echo star >expect &&
  52        git --literal-pathspecs log --format=%s -- "f*" >actual &&
  53        test_cmp expect actual
  54'
  55
  56test_expect_success 'no-glob option matches literally (bracket)' '
  57        echo bracket >expect &&
  58        git --literal-pathspecs log --format=%s -- "f[o][o]" >actual &&
  59        test_cmp expect actual
  60'
  61
  62test_expect_success 'no-glob environment variable works' '
  63        echo star >expect &&
  64        GIT_LITERAL_PATHSPECS=1 git log --format=%s -- "f*" >actual &&
  65        test_cmp expect actual
  66'
  67
  68test_done