3 # Copyright (c) 2011 David Caldwell
6 test_description
='Test git stash --include-untracked'
10 test_expect_success
'stash save --include-untracked some dirty working directory' '
14 git commit -m initial &&
21 echo untracked >untracked/untracked &&
22 git stash --include-untracked &&
23 git diff-files --quiet &&
24 git diff-index --cached --quiet HEAD
32 test_expect_success
'stash save --include-untracked cleaned the untracked files' '
33 git status --porcelain >actual &&
34 test_cmp expect actual
37 cat > expect.
diff <<EOF
38 diff --git a/file2 b/file2
40 index 0000000..d00491f
45 diff --git a/untracked/untracked b/untracked/untracked
47 index 0000000..5a72eb2
49 +++ b/untracked/untracked
53 cat > expect.lstree
<<EOF
58 test_expect_success
'stash save --include-untracked stashed the untracked files' '
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
66 test_expect_success
'stash save --patch --include-untracked fails' '
67 test_must_fail git stash --patch --include-untracked
70 test_expect_success
'stash save --patch --all fails' '
71 test_must_fail git stash --patch --all
74 git clean
--force --quiet
84 test_expect_success
'stash pop after save --include-untracked leaves files untracked again' '
86 git status --porcelain >actual &&
87 test_cmp expect actual &&
88 test "1" = "`cat file2`" &&
89 test untracked = "`cat untracked/untracked`"
92 git clean
--force --quiet -d
94 test_expect_success
'stash save -u dirty index' '
102 diff --git a/file3 b/file3
104 index 0000000..b8626c4
111 test_expect_success
'stash save --include-untracked dirty index got stashed' '
112 git stash pop --index &&
113 git diff --cached >actual &&
114 test_cmp expect actual
117 git
reset > /dev
/null
119 test_expect_success
'stash save --include-untracked -q is quiet' '
121 git stash save --include-untracked --quiet > output.out 2>&1 &&
125 test_expect_success
'stash save --include-untracked removed files' '
127 git stash save --include-untracked &&
134 test_expect_success
'stash save --include-untracked removed files got stashed' '
139 cat > .gitignore
<<EOF
145 test_expect_success
'stash save --include-untracked respects .gitignore' '
146 echo ignored > ignored &&
148 echo ignored >ignored.d/untracked &&
151 test -s ignored.d/untracked &&
155 test_expect_success
'stash save -u can stash with only untracked files different' '
161 test_expect_success
'stash save --all does not respect .gitignore' '
163 test "!" -f ignored &&
164 test "!" -e ignored.d &&
165 test "!" -f .gitignore
168 test_expect_success
'stash save --all is stash poppable' '
171 test -s ignored.d/untracked &&