3 test_description
='git init'
5 TEST_PASSES_SANITIZE_LEAK
=true
9 if test_path_is_dir
"$1" &&
10 test_path_is_file
"$1/config" && test_path_is_dir
"$1/refs"
14 echo "expected a directory $1, a file $1/config and $1/refs"
18 if test_have_prereq POSIXPERM
&& test -x "$1/config"
20 echo "$1/config is executable?"
24 bare
=$
(cd "$1" && git config
--bool core.bare
)
25 worktree
=$
(cd "$1" && git config core.worktree
) ||
28 test "$bare" = "$2" && test "$worktree" = "$3" ||
{
29 echo "expected bare=$2 worktree=$3"
30 echo " got bare=$bare worktree=$worktree"
35 test_expect_success
'plain' '
37 check_config plain/.git false unset
40 test_expect_success
'plain nested in bare' '
42 git init --bare bare-ancestor.git &&
43 cd bare-ancestor.git &&
48 check_config bare-ancestor.git/plain-nested/.git false unset
51 test_expect_success
'plain through aliased command, outside any git repo' '
53 HOME=$(pwd)/alias-config &&
56 echo "[alias] aliasedinit = init" >alias-config/.gitconfig &&
58 GIT_CEILING_DIRECTORIES=$(pwd) &&
59 export GIT_CEILING_DIRECTORIES &&
61 mkdir plain-aliased &&
65 check_config plain-aliased/.git false unset
68 test_expect_success
'plain nested through aliased command' '
70 git init plain-ancestor-aliased &&
71 cd plain-ancestor-aliased &&
72 echo "[alias] aliasedinit = init" >>.git/config &&
77 check_config plain-ancestor-aliased/plain-nested/.git false unset
80 test_expect_success
'plain nested in bare through aliased command' '
82 git init --bare bare-ancestor-aliased.git &&
83 cd bare-ancestor-aliased.git &&
84 echo "[alias] aliasedinit = init" >>config &&
89 check_config bare-ancestor-aliased.git/plain-nested/.git false unset
92 test_expect_success
'No extra GIT_* on alias scripts' '
93 write_script script <<-\EOF &&
96 -e "/^GIT_PREFIX=/d" \
97 -e "/^GIT_TEXTDOMAINDIR=/d" \
98 -e "/^GIT_TRACE2_PARENT/d" \
99 -e "/^GIT_/s/=.*//p" |
102 ./script >expected &&
103 git config alias.script \!./script &&
104 ( mkdir sub && cd sub && git script >../actual ) &&
105 test_cmp expected actual
108 test_expect_success
'plain with GIT_WORK_TREE' '
110 test_must_fail env GIT_WORK_TREE="$(pwd)/plain-wt" git init plain-wt
113 test_expect_success
'plain bare' '
114 git --bare init plain-bare-1 &&
115 check_config plain-bare-1 true unset
118 test_expect_success
'plain bare with GIT_WORK_TREE' '
119 mkdir plain-bare-2 &&
121 env GIT_WORK_TREE="$(pwd)/plain-bare-2" \
122 git --bare init plain-bare-2
125 test_expect_success
'GIT_DIR bare' '
126 mkdir git-dir-bare.git &&
127 GIT_DIR=git-dir-bare.git git init &&
128 check_config git-dir-bare.git true unset
131 test_expect_success
'init --bare' '
132 git init --bare init-bare.git &&
133 check_config init-bare.git true unset
136 test_expect_success
'GIT_DIR non-bare' '
141 GIT_DIR=.git git init
143 check_config non-bare/.git false unset
146 test_expect_success
'GIT_DIR & GIT_WORK_TREE (1)' '
149 mkdir git-dir-wt-1.git &&
150 GIT_WORK_TREE=$(pwd) GIT_DIR=git-dir-wt-1.git git init
152 check_config git-dir-wt-1.git false "$(pwd)"
155 test_expect_success
'GIT_DIR & GIT_WORK_TREE (2)' '
156 mkdir git-dir-wt-2.git &&
158 GIT_WORK_TREE="$(pwd)" \
159 GIT_DIR=git-dir-wt-2.git \
163 test_expect_success
'reinit' '
168 git -c init.defaultBranch=initial init >out1 2>err1 &&
169 git init >out2 2>err2
171 test_grep "Initialized empty" again/out1 &&
172 test_grep "Reinitialized existing" again/out2 &&
173 test_must_be_empty again/err1 &&
174 test_must_be_empty again/err2
177 test_expect_success
'init with --template' '
178 mkdir template-source &&
179 echo content >template-source/file &&
180 git init --template=template-source template-custom &&
181 test_cmp template-source/file template-custom/.git/file
184 test_expect_success
'init with --template (blank)' '
185 git init template-plain &&
186 test_path_is_file template-plain/.git/info/exclude &&
187 git init --template= template-blank &&
188 test_path_is_missing template-blank/.git/info/exclude
191 init_no_templatedir_env
() {
193 sane_unset GIT_TEMPLATE_DIR
&&
194 NO_SET_GIT_TEMPLATE_DIR
=t
&&
195 export NO_SET_GIT_TEMPLATE_DIR
&&
200 test_expect_success
'init with init.templatedir set' '
201 mkdir templatedir-source &&
202 echo Content >templatedir-source/file &&
203 test_config_global init.templatedir "${HOME}/templatedir-source" &&
205 init_no_templatedir_env templatedir-set &&
206 test_cmp templatedir-source/file templatedir-set/.git/file
209 test_expect_success
'init with init.templatedir using ~ expansion' '
210 mkdir -p templatedir-source &&
211 echo Content >templatedir-source/file &&
212 test_config_global init.templatedir "~/templatedir-source" &&
214 init_no_templatedir_env templatedir-expansion &&
215 test_cmp templatedir-source/file templatedir-expansion/.git/file
218 test_expect_success
'init --bare/--shared overrides system/global config' '
219 test_config_global core.bare false &&
220 test_config_global core.sharedRepository 0640 &&
221 git init --bare --shared=0666 init-bare-shared-override &&
222 check_config init-bare-shared-override true unset &&
224 x$(git config -f init-bare-shared-override/config core.sharedRepository)
227 test_expect_success
'init honors global core.sharedRepository' '
228 test_config_global core.sharedRepository 0666 &&
229 git init shared-honor-global &&
231 x$(git config -f shared-honor-global/.git/config core.sharedRepository)
234 test_expect_success
'init allows insanely long --template' '
235 git init --template=$(printf "x%09999dx" 1) test
238 test_expect_success
'init creates a new directory' '
241 test_path_is_dir newdir/.git/refs
244 test_expect_success
'init creates a new bare directory' '
246 git init --bare newdir &&
247 test_path_is_dir newdir/refs
250 test_expect_success
'init recreates a directory' '
254 test_path_is_dir newdir/.git/refs
257 test_expect_success
'init recreates a new bare directory' '
260 git init --bare newdir &&
261 test_path_is_dir newdir/refs
264 test_expect_success
'init creates a new deep directory' '
266 git init newdir/a/b/c &&
267 test_path_is_dir newdir/a/b/c/.git/refs
270 test_expect_success POSIXPERM
'init creates a new deep directory (umask vs. shared)' '
273 # Leading directories should honor umask while
274 # the repository itself should follow "shared"
276 # Remove a default ACL if possible.
277 (setfacl -k newdir 2>/dev/null || true) &&
279 git init --bare --shared=0660 newdir/a/b/c &&
280 test_path_is_dir newdir/a/b/c/refs &&
281 ls -ld newdir/a newdir/a/b > lsab.out &&
282 ! grep -v "^drwxrw[sx]r-x" lsab.out &&
283 ls -ld newdir/a/b/c > lsc.out &&
284 ! grep -v "^drwxrw[sx]---" lsc.out
288 test_expect_success
'init notices EEXIST (1)' '
291 test_must_fail git init newdir &&
292 test_path_is_file newdir
295 test_expect_success
'init notices EEXIST (2)' '
299 test_must_fail git init newdir/a/b &&
300 test_path_is_file newdir/a
303 test_expect_success POSIXPERM
,SANITY
'init notices EPERM' '
304 test_when_finished "chmod +w newdir" &&
308 test_must_fail git init newdir/a/b
311 test_expect_success
'init creates a new bare directory with global --bare' '
313 git --bare init newdir &&
314 test_path_is_dir newdir/refs
317 test_expect_success
'init prefers command line to GIT_DIR' '
320 GIT_DIR=otherdir git --bare init newdir &&
321 test_path_is_dir newdir/refs &&
322 test_path_is_missing otherdir/refs
325 test_expect_success
'init with separate gitdir' '
327 git init --separate-git-dir realgitdir newdir &&
328 newdir_git="$(cat newdir/.git)" &&
329 test_cmp_fspath "$(pwd)/realgitdir" "${newdir_git#gitdir: }" &&
330 test_path_is_dir realgitdir/refs
333 test_expect_success
'explicit bare & --separate-git-dir incompatible' '
334 test_must_fail git init --bare --separate-git-dir goop.git bare.git 2>err &&
335 test_grep "cannot be used together" err
338 test_expect_success
'implicit bare & --separate-git-dir incompatible' '
339 test_when_finished "rm -rf bare.git" &&
341 test_must_fail env GIT_DIR=. \
342 git -C bare.git init --separate-git-dir goop.git 2>err &&
343 test_grep "incompatible" err
346 test_expect_success
'bare & --separate-git-dir incompatible within worktree' '
347 test_when_finished "rm -rf bare.git linkwt seprepo" &&
349 git clone --bare . bare.git &&
350 git -C bare.git worktree add --detach ../linkwt &&
351 test_must_fail git -C linkwt init --separate-git-dir seprepo 2>err &&
352 test_grep "incompatible" err
355 test_lazy_prereq GETCWD_IGNORES_PERMS
'
356 base=GETCWD_TEST_BASE_DIR &&
357 mkdir -p $base/dir &&
359 BUG "cannot prepare $base"
369 BUG "cannot clean $base"
373 check_long_base_path
() {
374 # exceed initial buffer size of strbuf_getcwd()
375 component
=123456789abcdef
&&
376 test_when_finished
"chmod 0700 $component; rm -rf $component" &&
377 p31
=$component/$component &&
378 p127
=$p31/$p31/$p31/$p31 &&
390 test_expect_success
'init in long base path' '
394 test_expect_success GETCWD_IGNORES_PERMS
'init in long restricted base path' '
395 check_long_base_path 0111
398 test_expect_success
're-init on .git file' '
399 ( cd newdir && git init )
402 test_expect_success
're-init to update git link' '
403 git -C newdir init --separate-git-dir ../surrealgitdir &&
404 newdir_git="$(cat newdir/.git)" &&
405 test_cmp_fspath "$(pwd)/surrealgitdir" "${newdir_git#gitdir: }" &&
406 test_path_is_dir surrealgitdir/refs &&
407 test_path_is_missing realgitdir/refs
410 test_expect_success
're-init to move gitdir' '
411 rm -rf newdir realgitdir surrealgitdir &&
413 git -C newdir init --separate-git-dir ../realgitdir &&
414 newdir_git="$(cat newdir/.git)" &&
415 test_cmp_fspath "$(pwd)/realgitdir" "${newdir_git#gitdir: }" &&
416 test_path_is_dir realgitdir/refs
419 test_expect_success SYMLINKS
're-init to move gitdir symlink' '
420 rm -rf newdir realgitdir &&
426 git init --separate-git-dir ../realgitdir
428 echo "gitdir: $(pwd)/realgitdir" >expected &&
429 test_cmp expected newdir/.git &&
430 test_cmp expected newdir/here &&
431 test_path_is_dir realgitdir/refs
434 sep_git_dir_worktree
() {
435 test_when_finished
"rm -rf mainwt linkwt seprepo" &&
437 test_commit
-C mainwt gumby
&&
438 git
-C mainwt worktree add
--detach ..
/linkwt
&&
439 git
-C "$1" init
--separate-git-dir ..
/seprepo
&&
440 git
-C mainwt rev-parse
--git-common-dir >expect
&&
441 git
-C linkwt rev-parse
--git-common-dir >actual
&&
442 test_cmp expect actual
445 test_expect_success
're-init to move gitdir with linked worktrees' '
446 sep_git_dir_worktree mainwt
449 test_expect_success
're-init to move gitdir within linked worktree' '
450 sep_git_dir_worktree linkwt
453 test_expect_success MINGW
'.git hidden' '
456 sane_unset GIT_DIR GIT_WORK_TREE &&
460 test_path_is_hidden .git
462 check_config newdir/.git false unset
465 test_expect_success MINGW
'bare git dir not hidden' '
468 sane_unset GIT_DIR GIT_WORK_TREE GIT_CONFIG &&
476 test_expect_success
'remote init from does not use config from cwd' '
478 test_config core.logallrefupdates true &&
481 git -C newdir config --bool core.logallrefupdates >actual &&
482 test_cmp expect actual
485 test_expect_success
're-init from a linked worktree' '
486 git init main-worktree &&
490 git worktree add ../linked-worktree &&
491 mv .git/info/exclude expected-exclude &&
492 cp .git/config expected-config &&
493 find .git/worktrees -print | sort >expected &&
494 git -C ../linked-worktree init &&
495 test_cmp expected-exclude .git/info/exclude &&
496 test_cmp expected-config .git/config &&
497 find .git/worktrees -print | sort >actual &&
498 test_cmp expected actual
502 test_expect_success
'init honors GIT_DEFAULT_HASH' '
503 test_when_finished "rm -rf sha1 sha256" &&
504 GIT_DEFAULT_HASH=sha1 git init sha1 &&
505 git -C sha1 rev-parse --show-object-format >actual &&
506 echo sha1 >expected &&
507 test_cmp expected actual &&
508 GIT_DEFAULT_HASH=sha256 git init sha256 &&
509 git -C sha256 rev-parse --show-object-format >actual &&
510 echo sha256 >expected &&
511 test_cmp expected actual
514 test_expect_success
'init honors --object-format' '
515 test_when_finished "rm -rf explicit-sha1 explicit-sha256" &&
516 git init --object-format=sha1 explicit-sha1 &&
517 git -C explicit-sha1 rev-parse --show-object-format >actual &&
518 echo sha1 >expected &&
519 test_cmp expected actual &&
520 git init --object-format=sha256 explicit-sha256 &&
521 git -C explicit-sha256 rev-parse --show-object-format >actual &&
522 echo sha256 >expected &&
523 test_cmp expected actual
526 test_expect_success
'init honors init.defaultObjectFormat' '
527 test_when_finished "rm -rf sha1 sha256" &&
529 test_config_global init.defaultObjectFormat sha1 &&
531 sane_unset GIT_DEFAULT_HASH &&
533 git -C sha1 rev-parse --show-object-format >actual &&
534 echo sha1 >expected &&
535 test_cmp expected actual
538 test_config_global init.defaultObjectFormat sha256 &&
540 sane_unset GIT_DEFAULT_HASH &&
542 git -C sha256 rev-parse --show-object-format >actual &&
543 echo sha256 >expected &&
544 test_cmp expected actual
548 test_expect_success
'init warns about invalid init.defaultObjectFormat' '
549 test_when_finished "rm -rf repo" &&
550 test_config_global init.defaultObjectFormat garbage &&
552 echo "warning: unknown hash algorithm ${SQ}garbage${SQ}" >expect &&
553 git init repo 2>err &&
554 test_cmp expect err &&
556 git -C repo rev-parse --show-object-format >actual &&
557 echo $GIT_DEFAULT_HASH >expected &&
558 test_cmp expected actual
561 test_expect_success
'--object-format overrides GIT_DEFAULT_HASH' '
562 test_when_finished "rm -rf repo" &&
563 GIT_DEFAULT_HASH=sha1 git init --object-format=sha256 repo &&
564 git -C repo rev-parse --show-object-format >actual &&
565 echo sha256 >expected
568 test_expect_success
'GIT_DEFAULT_HASH overrides init.defaultObjectFormat' '
569 test_when_finished "rm -rf repo" &&
570 test_config_global init.defaultObjectFormat sha1 &&
571 GIT_DEFAULT_HASH=sha256 git init repo &&
572 git -C repo rev-parse --show-object-format >actual &&
573 echo sha256 >expected
576 test_expect_success
'extensions.objectFormat is not allowed with repo version 0' '
577 test_when_finished "rm -rf explicit-v0" &&
578 git init --object-format=sha256 explicit-v0 &&
579 git -C explicit-v0 config core.repositoryformatversion 0 &&
580 test_must_fail git -C explicit-v0 rev-parse --show-object-format
583 test_expect_success
'init rejects attempts to initialize with different hash' '
584 test_must_fail git -C sha1 init --object-format=sha256 &&
585 test_must_fail git -C sha256 init --object-format=sha1
588 test_expect_success DEFAULT_REPO_FORMAT
'extensions.refStorage is not allowed with repo version 0' '
589 test_when_finished "rm -rf refstorage" &&
590 git init refstorage &&
591 git -C refstorage config extensions.refStorage files &&
592 test_must_fail git -C refstorage rev-parse 2>err &&
593 grep "repo version is 0, but v1-only extension found" err
596 test_expect_success DEFAULT_REPO_FORMAT
'extensions.refStorage with files backend' '
597 test_when_finished "rm -rf refstorage" &&
598 git init refstorage &&
599 git -C refstorage config core.repositoryformatversion 1 &&
600 git -C refstorage config extensions.refStorage files &&
601 test_commit -C refstorage A &&
602 git -C refstorage rev-parse --verify HEAD
605 test_expect_success DEFAULT_REPO_FORMAT
'extensions.refStorage with unknown backend' '
606 test_when_finished "rm -rf refstorage" &&
607 git init refstorage &&
608 git -C refstorage config core.repositoryformatversion 1 &&
609 git -C refstorage config extensions.refStorage garbage &&
610 test_must_fail git -C refstorage rev-parse 2>err &&
611 grep "invalid value for ${SQ}extensions.refstorage${SQ}: ${SQ}garbage${SQ}" err
614 test_expect_success
'init with GIT_DEFAULT_REF_FORMAT=garbage' '
615 test_when_finished "rm -rf refformat" &&
616 cat >expect <<-EOF &&
617 fatal: unknown ref storage format ${SQ}garbage${SQ}
619 test_must_fail env GIT_DEFAULT_REF_FORMAT=garbage git init refformat 2>err &&
623 test_expect_success
'init warns about invalid init.defaultRefFormat' '
624 test_when_finished "rm -rf repo" &&
625 test_config_global init.defaultRefFormat garbage &&
627 echo "warning: unknown ref storage format ${SQ}garbage${SQ}" >expect &&
628 git init repo 2>err &&
629 test_cmp expect err &&
631 git -C repo rev-parse --show-ref-format >actual &&
632 echo $GIT_DEFAULT_REF_FORMAT >expected &&
633 test_cmp expected actual
636 backends
="files reftable"
637 for format
in $backends
639 test_expect_success DEFAULT_REPO_FORMAT
"init with GIT_DEFAULT_REF_FORMAT=$format" '
640 test_when_finished "rm -rf refformat" &&
641 GIT_DEFAULT_REF_FORMAT=$format git init refformat &&
643 if test $format = files
645 test_must_fail git -C refformat config extensions.refstorage &&
648 git -C refformat config extensions.refstorage &&
651 git -C refformat config core.repositoryformatversion >actual &&
652 test_cmp expect actual &&
654 echo $format >expect &&
655 git -C refformat rev-parse --show-ref-format >actual &&
656 test_cmp expect actual
659 test_expect_success
"init with --ref-format=$format" '
660 test_when_finished "rm -rf refformat" &&
661 git init --ref-format=$format refformat &&
662 echo $format >expect &&
663 git -C refformat rev-parse --show-ref-format >actual &&
664 test_cmp expect actual
667 test_expect_success
"init with init.defaultRefFormat=$format" '
668 test_when_finished "rm -rf refformat" &&
669 test_config_global init.defaultRefFormat $format &&
671 sane_unset GIT_DEFAULT_REF_FORMAT &&
675 echo $format >expect &&
676 git -C refformat rev-parse --show-ref-format >actual &&
677 test_cmp expect actual
680 test_expect_success
"--ref-format=$format overrides GIT_DEFAULT_REF_FORMAT" '
681 test_when_finished "rm -rf refformat" &&
682 GIT_DEFAULT_REF_FORMAT=garbage git init --ref-format=$format refformat &&
683 echo $format >expect &&
684 git -C refformat rev-parse --show-ref-format >actual &&
685 test_cmp expect actual
689 test_expect_success
"--ref-format= overrides GIT_DEFAULT_REF_FORMAT" '
690 test_when_finished "rm -rf refformat" &&
691 GIT_DEFAULT_REF_FORMAT=files git init --ref-format=reftable refformat &&
692 echo reftable >expect &&
693 git -C refformat rev-parse --show-ref-format >actual &&
694 test_cmp expect actual
697 test_expect_success
"GIT_DEFAULT_REF_FORMAT= overrides init.defaultRefFormat" '
698 test_when_finished "rm -rf refformat" &&
699 test_config_global init.defaultRefFormat files &&
701 GIT_DEFAULT_REF_FORMAT=reftable git init refformat &&
702 echo reftable >expect &&
703 git -C refformat rev-parse --show-ref-format >actual &&
704 test_cmp expect actual
707 for from_format
in $backends
709 test_expect_success
"re-init with same format ($from_format)" '
710 test_when_finished "rm -rf refformat" &&
711 git init --ref-format=$from_format refformat &&
712 git init --ref-format=$from_format refformat &&
713 echo $from_format >expect &&
714 git -C refformat rev-parse --show-ref-format >actual &&
715 test_cmp expect actual
718 for to_format
in $backends
720 if test "$from_format" = "$to_format"
725 test_expect_success
"re-init with different format fails ($from_format -> $to_format)" '
726 test_when_finished "rm -rf refformat" &&
727 git init --ref-format=$from_format refformat &&
728 cat >expect <<-EOF &&
729 fatal: attempt to reinitialize repository with different reference storage format
731 test_must_fail git init --ref-format=$to_format refformat 2>err &&
732 test_cmp expect err &&
733 echo $from_format >expect &&
734 git -C refformat rev-parse --show-ref-format >actual &&
735 test_cmp expect actual
740 test_expect_success
'init with --ref-format=garbage' '
741 test_when_finished "rm -rf refformat" &&
742 cat >expect <<-EOF &&
743 fatal: unknown ref storage format ${SQ}garbage${SQ}
745 test_must_fail git init --ref-format=garbage refformat 2>err &&
749 test_expect_success MINGW
'core.hidedotfiles = false' '
750 git config --global core.hidedotfiles false &&
754 sane_unset GIT_DIR GIT_WORK_TREE GIT_CONFIG &&
757 ! is_hidden newdir/.git
760 test_expect_success MINGW
'redirect std handles' '
761 GIT_REDIRECT_STDOUT=output.txt git rev-parse --git-dir &&
762 test .git = "$(cat output.txt)" &&
763 test -z "$(GIT_REDIRECT_STDOUT=off git rev-parse --git-dir)" &&
765 GIT_REDIRECT_STDOUT=output.txt \
766 GIT_REDIRECT_STDERR="2>&1" \
767 git rev-parse --git-dir --verify refs/invalid &&
768 grep "^\\.git\$" output.txt &&
769 grep "Needed a single revision" output.txt
772 test_expect_success
'--initial-branch' '
773 git init --initial-branch=hello initial-branch-option &&
774 git -C initial-branch-option symbolic-ref HEAD >actual &&
775 echo refs/heads/hello >expect &&
776 test_cmp expect actual &&
778 : re-initializing should not change the branch name &&
779 git init --initial-branch=ignore initial-branch-option 2>err &&
780 test_grep "ignored --initial-branch" err &&
781 git -C initial-branch-option symbolic-ref HEAD >actual &&
785 test_expect_success
'overridden default initial branch name (config)' '
786 test_config_global init.defaultBranch nmb &&
787 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= git init initial-branch-config &&
788 git -C initial-branch-config symbolic-ref HEAD >actual &&
792 test_expect_success
'advice on unconfigured init.defaultBranch' '
793 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= git -c color.advice=always \
794 init unconfigured-default-branch-name 2>err &&
795 test_decode_color <err >decoded &&
796 test_grep "<YELLOW>hint: " decoded
799 test_expect_success
'overridden default main branch name (env)' '
800 test_config_global init.defaultBranch nmb &&
801 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=env git init main-branch-env &&
802 git -C main-branch-env symbolic-ref HEAD >actual &&
806 test_expect_success
'invalid default branch name' '
807 test_must_fail env GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME="with space" \
808 git init initial-branch-invalid 2>err &&
809 test_grep "invalid branch name" err
812 test_expect_success
'branch -m with the initial branch' '
813 git init rename-initial &&
814 git -C rename-initial branch -m renamed &&
815 echo renamed >expect &&
816 git -C rename-initial symbolic-ref --short HEAD >actual &&
817 test_cmp expect actual &&
819 git -C rename-initial branch -m renamed again &&
820 echo again >expect &&
821 git -C rename-initial symbolic-ref --short HEAD >actual &&
822 test_cmp expect actual
825 test_expect_success
'init with includeIf.onbranch condition' '
826 test_when_finished "rm -rf repo" &&
827 git -c includeIf.onbranch:main.path=nonexistent init repo &&
828 echo $GIT_DEFAULT_REF_FORMAT >expect &&
829 git -C repo rev-parse --show-ref-format >actual &&
830 test_cmp expect actual
833 test_expect_success
'init with includeIf.onbranch condition with existing directory' '
834 test_when_finished "rm -rf repo" &&
836 git -c includeIf.onbranch:nonexistent.path=/does/not/exist init repo &&
837 echo $GIT_DEFAULT_REF_FORMAT >expect &&
838 git -C repo rev-parse --show-ref-format >actual &&
839 test_cmp expect actual
842 test_expect_success
're-init with includeIf.onbranch condition' '
843 test_when_finished "rm -rf repo" &&
845 git -c includeIf.onbranch:nonexistent.path=/does/not/exist init repo &&
846 echo $GIT_DEFAULT_REF_FORMAT >expect &&
847 git -C repo rev-parse --show-ref-format >actual &&
848 test_cmp expect actual
851 test_expect_success
're-init with includeIf.onbranch condition' '
852 test_when_finished "rm -rf repo" &&
854 git -c includeIf.onbranch:nonexistent.path=/does/not/exist init repo &&
855 echo $GIT_DEFAULT_REF_FORMAT >expect &&
856 git -C repo rev-parse --show-ref-format >actual &&
857 test_cmp expect actual
860 test_expect_success
're-init skips non-matching includeIf.onbranch' '
861 test_when_finished "rm -rf repo config" &&
862 cat >config <<-EOF &&
867 git -c includeIf.onbranch:nonexistent.path="$(test-tool path-utils absolute_path config)" init repo
870 test_expect_success
're-init reads matching includeIf.onbranch' '
871 test_when_finished "rm -rf repo config" &&
872 cat >config <<-EOF &&
876 path="$(test-tool path-utils absolute_path config)" &&
877 git init --initial-branch=branch repo &&
878 cat >expect <<-EOF &&
879 fatal: bad config line 1 in file $path
881 test_must_fail git -c includeIf.onbranch:branch.path="$path" init repo 2>err &&