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 &&
22 echo untracked >untracked/untracked &&
23 git stash --include-untracked &&
24 git diff-files --quiet &&
25 git diff-index --cached --quiet HEAD
33 test_expect_success 'stash save --include-untracked cleaned the untracked files' '
34 git status --porcelain >actual &&
35 test_cmp expect actual
38 cat > expect.diff <<EOF
39 diff --git a/HEAD b/HEAD
41 index 0000000..d00491f
46 diff --git a/file2 b/file2
48 index 0000000..d00491f
53 diff --git a/untracked/untracked b/untracked/untracked
55 index 0000000..5a72eb2
57 +++ b/untracked/untracked
61 cat > expect.lstree <<EOF
67 test_expect_success 'stash save --include-untracked stashed the untracked files' '
68 test_path_is_missing file2 &&
69 test_path_is_missing untracked &&
70 test_path_is_missing HEAD &&
71 git diff HEAD stash^3 -- HEAD file2 untracked >actual &&
72 test_cmp expect.diff actual &&
73 git ls-tree --name-only stash^3: >actual &&
74 test_cmp expect.lstree actual
76 test_expect_success 'stash save --patch --include-untracked fails' '
77 test_must_fail git stash --patch --include-untracked
80 test_expect_success 'stash save --patch --all fails' '
81 test_must_fail git stash --patch --all
84 git clean --force --quiet
95 test_expect_success 'stash pop after save --include-untracked leaves files untracked again' '
97 git status --porcelain >actual &&
98 test_cmp expect actual &&
99 test "1" = "`cat file2`" &&
100 test untracked = "`cat untracked/untracked`"
103 git clean --force --quiet -d
105 test_expect_success 'stash save -u dirty index' '
113 diff --git a/file3 b/file3
115 index 0000000..b8626c4
122 test_expect_success 'stash save --include-untracked dirty index got stashed' '
123 git stash pop --index &&
124 git diff --cached >actual &&
125 test_cmp expect actual
128 git reset > /dev/null
130 # Must direct output somewhere where it won't be considered an untracked file
131 test_expect_success 'stash save --include-untracked -q is quiet' '
133 git stash save --include-untracked --quiet > .git/stash-output.out 2>&1 &&
134 test_line_count = 0 .git/stash-output.out &&
135 rm -f .git/stash-output.out
138 test_expect_success 'stash save --include-untracked removed files' '
140 git stash save --include-untracked &&
147 test_expect_success 'stash save --include-untracked removed files got stashed' '
149 test_path_is_missing file
152 cat > .gitignore <<EOF
158 test_expect_success 'stash save --include-untracked respects .gitignore' '
159 echo ignored > ignored &&
161 echo ignored >ignored.d/untracked &&
164 test -s ignored.d/untracked &&
168 test_expect_success 'stash save -u can stash with only untracked files different' '
171 test_path_is_missing file4
174 test_expect_success 'stash save --all does not respect .gitignore' '
176 test_path_is_missing ignored &&
177 test_path_is_missing ignored.d &&
178 test_path_is_missing .gitignore
181 test_expect_success 'stash save --all is stash poppable' '
184 test -s ignored.d/untracked &&