chiark / gitweb /
Pick --revert option (formerly --reverse)
[stgit] / t / t3105-undo-external-mod.sh
1 #!/bin/sh
2
3 test_description='Undo external modifications of the stack'
4
5 . ./test-lib.sh
6
7 # Ignore our own output files.
8 cat > .git/info/exclude <<EOF
9 /expected.txt
10 /head?.txt
11 EOF
12
13 test_expect_success 'Initialize StGit stack' '
14     stg init &&
15     echo 000 >> a &&
16     git add a &&
17     git commit -m p0 &&
18     echo 111 >> a &&
19     git add a &&
20     git commit -m p1 &&
21     stg uncommit -n 1
22 '
23
24 cat > expected.txt <<EOF
25 000
26 111
27 222
28 EOF
29 test_expect_success 'Make a git commit and turn it into a patch' '
30     git rev-parse HEAD > head0.txt &&
31     echo 222 >> a &&
32     git add a &&
33     git commit -m p2 &&
34     git rev-parse HEAD > head1.txt &&
35     stg repair &&
36     test "$(echo $(stg series))" = "+ p1 > p2" &&
37     test_cmp expected.txt a
38 '
39
40 cat > expected.txt <<EOF
41 000
42 111
43 222
44 EOF
45 test_expect_success 'Undo the patchification' '
46     stg undo &&
47     git rev-parse HEAD > head2.txt &&
48     test_cmp head1.txt head2.txt &&
49     test "$(echo $(stg series))" = "> p1" &&
50     test_cmp expected.txt a
51 '
52
53 cat > expected.txt <<EOF
54 000
55 111
56 EOF
57 test_expect_success 'Undo the commit' '
58     stg undo &&
59     git rev-parse HEAD > head3.txt &&
60     test_cmp head0.txt head3.txt &&
61     test "$(echo $(stg series))" = "> p1" &&
62     test_cmp expected.txt a
63 '
64
65 test_done