Release 0.14.1
[stgit.git] / t / t1301-repair.sh
blob5d9bdbdc4b8e408eb997a9d2f38fd65302ede1f7
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 \
7 'Repair in a non-initialized repository' \
8 '! stg repair'
10 test_expect_success \
11 'Initialize the StGIT repository' \
12 'stg init'
14 test_expect_success \
15 'Repair in a repository without patches' \
16 'stg repair'
18 test_expect_success \
19 'Create a patch' \
21 stg new foo -m foo &&
22 echo foo > foo.txt &&
23 stg add foo.txt &&
24 stg refresh
27 test_expect_success \
28 'Repair when there is nothing to do' \
29 'stg repair'
31 test_expect_success \
32 'Create a GIT commit' \
34 echo bar > bar.txt &&
35 git add bar.txt &&
36 git commit -a -m bar
39 test_expect_success 'Turn one GIT commit into a patch' '
40 [ $(stg applied | wc -l) -eq 1 ] &&
41 stg repair &&
42 [ $(stg applied | wc -l) -eq 2 ]
45 test_expect_success \
46 'Create three more GIT commits' \
48 echo one > numbers.txt &&
49 git add numbers.txt &&
50 git commit -a -m one &&
51 echo two >> numbers.txt &&
52 git commit -a -m two &&
53 echo three >> numbers.txt &&
54 git commit -a -m three
57 test_expect_success 'Turn three GIT commits into patches' '
58 [ $(stg applied | wc -l) -eq 2 ] &&
59 stg repair &&
60 [ $(stg applied | wc -l) -eq 5 ]
63 test_expect_success \
64 'Create a merge commit' \
66 git checkout -b br master^^ &&
67 echo woof > woof.txt &&
68 git add woof.txt &&
69 git commit -a -m woof &&
70 git checkout master &&
71 git pull . br
74 test_expect_success 'Repair in the presence of a merge commit' '
75 [ $(stg applied | wc -l) -eq 5 ] &&
76 stg repair &&
77 [ $(stg applied | wc -l) -eq 0 ]
80 test_done