(command.CommandList children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:test_description) op: assign_op.Equal rhs: {(SQ <'git init'>)} spids: [4] ) ] ) (C {<.>} {<'./test-lib.sh'>}) (command.ShFunction name: check_config body: (BraceGroup children: [ (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.AndOr ops: [Id.Op_DAmp Id.Op_DAmp] children: [ (C {<test>} {<-d>} {(DQ ($ Id.VSub_Number '$1'))}) (C {<test>} {<-f>} {(DQ ($ Id.VSub_Number '$1') <'/config'>)}) (C {<test>} {<-d>} {(DQ ($ Id.VSub_Number '$1') <'/refs'>)}) ] ) ] ) action: [(C {<Id.Lit_Colon ':'>} {<happy>})] spids: [23 56] ) ] else_action: [ (C {<echo>} { (DQ <'expected a directory '> ($ Id.VSub_Number '$1') <', a file '> ($ Id.VSub_Number '$1') <'/config and '> ($ Id.VSub_Number '$1') <'/refs'> ) } ) (command.ControlFlow token: <Id.ControlFlow_Return return> arg_word: {<1>} ) ] ) (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.AndOr ops: [Id.Op_DAmp] children: [ (C {<test_have_prereq>} {<POSIXPERM>}) (C {<test>} {<-x>} {(DQ ($ Id.VSub_Number '$1') <'/config'>)}) ] ) ] ) action: [ (C {<echo>} {(DQ ($ Id.VSub_Number '$1') <'/config is executable?'>)}) (command.ControlFlow token: <Id.ControlFlow_Return return> arg_word: {<1>} ) ] spids: [89 107] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:bare) op: assign_op.Equal rhs: { (command_sub left_token: <Id.Left_DollarParen '$('> child: (command.AndOr ops: [Id.Op_DAmp] children: [ (C {<cd>} {(DQ ($ Id.VSub_Number '$1'))}) (C {<git>} {<config>} {<--bool>} {<core.bare>}) ] ) ) } spids: [127] ) ] ) (command.AndOr ops: [Id.Op_DPipe] children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:worktree) op: assign_op.Equal rhs: { (command_sub left_token: <Id.Left_DollarParen '$('> child: (command.AndOr ops: [Id.Op_DAmp] children: [ (C {<cd>} {(DQ ($ Id.VSub_Number '$1'))}) (C {<git>} {<config>} {<core.worktree>}) ] ) ) } spids: [147] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:worktree) op: assign_op.Equal rhs: {<unset>} spids: [167] ) ] ) ] ) (command.AndOr ops: [Id.Op_DAmp Id.Op_DPipe] children: [ (C {<test>} {(DQ ($ Id.VSub_DollarName '$bare'))} {<Id.Lit_Equals '='>} {(DQ ($ Id.VSub_Number '$2'))} ) (C {<test>} {(DQ ($ Id.VSub_DollarName '$worktree'))} {<Id.Lit_Equals '='>} {(DQ ($ Id.VSub_Number '$3'))} ) (BraceGroup children: [ (C {<echo>} { (DQ <'expected bare='> ($ Id.VSub_Number '$2') <' worktree='> ($ Id.VSub_Number '$3') ) } ) (C {<echo>} { (DQ <' got bare='> ($ Id.VSub_DollarName '$bare') <' worktree='> ($ Id.VSub_DollarName '$worktree') ) } ) (command.ControlFlow token: <Id.ControlFlow_Return return> arg_word: {<1>} ) ] ) ] ) ] ) ) (C {<test_expect_success>} {(SQ <plain>)} {(SQ <'\n'> <'\tgit init plain &&\n'> <'\tcheck_config plain/.git false unset\n'>)} ) (C {<test_expect_success>} {(SQ <'plain nested in bare'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tgit init --bare bare-ancestor.git &&\n'> <'\t\tcd bare-ancestor.git &&\n'> <'\t\tmkdir plain-nested &&\n'> <'\t\tcd plain-nested &&\n'> <'\t\tgit init\n'> <'\t) &&\n'> <'\tcheck_config bare-ancestor.git/plain-nested/.git false unset\n'> ) } ) (C {<test_expect_success>} {(SQ <'plain through aliased command, outside any git repo'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tHOME=$(pwd)/alias-config &&\n'> <'\t\texport HOME &&\n'> <'\t\tmkdir alias-config &&\n'> <'\t\techo "[alias] aliasedinit = init" >alias-config/.gitconfig &&\n'> <'\n'> <'\t\tGIT_CEILING_DIRECTORIES=$(pwd) &&\n'> <'\t\texport GIT_CEILING_DIRECTORIES &&\n'> <'\n'> <'\t\tmkdir plain-aliased &&\n'> <'\t\tcd plain-aliased &&\n'> <'\t\tgit aliasedinit\n'> <'\t) &&\n'> <'\tcheck_config plain-aliased/.git false unset\n'> ) } ) (C {<test_expect_success>} {(SQ <'plain nested through aliased command'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tgit init plain-ancestor-aliased &&\n'> <'\t\tcd plain-ancestor-aliased &&\n'> <'\t\techo "[alias] aliasedinit = init" >>.git/config &&\n'> <'\t\tmkdir plain-nested &&\n'> <'\t\tcd plain-nested &&\n'> <'\t\tgit aliasedinit\n'> <'\t) &&\n'> <'\tcheck_config plain-ancestor-aliased/plain-nested/.git false unset\n'> ) } ) (C {<test_expect_success>} {(SQ <'plain nested in bare through aliased command'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tgit init --bare bare-ancestor-aliased.git &&\n'> <'\t\tcd bare-ancestor-aliased.git &&\n'> <'\t\techo "[alias] aliasedinit = init" >>config &&\n'> <'\t\tmkdir plain-nested &&\n'> <'\t\tcd plain-nested &&\n'> <'\t\tgit aliasedinit\n'> <'\t) &&\n'> <'\tcheck_config bare-ancestor-aliased.git/plain-nested/.git false unset\n'> ) } ) (C {<test_expect_success>} {(SQ <'No extra GIT_* on alias scripts'>)} { (SQ <'\n'> <'\twrite_script script <<-\\EOF &&\n'> <'\tenv |\n'> <'\t\tsed -n \\\n'> <'\t\t\t-e "/^GIT_PREFIX=/d" \\\n'> <'\t\t\t-e "/^GIT_TEXTDOMAINDIR=/d" \\\n'> <'\t\t\t-e "/^GIT_/s/=.*//p" |\n'> <'\t\tsort\n'> <'\tEOF\n'> <'\t./script >expected &&\n'> <'\tgit config alias.script \\!./script &&\n'> <'\t( mkdir sub && cd sub && git script >../actual ) &&\n'> <'\ttest_cmp expected actual\n'> ) } ) (C {<test_expect_success>} {(SQ <'plain with GIT_WORK_TREE'>)} { (SQ <'\n'> <'\tmkdir plain-wt &&\n'> <'\ttest_must_fail env GIT_WORK_TREE="$(pwd)/plain-wt" git init plain-wt\n'> ) } ) (C {<test_expect_success>} {(SQ <'plain bare'>)} { (SQ <'\n'> <'\tgit --bare init plain-bare-1 &&\n'> <'\tcheck_config plain-bare-1 true unset\n'>) } ) (C {<test_expect_success>} {(SQ <'plain bare with GIT_WORK_TREE'>)} { (SQ <'\n'> <'\tmkdir plain-bare-2 &&\n'> <'\ttest_must_fail \\\n'> <'\t\tenv GIT_WORK_TREE="$(pwd)/plain-bare-2" \\\n'> <'\t\tgit --bare init plain-bare-2\n'> ) } ) (C {<test_expect_success>} {(SQ <'GIT_DIR bare'>)} { (SQ <'\n'> <'\tmkdir git-dir-bare.git &&\n'> <'\tGIT_DIR=git-dir-bare.git git init &&\n'> <'\tcheck_config git-dir-bare.git true unset\n'> ) } ) (C {<test_expect_success>} {(SQ <'init --bare'>)} { (SQ <'\n'> <'\tgit init --bare init-bare.git &&\n'> <'\tcheck_config init-bare.git true unset\n'> ) } ) (C {<test_expect_success>} {(SQ <'GIT_DIR non-bare'>)} { (SQ <'\n'> <'\n'> <'\t(\n'> <'\t\tmkdir non-bare &&\n'> <'\t\tcd non-bare &&\n'> <'\t\tGIT_DIR=.git git init\n'> <'\t) &&\n'> <'\tcheck_config non-bare/.git false unset\n'> ) } ) (C {<test_expect_success>} {(SQ <'GIT_DIR & GIT_WORK_TREE (1)'>)} { (SQ <'\n'> <'\n'> <'\t(\n'> <'\t\tmkdir git-dir-wt-1.git &&\n'> <'\t\tGIT_WORK_TREE=$(pwd) GIT_DIR=git-dir-wt-1.git git init\n'> <'\t) &&\n'> <'\tcheck_config git-dir-wt-1.git false "$(pwd)"\n'> ) } ) (C {<test_expect_success>} {(SQ <'GIT_DIR & GIT_WORK_TREE (2)'>)} { (SQ <'\n'> <'\tmkdir git-dir-wt-2.git &&\n'> <'\ttest_must_fail env \\\n'> <'\t\tGIT_WORK_TREE="$(pwd)" \\\n'> <'\t\tGIT_DIR=git-dir-wt-2.git \\\n'> <'\t\tgit --bare init\n'> ) } ) (C {<test_expect_success>} {(SQ <reinit>)} { (SQ <'\n'> <'\n'> <'\t(\n'> <'\t\tmkdir again &&\n'> <'\t\tcd again &&\n'> <'\t\tgit init >out1 2>err1 &&\n'> <'\t\tgit init >out2 2>err2\n'> <'\t) &&\n'> <'\ttest_i18ngrep "Initialized empty" again/out1 &&\n'> <'\ttest_i18ngrep "Reinitialized existing" again/out2 &&\n'> <'\t>again/empty &&\n'> <'\ttest_i18ncmp again/empty again/err1 &&\n'> <'\ttest_i18ncmp again/empty again/err2\n'> ) } ) (C {<test_expect_success>} {(SQ <'init with --template'>)} { (SQ <'\n'> <'\tmkdir template-source &&\n'> <'\techo content >template-source/file &&\n'> <'\tgit init --template=../template-source template-custom &&\n'> <'\ttest_cmp template-source/file template-custom/.git/file\n'> ) } ) (C {<test_expect_success>} {(SQ <'init with --template (blank)'>)} { (SQ <'\n'> <'\tgit init template-plain &&\n'> <'\ttest_path_is_file template-plain/.git/info/exclude &&\n'> <'\tgit init --template= template-blank &&\n'> <'\ttest_path_is_missing template-blank/.git/info/exclude\n'> ) } ) (C {<test_expect_success>} {(SQ <'init with init.templatedir set'>)} { (SQ <'\n'> <'\tmkdir templatedir-source &&\n'> <'\techo Content >templatedir-source/file &&\n'> <'\ttest_config_global init.templatedir "${HOME}/templatedir-source" &&\n'> <'\t(\n'> <'\t\tmkdir templatedir-set &&\n'> <'\t\tcd templatedir-set &&\n'> <'\t\tsane_unset GIT_TEMPLATE_DIR &&\n'> <'\t\tNO_SET_GIT_TEMPLATE_DIR=t &&\n'> <'\t\texport NO_SET_GIT_TEMPLATE_DIR &&\n'> <'\t\tgit init\n'> <'\t) &&\n'> <'\ttest_cmp templatedir-source/file templatedir-set/.git/file\n'> ) } ) (C {<test_expect_success>} {(SQ <'init --bare/--shared overrides system/global config'>)} { (SQ <'\n'> <'\ttest_config_global core.bare false &&\n'> <'\ttest_config_global core.sharedRepository 0640 &&\n'> <'\tgit init --bare --shared=0666 init-bare-shared-override &&\n'> <'\tcheck_config init-bare-shared-override true unset &&\n'> <'\ttest x0666 = \\\n'> <'\tx$(git config -f init-bare-shared-override/config core.sharedRepository)\n'> ) } ) (C {<test_expect_success>} {(SQ <'init honors global core.sharedRepository'>)} { (SQ <'\n'> <'\ttest_config_global core.sharedRepository 0666 &&\n'> <'\tgit init shared-honor-global &&\n'> <'\ttest x0666 = \\\n'> <'\tx$(git config -f shared-honor-global/.git/config core.sharedRepository)\n'> ) } ) (C {<test_expect_success>} {(SQ <'init allows insanely long --template'>)} {(SQ <'\n'> <'\tgit init --template=$(printf "x%09999dx" 1) test\n'>)} ) (C {<test_expect_success>} {(SQ <'init creates a new directory'>)} { (SQ <'\n'> <'\trm -fr newdir &&\n'> <'\tgit init newdir &&\n'> <'\ttest_path_is_dir newdir/.git/refs\n'> ) } ) (C {<test_expect_success>} {(SQ <'init creates a new bare directory'>)} { (SQ <'\n'> <'\trm -fr newdir &&\n'> <'\tgit init --bare newdir &&\n'> <'\ttest_path_is_dir newdir/refs\n'> ) } ) (C {<test_expect_success>} {(SQ <'init recreates a directory'>)} { (SQ <'\n'> <'\trm -fr newdir &&\n'> <'\tmkdir newdir &&\n'> <'\tgit init newdir &&\n'> <'\ttest_path_is_dir newdir/.git/refs\n'> ) } ) (C {<test_expect_success>} {(SQ <'init recreates a new bare directory'>)} { (SQ <'\n'> <'\trm -fr newdir &&\n'> <'\tmkdir newdir &&\n'> <'\tgit init --bare newdir &&\n'> <'\ttest_path_is_dir newdir/refs\n'> ) } ) (C {<test_expect_success>} {(SQ <'init creates a new deep directory'>)} { (SQ <'\n'> <'\trm -fr newdir &&\n'> <'\tgit init newdir/a/b/c &&\n'> <'\ttest_path_is_dir newdir/a/b/c/.git/refs\n'> ) } ) (C {<test_expect_success>} {<POSIXPERM>} {(SQ <'init creates a new deep directory (umask vs. shared)'>)} { (SQ <'\n'> <'\trm -fr newdir &&\n'> <'\t(\n'> <'\t\t# Leading directories should honor umask while\n'> <'\t\t# the repository itself should follow "shared"\n'> <'\t\tumask 002 &&\n'> <'\t\tgit init --bare --shared=0660 newdir/a/b/c &&\n'> <'\t\ttest_path_is_dir newdir/a/b/c/refs &&\n'> <'\t\tls -ld newdir/a newdir/a/b > lsab.out &&\n'> <'\t\t! grep -v "^drwxrw[sx]r-x" lsab.out &&\n'> <'\t\tls -ld newdir/a/b/c > lsc.out &&\n'> <'\t\t! grep -v "^drwxrw[sx]---" lsc.out\n'> <'\t)\n'> ) } ) (C {<test_expect_success>} {(SQ <'init notices EEXIST (1)'>)} { (SQ <'\n'> <'\trm -fr newdir &&\n'> <'\t>newdir &&\n'> <'\ttest_must_fail git init newdir &&\n'> <'\ttest_path_is_file newdir\n'> ) } ) (C {<test_expect_success>} {(SQ <'init notices EEXIST (2)'>)} { (SQ <'\n'> <'\trm -fr newdir &&\n'> <'\tmkdir newdir &&\n'> <'\t>newdir/a &&\n'> <'\ttest_must_fail git init newdir/a/b &&\n'> <'\ttest_path_is_file newdir/a\n'> ) } ) (C {<test_expect_success>} {<POSIXPERM> <Id.Lit_Comma ','> <SANITY>} {(SQ <'init notices EPERM'>)} { (SQ <'\n'> <'\trm -fr newdir &&\n'> <'\tmkdir newdir &&\n'> <'\tchmod -w newdir &&\n'> <'\ttest_must_fail git init newdir/a/b\n'> ) } ) (C {<test_expect_success>} {(SQ <'init creates a new bare directory with global --bare'>)} { (SQ <'\n'> <'\trm -rf newdir &&\n'> <'\tgit --bare init newdir &&\n'> <'\ttest_path_is_dir newdir/refs\n'> ) } ) (C {<test_expect_success>} {(SQ <'init prefers command line to GIT_DIR'>)} { (SQ <'\n'> <'\trm -rf newdir &&\n'> <'\tmkdir otherdir &&\n'> <'\tGIT_DIR=otherdir git --bare init newdir &&\n'> <'\ttest_path_is_dir newdir/refs &&\n'> <'\ttest_path_is_missing otherdir/refs\n'> ) } ) (C {<test_expect_success>} {(SQ <'init with separate gitdir'>)} { (SQ <'\n'> <'\trm -rf newdir &&\n'> <'\tgit init --separate-git-dir realgitdir newdir &&\n'> <'\techo "gitdir: $(pwd)/realgitdir" >expected &&\n'> <'\ttest_cmp expected newdir/.git &&\n'> <'\ttest_path_is_dir realgitdir/refs\n'> ) } ) (C {<test_expect_success>} {(SQ <'re-init on .git file'>)} {(SQ <'\n'> <'\t( cd newdir && git init )\n'>)} ) (C {<test_expect_success>} {(SQ <'re-init to update git link'>)} { (SQ <'\n'> <'\t(\n'> <'\tcd newdir &&\n'> <'\tgit init --separate-git-dir ../surrealgitdir\n'> <'\t) &&\n'> <'\techo "gitdir: $(pwd)/surrealgitdir" >expected &&\n'> <'\ttest_cmp expected newdir/.git &&\n'> <'\ttest_path_is_dir surrealgitdir/refs &&\n'> <'\ttest_path_is_missing realgitdir/refs\n'> ) } ) (C {<test_expect_success>} {(SQ <'re-init to move gitdir'>)} { (SQ <'\n'> <'\trm -rf newdir realgitdir surrealgitdir &&\n'> <'\tgit init newdir &&\n'> <'\t(\n'> <'\tcd newdir &&\n'> <'\tgit init --separate-git-dir ../realgitdir\n'> <'\t) &&\n'> <'\techo "gitdir: $(pwd)/realgitdir" >expected &&\n'> <'\ttest_cmp expected newdir/.git &&\n'> <'\ttest_path_is_dir realgitdir/refs\n'> ) } ) (C {<test_expect_success>} {<SYMLINKS>} {(SQ <'re-init to move gitdir symlink'>)} { (SQ <'\n'> <'\trm -rf newdir realgitdir &&\n'> <'\tgit init newdir &&\n'> <'\t(\n'> <'\tcd newdir &&\n'> <'\tmv .git here &&\n'> <'\tln -s here .git &&\n'> <'\tgit init --separate-git-dir ../realgitdir\n'> <'\t) &&\n'> <'\techo "gitdir: $(pwd)/realgitdir" >expected &&\n'> <'\ttest_cmp expected newdir/.git &&\n'> <'\ttest_cmp expected newdir/here &&\n'> <'\ttest_path_is_dir realgitdir/refs\n'> ) } ) (command.ShFunction name: is_hidden body: (BraceGroup children: [ (command.Case to_match: { (DQ (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {<attrib>} {(DQ ($ Id.VSub_Number '$1'))}) ) ) } arms: [ (case_arm pat_list: [ {<Id.Lit_Star '*'> <H> <Id.Lit_Star '*'> <Id.Lit_QMark '?'> <Id.Lit_Colon ':'> <Id.Lit_Star '*'> } ] action: [(command.ControlFlow token:<Id.ControlFlow_Return return> arg_word:{<0>})] spids: [890 896 901 -1] ) ] ) (command.ControlFlow token:<Id.ControlFlow_Return return> arg_word:{<1>}) ] ) ) (C {<test_expect_success>} {<MINGW>} {(SQ <'.git hidden'>)} { (SQ <'\n'> <'\trm -rf newdir &&\n'> <'\t(\n'> <'\t\tunset GIT_DIR GIT_WORK_TREE\n'> <'\t\tmkdir newdir &&\n'> <'\t\tcd newdir &&\n'> <'\t\tgit init &&\n'> <'\t\tis_hidden .git\n'> <'\t) &&\n'> <'\tcheck_config newdir/.git false unset\n'> ) } ) (C {<test_expect_success>} {<MINGW>} {(SQ <'bare git dir not hidden'>)} { (SQ <'\n'> <'\trm -rf newdir &&\n'> <'\t(\n'> <'\t\tunset GIT_DIR GIT_WORK_TREE GIT_CONFIG\n'> <'\t\tmkdir newdir &&\n'> <'\t\tcd newdir &&\n'> <'\t\tgit --bare init\n'> <'\t) &&\n'> <'\t! is_hidden newdir\n'> ) } ) (C {<test_expect_success>} {(SQ <'remote init from does not use config from cwd'>)} { (SQ <'\n'> <'\trm -rf newdir &&\n'> <'\ttest_config core.logallrefupdates true &&\n'> <'\tgit init newdir &&\n'> <'\techo true >expect &&\n'> <'\tgit -C newdir config --bool core.logallrefupdates >actual &&\n'> <'\ttest_cmp expect actual\n'> ) } ) (C {<test_expect_success>} {(SQ <'re-init from a linked worktree'>)} { (SQ <'\n'> <'\tgit init main-worktree &&\n'> <'\t(\n'> <'\t\tcd main-worktree &&\n'> <'\t\ttest_commit first &&\n'> <'\t\tgit worktree add ../linked-worktree &&\n'> <'\t\tmv .git/info/exclude expected-exclude &&\n'> <'\t\tcp .git/config expected-config &&\n'> <'\t\tfind .git/worktrees -print | sort >expected &&\n'> <'\t\tgit -C ../linked-worktree init &&\n'> <'\t\ttest_cmp expected-exclude .git/info/exclude &&\n'> <'\t\ttest_cmp expected-config .git/config &&\n'> <'\t\tfind .git/worktrees -print | sort >actual &&\n'> <'\t\ttest_cmp expected actual\n'> <'\t)\n'> ) } ) (C {<test_done>}) ] )