t / t6132-pathspec-exclude.shon commit Merge branch 'es/local-atomic-push-failure-with-http' into maint (1a27b78)
   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 pathspec uses default implicit pathspec' '
  29        git log --oneline --format=%s -- . ":(exclude)sub" >expect &&
  30        git log --oneline --format=%s -- ":(exclude)sub" >actual &&
  31        test_cmp expect actual
  32'
  33
  34test_expect_success 't_e_i() exclude sub' '
  35        git log --oneline --format=%s -- . ":(exclude)sub" >actual &&
  36        cat <<EOF >expect &&
  37sub2/file
  38file
  39EOF
  40        test_cmp expect actual
  41'
  42
  43test_expect_success 't_e_i() exclude sub/sub/file' '
  44        git log --oneline --format=%s -- . ":(exclude)sub/sub/file" >actual &&
  45        cat <<EOF >expect &&
  46sub2/file
  47sub/sub/sub/file
  48sub/file2
  49sub/file
  50file
  51EOF
  52        test_cmp expect actual
  53'
  54
  55test_expect_success 't_e_i() exclude sub using mnemonic' '
  56        git log --oneline --format=%s -- . ":!sub" >actual &&
  57        cat <<EOF >expect &&
  58sub2/file
  59file
  60EOF
  61        test_cmp expect actual
  62'
  63
  64test_expect_success 't_e_i() exclude :(icase)SUB' '
  65        git log --oneline --format=%s -- . ":(exclude,icase)SUB" >actual &&
  66        cat <<EOF >expect &&
  67sub2/file
  68file
  69EOF
  70        test_cmp expect actual
  71'
  72
  73test_expect_success 't_e_i() exclude sub2 from sub' '
  74        (
  75        cd sub &&
  76        git log --oneline --format=%s -- :/ ":/!sub2" >actual &&
  77        cat <<EOF >expect &&
  78sub/sub/sub/file
  79sub/file2
  80sub/sub/file
  81sub/file
  82file
  83EOF
  84        test_cmp expect actual
  85        )
  86'
  87
  88test_expect_success 't_e_i() exclude sub/*file' '
  89        git log --oneline --format=%s -- . ":(exclude)sub/*file" >actual &&
  90        cat <<EOF >expect &&
  91sub2/file
  92sub/file2
  93file
  94EOF
  95        test_cmp expect actual
  96'
  97
  98test_expect_success 't_e_i() exclude :(glob)sub/*/file' '
  99        git log --oneline --format=%s -- . ":(exclude,glob)sub/*/file" >actual &&
 100        cat <<EOF >expect &&
 101sub2/file
 102sub/sub/sub/file
 103sub/file2
 104sub/file
 105file
 106EOF
 107        test_cmp expect actual
 108'
 109
 110test_expect_success 'm_p_d() exclude sub' '
 111        git ls-files -- . ":(exclude)sub" >actual &&
 112        cat <<EOF >expect &&
 113file
 114sub2/file
 115EOF
 116        test_cmp expect actual
 117'
 118
 119test_expect_success 'm_p_d() exclude sub/sub/file' '
 120        git ls-files -- . ":(exclude)sub/sub/file" >actual &&
 121        cat <<EOF >expect &&
 122file
 123sub/file
 124sub/file2
 125sub/sub/sub/file
 126sub2/file
 127EOF
 128        test_cmp expect actual
 129'
 130
 131test_expect_success 'm_p_d() exclude sub using mnemonic' '
 132        git ls-files -- . ":!sub" >actual &&
 133        cat <<EOF >expect &&
 134file
 135sub2/file
 136EOF
 137        test_cmp expect actual
 138'
 139
 140test_expect_success 'm_p_d() exclude :(icase)SUB' '
 141        git ls-files -- . ":(exclude,icase)SUB" >actual &&
 142        cat <<EOF >expect &&
 143file
 144sub2/file
 145EOF
 146        test_cmp expect actual
 147'
 148
 149test_expect_success 'm_p_d() exclude sub2 from sub' '
 150        (
 151        cd sub &&
 152        git ls-files -- :/ ":/!sub2" >actual &&
 153        cat <<EOF >expect &&
 154../file
 155file
 156file2
 157sub/file
 158sub/sub/file
 159EOF
 160        test_cmp expect actual
 161        )
 162'
 163
 164test_expect_success 'm_p_d() exclude sub/*file' '
 165        git ls-files -- . ":(exclude)sub/*file" >actual &&
 166        cat <<EOF >expect &&
 167file
 168sub/file2
 169sub2/file
 170EOF
 171        test_cmp expect actual
 172'
 173
 174test_expect_success 'm_p_d() exclude :(glob)sub/*/file' '
 175        git ls-files -- . ":(exclude,glob)sub/*/file" >actual &&
 176        cat <<EOF >expect &&
 177file
 178sub/file
 179sub/file2
 180sub/sub/sub/file
 181sub2/file
 182EOF
 183        test_cmp expect actual
 184'
 185
 186test_expect_success 'multiple exclusions' '
 187        git ls-files -- ":^*/file2" ":^sub2" >actual &&
 188        cat <<-\EOF >expect &&
 189        file
 190        sub/file
 191        sub/sub/file
 192        sub/sub/sub/file
 193        EOF
 194        test_cmp expect actual
 195'
 196
 197test_expect_success 't_e_i() exclude case #8' '
 198        git init case8 &&
 199        (
 200                cd case8 &&
 201                echo file >file1 &&
 202                echo file >file2 &&
 203                git add file1 file2 &&
 204                git commit -m twofiles &&
 205                git grep -l file HEAD :^file2 >actual &&
 206                echo HEAD:file1 >expected &&
 207                test_cmp expected actual &&
 208                git grep -l file HEAD :^file1 >actual &&
 209                echo HEAD:file2 >expected &&
 210                test_cmp expected actual
 211        )
 212'
 213
 214test_done