Allow StGIT commands to run correctly in subdirectories
[stgit] / t / t2300-refresh-subdir.sh
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 foo -m foo &&
8 echo foo >> foo.txt &&
9 mkdir bar &&
10 echo bar >> bar/bar.txt &&
11 stg 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_done