@matheusbsbs / matheus-bagliano / commits / 4a588075c5
Fork 0

Add a test for "git stash branch"

Make sure that applying the stash to a new branch after a conflicting change doesn't result in an error when you try to commit. Signed-off-by: Abhijit Menon-Sen <ams@toroid.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Abhijit Menon-Sen committed Jul 7, 2008 at 02:50 UTC 4a588075c54cd5902e5f4d43b9d6b0c31d0f9769
1 file changed +60
t/t3903-stash.sh
+60
@@ -117,4 +117,64 @@ test_expect_success 'stash pop' '
117 test 0 = $(git stash list | wc -l)
118 '
119
120 +cat > expect << EOF
121 +diff --git a/file2 b/file2
122 +new file mode 100644
123 +index 0000000..1fe912c
124 +--- /dev/null
125 ++++ b/file2
126 +@@ -0,0 +1 @@
127 ++bar2
128 +EOF
129 +
130 +cat > expect1 << EOF
131 +diff --git a/file b/file
132 +index 257cc56..5716ca5 100644
133 +--- a/file
134 ++++ b/file
135 +@@ -1 +1 @@
136 +-foo
137 ++bar
138 +EOF
139 +
140 +cat > expect2 << EOF
141 +diff --git a/file b/file
142 +index 7601807..5716ca5 100644
143 +--- a/file
144 ++++ b/file
145 +@@ -1 +1 @@
146 +-baz
147 ++bar
148 +diff --git a/file2 b/file2
149 +new file mode 100644
150 +index 0000000..1fe912c
151 +--- /dev/null
152 ++++ b/file2
153 +@@ -0,0 +1 @@
154 ++bar2
155 +EOF
156 +
157 +test_expect_success 'stash branch' '
158 + echo foo > file &&
159 + git commit file -m first
160 + echo bar > file &&
161 + echo bar2 > file2 &&
162 + git add file2 &&
163 + git stash &&
164 + echo baz > file &&
165 + git commit file -m second &&
166 + git stash branch stashbranch &&
167 + test refs/heads/stashbranch = $(git symbolic-ref HEAD) &&
168 + test $(git rev-parse HEAD) = $(git rev-parse master^) &&
169 + git diff --cached > output &&
170 + test_cmp output expect &&
171 + git diff > output &&
172 + test_cmp output expect1 &&
173 + git add file &&
174 + git commit -m alternate\ second &&
175 + git diff master..stashbranch > output &&
176 + test_cmp output expect2 &&
177 + test 0 = $(git stash list | wc -l)
178 +'
179 +
180 test_done