Convert "pop" to the lib infrastructure
[stgit] / t / t3101-reset-hard.sh
CommitLineData
9690617a
KH
1#!/bin/sh
2
3test_description='Simple test cases for "stg reset"'
4
5. ./test-lib.sh
6
7# Ignore our own output files.
8cat > .git/info/exclude <<EOF
9/expected.txt
10/actual.txt
11EOF
12
13test_expect_success 'Initialize StGit stack with three patches' '
14 stg init &&
15 echo 000 >> a &&
16 git 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
25'
26
27cat > expected.txt <<EOF
28C a
29EOF
30test_expect_success 'Pop middle patch, creating a conflict' '
1056440b 31 conflict stg pop p2 &&
9690617a
KH
32 stg status a > actual.txt &&
33 test_cmp expected.txt actual.txt &&
34 test "$(echo $(stg series))" = "+ p1 > p3 - p2"
35'
36
37test_expect_success 'Try to reset without --hard' '
38 command_error stg reset master.stgit^~1 &&
39 stg status a > actual.txt &&
40 test_cmp expected.txt actual.txt &&
41 test "$(echo $(stg series))" = "+ p1 > p3 - p2"
42'
43
44cat > expected.txt <<EOF
45EOF
46test_expect_success 'Try to reset with --hard' '
47 stg reset --hard master.stgit^~1 &&
48 stg status a > actual.txt &&
49 test_cmp expected.txt actual.txt &&
1056440b 50 test "$(echo $(stg series))" = "> p1 - p2 - p3"
9690617a
KH
51'
52
53test_done