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
9 test_expect_success
'clone -c sets config in cloned repo' '
11 git clone -c core.foo=bar . child &&
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' '
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' '
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' '
35 git clone -c core.foo . child &&
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' '
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' '
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 &&
61 refs/remotes/origin/HEAD
62 refs/remotes/origin/master
64 test_cmp expect actual
67 test_expect_success
'git -c remote.origin.fetch=<refspec> clone works' '
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 &&
75 refs/remotes/origin/HEAD
76 refs/remotes/origin/master
78 test_cmp expect actual
81 test_expect_success
'clone -c remote.<remote>.fetch=<refspec> --origin=<name>' '
83 git clone --origin=upstream \
84 -c "remote.upstream.fetch=+refs/grab/*:refs/grab/*" \
85 -c "remote.origin.fetch=+refs/leave/*:refs/leave/*" \
87 git -C child for-each-ref --format="%(refname)" >actual &&
89 cat >expect <<-\EOF &&
92 refs/remotes/upstream/HEAD
93 refs/remotes/upstream/master
95 test_cmp expect actual
98 test_expect_success MINGW
'clone -c core.hideDotFiles' '
99 test_commit attributes .gitattributes "" &&
101 git clone -c core.hideDotFiles=false . child &&
102 ! test_path_is_hidden child/.gitattributes &&
104 git clone -c core.hideDotFiles=dotGitOnly . child &&
105 ! test_path_is_hidden child/.gitattributes &&
107 git clone -c core.hideDotFiles=true . child &&
108 test_path_is_hidden child/.gitattributes