chiark / gitweb /
stgit.el: Add "d" for a few diff commands, similar to git.el
[stgit] / t / t3102-undo.sh
CommitLineData
069a1e95
KH
1#!/bin/sh
2
3test_description='Simple test cases for "stg undo"'
4
5. ./test-lib.sh
6
7# Ignore our own output files.
8cat > .git/info/exclude <<EOF
9/expected.txt
10EOF
11
12test_expect_success 'Initialize StGit stack with three patches' '
13 stg init &&
14 echo 000 >> a &&
15 git add a &&
16 git commit -m a &&
17 echo 111 >> a &&
18 git commit -a -m p1 &&
19 echo 222 >> a &&
20 git commit -a -m p2 &&
21 echo 333 >> a &&
22 git commit -a -m p3 &&
23 stg uncommit -n 3 &&
24 stg pop
25'
26
27cat > expected.txt <<EOF
28000
29111
30EOF
31test_expect_success 'Pop one patch ...' '
32 stg pop &&
33 test "$(echo $(stg series))" = "> p1 - p2 - p3" &&
34 test_cmp expected.txt a
35'
36
37cat > expected.txt <<EOF
38000
39111
40222
41EOF
42test_expect_success '... and undo it' '
43 stg undo &&
44 test "$(echo $(stg series))" = "+ p1 > p2 - p3" &&
45 test_cmp expected.txt a
46'
47
48cat > expected.txt <<EOF
49000
50EOF
51test_expect_success 'Pop two patches ...' '
52 stg pop &&
53 stg pop &&
54 test "$(echo $(stg series))" = "- p1 - p2 - p3" &&
55 test_cmp expected.txt a
56'
57
58cat > expected.txt <<EOF
59000
60111
61222
62EOF
63test_expect_success '... and undo it' '
64 stg undo &&
65 stg undo &&
66 test "$(echo $(stg series))" = "+ p1 > p2 - p3" &&
67 test_cmp expected.txt a
68'
69
70cat > expected.txt <<EOF
71000
72111
73222
74EOF
75test_expect_success 'Undo past end of history' '
76 command_error stg undo -n 100 &&
77 test "$(echo $(stg series))" = "+ p1 > p2 - p3" &&
78 test_cmp expected.txt a
79'
80
81test_done