Makefile: do not set setgid bit on directories on GNU/kFreeBSD
[git/jnareb-git.git] / t / t3905-stash-include-untracked.sh
blob4f2eedfd4f87bdf7b6ba8035b203fb9d7bbb2dbe
1 #!/bin/sh
3 # Copyright (c) 2011 David Caldwell
6 test_description='Test git stash --include-untracked'
8 . ./test-lib.sh
10 test_expect_success 'stash save --include-untracked some dirty working directory' '
11 echo 1 > file &&
12 git add file &&
13 test_tick &&
14 git commit -m initial &&
15 echo 2 > file &&
16 git add file &&
17 echo 3 > file &&
18 test_tick &&
19 echo 1 > file2 &&
20 git stash --include-untracked &&
21 git diff-files --quiet &&
22 git diff-index --cached --quiet HEAD
25 cat > expect <<EOF
26 ?? expect
27 ?? output
28 EOF
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
37 new file mode 100644
38 index 0000000..d00491f
39 --- /dev/null
40 +++ b/file2
41 @@ -0,0 +1 @@
43 EOF
44 cat > expect.lstree <<EOF
45 file2
46 EOF
48 test_expect_success 'stash save --include-untracked stashed the untracked files' '
49 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
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
65 cat > expect <<EOF
66 M file
67 ?? expect
68 ?? file2
69 ?? output
70 EOF
72 test_expect_success 'stash pop after save --include-untracked leaves files untracked again' '
73 git stash pop &&
74 git status --porcelain > output
75 test_cmp output expect
78 git clean --force --quiet
80 test_expect_success 'stash save -u dirty index' '
81 echo 4 > file3 &&
82 git add file3 &&
83 test_tick &&
84 git stash -u
87 cat > expect <<EOF
88 diff --git a/file3 b/file3
89 new file mode 100644
90 index 0000000..b8626c4
91 --- /dev/null
92 +++ b/file3
93 @@ -0,0 +1 @@
95 EOF
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' '
106 echo 1 > file5 &&
107 git stash save --include-untracked --quiet > output.out 2>&1 &&
108 test ! -s output.out
111 test_expect_success 'stash save --include-untracked removed files' '
112 rm -f file &&
113 git stash save --include-untracked &&
114 echo 1 > expect &&
115 test_cmp file expect
118 rm -f expect
120 test_expect_success 'stash save --include-untracked removed files got stashed' '
121 git stash pop &&
122 test ! -f file
125 cat > .gitignore <<EOF
126 .gitignore
127 ignored
130 test_expect_success 'stash save --include-untracked respects .gitignore' '
131 echo ignored > ignored &&
132 git stash -u &&
133 test -s ignored &&
134 test -s .gitignore
137 test_expect_success 'stash save -u can stash with only untracked files different' '
138 echo 4 > file4 &&
139 git stash -u
140 test "!" -f file4
143 test_expect_success 'stash save --all does not respect .gitignore' '
144 git stash -a &&
145 test "!" -f ignored &&
146 test "!" -f .gitignore
149 test_expect_success 'stash save --all is stash poppable' '
150 git stash pop &&
151 test -s ignored &&
152 test -s .gitignore
155 test_done