ci: use upload-artifacts v1 for dockerized jobs
[git/debian.git] / t / t5611-clone-config.sh
blobf8625f915821b5db03a5667b548ed055d26ccca3
1 #!/bin/sh
3 test_description='tests for git clone -c key=value'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
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/main &&
54 git update-ref refs/leave/out refs/heads/main &&
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/main
61 refs/remotes/origin/HEAD
62 refs/remotes/origin/main
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/main
75 refs/remotes/origin/HEAD
76 refs/remotes/origin/main
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/main
92 refs/remotes/upstream/HEAD
93 refs/remotes/upstream/main
94 EOF
95 test_cmp expect actual
98 test_expect_success 'set up shallow repository' '
99 git clone --depth=1 --no-local . shallow-repo
102 test_expect_success 'clone.rejectshallow=true should reject cloning shallow repo' '
103 test_when_finished "rm -rf out" &&
104 test_must_fail git -c clone.rejectshallow=true clone --no-local shallow-repo out 2>err &&
105 test_i18ngrep -e "source repository is shallow, reject to clone." err &&
107 git -c clone.rejectshallow=false clone --no-local shallow-repo out
110 test_expect_success 'option --[no-]reject-shallow override clone.rejectshallow config' '
111 test_when_finished "rm -rf out" &&
112 test_must_fail git -c clone.rejectshallow=false clone --reject-shallow --no-local shallow-repo out 2>err &&
113 test_i18ngrep -e "source repository is shallow, reject to clone." err &&
115 git -c clone.rejectshallow=true clone --no-reject-shallow --no-local shallow-repo out
118 test_expect_success 'clone.rejectshallow=true should succeed cloning normal repo' '
119 test_when_finished "rm -rf out" &&
120 git -c clone.rejectshallow=true clone --no-local . out
123 test_expect_success MINGW 'clone -c core.hideDotFiles' '
124 test_commit attributes .gitattributes "" &&
125 rm -rf child &&
126 git clone -c core.hideDotFiles=false . child &&
127 ! test_path_is_hidden child/.gitattributes &&
128 rm -rf child &&
129 git clone -c core.hideDotFiles=dotGitOnly . child &&
130 ! test_path_is_hidden child/.gitattributes &&
131 rm -rf child &&
132 git clone -c core.hideDotFiles=true . child &&
133 test_path_is_hidden child/.gitattributes
136 test_done