2 # Copyright (c) 2006 Karl Hasselström
3 test_description
='Test the repair command.'
6 test_expect_success
'Repair in a non-initialized repository' '
7 command_error stg repair
10 test_expect_success
'Initialize the StGit repository' '
14 test_expect_success
'Repair in a repository without patches' '
18 test_expect_success
'Repair with invalid arguments' '
19 command_error stg repair xxx 2>&1 |
20 grep -e "incorrect number of arguments"
23 test_expect_success
'Create a patch' '
30 test_expect_success
'Attempt repair of protected branch' '
31 test_when_finished "stg branch --unprotect" &&
32 stg branch --protect &&
33 command_error stg repair 2>&1 |
34 grep -e "This branch is protected"
37 test_expect_success
'Repair when there is nothing to do' '
41 test_expect_success
'Create a Git commit' '
47 test_expect_success
'Turn one Git commit into a patch' '
48 [ "$(echo $(stg series --applied --noprefix))" = "foo" ]
50 [ "$(echo $(stg series --applied --noprefix))" = "foo bar" ]
51 [ $(stg series --unapplied -c) -eq 0 ]
54 test_expect_success
'Create three more Git commits' '
55 echo one > numbers.txt &&
56 git add numbers.txt &&
57 git commit -a -m one &&
58 echo two >> numbers.txt &&
59 git commit -a -m two &&
60 echo three >> numbers.txt &&
61 git commit -a -m three
64 test_expect_success
'Turn three Git commits into patches' '
65 [ "$(echo $(stg series --applied --noprefix))" = "foo bar" ]
67 [ "$(echo $(stg series --applied --noprefix))" = "foo bar one two three" ]
68 [ $(stg series --unapplied -c) -eq 0 ]
71 test_expect_success
'Create a merge commit' '
72 git config pull.rebase false &&
73 git checkout -b br master^^ &&
74 echo woof > woof.txt &&
76 git commit -a -m woof &&
77 git checkout master &&
81 test_expect_success
'Repair in the presence of a merge commit' '
82 [ "$(echo $(stg series --applied --noprefix))" = "foo bar one two three" ]
84 [ "$(echo $(stg series --unapplied --noprefix))" = "foo bar one two three" ]
85 [ $(stg series --applied -c) -eq 0 ]