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