| 1 | #!/bin/sh |
| 2 | test_description='Test the refresh command from a subdirectory' |
| 3 | . ./test-lib.sh |
| 4 | stg init |
| 5 | |
| 6 | test_expect_success 'Refresh from a subdirectory' ' |
| 7 | stg new p0 -m p0 && |
| 8 | echo foo >> foo.txt && |
| 9 | mkdir bar && |
| 10 | echo bar >> bar/bar.txt && |
| 11 | git add foo.txt bar/bar.txt && |
| 12 | cd bar && |
| 13 | stg refresh && |
| 14 | cd .. && |
| 15 | [ "$(stg status)" = "" ] |
| 16 | ' |
| 17 | |
| 18 | test_expect_success 'Refresh again' ' |
| 19 | echo foo2 >> foo.txt && |
| 20 | echo bar2 >> bar/bar.txt && |
| 21 | cd bar && |
| 22 | stg refresh && |
| 23 | cd .. && |
| 24 | [ "$(stg status)" = "" ] |
| 25 | ' |
| 26 | |
| 27 | test_expect_success 'Refresh file in subdirectory' ' |
| 28 | echo foo3 >> foo.txt && |
| 29 | echo bar3 >> bar/bar.txt && |
| 30 | cd bar && |
| 31 | stg refresh bar.txt && |
| 32 | cd .. && |
| 33 | [ "$(stg status)" = "M foo.txt" ] |
| 34 | ' |
| 35 | |
| 36 | test_expect_success 'Refresh whole subdirectory' ' |
| 37 | echo bar4 >> bar/bar.txt && |
| 38 | stg refresh bar && |
| 39 | [ "$(stg status)" = "M foo.txt" ] |
| 40 | ' |
| 41 | |
| 42 | test_expect_success 'Refresh subdirectories recursively' ' |
| 43 | echo bar5 >> bar/bar.txt && |
| 44 | stg refresh . && |
| 45 | [ "$(stg status)" = "" ] |
| 46 | ' |
| 47 | |
| 48 | test_expect_success 'refresh -u' ' |
| 49 | echo baz >> bar/baz.txt && |
| 50 | stg new p1 -m p1 && |
| 51 | git add bar/baz.txt && |
| 52 | stg refresh --index && |
| 53 | echo xyzzy >> foo.txt && |
| 54 | echo xyzzy >> bar/bar.txt && |
| 55 | echo xyzzy >> bar/baz.txt && |
| 56 | stg refresh -u && |
| 57 | test "$(echo $(stg status))" = "M bar/bar.txt M foo.txt" |
| 58 | ' |
| 59 | |
| 60 | test_expect_success 'refresh -u -p <subdir>' ' |
| 61 | echo xyzzy >> bar/baz.txt && |
| 62 | stg refresh -p p0 -u bar && |
| 63 | test "$(echo $(stg status))" = "M bar/baz.txt M foo.txt" |
| 64 | ' |
| 65 | |
| 66 | test_expect_success 'refresh an unapplied patch' ' |
| 67 | stg refresh -u && |
| 68 | stg goto --keep p0 && |
| 69 | test "$(stg status)" = "M foo.txt" && |
| 70 | stg refresh -p p1 && |
| 71 | test "$(stg status)" = "" && |
| 72 | test "$(echo $(stg files p1))" = "A bar/baz.txt M foo.txt" |
| 73 | ' |
| 74 | |
| 75 | test_done |