#!/bin/sh global test_description := ''tests for git clone -c key=value'' source ./test-lib.sh test_expect_success 'clone -c sets config in cloned repo' ' rm -rf child && git clone -c core.foo=bar . child && echo bar >expect && git --git-dir=child/.git config core.foo >actual && test_cmp expect actual ' test_expect_success 'clone -c can set multi-keys' ' rm -rf child && git clone -c core.foo=bar -c core.foo=baz . child && { echo bar; echo baz; } >expect && git --git-dir=child/.git config --get-all core.foo >actual && test_cmp expect actual ' test_expect_success 'clone -c without a value is boolean true' ' rm -rf child && git clone -c core.foo . child && echo true >expect && git --git-dir=child/.git config --bool core.foo >actual && test_cmp expect actual ' test_expect_success 'clone -c config is available during clone' ' echo content >file && git add file && git commit -m one && rm -rf child && git clone -c core.autocrlf . child && printf "content\\r\\n" >expect && test_cmp expect child/file ' # Tests for the hidden file attribute on windows proc is_hidden { # Use the output of `attrib`, ignore the absolute path matchstr $[attrib $1] { *H*?:* { return 0} } return 1 } test_expect_success MINGW 'clone -c core.hideDotFiles' ' test_commit attributes .gitattributes "" && rm -rf child && git clone -c core.hideDotFiles=false . child && ! is_hidden child/.gitattributes && rm -rf child && git clone -c core.hideDotFiles=dotGitOnly . child && ! is_hidden child/.gitattributes && rm -rf child && git clone -c core.hideDotFiles=true . child && is_hidden child/.gitattributes ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"tests for git clone -c key=value">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(SQ <"clone -c sets config in cloned repo">)} { (SQ <"\n"> <"\trm -rf child &&\n"> <"\tgit clone -c core.foo=bar . child &&\n"> <"\techo bar >expect &&\n"> <"\tgit --git-dir=child/.git config core.foo >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"clone -c can set multi-keys">)} { (SQ <"\n"> <"\trm -rf child &&\n"> <"\tgit clone -c core.foo=bar -c core.foo=baz . child &&\n"> <"\t{ echo bar; echo baz; } >expect &&\n"> <"\tgit --git-dir=child/.git config --get-all core.foo >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"clone -c without a value is boolean true">)} { (SQ <"\n"> <"\trm -rf child &&\n"> <"\tgit clone -c core.foo . child &&\n"> <"\techo true >expect &&\n"> <"\tgit --git-dir=child/.git config --bool core.foo >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"clone -c config is available during clone">)} { (SQ <"\n"> <"\techo content >file &&\n"> <"\tgit add file &&\n"> <"\tgit commit -m one &&\n"> <"\trm -rf child &&\n"> <"\tgit clone -c core.autocrlf . child &&\n"> <"\tprintf \"content\\\\r\\\\n\" >expect &&\n"> <"\ttest_cmp expect child/file\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: spids: [98 104] ) ) } arms: [ (case_arm pat_list: [ {(Lit_Other "*") (H) (Lit_Other "*") (Lit_Other "?") (Lit_Other ":") (Lit_Other "*")} ] action: [(ControlFlow token: arg_word:{(0)})] spids: [109 115 120 -1] ) ] spids: [95 107 122] ) (ControlFlow token: arg_word:{(1)}) ] spids: [88] ) spids: [83 87] ) (C {(test_expect_success)} {(MINGW)} {(SQ <"clone -c core.hideDotFiles">)} { (SQ <"\n"> <"\ttest_commit attributes .gitattributes \"\" &&\n"> <"\trm -rf child &&\n"> <"\tgit clone -c core.hideDotFiles=false . child &&\n"> <"\t! is_hidden child/.gitattributes &&\n"> <"\trm -rf child &&\n"> <"\tgit clone -c core.hideDotFiles=dotGitOnly . child &&\n"> <"\t! is_hidden child/.gitattributes &&\n"> <"\trm -rf child &&\n"> <"\tgit clone -c core.hideDotFiles=true . child &&\n"> <"\tis_hidden child/.gitattributes\n"> ) } ) (C {(test_done)}) ] )