t / t7061-wtstatus-ignore.shon commit Merge branch 'sg/commit-graph-validate' (6ba06b5)
   1#!/bin/sh
   2
   3test_description='git-status ignored files'
   4
   5. ./test-lib.sh
   6
   7cat >expected <<\EOF
   8?? .gitignore
   9?? actual
  10?? expected
  11?? untracked/
  12!! untracked/ignored
  13EOF
  14
  15test_expect_success 'status untracked directory with --ignored' '
  16        echo "ignored" >.gitignore &&
  17        mkdir untracked &&
  18        : >untracked/ignored &&
  19        : >untracked/uncommitted &&
  20        git status --porcelain --ignored >actual &&
  21        test_cmp expected actual
  22'
  23
  24test_expect_success 'same with gitignore starting with BOM' '
  25        printf "\357\273\277ignored\n" >.gitignore &&
  26        mkdir -p untracked &&
  27        : >untracked/ignored &&
  28        : >untracked/uncommitted &&
  29        git status --porcelain --ignored >actual &&
  30        test_cmp expected actual
  31'
  32
  33cat >expected <<\EOF
  34?? .gitignore
  35?? actual
  36?? expected
  37?? untracked/uncommitted
  38!! untracked/ignored
  39EOF
  40
  41test_expect_success 'status untracked directory with --ignored -u' '
  42        git status --porcelain --ignored -u >actual &&
  43        test_cmp expected actual
  44'
  45cat >expected <<\EOF
  46?? untracked/uncommitted
  47!! untracked/ignored
  48EOF
  49
  50test_expect_success 'status prefixed untracked directory with --ignored' '
  51        git status --porcelain --ignored untracked/ >actual &&
  52        test_cmp expected actual
  53'
  54
  55cat >expected <<\EOF
  56?? untracked/uncommitted
  57!! untracked/ignored
  58EOF
  59
  60test_expect_success 'status prefixed untracked sub-directory with --ignored -u' '
  61        git status --porcelain --ignored -u untracked/ >actual &&
  62        test_cmp expected actual
  63'
  64
  65cat >expected <<\EOF
  66?? .gitignore
  67?? actual
  68?? expected
  69!! ignored/
  70EOF
  71
  72test_expect_success 'status ignored directory with --ignore' '
  73        rm -rf untracked &&
  74        mkdir ignored &&
  75        : >ignored/uncommitted &&
  76        git status --porcelain --ignored >actual &&
  77        test_cmp expected actual
  78'
  79
  80cat >expected <<\EOF
  81?? .gitignore
  82?? actual
  83?? expected
  84!! ignored/uncommitted
  85EOF
  86
  87test_expect_success 'status ignored directory with --ignore -u' '
  88        git status --porcelain --ignored -u >actual &&
  89        test_cmp expected actual
  90'
  91
  92cat >expected <<\EOF
  93?? .gitignore
  94?? actual
  95?? expected
  96EOF
  97
  98test_expect_success 'status empty untracked directory with --ignore' '
  99        rm -rf ignored &&
 100        mkdir untracked-ignored &&
 101        mkdir untracked-ignored/test &&
 102        git status --porcelain --ignored >actual &&
 103        test_cmp expected actual
 104'
 105
 106cat >expected <<\EOF
 107?? .gitignore
 108?? actual
 109?? expected
 110EOF
 111
 112test_expect_success 'status empty untracked directory with --ignore -u' '
 113        git status --porcelain --ignored -u >actual &&
 114        test_cmp expected actual
 115'
 116
 117cat >expected <<\EOF
 118?? .gitignore
 119?? actual
 120?? expected
 121!! untracked-ignored/
 122EOF
 123
 124test_expect_success 'status untracked directory with ignored files with --ignore' '
 125        : >untracked-ignored/ignored &&
 126        : >untracked-ignored/test/ignored &&
 127        git status --porcelain --ignored >actual &&
 128        test_cmp expected actual
 129'
 130
 131cat >expected <<\EOF
 132?? .gitignore
 133?? actual
 134?? expected
 135!! untracked-ignored/ignored
 136!! untracked-ignored/test/ignored
 137EOF
 138
 139test_expect_success 'status untracked directory with ignored files with --ignore -u' '
 140        git status --porcelain --ignored -u >actual &&
 141        test_cmp expected actual
 142'
 143
 144cat >expected <<\EOF
 145?? .gitignore
 146?? actual
 147?? expected
 148EOF
 149
 150test_expect_success 'status ignored tracked directory with --ignore' '
 151        rm -rf untracked-ignored &&
 152        mkdir tracked &&
 153        : >tracked/committed &&
 154        git add tracked/committed &&
 155        git commit -m. &&
 156        echo "tracked" >.gitignore &&
 157        git status --porcelain --ignored >actual &&
 158        test_cmp expected actual
 159'
 160
 161cat >expected <<\EOF
 162?? .gitignore
 163?? actual
 164?? expected
 165EOF
 166
 167test_expect_success 'status ignored tracked directory with --ignore -u' '
 168        git status --porcelain --ignored -u >actual &&
 169        test_cmp expected actual
 170'
 171
 172cat >expected <<\EOF
 173?? .gitignore
 174?? actual
 175?? expected
 176EOF
 177
 178test_expect_success 'status ignored tracked directory and ignored file with --ignore' '
 179        echo "committed" >>.gitignore &&
 180        git status --porcelain --ignored >actual &&
 181        test_cmp expected actual
 182'
 183
 184cat >expected <<\EOF
 185?? .gitignore
 186?? actual
 187?? expected
 188EOF
 189
 190test_expect_success 'status ignored tracked directory and ignored file with --ignore -u' '
 191        git status --porcelain --ignored -u >actual &&
 192        test_cmp expected actual
 193'
 194
 195cat >expected <<\EOF
 196?? .gitignore
 197?? actual
 198?? expected
 199!! tracked/uncommitted
 200EOF
 201
 202test_expect_success 'status ignored tracked directory and uncommitted file with --ignore' '
 203        echo "tracked" >.gitignore &&
 204        : >tracked/uncommitted &&
 205        git status --porcelain --ignored >actual &&
 206        test_cmp expected actual
 207'
 208
 209cat >expected <<\EOF
 210?? .gitignore
 211?? actual
 212?? expected
 213!! tracked/uncommitted
 214EOF
 215
 216test_expect_success 'status ignored tracked directory and uncommitted file with --ignore -u' '
 217        git status --porcelain --ignored -u >actual &&
 218        test_cmp expected actual
 219'
 220
 221cat >expected <<\EOF
 222?? .gitignore
 223?? actual
 224?? expected
 225!! tracked/ignored/
 226EOF
 227
 228test_expect_success 'status ignored tracked directory with uncommitted file in untracked subdir with --ignore' '
 229        rm -rf tracked/uncommitted &&
 230        mkdir tracked/ignored &&
 231        : >tracked/ignored/uncommitted &&
 232        git status --porcelain --ignored >actual &&
 233        test_cmp expected actual
 234'
 235
 236cat >expected <<\EOF
 237?? .gitignore
 238?? actual
 239?? expected
 240!! tracked/ignored/uncommitted
 241EOF
 242
 243test_expect_success 'status ignored tracked directory with uncommitted file in untracked subdir with --ignore -u' '
 244        git status --porcelain --ignored -u >actual &&
 245        test_cmp expected actual
 246'
 247
 248cat >expected <<\EOF
 249?? .gitignore
 250?? actual
 251?? expected
 252!! tracked/ignored/uncommitted
 253EOF
 254
 255test_expect_success 'status ignored tracked directory with uncommitted file in tracked subdir with --ignore' '
 256        : >tracked/ignored/committed &&
 257        git add -f tracked/ignored/committed &&
 258        git commit -m. &&
 259        git status --porcelain --ignored >actual &&
 260        test_cmp expected actual
 261'
 262
 263cat >expected <<\EOF
 264?? .gitignore
 265?? actual
 266?? expected
 267!! tracked/ignored/uncommitted
 268EOF
 269
 270test_expect_success 'status ignored tracked directory with uncommitted file in tracked subdir with --ignore -u' '
 271        git status --porcelain --ignored -u >actual &&
 272        test_cmp expected actual
 273'
 274
 275cat >expected <<\EOF
 276!! tracked/submodule/
 277EOF
 278
 279test_expect_success 'status ignores submodule in excluded directory' '
 280        git init tracked/submodule &&
 281        test_commit -C tracked/submodule initial &&
 282        git status --porcelain --ignored -u tracked/submodule >actual &&
 283        test_cmp expected actual
 284'
 285
 286test_done