gitignore: Add ChangeLog to .gitignore
[stgit.git] / t / t1205-push-subdir.sh
blob79aef68a4aedf6c37a04eccef3fa5d81604f4e61
1 #!/bin/sh
2 test_description='Test the push command from a subdirectory'
3 . ./test-lib.sh
4 stg init
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 series --applied --noprefix))" = "p0 p1 p2" ] &&
16 [ "$(echo $(stg series --unapplied --noprefix))" = "" ]
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" ]
30 test_expect_success '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" ]
45 test_expect_success '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 conflict stg push p2 &&
51 cd .. &&
52 [ "$(echo $(stg status))" = "UU foo/y.txt UU x.txt" ]
55 test_expect_success 'Conflicting add/unknown file in subdir' '
56 stg reset --hard &&
57 stg new foo -m foo &&
58 mkdir d &&
59 echo foo > d/test &&
60 stg add d/test &&
61 stg refresh &&
62 stg pop &&
63 mkdir -p d &&
64 echo bar > d/test &&
65 command_error stg push foo &&
66 [ $(stg top) != "foo" ]
69 test_done