chiark / gitweb /
Do not raise an exception if no FETCH_HEAD
[stgit] / t / t1205-push-subdir.sh
CommitLineData
86795a31
KH
1#!/bin/sh
2test_description='Test the push command from a subdirectory'
3. ./test-lib.sh
4stg init
5
6test_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
19test_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 30test_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 &&
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
89d889f4 45test_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 &&
50 ! stg push p2 &&
51 cd .. &&
52 [ "$(echo $(stg status --conflict))" = "foo/y.txt x.txt" ]
53'
54
55test_done