chiark / gitweb /
6502c2007938cf0cf4201be2a2ce10d50abcab14
[stgit] / t / t1205-push-subdir.sh
1 #!/bin/sh
2 test_description='Test the push command from a subdirectory'
3 . ./test-lib.sh
4 stg init
5
6 test_expect_success 'Create some patches' '
7     mkdir foo
8     for i in 0 1 2; do
9         stg new p$i -m p$i &&
10         echo x$i >> x.txt &&
11         echo y$i >> foo/y.txt &&
12         stg add x.txt foo/y.txt &&
13         stg refresh
14     done &&
15     [ "$(echo $(stg applied))" = "p0 p1 p2" ] &&
16     [ "$(echo $(stg unapplied))" = "" ]
17 '
18
19 test_expect_success 'Fast-forward push from a subdir' '
20     stg pop &&
21     [ "$(echo $(cat x.txt))" = "x0 x1" ] &&
22     [ "$(echo $(cat foo/y.txt))" = "y0 y1" ] &&
23     cd foo &&
24     stg push &&
25     cd .. &&
26     [ "$(echo $(cat x.txt))" = "x0 x1 x2" ] &&
27     [ "$(echo $(cat foo/y.txt))" = "y0 y1 y2" ]
28 '
29
30 test_expect_failure 'Modifying push from a subdir' '
31     stg pop &&
32     [ "$(echo $(cat x.txt))" = "x0 x1" ] &&
33     [ "$(echo $(cat foo/y.txt))" = "y0 y1" ] &&
34     stg new extra -m extra &&
35     echo extra >> extra.txt &&
36     stg add extra.txt &&
37     stg refresh &&
38     cd foo &&
39     stg push &&
40     cd .. &&
41     [ "$(echo $(cat x.txt))" = "x0 x1 x2" ] &&
42     [ "$(echo $(cat foo/y.txt))" = "y0 y1 y2" ]
43 '
44
45 test_expect_failure 'Conflicting push from subdir' '
46     stg pop p1 p2 &&
47     [ "$(echo $(cat x.txt))" = "x0" ] &&
48     [ "$(echo $(cat foo/y.txt))" = "y0" ] &&
49     cd foo &&
50     ! stg push p2 &&
51     cd .. &&
52     [ "$(echo $(stg status --conflict))" = "foo/y.txt x.txt" ]
53 '
54
55 test_done