tests: mark tests relying on the current default for `init.defaultBranch`
[alt-git.git] / t / t5611-clone-config.sh
blobbe4ae10c82fc144d10eae8ec8bf166d87317f4b0
1 #!/bin/sh
3 test_description='tests for git clone -c key=value'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7 . ./test-lib.sh
9 test_expect_success 'clone -c sets config in cloned repo' '
10 rm -rf child &&
11 git clone -c core.foo=bar . child &&
12 echo bar >expect &&
13 git --git-dir=child/.git config core.foo >actual &&
14 test_cmp expect actual
17 test_expect_success 'clone -c can set multi-keys' '
18 rm -rf child &&
19 git clone -c core.foo=bar -c core.foo=baz . child &&
20 { echo bar; echo baz; } >expect &&
21 git --git-dir=child/.git config --get-all core.foo >actual &&
22 test_cmp expect actual
25 test_expect_success 'clone -c can set multi-keys, including some empty' '
26 rm -rf child &&
27 git clone -c credential.helper= -c credential.helper=hi . child &&
28 printf "%s\n" "" hi >expect &&
29 git --git-dir=child/.git config --get-all credential.helper >actual &&
30 test_cmp expect actual
33 test_expect_success 'clone -c without a value is boolean true' '
34 rm -rf child &&
35 git clone -c core.foo . child &&
36 echo true >expect &&
37 git --git-dir=child/.git config --bool core.foo >actual &&
38 test_cmp expect actual
41 test_expect_success 'clone -c config is available during clone' '
42 echo content >file &&
43 git add file &&
44 git commit -m one &&
45 rm -rf child &&
46 git clone -c core.autocrlf . child &&
47 printf "content\\r\\n" >expect &&
48 test_cmp expect child/file
51 test_expect_success 'clone -c remote.origin.fetch=<refspec> works' '
52 rm -rf child &&
53 git update-ref refs/grab/it refs/heads/master &&
54 git update-ref refs/leave/out refs/heads/master &&
55 git clone -c "remote.origin.fetch=+refs/grab/*:refs/grab/*" . child &&
56 git -C child for-each-ref --format="%(refname)" >actual &&
58 cat >expect <<-\EOF &&
59 refs/grab/it
60 refs/heads/master
61 refs/remotes/origin/HEAD
62 refs/remotes/origin/master
63 EOF
64 test_cmp expect actual
67 test_expect_success 'git -c remote.origin.fetch=<refspec> clone works' '
68 rm -rf child &&
69 git -c "remote.origin.fetch=+refs/grab/*:refs/grab/*" clone . child &&
70 git -C child for-each-ref --format="%(refname)" >actual &&
72 cat >expect <<-\EOF &&
73 refs/grab/it
74 refs/heads/master
75 refs/remotes/origin/HEAD
76 refs/remotes/origin/master
77 EOF
78 test_cmp expect actual
81 test_expect_success 'clone -c remote.<remote>.fetch=<refspec> --origin=<name>' '
82 rm -rf child &&
83 git clone --origin=upstream \
84 -c "remote.upstream.fetch=+refs/grab/*:refs/grab/*" \
85 -c "remote.origin.fetch=+refs/leave/*:refs/leave/*" \
86 . child &&
87 git -C child for-each-ref --format="%(refname)" >actual &&
89 cat >expect <<-\EOF &&
90 refs/grab/it
91 refs/heads/master
92 refs/remotes/upstream/HEAD
93 refs/remotes/upstream/master
94 EOF
95 test_cmp expect actual
98 test_expect_success MINGW 'clone -c core.hideDotFiles' '
99 test_commit attributes .gitattributes "" &&
100 rm -rf child &&
101 git clone -c core.hideDotFiles=false . child &&
102 ! test_path_is_hidden child/.gitattributes &&
103 rm -rf child &&
104 git clone -c core.hideDotFiles=dotGitOnly . child &&
105 ! test_path_is_hidden child/.gitattributes &&
106 rm -rf child &&
107 git clone -c core.hideDotFiles=true . child &&
108 test_path_is_hidden child/.gitattributes
111 test_done