stgit.el: Allow revert on index and work tree
[stgit] / t / t1204-pop-keep.sh
1 #!/bin/sh
2
3 test_description='Test "stg pop -keep"'
4 . ./test-lib.sh
5 stg init
6
7 test_expect_success 'Create a few patches' '
8 for i in 0 1 2; do
9 stg new p$i -m p$i &&
10 echo "patch$i" >> patch$i.txt &&
11 git add patch$i.txt &&
12 stg refresh
13 done &&
14 [ "$(echo $(stg series --applied --noprefix))" = "p0 p1 p2" ] &&
15 [ "$(echo $(stg series --unapplied --noprefix))" = "" ]
16 '
17
18 test_expect_success 'Make some non-conflicting local changes' '
19 echo "local" >> patch0.txt
20 '
21
22 test_expect_success 'Pop two patches, keeping local changes' '
23 stg pop -n 2 --keep &&
24 [ "$(echo $(stg series --applied --noprefix))" = "p0" ] &&
25 [ "$(echo $(stg series --unapplied --noprefix))" = "p1 p2" ] &&
26 [ "$(echo $(ls patch?.txt))" = "patch0.txt" ] &&
27 [ "$(echo $(cat patch0.txt))" = "patch0 local" ]
28 '
29
30 test_expect_success 'Reset and push patches again' '
31 git reset --hard &&
32 stg push -a
33 '
34
35 test_expect_success 'Pop a patch without local changes' '
36 stg pop --keep &&
37 [ "$(echo $(stg series --applied --noprefix))" = "p0 p1" ] &&
38 [ "$(echo $(stg series --unapplied --noprefix))" = "p2" ] &&
39 [ "$(echo $(ls patch?.txt))" = "patch0.txt patch1.txt" ]
40 '
41
42 test_done