(CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"Test git config-set API in different settings">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (FuncDef name: check_config body: (BraceGroup children: [ (AndOr children: [ (If arms: [ (if_arm cond: [(C {(test)} {(DQ ($ VSub_Number "$1"))} {(Lit_Other "=")} {(expect_code)})] action: [ (AndOr children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:expect_code) op: Equal rhs: {(DQ ($ VSub_Number "$2"))} spids: [45] ) ] spids: [45] ) (AndOr children: [(C {(shift)}) (C {(shift)})] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] spids: [-1 42] ) ] else_action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:expect_code) op: Equal rhs: {(0)} spids: [62] ) ] spids: [62] ) ] spids: [59 66] ) (AndOr children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:op) op: Equal rhs: {($ VSub_Number "$1")} spids: [71] ) (assign_pair lhs: (LhsName name:key) op: Equal rhs: {($ VSub_Number "$2")} spids: [74] ) ] spids: [71] ) (AndOr children: [ (C {(shift)}) (AndOr children: [ (C {(shift)}) (AndOr children: [ (If arms: [ (if_arm cond: [ (C {(test)} {($ VSub_Pound "$#")} {(KW_Bang "!") (Lit_Other "=")} {(0)} ) ] action: [ (C {(printf)} { (DQ ("%s") (EscapedLiteralPart token: <Lit_EscapedChar "\\n"> ) ) } {(DQ ($ VSub_At "$@"))} ) ] spids: [-1 100] ) ] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(expect)} spids: [117] ) ] spids: [-1 115] ) (AndOr children: [ (SimpleCommand words: [ {(test_expect_code)} {($ VSub_Name "$expect_code")} {(test-config)} {(DQ ($ VSub_Name "$op"))} {(DQ ($ VSub_Name "$key"))} ] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(actual)} spids: [137] ) ] ) (C {(test_cmp)} {(expect)} {(actual)}) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] spids: [26] ) spids: [21 25] ) (C {(test_expect_success)} {(SQ <"setup default config">)} { (SQ <"\n"> <"\tcat >.git/config <<-\\EOF\n"> <"\t[case]\n"> <"\t\tpenguin = very blue\n"> <"\t\tMovie = BadPhysics\n"> <"\t\tUPPERCASE = true\n"> <"\t\tMixedCase = true\n"> <"\t\tmy =\n"> <"\t\tfoo\n"> <"\t\tbaz = sam\n"> <"\t[Cores]\n"> <"\t\tWhatEver = Second\n"> <"\t\tbaz = bar\n"> <"\t[cores]\n"> <"\t\tbaz = bat\n"> <"\t[CORES]\n"> <"\t\tbaz = ball\n"> <"\t[my \"Foo bAr\"]\n"> <"\t\thi = mixed-case\n"> <"\t[my \"FOO BAR\"]\n"> <"\t\thi = upper-case\n"> <"\t[my \"foo bar\"]\n"> <"\t\thi = lower-case\n"> <"\t[case]\n"> <"\t\tbaz = bat\n"> <"\t\tbaz = hask\n"> <"\t[lamb]\n"> <"\t\tchop = 65\n"> <"\t\thead = none\n"> <"\t[goat]\n"> <"\t\tlegs = 4\n"> <"\t\thead = true\n"> <"\t\tskin = false\n"> <"\t\tnose = 1\n"> <"\t\thorns\n"> <"\tEOF\n"> ) } ) (C {(test_expect_success)} {(SQ <"get value for a simple key">)} {(SQ <"\n"> <"\tcheck_config get_value case.penguin \"very blue\"\n">)} ) (C {(test_expect_success)} {(SQ <"get value for a key with value as an empty string">)} {(SQ <"\n"> <"\tcheck_config get_value case.my \"\"\n">)} ) (C {(test_expect_success)} {(SQ <"get value for a key with value as NULL">)} {(SQ <"\n"> <"\tcheck_config get_value case.foo \"(NULL)\"\n">)} ) (C {(test_expect_success)} {(SQ <"upper case key">)} { (SQ <"\n"> <"\tcheck_config get_value case.UPPERCASE \"true\" &&\n"> <"\tcheck_config get_value case.uppercase \"true\"\n"> ) } ) (C {(test_expect_success)} {(SQ <"mixed case key">)} { (SQ <"\n"> <"\tcheck_config get_value case.MixedCase \"true\" &&\n"> <"\tcheck_config get_value case.MIXEDCASE \"true\" &&\n"> <"\tcheck_config get_value case.mixedcase \"true\"\n"> ) } ) (C {(test_expect_success)} {(SQ <"key and value with mixed case">)} {(SQ <"\n"> <"\tcheck_config get_value case.Movie \"BadPhysics\"\n">)} ) (C {(test_expect_success)} {(SQ <"key with case sensitive subsection">)} { (SQ <"\n"> <"\tcheck_config get_value \"my.Foo bAr.hi\" \"mixed-case\" &&\n"> <"\tcheck_config get_value \"my.FOO BAR.hi\" \"upper-case\" &&\n"> <"\tcheck_config get_value \"my.foo bar.hi\" \"lower-case\"\n"> ) } ) (C {(test_expect_success)} {(SQ <"key with case insensitive section header">)} { (SQ <"\n"> <"\tcheck_config get_value cores.baz \"ball\" &&\n"> <"\tcheck_config get_value Cores.baz \"ball\" &&\n"> <"\tcheck_config get_value CORES.baz \"ball\" &&\n"> <"\tcheck_config get_value coreS.baz \"ball\"\n"> ) } ) (C {(test_expect_success)} {(SQ <"key with case insensitive section header & variable">)} { (SQ <"\n"> <"\tcheck_config get_value CORES.BAZ \"ball\" &&\n"> <"\tcheck_config get_value cores.baz \"ball\" &&\n"> <"\tcheck_config get_value cores.BaZ \"ball\" &&\n"> <"\tcheck_config get_value cOreS.bAz \"ball\"\n"> ) } ) (C {(test_expect_success)} {(SQ <"find value with misspelled key">)} { (SQ <"\n"> < "\tcheck_config expect_code 1 get_value \"my.fOo Bar.hi\" \"Value not found for \\\"my.fOo Bar.hi\\\"\"\n" > ) } ) (C {(test_expect_success)} {(SQ <"find value with the highest priority">)} {(SQ <"\n"> <"\tcheck_config get_value case.baz \"hask\"\n">)} ) (C {(test_expect_success)} {(SQ <"find integer value for a key">)} {(SQ <"\n"> <"\tcheck_config get_int lamb.chop 65\n">)} ) (C {(test_expect_success)} {(SQ <"find string value for a key">)} { (SQ <"\n"> <"\tcheck_config get_string case.baz hask &&\n"> < "\tcheck_config expect_code 1 get_string case.ba \"Value not found for \\\"case.ba\\\"\"\n" > ) } ) (C {(test_expect_success)} {(SQ <"check line error when NULL string is queried">)} { (SQ <"\n"> <"\ttest_expect_code 128 test-config get_string case.foo 2>result &&\n"> <"\ttest_i18ngrep \"fatal: .*case\\.foo.*\\.git/config.*line 7\" result\n"> ) } ) (C {(test_expect_success)} {(SQ <"find integer if value is non parse-able">)} {(SQ <"\n"> <"\tcheck_config expect_code 128 get_int lamb.head\n">)} ) (C {(test_expect_success)} {(SQ <"find bool value for the entered key">)} { (SQ <"\n"> <"\tcheck_config get_bool goat.head 1 &&\n"> <"\tcheck_config get_bool goat.skin 0 &&\n"> <"\tcheck_config get_bool goat.nose 1 &&\n"> <"\tcheck_config get_bool goat.horns 1 &&\n"> <"\tcheck_config get_bool goat.legs 1\n"> ) } ) (C {(test_expect_success)} {(SQ <"find multiple values">)} {(SQ <"\n"> <"\tcheck_config get_value_multi case.baz sam bat hask\n">)} ) (C {(test_expect_success)} {(SQ <"find value from a configset">)} { (SQ <"\n"> <"\tcat >config2 <<-\\EOF &&\n"> <"\t[case]\n"> <"\t\tbaz = lama\n"> <"\t[my]\n"> <"\t\tnew = silk\n"> <"\t[case]\n"> <"\t\tbaz = ball\n"> <"\tEOF\n"> <"\techo silk >expect &&\n"> <"\ttest-config configset_get_value my.new config2 .git/config >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"find value with highest priority from a configset">)} { (SQ <"\n"> <"\techo hask >expect &&\n"> <"\ttest-config configset_get_value case.baz config2 .git/config >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"find value_list for a key from a configset">)} { (SQ <"\n"> <"\tcat >except <<-\\EOF &&\n"> <"\tsam\n"> <"\tbat\n"> <"\thask\n"> <"\tlama\n"> <"\tball\n"> <"\tEOF\n"> <"\ttest-config configset_get_value case.baz config2 .git/config >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"proper error on non-existent files">)} { (SQ <"\n"> <"\techo \"Error (-1) reading configuration file non-existent-file.\" >expect &&\n"> <"\ttest_expect_code 2 test-config configset_get_value foo.bar non-existent-file 2>actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(POSIXPERM) (Lit_Comma ",") (SANITY)} {(SQ <"proper error on non-accessible files">)} { (SQ <"\n"> <"\tchmod -r .git/config &&\n"> <"\ttest_when_finished \"chmod +r .git/config\" &&\n"> <"\techo \"Error (-1) reading configuration file .git/config.\" >expect &&\n"> < "\ttest_expect_code 2 test-config configset_get_value foo.bar .git/config 2>actual &&\n" > <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"proper error on error in default config files">)} { (SQ <"\n"> <"\tcp .git/config .git/config.old &&\n"> <"\ttest_when_finished \"mv .git/config.old .git/config\" &&\n"> <"\techo \"[\" >>.git/config &&\n"> <"\techo \"fatal: bad config line 34 in file .git/config\" >expect &&\n"> <"\ttest_expect_code 128 test-config get_value foo.bar 2>actual &&\n"> <"\ttest_i18ncmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"proper error on error in custom config files">)} { (SQ <"\n"> <"\techo \"[\" >>syntax-error &&\n"> <"\techo \"fatal: bad config line 1 in file syntax-error\" >expect &&\n"> <"\ttest_expect_code 128 test-config configset_get_value foo.bar syntax-error 2>actual &&\n"> <"\ttest_i18ncmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"check line errors for malformed values">)} { (SQ <"\n"> <"\tmv .git/config .git/config.old &&\n"> <"\ttest_when_finished \"mv .git/config.old .git/config\" &&\n"> <"\tcat >.git/config <<-\\EOF &&\n"> <"\t[alias]\n"> <"\t\tbr\n"> <"\tEOF\n"> <"\ttest_expect_code 128 git br 2>result &&\n"> <"\ttest_i18ngrep \"fatal: .*alias\\.br.*\\.git/config.*line 2\" result\n"> ) } ) (C {(test_expect_success)} {(SQ <"error on modifying repo config without repo">)} { (SQ <"\n"> <"\tmkdir no-repo &&\n"> <"\t(\n"> <"\t\tGIT_CEILING_DIRECTORIES=$(pwd) &&\n"> <"\t\texport GIT_CEILING_DIRECTORIES &&\n"> <"\t\tcd no-repo &&\n"> <"\t\ttest_must_fail git config a.b c 2>err &&\n"> <"\t\tgrep \"not in a git directory\" err\n"> <"\t)\n"> ) } ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:cmdline_config) op: Equal rhs: {(DQ ("'foo.bar=from-cmdline'"))} spids: [579] ) ] spids: [579] ) (C {(test_expect_success)} {(SQ <"iteration shows correct origins">)} { (SQ <"\n"> <"\techo \"[foo]bar = from-repo\" >.git/config &&\n"> <"\techo \"[foo]bar = from-home\" >.gitconfig &&\n"> <"\tif test_have_prereq MINGW\n"> <"\tthen\n"> <"\t\t# Use Windows path (i.e. *not* $HOME)\n"> <"\t\tHOME_GITCONFIG=$(pwd)/.gitconfig\n"> <"\telse\n"> <"\t\t# Do not get fooled by symbolic links, i.e. $HOME != $(pwd)\n"> <"\t\tHOME_GITCONFIG=$HOME/.gitconfig\n"> <"\tfi &&\n"> <"\tcat >expect <<-EOF &&\n"> <"\tkey=foo.bar\n"> <"\tvalue=from-home\n"> <"\torigin=file\n"> <"\tname=$HOME_GITCONFIG\n"> <"\tscope=global\n"> <"\n"> <"\tkey=foo.bar\n"> <"\tvalue=from-repo\n"> <"\torigin=file\n"> <"\tname=.git/config\n"> <"\tscope=repo\n"> <"\n"> <"\tkey=foo.bar\n"> <"\tvalue=from-cmdline\n"> <"\torigin=command line\n"> <"\tname=\n"> <"\tscope=cmdline\n"> <"\tEOF\n"> <"\tGIT_CONFIG_PARAMETERS=$cmdline_config test-config iterate >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_done)}) ] )