| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | |
| 3 | test_description='git-status ignored files' |
| 4 | |
| 5 | . ./test-lib.shscip-shell source . . `./test-lib.sh`. |
| 6 | |
| 7 | catscip-shell system . . cat. >expected <<\EOF |
| 8 | ?? .gitignore |
| 9 | ?? actual |
| 10 | ?? expected |
| 11 | ?? untracked/ |
| 12 | !! untracked/ignored |
| 13 | EOF |
| 14 | |
| 15 | test_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 | |
| 24 | test_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 | |
| 33 | test_expect_success 'status untracked files --ignored with pathspec (no match)' ' |
| 34 | git status --porcelain --ignored -- untracked/i >actual && |
| 35 | test_must_be_empty actual && |
| 36 | git status --porcelain --ignored -- untracked/u >actual && |
| 37 | test_must_be_empty actual |
| 38 | ' |
| 39 | |
| 40 | test_expect_success 'status untracked files --ignored with pathspec (literal match)' ' |
| 41 | git status --porcelain --ignored -- untracked/ignored >actual && |
| 42 | echo "!! untracked/ignored" >expected && |
| 43 | test_cmp expected actual && |
| 44 | git status --porcelain --ignored -- untracked/uncommitted >actual && |
| 45 | echo "?? untracked/uncommitted" >expected && |
| 46 | test_cmp expected actual |
| 47 | ' |
| 48 | |
| 49 | test_expect_success 'status untracked files --ignored with pathspec (glob match)' ' |
| 50 | git status --porcelain --ignored -- untracked/i\* >actual && |
| 51 | echo "!! untracked/ignored" >expected && |
| 52 | test_cmp expected actual && |
| 53 | git status --porcelain --ignored -- untracked/u\* >actual && |
| 54 | echo "?? untracked/uncommitted" >expected && |
| 55 | test_cmp expected actual |
| 56 | ' |
| 57 | |
| 58 | catscip-shell system . . cat. >expected <<\EOF |
| 59 | ?? .gitignore |
| 60 | ?? actual |
| 61 | ?? expected |
| 62 | ?? untracked/uncommitted |
| 63 | !! untracked/ignored |
| 64 | EOF |
| 65 | |
| 66 | test_expect_success 'status untracked directory with --ignored -u' ' |
| 67 | git status --porcelain --ignored -u >actual && |
| 68 | test_cmp expected actual |
| 69 | ' |
| 70 | catscip-shell system . . cat. >expected <<\EOF |
| 71 | ?? untracked/ |
| 72 | !! untracked/ignored |
| 73 | EOF |
| 74 | |
| 75 | test_expect_success 'status of untracked directory with --ignored works with or without prefix' ' |
| 76 | git status --porcelain --ignored >tmp && |
| 77 | grep untracked/ tmp >actual && |
| 78 | rm tmp && |
| 79 | test_cmp expected actual && |
| 80 | |
| 81 | git status --porcelain --ignored untracked/ >actual && |
| 82 | test_cmp expected actual |
| 83 | ' |
| 84 | |
| 85 | catscip-shell system . . cat. >expected <<\EOF |
| 86 | ?? untracked/uncommitted |
| 87 | !! untracked/ignored |
| 88 | EOF |
| 89 | |
| 90 | test_expect_success 'status prefixed untracked sub-directory with --ignored -u' ' |
| 91 | git status --porcelain --ignored -u untracked/ >actual && |
| 92 | test_cmp expected actual |
| 93 | ' |
| 94 | |
| 95 | catscip-shell system . . cat. >expected <<\EOF |
| 96 | ?? .gitignore |
| 97 | ?? actual |
| 98 | ?? expected |
| 99 | !! ignored/ |
| 100 | EOF |
| 101 | |
| 102 | test_expect_success 'status ignored directory with --ignore' ' |
| 103 | rm -rf untracked && |
| 104 | mkdir ignored && |
| 105 | : >ignored/uncommitted && |
| 106 | git status --porcelain --ignored >actual && |
| 107 | test_cmp expected actual |
| 108 | ' |
| 109 | |
| 110 | catscip-shell system . . cat. >expected <<\EOF |
| 111 | ?? .gitignore |
| 112 | ?? actual |
| 113 | ?? expected |
| 114 | !! ignored/uncommitted |
| 115 | EOF |
| 116 | |
| 117 | test_expect_success 'status ignored directory with --ignore -u' ' |
| 118 | git status --porcelain --ignored -u >actual && |
| 119 | test_cmp expected actual |
| 120 | ' |
| 121 | |
| 122 | catscip-shell system . . cat. >expected <<\EOF |
| 123 | ?? .gitignore |
| 124 | ?? actual |
| 125 | ?? expected |
| 126 | EOF |
| 127 | |
| 128 | test_expect_success 'status empty untracked directory with --ignore' ' |
| 129 | rm -rf ignored && |
| 130 | mkdir untracked-ignored && |
| 131 | mkdir untracked-ignored/test && |
| 132 | git status --porcelain --ignored >actual && |
| 133 | test_cmp expected actual |
| 134 | ' |
| 135 | |
| 136 | catscip-shell system . . cat. >expected <<\EOF |
| 137 | ?? .gitignore |
| 138 | ?? actual |
| 139 | ?? expected |
| 140 | EOF |
| 141 | |
| 142 | test_expect_success 'status empty untracked directory with --ignore -u' ' |
| 143 | git status --porcelain --ignored -u >actual && |
| 144 | test_cmp expected actual |
| 145 | ' |
| 146 | |
| 147 | catscip-shell system . . cat. >expected <<\EOF |
| 148 | ?? .gitignore |
| 149 | ?? actual |
| 150 | ?? expected |
| 151 | !! untracked-ignored/ |
| 152 | EOF |
| 153 | |
| 154 | test_expect_success 'status untracked directory with ignored files with --ignore' ' |
| 155 | : >untracked-ignored/ignored && |
| 156 | : >untracked-ignored/test/ignored && |
| 157 | git status --porcelain --ignored >actual && |
| 158 | test_cmp expected actual |
| 159 | ' |
| 160 | |
| 161 | catscip-shell system . . cat. >expected <<\EOF |
| 162 | ?? .gitignore |
| 163 | ?? actual |
| 164 | ?? expected |
| 165 | !! untracked-ignored/ignored |
| 166 | !! untracked-ignored/test/ignored |
| 167 | EOF |
| 168 | |
| 169 | test_expect_success 'status untracked directory with ignored files with --ignore -u' ' |
| 170 | git status --porcelain --ignored -u >actual && |
| 171 | test_cmp expected actual |
| 172 | ' |
| 173 | |
| 174 | catscip-shell system . . cat. >expected <<\EOF |
| 175 | ?? .gitignore |
| 176 | ?? actual |
| 177 | ?? expected |
| 178 | EOF |
| 179 | |
| 180 | test_expect_success 'status ignored tracked directory with --ignore' ' |
| 181 | rm -rf untracked-ignored && |
| 182 | mkdir tracked && |
| 183 | : >tracked/committed && |
| 184 | git add tracked/committed && |
| 185 | git commit -m. && |
| 186 | echo "tracked" >.gitignore && |
| 187 | git status --porcelain --ignored >actual && |
| 188 | test_cmp expected actual |
| 189 | ' |
| 190 | |
| 191 | catscip-shell system . . cat. >expected <<\EOF |
| 192 | ?? .gitignore |
| 193 | ?? actual |
| 194 | ?? expected |
| 195 | EOF |
| 196 | |
| 197 | test_expect_success 'status ignored tracked directory with --ignore -u' ' |
| 198 | git status --porcelain --ignored -u >actual && |
| 199 | test_cmp expected actual |
| 200 | ' |
| 201 | |
| 202 | catscip-shell system . . cat. >expected <<\EOF |
| 203 | ?? .gitignore |
| 204 | ?? actual |
| 205 | ?? expected |
| 206 | EOF |
| 207 | |
| 208 | test_expect_success 'status ignored tracked directory and ignored file with --ignore' ' |
| 209 | echo "committed" >>.gitignore && |
| 210 | git status --porcelain --ignored >actual && |
| 211 | test_cmp expected actual |
| 212 | ' |
| 213 | |
| 214 | catscip-shell system . . cat. >expected <<\EOF |
| 215 | ?? .gitignore |
| 216 | ?? actual |
| 217 | ?? expected |
| 218 | EOF |
| 219 | |
| 220 | test_expect_success 'status ignored tracked directory and ignored file with --ignore -u' ' |
| 221 | git status --porcelain --ignored -u >actual && |
| 222 | test_cmp expected actual |
| 223 | ' |
| 224 | |
| 225 | catscip-shell system . . cat. >expected <<\EOF |
| 226 | ?? .gitignore |
| 227 | ?? actual |
| 228 | ?? expected |
| 229 | !! tracked/uncommitted |
| 230 | EOF |
| 231 | |
| 232 | test_expect_success 'status ignored tracked directory and uncommitted file with --ignore' ' |
| 233 | echo "tracked" >.gitignore && |
| 234 | : >tracked/uncommitted && |
| 235 | git status --porcelain --ignored >actual && |
| 236 | test_cmp expected actual |
| 237 | ' |
| 238 | |
| 239 | catscip-shell system . . cat. >expected <<\EOF |
| 240 | ?? .gitignore |
| 241 | ?? actual |
| 242 | ?? expected |
| 243 | !! tracked/uncommitted |
| 244 | EOF |
| 245 | |
| 246 | test_expect_success 'status ignored tracked directory and uncommitted file with --ignore -u' ' |
| 247 | git status --porcelain --ignored -u >actual && |
| 248 | test_cmp expected actual |
| 249 | ' |
| 250 | |
| 251 | catscip-shell system . . cat. >expected <<\EOF |
| 252 | ?? .gitignore |
| 253 | ?? actual |
| 254 | ?? expected |
| 255 | !! tracked/ignored/ |
| 256 | EOF |
| 257 | |
| 258 | test_expect_success 'status ignored tracked directory with uncommitted file in untracked subdir with --ignore' ' |
| 259 | rm -rf tracked/uncommitted && |
| 260 | mkdir tracked/ignored && |
| 261 | : >tracked/ignored/uncommitted && |
| 262 | git status --porcelain --ignored >actual && |
| 263 | test_cmp expected actual |
| 264 | ' |
| 265 | |
| 266 | catscip-shell system . . cat. >expected <<\EOF |
| 267 | ?? .gitignore |
| 268 | ?? actual |
| 269 | ?? expected |
| 270 | !! tracked/ignored/uncommitted |
| 271 | EOF |
| 272 | |
| 273 | test_expect_success 'status ignored tracked directory with uncommitted file in untracked subdir with --ignore -u' ' |
| 274 | git status --porcelain --ignored -u >actual && |
| 275 | test_cmp expected actual |
| 276 | ' |
| 277 | |
| 278 | catscip-shell system . . cat. >expected <<\EOF |
| 279 | ?? .gitignore |
| 280 | ?? actual |
| 281 | ?? expected |
| 282 | !! tracked/ignored/uncommitted |
| 283 | EOF |
| 284 | |
| 285 | test_expect_success 'status ignored tracked directory with uncommitted file in tracked subdir with --ignore' ' |
| 286 | : >tracked/ignored/committed && |
| 287 | git add -f tracked/ignored/committed && |
| 288 | git commit -m. && |
| 289 | git status --porcelain --ignored >actual && |
| 290 | test_cmp expected actual |
| 291 | ' |
| 292 | |
| 293 | catscip-shell system . . cat. >expected <<\EOF |
| 294 | ?? .gitignore |
| 295 | ?? actual |
| 296 | ?? expected |
| 297 | !! tracked/ignored/uncommitted |
| 298 | EOF |
| 299 | |
| 300 | test_expect_success 'status ignored tracked directory with uncommitted file in tracked subdir with --ignore -u' ' |
| 301 | git status --porcelain --ignored -u >actual && |
| 302 | test_cmp expected actual |
| 303 | ' |
| 304 | |
| 305 | catscip-shell system . . cat. >expected <<\EOF |
| 306 | !! tracked/submodule/ |
| 307 | EOF |
| 308 | |
| 309 | test_expect_success 'status ignores submodule in excluded directory' ' |
| 310 | git init tracked/submodule && |
| 311 | test_commit -C tracked/submodule initial && |
| 312 | git status --porcelain --ignored -u tracked/submodule >actual && |
| 313 | test_cmp expected actual |
| 314 | ' |
| 315 | |
| 316 | test_done |