| 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 | git 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_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 | git 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_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 | ! stg push p2 && |
| 51 | cd .. && |
| 52 | [ "$(echo $(stg status --conflict))" = "foo/y.txt x.txt" ] |
| 53 | ' |
| 54 | |
| 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 && |
| 60 | git add d/test && |
| 61 | stg refresh && |
| 62 | stg pop && |
| 63 | mkdir -p d && |
| 64 | echo bar > d/test && |
| 65 | ! stg push foo && |
| 66 | [ $(stg top) != "foo" ] |
| 67 | ' |
| 68 | |
| 69 | test_done |