Restore `stg sink --nopush` capability
[stgit.git] / t / t1301-repair.sh
blob1a80fdc400c27a55ccc9e9b66e2de121f01c95de
1 #!/bin/sh
2 # Copyright (c) 2006 Karl Hasselström
3 test_description='Test the repair command.'
4 . ./test-lib.sh
6 test_expect_success 'Repair in a non-initialized repository' '
7 command_error stg repair
10 test_expect_success 'Initialize the StGit repository' '
11 stg init
14 test_expect_success 'Repair in a repository without patches' '
15 stg repair
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' '
24 stg new foo -m foo &&
25 echo foo > foo.txt &&
26 stg add foo.txt &&
27 stg refresh
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' '
38 stg repair
41 test_expect_success 'Create a Git commit' '
42 echo bar > bar.txt &&
43 git add bar.txt &&
44 git commit -a -m bar
47 test_expect_success 'Turn one Git commit into a patch' '
48 [ "$(echo $(stg series --applied --noprefix))" = "foo" ]
49 stg repair &&
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" ]
66 stg repair &&
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 &&
75 stg add woof.txt &&
76 git commit -a -m woof &&
77 git checkout master &&
78 git pull . br
81 test_expect_success 'Repair in the presence of a merge commit' '
82 [ "$(echo $(stg series --applied --noprefix))" = "foo bar one two three" ]
83 stg repair &&
84 [ "$(echo $(stg series --unapplied --noprefix))" = "foo bar one two three" ]
85 [ $(stg series --applied -c) -eq 0 ]
88 test_done