Skip to content

Commit 3ebfe63

Browse files
glandiumgitster
authored andcommitted
Add test for git rebase --abort
We expect git rebase --abort to come back to the original (pre-rebase) head, independently from when it's run during a rebase. Signed-off-by: Mike Hommey <mh@glandium.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent c3b088d commit 3ebfe63

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

t/t3407-rebase-abort.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/sh
2+
3+
test_description='git rebase --abort tests'
4+
5+
. ./test-lib.sh
6+
7+
test_expect_success setup '
8+
echo a > a &&
9+
git add a &&
10+
git commit -m a &&
11+
git branch to-rebase &&
12+
13+
echo b > a &&
14+
git commit -a -m b &&
15+
echo c > a &&
16+
git commit -a -m c &&
17+
18+
git checkout to-rebase &&
19+
echo d > a &&
20+
git commit -a -m "merge should fail on this" &&
21+
echo e > a &&
22+
git commit -a -m "merge should fail on this, too" &&
23+
git branch pre-rebase
24+
'
25+
26+
test_expect_success 'rebase --abort' '
27+
test_must_fail git rebase master &&
28+
git rebase --abort &&
29+
test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase)
30+
'
31+
32+
test_expect_failure 'rebase --abort after --skip' '
33+
# Clean up the state from the previous one
34+
git reset --hard pre-rebase
35+
rm -rf .dotest
36+
37+
test_must_fail git rebase master &&
38+
test_must_fail git rebase --skip &&
39+
test $(git rev-parse HEAD) = $(git rev-parse master) &&
40+
git rebase --abort &&
41+
test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase)
42+
'
43+
44+
test_expect_success 'rebase --abort after --continue' '
45+
# Clean up the state from the previous one
46+
git reset --hard pre-rebase
47+
rm -rf .dotest
48+
49+
test_must_fail git rebase master &&
50+
echo c > a &&
51+
echo d >> a &&
52+
git add a &&
53+
test_must_fail git rebase --continue &&
54+
test $(git rev-parse HEAD) != $(git rev-parse master) &&
55+
git rebase --abort &&
56+
test $(git rev-parse to-rebase) = $(git rev-parse pre-rebase)
57+
'
58+
59+
test_done

0 commit comments

Comments
 (0)