Commit | Line | Data |
---|---|---|
86795a31 KH |
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 && | |
ea5b7bf3 | 12 | git add x.txt foo/y.txt && |
86795a31 KH |
13 | stg refresh |
14 | done && | |
f9d9a062 CM |
15 | [ "$(echo $(stg series --applied --noprefix))" = "p0 p1 p2" ] && |
16 | [ "$(echo $(stg series --unapplied --noprefix))" = "" ] | |
86795a31 KH |
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 | ||
89d889f4 | 30 | test_expect_success 'Modifying push from a subdir' ' |
86795a31 KH |
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 && | |
ea5b7bf3 | 36 | git add extra.txt && |
86795a31 KH |
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 | ||
d4f2b3e9 | 45 | test_expect_success 'Conflicting push from subdir' ' |
86795a31 KH |
46 | stg pop p1 p2 && |
47 | [ "$(echo $(cat x.txt))" = "x0" ] && | |
48 | [ "$(echo $(cat foo/y.txt))" = "y0" ] && | |
49 | cd foo && | |
f03004e2 | 50 | conflict_old stg push p2 && |
86795a31 KH |
51 | cd .. && |
52 | [ "$(echo $(stg status --conflict))" = "foo/y.txt x.txt" ] | |
53 | ' | |
54 | ||
a138c01c CM |
55 | test_expect_success 'Conflicting add/unknown file in subdir' ' |
56 | stg status --reset && | |
57 | stg new foo -m foo && | |
58 | mkdir d && | |
59 | echo foo > d/test && | |
ea5b7bf3 | 60 | git add d/test && |
a138c01c CM |
61 | stg refresh && |
62 | stg pop && | |
63 | mkdir -p d && | |
64 | echo bar > d/test && | |
f03004e2 | 65 | command_error stg push foo && |
a138c01c CM |
66 | [ $(stg top) != "foo" ] |
67 | ' | |
68 | ||
86795a31 | 69 | test_done |