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 &&
20 git stash --include-untracked &&
21 git diff-files --quiet &&
22 git diff-index --cached --quiet HEAD
30 test_expect_success 'stash save --include-untracked cleaned the untracked files' '
31 git status --porcelain > output
32 test_cmp output expect
35 cat > expect.diff <<EOF
36 diff --git a/file2 b/file2
38 index 0000000..d00491f
44 cat > expect.lstree <<EOF
48 test_expect_success 'stash save --include-untracked stashed the untracked files' '
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
55 test_expect_success 'stash save --patch --include-untracked fails' '
56 test_must_fail git stash --patch --include-untracked
59 test_expect_success 'stash save --patch --all fails' '
60 test_must_fail git stash --patch --all
63 git clean --force --quiet
72 test_expect_success 'stash pop after save --include-untracked leaves files untracked again' '
74 git status --porcelain > output
75 test_cmp output expect
78 git clean --force --quiet
80 test_expect_success 'stash save -u dirty index' '
88 diff --git a/file3 b/file3
90 index 0000000..b8626c4
97 test_expect_success 'stash save --include-untracked dirty index got stashed' '
98 git stash pop --index &&
99 git diff --cached > output &&
100 test_cmp output expect
103 git reset > /dev/null
105 test_expect_success 'stash save --include-untracked -q is quiet' '
107 git stash save --include-untracked --quiet > output.out 2>&1 &&
111 test_expect_success 'stash save --include-untracked removed files' '
113 git stash save --include-untracked &&
120 test_expect_success 'stash save --include-untracked removed files got stashed' '
125 cat > .gitignore <<EOF
130 test_expect_success 'stash save --include-untracked respects .gitignore' '
131 echo ignored > ignored &&
137 test_expect_success 'stash save -u can stash with only untracked files different' '
143 test_expect_success 'stash save --all does not respect .gitignore' '
145 test "!" -f ignored &&
146 test "!" -f .gitignore
149 test_expect_success 'stash save --all is stash poppable' '