t / t6132-pathspec-exclude.shon commit update-ref.c: extract a new function, parse_next_sha1() (3afcc46)
   1#!/bin/sh
   2
   3test_description='test case exclude pathspec'
   4
   5. ./test-lib.sh
   6
   7test_expect_success 'setup' '
   8        for p in file sub/file sub/sub/file sub/file2 sub/sub/sub/file sub2/file; do
   9                if echo $p | grep /; then
  10                        mkdir -p `dirname $p`
  11                fi &&
  12                : >$p &&
  13                git add $p &&
  14                git commit -m $p
  15        done &&
  16        git log --oneline --format=%s >actual &&
  17        cat <<EOF >expect &&
  18sub2/file
  19sub/sub/sub/file
  20sub/file2
  21sub/sub/file
  22sub/file
  23file
  24EOF
  25        test_cmp expect actual
  26'
  27
  28test_expect_success 'exclude only should error out' '
  29        test_must_fail git log --oneline --format=%s -- ":(exclude)sub"
  30'
  31
  32test_expect_success 't_e_i() exclude sub' '
  33        git log --oneline --format=%s -- . ":(exclude)sub" >actual
  34        cat <<EOF >expect &&
  35sub2/file
  36file
  37EOF
  38        test_cmp expect actual
  39'
  40
  41test_expect_success 't_e_i() exclude sub/sub/file' '
  42        git log --oneline --format=%s -- . ":(exclude)sub/sub/file" >actual
  43        cat <<EOF >expect &&
  44sub2/file
  45sub/sub/sub/file
  46sub/file2
  47sub/file
  48file
  49EOF
  50        test_cmp expect actual
  51'
  52
  53test_expect_success 't_e_i() exclude sub using mnemonic' '
  54        git log --oneline --format=%s -- . ":!sub" >actual
  55        cat <<EOF >expect &&
  56sub2/file
  57file
  58EOF
  59        test_cmp expect actual
  60'
  61
  62test_expect_success 't_e_i() exclude :(icase)SUB' '
  63        git log --oneline --format=%s -- . ":(exclude,icase)SUB" >actual
  64        cat <<EOF >expect &&
  65sub2/file
  66file
  67EOF
  68        test_cmp expect actual
  69'
  70
  71test_expect_success 't_e_i() exclude sub2 from sub' '
  72        (
  73        cd sub &&
  74        git log --oneline --format=%s -- :/ ":/!sub2" >actual
  75        cat <<EOF >expect &&
  76sub/sub/sub/file
  77sub/file2
  78sub/sub/file
  79sub/file
  80file
  81EOF
  82        test_cmp expect actual
  83        )
  84'
  85
  86test_expect_success 't_e_i() exclude sub/*file' '
  87        git log --oneline --format=%s -- . ":(exclude)sub/*file" >actual
  88        cat <<EOF >expect &&
  89sub2/file
  90sub/file2
  91file
  92EOF
  93        test_cmp expect actual
  94'
  95
  96test_expect_success 't_e_i() exclude :(glob)sub/*/file' '
  97        git log --oneline --format=%s -- . ":(exclude,glob)sub/*/file" >actual
  98        cat <<EOF >expect &&
  99sub2/file
 100sub/sub/sub/file
 101sub/file2
 102sub/file
 103file
 104EOF
 105        test_cmp expect actual
 106'
 107
 108test_expect_success 'm_p_d() exclude sub' '
 109        git ls-files -- . ":(exclude)sub" >actual
 110        cat <<EOF >expect &&
 111file
 112sub2/file
 113EOF
 114        test_cmp expect actual
 115'
 116
 117test_expect_success 'm_p_d() exclude sub/sub/file' '
 118        git ls-files -- . ":(exclude)sub/sub/file" >actual
 119        cat <<EOF >expect &&
 120file
 121sub/file
 122sub/file2
 123sub/sub/sub/file
 124sub2/file
 125EOF
 126        test_cmp expect actual
 127'
 128
 129test_expect_success 'm_p_d() exclude sub using mnemonic' '
 130        git ls-files -- . ":!sub" >actual
 131        cat <<EOF >expect &&
 132file
 133sub2/file
 134EOF
 135        test_cmp expect actual
 136'
 137
 138test_expect_success 'm_p_d() exclude :(icase)SUB' '
 139        git ls-files -- . ":(exclude,icase)SUB" >actual
 140        cat <<EOF >expect &&
 141file
 142sub2/file
 143EOF
 144        test_cmp expect actual
 145'
 146
 147test_expect_success 'm_p_d() exclude sub2 from sub' '
 148        (
 149        cd sub &&
 150        git ls-files -- :/ ":/!sub2" >actual
 151        cat <<EOF >expect &&
 152../file
 153file
 154file2
 155sub/file
 156sub/sub/file
 157EOF
 158        test_cmp expect actual
 159        )
 160'
 161
 162test_expect_success 'm_p_d() exclude sub/*file' '
 163        git ls-files -- . ":(exclude)sub/*file" >actual
 164        cat <<EOF >expect &&
 165file
 166sub/file2
 167sub2/file
 168EOF
 169        test_cmp expect actual
 170'
 171
 172test_expect_success 'm_p_d() exclude :(glob)sub/*/file' '
 173        git ls-files -- . ":(exclude,glob)sub/*/file" >actual
 174        cat <<EOF >expect &&
 175file
 176sub/file
 177sub/file2
 178sub/sub/sub/file
 179sub2/file
 180EOF
 181        test_cmp expect actual
 182'
 183
 184test_done