(CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"git init">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (FuncDef name: check_config body: (BraceGroup children: [ (If arms: [ (if_arm cond: [ (AndOr children: [ (C {(test)} {(-d)} {(DQ ($ VSub_Number "$1"))}) (AndOr children: [ (C {(test)} {(-f)} {(DQ ($ VSub_Number "$1") (/config))}) (C {(test)} {(-d)} {(DQ ($ VSub_Number "$1") (/refs))}) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] action: [(C {(Lit_Other ":")} {(happy)})] spids: [-1 56] ) ] else_action: [ (C {(echo)} { (DQ ("expected a directory ") ($ VSub_Number "$1") (", a file ") ($ VSub_Number "$1") ("/config and ") ($ VSub_Number "$1") (/refs) ) } ) (ControlFlow token:<ControlFlow_Return return> arg_word:{(1)}) ] spids: [64 85] ) (If arms: [ (if_arm cond: [ (AndOr children: [ (C {(test_have_prereq)} {(POSIXPERM)}) (C {(test)} {(-x)} {(DQ ($ VSub_Number "$1") (/config))}) ] op_id: Op_DAmp ) ] action: [ (C {(echo)} {(DQ ($ VSub_Number "$1") ("/config is executable?"))}) (ControlFlow token:<ControlFlow_Return return> arg_word:{(1)}) ] spids: [-1 107] ) ] spids: [-1 123] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:bare) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (AndOr children: [ (C {(cd)} {(DQ ($ VSub_Number "$1"))}) (C {(git)} {(config)} {(--bool)} {(core.bare)}) ] op_id: Op_DAmp ) ] ) left_token: <Left_CommandSub "$("> spids: [128 144] ) } spids: [127] ) ] spids: [127] ) (AndOr children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:worktree) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (AndOr children: [ (C {(cd)} {(DQ ($ VSub_Number "$1"))}) (C {(git)} {(config)} {(core.worktree)}) ] op_id: Op_DAmp ) ] ) left_token: <Left_CommandSub "$("> spids: [148 162] ) } spids: [147] ) ] spids: [147] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:worktree) op: Equal rhs: {(unset)} spids: [167] ) ] spids: [167] ) ] op_id: Op_DPipe ) (AndOr children: [ (C {(test)} {(DQ ($ VSub_Name "$bare"))} {(Lit_Other "=")} {(DQ ($ VSub_Number "$2"))}) (AndOr children: [ (C {(test)} {(DQ ($ VSub_Name "$worktree"))} {(Lit_Other "=")} {(DQ ($ VSub_Number "$3"))} ) (BraceGroup children: [ (C {(echo)} { (DQ ("expected bare=") ($ VSub_Number "$2") (" worktree=") ($ VSub_Number "$3") ) } ) (C {(echo)} { (DQ (" got bare=") ($ VSub_Name "$bare") (" worktree=") ($ VSub_Name "$worktree") ) } ) (ControlFlow token: <ControlFlow_Return return> arg_word: {(1)} ) ] spids: [200] ) ] op_id: Op_DPipe ) ] op_id: Op_DAmp ) ] spids: [20] ) spids: [15 19] ) (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) (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"> ) } ) (FuncDef name: is_hidden body: (BraceGroup children: [ (Case to_match: { (DQ (CommandSubPart command_list: (CommandList children: [(C {(attrib)} {(DQ ($ VSub_Number "$1"))})] ) left_token: <Left_CommandSub "$("> spids: [879 885] ) ) } arms: [ (case_arm pat_list: [ {(Lit_Other "*") (H) (Lit_Other "*") (Lit_Other "?") (Lit_Other ":") (Lit_Other "*")} ] action: [(ControlFlow token:<ControlFlow_Return return> arg_word:{(0)})] spids: [890 896 901 -1] ) ] spids: [876 888 903] ) (ControlFlow token:<ControlFlow_Return return> arg_word:{(1)}) ] spids: [869] ) spids: [864 868] ) (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)}) ] )