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