refs: remove API function update_refs()
[git.git] / t / t0056-git-C.sh
blob99c037703a676dd63e4c2b53ea87601fc2503b88
1 #!/bin/sh
3 test_description='"-C <path>" option and its effects on other path-related options'
5 . ./test-lib.sh
7 test_expect_success '"git -C <path>" runs git from the directory <path>' '
8 test_create_repo dir1 &&
9 echo 1 >dir1/a.txt &&
10 msg="initial in dir1" &&
11 (cd dir1 && git add a.txt && git commit -m "$msg") &&
12 echo "$msg" >expected &&
13 git -C dir1 log --format=%s >actual &&
14 test_cmp expected actual
17 test_expect_success 'Multiple -C options: "-C dir1 -C dir2" is equivalent to "-C dir1/dir2"' '
18 test_create_repo dir1/dir2 &&
19 echo 1 >dir1/dir2/b.txt &&
20 git -C dir1/dir2 add b.txt &&
21 msg="initial in dir1/dir2" &&
22 echo "$msg" >expected &&
23 git -C dir1/dir2 commit -m "$msg" &&
24 git -C dir1 -C dir2 log --format=%s >actual &&
25 test_cmp expected actual
28 test_expect_success 'Effect on --git-dir option: "-C c --git-dir=a.git" is equivalent to "--git-dir c/a.git"' '
29 mkdir c &&
30 mkdir c/a &&
31 mkdir c/a.git &&
32 (cd c/a.git && git init --bare) &&
33 echo 1 >c/a/a.txt &&
34 git --git-dir c/a.git --work-tree=c/a add a.txt &&
35 git --git-dir c/a.git --work-tree=c/a commit -m "initial" &&
36 git --git-dir=c/a.git log -1 --format=%s >expected &&
37 git -C c --git-dir=a.git log -1 --format=%s >actual &&
38 test_cmp expected actual
41 test_expect_success 'Order should not matter: "--git-dir=a.git -C c" is equivalent to "-C c --git-dir=a.git"' '
42 git -C c --git-dir=a.git log -1 --format=%s >expected &&
43 git --git-dir=a.git -C c log -1 --format=%s >actual &&
44 test_cmp expected actual
47 test_expect_success 'Effect on --work-tree option: "-C c/a.git --work-tree=../a" is equivalent to "--work-tree=c/a --git-dir=c/a.git"' '
48 rm c/a/a.txt &&
49 git --git-dir=c/a.git --work-tree=c/a status >expected &&
50 git -C c/a.git --work-tree=../a status >actual &&
51 test_cmp expected actual
54 test_expect_success 'Order should not matter: "--work-tree=../a -C c/a.git" is equivalent to "-C c/a.git --work-tree=../a"' '
55 git -C c/a.git --work-tree=../a status >expected &&
56 git --work-tree=../a -C c/a.git status >actual &&
57 test_cmp expected actual
60 test_expect_success 'Effect on --git-dir and --work-tree options - "-C c --git-dir=a.git --work-tree=a" is equivalent to "--git-dir=c/a.git --work-tree=c/a"' '
61 git --git-dir=c/a.git --work-tree=c/a status >expected &&
62 git -C c --git-dir=a.git --work-tree=a status >actual &&
63 test_cmp expected actual
66 test_expect_success 'Order should not matter: "-C c --git-dir=a.git --work-tree=a" is equivalent to "--git-dir=a.git -C c --work-tree=a"' '
67 git -C c --git-dir=a.git --work-tree=a status >expected &&
68 git --git-dir=a.git -C c --work-tree=a status >actual &&
69 test_cmp expected actual
72 test_expect_success 'Order should not matter: "-C c --git-dir=a.git --work-tree=a" is equivalent to "--git-dir=a.git --work-tree=a -C c"' '
73 git -C c --git-dir=a.git --work-tree=a status >expected &&
74 git --git-dir=a.git --work-tree=a -C c status >actual &&
75 test_cmp expected actual
78 test_expect_success 'Relative followed by fullpath: "-C ./here -C /there" is equivalent to "-C /there"' '
79 echo "initial in dir1/dir2" >expected &&
80 git -C dir1 -C "$(pwd)/dir1/dir2" log --format=%s >actual &&
81 test_cmp expected actual
84 test_done