stgit.el: Allow revert on index and work tree
[stgit] / t / t3105-undo-external-mod.sh
CommitLineData
c70033b4
KH
1#!/bin/sh
2
3test_description='Undo external modifications of the stack'
4
5. ./test-lib.sh
6
7# Ignore our own output files.
8cat > .git/info/exclude <<EOF
9/expected.txt
10/head?.txt
11EOF
12
13test_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
24cat > expected.txt <<EOF
25000
26111
27222
28EOF
29test_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
40cat > expected.txt <<EOF
41000
42111
43222
44EOF
45test_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
53cat > expected.txt <<EOF
54000
55111
56EOF
57test_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
65test_done