Skip to content

Commit 4a58807

Browse files
amenonsengitster
authored andcommitted
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>
1 parent 656b503 commit 4a58807

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

t/t3903-stash.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,64 @@ test_expect_success 'stash pop' '
117117
test 0 = $(git stash list | wc -l)
118118
'
119119

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+
120180
test_done

0 commit comments

Comments
 (0)