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'
35
36cat >expected <<\EOF
37?? .gitignore
38?? actual
39?? expected
40!! ignored/
41EOF
42
43test_expect_success 'status ignored directory with --ignore' '
44 rm -rf untracked &&
45 mkdir ignored &&
46 : >ignored/uncommitted &&
47 git status --porcelain --ignored >actual &&
48 test_cmp expected actual
49'
50
51cat >expected <<\EOF
52?? .gitignore
53?? actual
54?? expected
55!! ignored/uncommitted
56EOF
57
58test_expect_success 'status ignored directory with --ignore -u' '
59 git status --porcelain --ignored -u >actual &&
60 test_cmp expected actual
61'
62
63cat >expected <<\EOF
64?? .gitignore
65?? actual
66?? expected
67!! untracked-ignored/
68EOF
69
70test_expect_success 'status untracked directory with ignored files with --ignore' '
71 rm -rf ignored &&
72 mkdir untracked-ignored &&
73 mkdir untracked-ignored/test &&
74 : >untracked-ignored/ignored &&
75 : >untracked-ignored/test/ignored &&
76 git status --porcelain --ignored >actual &&
77 test_cmp expected actual
78'
79
80cat >expected <<\EOF
81?? .gitignore
82?? actual
83?? expected
84!! untracked-ignored/ignored
85!! untracked-ignored/test/ignored
86EOF
87
88test_expect_success 'status untracked directory with ignored files with --ignore -u' '
89 git status --porcelain --ignored -u >actual &&
90 test_cmp expected actual
91'
92
93cat >expected <<\EOF
94?? .gitignore
95?? actual
96?? expected
97EOF
98
99test_expect_success 'status ignored tracked directory with --ignore' '
100 rm -rf untracked-ignored &&
101 mkdir tracked &&
102 : >tracked/committed &&
103 git add tracked/committed &&
104 git commit -m. &&
105 echo "tracked" >.gitignore &&
106 git status --porcelain --ignored >actual &&
107 test_cmp expected actual
108'
109
110cat >expected <<\EOF
111?? .gitignore
112?? actual
113?? expected
114EOF
115
116test_expect_success 'status ignored tracked directory with --ignore -u' '
117 git status --porcelain --ignored -u >actual &&
118 test_cmp expected actual
119'
120
121cat >expected <<\EOF
122?? .gitignore
123?? actual
124?? expected
125!! tracked/
126EOF
127
128test_expect_success 'status ignored tracked directory and uncommitted file with --ignore' '
129 : >tracked/uncommitted &&
130 git status --porcelain --ignored >actual &&
131 test_cmp expected actual
132'
133
134cat >expected <<\EOF
135?? .gitignore
136?? actual
137?? expected
138!! tracked/uncommitted
139EOF
140
141test_expect_success 'status ignored tracked directory and uncommitted file with --ignore -u' '
142 git status --porcelain --ignored -u >actual &&
143 test_cmp expected actual
144'
145
146test_done