2 test_description
='Test "stg repair" of amended commits'
5 test_expect_success
'Initialize the StGit patch' '
7 echo "hello" > foo.txt &&
13 test_expect_success
'Amend patch commit with git' '
14 echo "amended" >> foo.txt &&
15 git commit -a --amend -m "p0 amended"
18 test_expect_success
'Repair amended patch' '
20 test "$(echo $(stg series --noprefix --applied))" = "p0-amended" &&
21 test "$(echo $(stg series --noprefix --unapplied))" = "p0" &&
22 test "$(tail -n1 foo.txt)" = "amended"
25 test_expect_success
'Reset to original patch' '
26 stg delete p0-amended &&
30 test_expect_success
'Add more applied and unapplied patches' '
32 echo "from p1" >> foo.txt &&
35 echo "from p2" >> foo.txt &&
38 test "$(echo $(stg series --noprefix --applied))" = "p0 p1" &&
39 test "$(echo $(stg series --noprefix --unapplied))" = "p2"
42 test_expect_success
'Amend middle patch' '
43 echo "p1 amended" >> foo.txt &&
44 git commit -a --amend -m "p1 amended"
47 test_expect_success
'Repair amended middle patch' '
49 test "$(echo $(stg series --noprefix --applied))" = "p0 p1-amended" &&
50 test "$(echo $(stg series --noprefix --unapplied))" = "p1 p2" &&
51 test "$(tail -n1 foo.txt)" = "p1 amended"
54 test_expect_success
'Reset to non-amended patches' '
55 stg delete p1-amended &&
59 test_expect_success
'Add commit onto stack base' '
60 echo "new commit" > foo.txt &&
62 git commit -m "add foo"
65 test_expect_success
'Repair new commit on stack base' '
67 test "$(echo $(stg series --noprefix --applied))" = "" &&
68 test "$(echo $(stg series --noprefix --unapplied))" = "p0 p1 p2" &&
69 test "$(tail -n1 foo.txt)" = "new commit"