Preserve picked patch name when possible
[stgit.git] / t / t3101-reset-hard.sh
blob94878acafbdae7869566ac5251fb44f2d5c49c9b
1 #!/bin/sh
3 test_description='Simple test cases for "stg reset"'
5 . ./test-lib.sh
7 # Ignore our own output files.
8 cat >> .git/info/exclude <<EOF
9 /expected.txt
10 /actual.txt
11 EOF
13 test_expect_success 'Initialize StGit stack with three patches' '
14 stg init &&
15 echo 000 >> a &&
16 stg add a &&
17 git commit -m a &&
18 echo 111 >> a &&
19 git commit -a -m p1 &&
20 echo 222 >> a &&
21 git commit -a -m p2 &&
22 echo 333 >> a &&
23 git commit -a -m p3 &&
24 stg uncommit -n 3
27 test_expect_success 'Invalid arguments' '
28 command_error stg reset 2>err &&
29 grep -e "Wrong options" err &&
30 rm err
33 cat > expected.txt <<EOF
34 UU a
35 EOF
36 test_expect_success 'Pop middle patch, creating a conflict' '
37 conflict stg pop p2 &&
38 stg status a > actual.txt &&
39 test_cmp expected.txt actual.txt &&
40 test "$(echo $(stg series))" = "+ p1 > p3 - p2"
43 test_expect_success 'Try to reset without --hard' '
44 command_error stg reset refs/stacks/master^~1 &&
45 stg status a > actual.txt &&
46 test_cmp expected.txt actual.txt &&
47 test "$(echo $(stg series))" = "+ p1 > p3 - p2"
50 cat > expected.txt <<EOF
51 EOF
52 test_expect_success 'Try to reset with --hard' '
53 stg reset --hard refs/stacks/master^~1 &&
54 stg status a > actual.txt &&
55 test_cmp expected.txt actual.txt &&
56 test "$(echo $(stg series))" = "+ p1 + p2 > p3"
59 test_done