chiark / gitweb /
stgit.el: Add "d" for a few diff commands, similar to git.el
[stgit] / t / t1301-repair.sh
CommitLineData
519a11f9
KH
1#!/bin/sh
2# Copyright (c) 2006 Karl Hasselström
051090dd 3test_description='Test the repair command.'
519a11f9
KH
4. ./test-lib.sh
5
6test_expect_success \
051090dd 7 'Repair in a non-initialized repository' \
f03004e2 8 'command_error stg repair'
519a11f9
KH
9
10test_expect_success \
11 'Initialize the StGIT repository' \
12 'stg init'
13
14test_expect_success \
051090dd
KH
15 'Repair in a repository without patches' \
16 'stg repair'
519a11f9
KH
17
18test_expect_success \
19 'Create a patch' \
20 '
21 stg new foo -m foo &&
22 echo foo > foo.txt &&
ea5b7bf3 23 git add foo.txt &&
519a11f9
KH
24 stg refresh
25 '
26
27test_expect_success \
051090dd
KH
28 'Repair when there is nothing to do' \
29 'stg repair'
519a11f9
KH
30
31test_expect_success \
32 'Create a GIT commit' \
33 '
34 echo bar > bar.txt &&
35 git add bar.txt &&
36 git commit -a -m bar
37 '
38
051090dd 39test_expect_success 'Turn one GIT commit into a patch' '
f9d9a062 40 [ $(stg series --applied -c) -eq 1 ] &&
051090dd 41 stg repair &&
f9d9a062 42 [ $(stg series --applied -c) -eq 2 ]
519a11f9
KH
43 '
44
45test_expect_success \
46 'Create three more GIT commits' \
47 '
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
55 '
56
051090dd 57test_expect_success 'Turn three GIT commits into patches' '
f9d9a062 58 [ $(stg series --applied -c) -eq 2 ] &&
051090dd 59 stg repair &&
f9d9a062 60 [ $(stg series --applied -c) -eq 5 ]
519a11f9
KH
61 '
62
63test_expect_success \
a9d090f4 64 'Create a merge commit' \
519a11f9
KH
65 '
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
72 '
73
051090dd 74test_expect_success 'Repair in the presence of a merge commit' '
f9d9a062 75 [ $(stg series --applied -c) -eq 5 ] &&
051090dd 76 stg repair &&
f9d9a062 77 [ $(stg series --applied -c) -eq 0 ]
ca216016 78'
519a11f9
KH
79
80test_done