Make the 'series --short' length configurable
[stgit/ydirson.git] / t / t2000-sync.sh
blob3dd1cd6f34cc4960e59cad0728db421253375646
1 #!/bin/sh
3 # Copyright (c) 2006 Catalin Marinas
6 test_description='Test the sync command.'
8 . ./test-lib.sh
10 test_expect_success \
11 'Initialize the StGIT repository' \
13 stg init
16 test_expect_success \
17 'Create some patches' \
19 stg new p1 -m p1 &&
20 echo foo1 > foo1.txt &&
21 stg add foo1.txt &&
22 stg refresh &&
23 stg new p2 -m p2 &&
24 echo foo2 > foo2.txt &&
25 stg add foo2.txt &&
26 stg refresh &&
27 stg new p3 -m p3 &&
28 echo foo3 > foo3.txt &&
29 stg add foo3.txt &&
30 stg refresh &&
31 stg export &&
32 stg pop
35 test_expect_success \
36 'Create a branch with empty patches' \
38 stg branch -c foo base &&
39 stg new p1 -m p1 &&
40 stg new p2 -m p2 &&
41 stg new p3 -m p3
42 test $(stg applied -c) -eq 3
45 test_expect_success \
46 'Synchronise second patch with the master branch' \
48 stg sync -b master p2 &&
49 test $(stg applied -c) -eq 3 &&
50 test $(cat foo2.txt) == "foo2"
53 test_expect_success \
54 'Synchronise the first two patches with the master branch' \
56 stg sync -b master -a &&
57 test $(stg applied -c) -eq 3 &&
58 test $(cat foo1.txt) == "foo1" &&
59 test $(cat foo2.txt) == "foo2"
62 test_expect_success \
63 'Synchronise all the patches with the exported series' \
65 stg sync -s patches-master/series -a &&
66 test $(stg applied -c) -eq 3 &&
67 test $(cat foo1.txt) == "foo1" &&
68 test $(cat foo2.txt) == "foo2" &&
69 test $(cat foo3.txt) == "foo3"
72 test_expect_success \
73 'Modify the master patches' \
75 stg branch master &&
76 stg goto p1 &&
77 echo bar1 >> foo1.txt &&
78 stg refresh &&
79 stg goto p2 &&
80 echo bar2 > bar2.txt &&
81 stg add bar2.txt &&
82 stg refresh &&
83 stg goto p3 &&
84 echo bar3 >> foo3.txt &&
85 stg refresh &&
86 stg export &&
87 stg branch foo
90 test_expect_success \
91 'Synchronise second patch with the master branch' \
93 stg sync -b master p2 &&
94 test $(stg applied -c) -eq 3 &&
95 test $(cat bar2.txt) == "bar2"
98 test_expect_failure \
99 'Synchronise the first two patches with the master branch (to fail)' \
101 stg sync -b master -a
104 test_expect_success \
105 'Restore the stack status after the failed sync' \
107 test $(stg applied -c) -eq 1 &&
108 stg resolved -a &&
109 stg refresh &&
110 stg goto p3
113 test_expect_failure \
114 'Synchronise the third patch with the exported series (to fail)' \
116 stg sync -s patches-master/series p3
119 test_expect_success \
120 'Restore the stack status after the failed sync' \
122 test $(stg applied -c) -eq 3 &&
123 stg resolved -a &&
124 stg refresh
127 test_done