]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5606-clone-options.sh
Git 2.30
[thirdparty/git.git] / t / t5606-clone-options.sh
CommitLineData
ecaa0cff
JK
1#!/bin/sh
2
3test_description='basic clone options'
4. ./test-lib.sh
5
6test_expect_success 'setup' '
7
8 mkdir parent &&
9 (cd parent && git init &&
10 echo one >file && git add file &&
11 git commit -m one)
12
13'
14
15test_expect_success 'clone -o' '
16
17 git clone -o foo parent clone-o &&
349cff76
SB
18 git -C clone-o rev-parse --verify refs/remotes/foo/master
19
20'
21
de9ed3ef
SB
22test_expect_success 'rejects invalid -o/--origin' '
23
24 test_must_fail git clone -o "bad...name" parent clone-bad-name 2>err &&
25 test_i18ngrep "'\''bad...name'\'' is not a valid remote name" err
26
27'
28
349cff76
SB
29test_expect_success 'disallows --bare with --origin' '
30
31 test_must_fail git clone -o foo --bare parent clone-bare-o 2>err &&
32 test_debug "cat err" &&
33 test_i18ngrep -e "--bare and --origin foo options are incompatible" err
34
35'
36
37test_expect_success 'disallows --bare with --separate-git-dir' '
38
39 test_must_fail git clone --bare --separate-git-dir dot-git-destiation parent clone-bare-sgd 2>err &&
40 test_debug "cat err" &&
41 test_i18ngrep -e "--bare and --separate-git-dir are incompatible" err
42
43'
44
45test_expect_success 'uses "origin" for default remote name' '
46
47 git clone parent clone-default-origin &&
48 git -C clone-default-origin rev-parse --verify refs/remotes/origin/master
49
50'
51
52test_expect_success 'prefers --template config over normal config' '
53
54 template="$TRASH_DIRECTORY/template-with-config" &&
55 mkdir "$template" &&
56 git config --file "$template/config" foo.bar from_template &&
57 test_config_global foo.bar from_global &&
58 git clone "--template=$template" parent clone-template-config &&
59 test "$(git -C clone-template-config config --local foo.bar)" = "from_template"
60
61'
62
63test_expect_success 'prefers -c config over --template config' '
64
65 template="$TRASH_DIRECTORY/template-with-ignored-config" &&
66 mkdir "$template" &&
67 git config --file "$template/config" foo.bar from_template &&
68 git clone "--template=$template" -c foo.bar=inline parent clone-template-inline-config &&
69 test "$(git -C clone-template-inline-config config --local foo.bar)" = "inline"
ecaa0cff
JK
70
71'
72
de9ed3ef
SB
73test_expect_success 'prefers config "clone.defaultRemoteName" over default' '
74
75 test_config_global clone.defaultRemoteName from_config &&
76 git clone parent clone-config-origin &&
77 git -C clone-config-origin rev-parse --verify refs/remotes/from_config/master
78
79'
80
81test_expect_success 'prefers --origin over -c config' '
82
83 git clone -c clone.defaultRemoteName=inline --origin from_option parent clone-o-and-inline-config &&
84 git -C clone-o-and-inline-config rev-parse --verify refs/remotes/from_option/master
85
86'
87
68b939b2 88test_expect_success 'redirected clone does not show progress' '
21188b1e
MV
89
90 git clone "file://$(pwd)/parent" clone-redirected >out 2>err &&
2856cbf0
JK
91 ! grep % err &&
92 test_i18ngrep ! "Checking connectivity" err
21188b1e
MV
93
94'
68b939b2
JK
95
96test_expect_success 'redirected clone -v does show progress' '
21188b1e 97
5a518ad4
TRC
98 git clone --progress "file://$(pwd)/parent" clone-redirected-progress \
99 >out 2>err &&
68b939b2 100 grep % err
21188b1e
MV
101
102'
103
0cc1b475
JS
104test_expect_success 'chooses correct default initial branch name' '
105 git init --bare empty &&
704fed9e 106 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \
0cc1b475
JS
107 git -c init.defaultBranch=up clone empty whats-up &&
108 test refs/heads/up = $(git -C whats-up symbolic-ref HEAD) &&
109 test refs/heads/up = $(git -C whats-up config branch.up.merge)
110'
111
112test_expect_success 'guesses initial branch name correctly' '
113 git init --initial-branch=guess initial-branch &&
114 test_commit -C initial-branch no-spoilers &&
115 git -C initial-branch branch abc guess &&
116 git clone initial-branch is-it &&
a471214b
JS
117 test refs/heads/guess = $(git -C is-it symbolic-ref HEAD) &&
118
119 git -c init.defaultBranch=none init --bare no-head &&
120 git -C initial-branch push ../no-head guess abc &&
704fed9e 121 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \
a471214b
JS
122 git clone no-head is-it2 &&
123 test_must_fail git -C is-it2 symbolic-ref refs/remotes/origin/HEAD &&
124 git -C no-head update-ref --no-deref HEAD refs/heads/guess &&
704fed9e 125 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \
a471214b
JS
126 git -c init.defaultBranch=guess clone no-head is-it3 &&
127 test refs/remotes/origin/guess = \
128 $(git -C is-it3 symbolic-ref refs/remotes/origin/HEAD)
0cc1b475
JS
129'
130
ecaa0cff 131test_done