@@ -17,19 +17,21 @@ test_expect_success 'stash save --include-untracked some dirty working directory
17
17
echo 3 > file &&
18
18
test_tick &&
19
19
echo 1 > file2 &&
20
+ mkdir untracked &&
21
+ echo untracked >untracked/untracked &&
20
22
git stash --include-untracked &&
21
23
git diff-files --quiet &&
22
24
git diff-index --cached --quiet HEAD
23
25
'
24
26
25
27
cat > expect << EOF
28
+ ?? actual
26
29
?? expect
27
- ?? output
28
30
EOF
29
31
30
32
test_expect_success ' stash save --include-untracked cleaned the untracked files' '
31
- git status --porcelain > output
32
- test_cmp output expect
33
+ git status --porcelain >actual &&
34
+ test_cmp expect actual
33
35
'
34
36
35
37
cat > expect.diff << EOF
@@ -40,17 +42,26 @@ index 0000000..d00491f
40
42
+++ b/file2
41
43
@@ -0,0 +1 @@
42
44
+1
45
+ diff --git a/untracked/untracked b/untracked/untracked
46
+ new file mode 100644
47
+ index 0000000..5a72eb2
48
+ --- /dev/null
49
+ +++ b/untracked/untracked
50
+ @@ -0,0 +1 @@
51
+ +untracked
43
52
EOF
44
53
cat > expect.lstree << EOF
45
54
file2
55
+ untracked
46
56
EOF
47
57
48
58
test_expect_success ' stash save --include-untracked stashed the untracked files' '
49
59
test "!" -f file2 &&
50
- git diff HEAD..stash^3 -- file2 > output &&
51
- test_cmp output expect.diff &&
52
- git ls-tree --name-only stash^3: > output &&
53
- test_cmp output expect.lstree
60
+ test ! -e untracked &&
61
+ git diff HEAD stash^3 -- file2 untracked >actual &&
62
+ test_cmp expect.diff actual &&
63
+ git ls-tree --name-only stash^3: >actual &&
64
+ test_cmp expect.lstree actual
54
65
'
55
66
test_expect_success ' stash save --patch --include-untracked fails' '
56
67
test_must_fail git stash --patch --include-untracked
@@ -64,18 +75,21 @@ git clean --force --quiet
64
75
65
76
cat > expect << EOF
66
77
M file
78
+ ?? actual
67
79
?? expect
68
80
?? file2
69
- ?? output
81
+ ?? untracked/
70
82
EOF
71
83
72
84
test_expect_success ' stash pop after save --include-untracked leaves files untracked again' '
73
85
git stash pop &&
74
- git status --porcelain > output
75
- test_cmp output expect
86
+ git status --porcelain >actual &&
87
+ test_cmp expect actual &&
88
+ test "1" = "`cat file2`" &&
89
+ test untracked = "`cat untracked/untracked`"
76
90
'
77
91
78
- git clean --force --quiet
92
+ git clean --force --quiet -d
79
93
80
94
test_expect_success ' stash save -u dirty index' '
81
95
echo 4 > file3 &&
96
110
97
111
test_expect_success ' stash save --include-untracked dirty index got stashed' '
98
112
git stash pop --index &&
99
- git diff --cached > output &&
100
- test_cmp output expect
113
+ git diff --cached >actual &&
114
+ test_cmp expect actual
101
115
'
102
116
103
117
git reset > /dev/null
@@ -125,30 +139,36 @@ test_expect_success 'stash save --include-untracked removed files got stashed' '
125
139
cat > .gitignore << EOF
126
140
.gitignore
127
141
ignored
142
+ ignored.d/
128
143
EOF
129
144
130
145
test_expect_success ' stash save --include-untracked respects .gitignore' '
131
146
echo ignored > ignored &&
147
+ mkdir ignored.d &&
148
+ echo ignored >ignored.d/untracked &&
132
149
git stash -u &&
133
150
test -s ignored &&
151
+ test -s ignored.d/untracked &&
134
152
test -s .gitignore
135
153
'
136
154
137
155
test_expect_success ' stash save -u can stash with only untracked files different' '
138
156
echo 4 > file4 &&
139
- git stash -u
157
+ git stash -u &&
140
158
test "!" -f file4
141
159
'
142
160
143
161
test_expect_success ' stash save --all does not respect .gitignore' '
144
162
git stash -a &&
145
163
test "!" -f ignored &&
164
+ test "!" -e ignored.d &&
146
165
test "!" -f .gitignore
147
166
'
148
167
149
168
test_expect_success ' stash save --all is stash poppable' '
150
169
git stash pop &&
151
170
test -s ignored &&
171
+ test -s ignored.d/untracked &&
152
172
test -s .gitignore
153
173
'
154
174
0 commit comments