(command.CommandList children: [ (command.FuncDef name: check body: (command.BraceGroup children: [ (command.Assignment keyword: Assign_None pairs: [(assign_pair lhs:(lhs_expr.LhsName name:credential_opts) op:Equal rhs:(word.EmptyWord))] ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:credential_cmd) op: Equal rhs: {($ VSub_Number '$1')} ) ] ) (C {(shift)}) (command.ForEach iter_name: arg iter_words: [{(DQ ($ VSub_At '$@'))}] do_arg_iter: F body: (command.DoGroup children: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:credential_opts) op: Equal rhs: { (DQ ($ VSub_DollarName '$credential_opts') (" -c credential.helper='") ($ VSub_DollarName '$arg') ("'") ) } ) ] ) ] ) ) (command.AndOr ops: [Op_DAmp Op_DAmp Op_DAmp Op_DAmp Op_DAmp] children: [ (command.SimpleCommand words: [{(read_chunk)}] redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(stdin)})] ) (command.SimpleCommand words: [{(read_chunk)}] redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expect-stdout)})] ) (command.SimpleCommand words: [{(read_chunk)}] redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expect-stderr)})] ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (command.Pipeline children: [ (C {(eval)} { (DQ ('git ') ($ VSub_DollarName '$credential_opts') (' credential ') ($ VSub_DollarName '$credential_cmd') (' <stdin >stdout 2>stderr') ) } ) ] negated: T ) terminator: <Op_Semi ';'> ) ] action: [ (command.AndOr ops: [Op_DAmp Op_DAmp] children: [ (C {(echo)} {(DQ ('git credential failed with code ') ($ VSub_QMark '$?'))}) (C {(cat)} {(stderr)}) (C {(false)}) ] ) ] ) ] ) (C {(test_cmp)} {(expect-stdout)} {(stdout)}) (C {(test_cmp)} {(expect-stderr)} {(stderr)}) ] ) ] ) ) (command.FuncDef name: read_chunk body: (command.BraceGroup children: [ (command.WhileUntil keyword: <KW_While while> cond: [(command.Sentence child:(C {(read)} {(line)}) terminator:<Op_Semi ';'>)] body: (command.DoGroup children: [ (command.Case to_match: {(DQ ($ VSub_DollarName '$line'))} arms: [ (case_arm pat_list: [{(--)}] action: [(command.ControlFlow token:<ControlFlow_Break break>)] ) (case_arm pat_list: [{(Lit_Other '*')}] action: [(C {(echo)} {(DQ ($ VSub_DollarName '$line'))})] ) ] ) ] ) ) ] ) ) (command.FuncDef name: helper_test_clean body: (command.BraceGroup children: [ (C {(reject)} {($ VSub_Number '$1')} {(https)} {(example.com)} {(store-user)}) (C {(reject)} {($ VSub_Number '$1')} {(https)} {(example.com)} {(user1)}) (C {(reject)} {($ VSub_Number '$1')} {(https)} {(example.com)} {(user2)}) (C {(reject)} {($ VSub_Number '$1')} {(http)} {(path.tld)} {(user)}) (C {(reject)} {($ VSub_Number '$1')} {(https)} {(timeout.tld)} {(user)}) ] ) ) (command.FuncDef name: reject body: (command.BraceGroup children: [ (command.Pipeline children: [ (command.Subshell command_list: (command.CommandList children: [ (C {(echo)} {(Lit_VarLike 'protocol=') ($ VSub_Number '$2')}) (C {(echo)} {(Lit_VarLike 'host=') ($ VSub_Number '$3')}) (C {(echo)} {(Lit_VarLike 'username=') ($ VSub_Number '$4')}) ] ) ) (C {(git)} {(-c)} {(credential.helper) (Lit_Other '=') ($ VSub_Number '$1')} {(credential)} {(reject)} ) ] negated: F ) ] ) ) (command.FuncDef name: helper_test body: (command.BraceGroup children: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:HELPER) op: Equal rhs: {($ VSub_Number '$1')} ) ] ) (C {(test_expect_success)} {(DQ ('helper (') ($ VSub_DollarName '$HELPER') (') has no existing data'))} { (SQ <'\n'> <'\t\tcheck fill $HELPER <<-\\EOF\n'> <'\t\tprotocol=https\n'> <'\t\thost=example.com\n'> <'\t\t--\n'> <'\t\tprotocol=https\n'> <'\t\thost=example.com\n'> <'\t\tusername=askpass-username\n'> <'\t\tpassword=askpass-password\n'> <'\t\t--\n'> <'\t\taskpass: Username for '> ) (word_part.EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <'https://example.com'>) (word_part.EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <':\n'> <'\t\taskpass: Password for '>) (word_part.EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <'https://askpass-username@example.com'>) (word_part.EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <':\n'> <'\t\tEOF\n'> <'\t'>) } ) (C {(test_expect_success)} {(DQ ('helper (') ($ VSub_DollarName '$HELPER') (') stores password'))} { (SQ <'\n'> <'\t\tcheck approve $HELPER <<-\\EOF\n'> <'\t\tprotocol=https\n'> <'\t\thost=example.com\n'> <'\t\tusername=store-user\n'> <'\t\tpassword=store-pass\n'> <'\t\tEOF\n'> <'\t'> ) } ) (C {(test_expect_success)} {(DQ ('helper (') ($ VSub_DollarName '$HELPER') (') can retrieve password'))} { (SQ <'\n'> <'\t\tcheck fill $HELPER <<-\\EOF\n'> <'\t\tprotocol=https\n'> <'\t\thost=example.com\n'> <'\t\t--\n'> <'\t\tprotocol=https\n'> <'\t\thost=example.com\n'> <'\t\tusername=store-user\n'> <'\t\tpassword=store-pass\n'> <'\t\t--\n'> <'\t\tEOF\n'> <'\t'> ) } ) (C {(test_expect_success)} {(DQ ('helper (') ($ VSub_DollarName '$HELPER') (') requires matching protocol'))} { (SQ <'\n'> <'\t\tcheck fill $HELPER <<-\\EOF\n'> <'\t\tprotocol=http\n'> <'\t\thost=example.com\n'> <'\t\t--\n'> <'\t\tprotocol=http\n'> <'\t\thost=example.com\n'> <'\t\tusername=askpass-username\n'> <'\t\tpassword=askpass-password\n'> <'\t\t--\n'> <'\t\taskpass: Username for '> ) (word_part.EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <'http://example.com'>) (word_part.EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <':\n'> <'\t\taskpass: Password for '>) (word_part.EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <'http://askpass-username@example.com'>) (word_part.EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <':\n'> <'\t\tEOF\n'> <'\t'>) } ) (C {(test_expect_success)} {(DQ ('helper (') ($ VSub_DollarName '$HELPER') (') requires matching host'))} { (SQ <'\n'> <'\t\tcheck fill $HELPER <<-\\EOF\n'> <'\t\tprotocol=https\n'> <'\t\thost=other.tld\n'> <'\t\t--\n'> <'\t\tprotocol=https\n'> <'\t\thost=other.tld\n'> <'\t\tusername=askpass-username\n'> <'\t\tpassword=askpass-password\n'> <'\t\t--\n'> <'\t\taskpass: Username for '> ) (word_part.EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <'https://other.tld'>) (word_part.EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <':\n'> <'\t\taskpass: Password for '>) (word_part.EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <'https://askpass-username@other.tld'>) (word_part.EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <':\n'> <'\t\tEOF\n'> <'\t'>) } ) (C {(test_expect_success)} {(DQ ('helper (') ($ VSub_DollarName '$HELPER') (') requires matching username'))} { (SQ <'\n'> <'\t\tcheck fill $HELPER <<-\\EOF\n'> <'\t\tprotocol=https\n'> <'\t\thost=example.com\n'> <'\t\tusername=other\n'> <'\t\t--\n'> <'\t\tprotocol=https\n'> <'\t\thost=example.com\n'> <'\t\tusername=other\n'> <'\t\tpassword=askpass-password\n'> <'\t\t--\n'> <'\t\taskpass: Password for '> ) (word_part.EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <'https://other@example.com'>) (word_part.EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <':\n'> <'\t\tEOF\n'> <'\t'>) } ) (C {(test_expect_success)} {(DQ ('helper (') ($ VSub_DollarName '$HELPER') (') requires matching path'))} { (SQ <'\n'> <'\t\ttest_config credential.usehttppath true &&\n'> <'\t\tcheck approve $HELPER <<-\\EOF &&\n'> <'\t\tprotocol=http\n'> <'\t\thost=path.tld\n'> <'\t\tpath=foo.git\n'> <'\t\tusername=user\n'> <'\t\tpassword=pass\n'> <'\t\tEOF\n'> <'\t\tcheck fill $HELPER <<-\\EOF\n'> <'\t\tprotocol=http\n'> <'\t\thost=path.tld\n'> <'\t\tpath=bar.git\n'> <'\t\t--\n'> <'\t\tprotocol=http\n'> <'\t\thost=path.tld\n'> <'\t\tpath=bar.git\n'> <'\t\tusername=askpass-username\n'> <'\t\tpassword=askpass-password\n'> <'\t\t--\n'> <'\t\taskpass: Username for '> ) (word_part.EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <'http://path.tld/bar.git'>) (word_part.EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <':\n'> <'\t\taskpass: Password for '>) (word_part.EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <'http://askpass-username@path.tld/bar.git'>) (word_part.EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <':\n'> <'\t\tEOF\n'> <'\t'>) } ) (C {(test_expect_success)} {(DQ ('helper (') ($ VSub_DollarName '$HELPER') (') can forget host'))} { (SQ <'\n'> <'\t\tcheck reject $HELPER <<-\\EOF &&\n'> <'\t\tprotocol=https\n'> <'\t\thost=example.com\n'> <'\t\tEOF\n'> <'\t\tcheck fill $HELPER <<-\\EOF\n'> <'\t\tprotocol=https\n'> <'\t\thost=example.com\n'> <'\t\t--\n'> <'\t\tprotocol=https\n'> <'\t\thost=example.com\n'> <'\t\tusername=askpass-username\n'> <'\t\tpassword=askpass-password\n'> <'\t\t--\n'> <'\t\taskpass: Username for '> ) (word_part.EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <'https://example.com'>) (word_part.EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <':\n'> <'\t\taskpass: Password for '>) (word_part.EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <'https://askpass-username@example.com'>) (word_part.EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <':\n'> <'\t\tEOF\n'> <'\t'>) } ) (C {(test_expect_success)} {(DQ ('helper (') ($ VSub_DollarName '$HELPER') (') can store multiple users'))} { (SQ <'\n'> <'\t\tcheck approve $HELPER <<-\\EOF &&\n'> <'\t\tprotocol=https\n'> <'\t\thost=example.com\n'> <'\t\tusername=user1\n'> <'\t\tpassword=pass1\n'> <'\t\tEOF\n'> <'\t\tcheck approve $HELPER <<-\\EOF &&\n'> <'\t\tprotocol=https\n'> <'\t\thost=example.com\n'> <'\t\tusername=user2\n'> <'\t\tpassword=pass2\n'> <'\t\tEOF\n'> <'\t\tcheck fill $HELPER <<-\\EOF &&\n'> <'\t\tprotocol=https\n'> <'\t\thost=example.com\n'> <'\t\tusername=user1\n'> <'\t\t--\n'> <'\t\tprotocol=https\n'> <'\t\thost=example.com\n'> <'\t\tusername=user1\n'> <'\t\tpassword=pass1\n'> <'\t\tEOF\n'> <'\t\tcheck fill $HELPER <<-\\EOF\n'> <'\t\tprotocol=https\n'> <'\t\thost=example.com\n'> <'\t\tusername=user2\n'> <'\t\t--\n'> <'\t\tprotocol=https\n'> <'\t\thost=example.com\n'> <'\t\tusername=user2\n'> <'\t\tpassword=pass2\n'> <'\t\tEOF\n'> <'\t'> ) } ) (C {(test_expect_success)} {(DQ ('helper (') ($ VSub_DollarName '$HELPER') (') can forget user'))} { (SQ <'\n'> <'\t\tcheck reject $HELPER <<-\\EOF &&\n'> <'\t\tprotocol=https\n'> <'\t\thost=example.com\n'> <'\t\tusername=user1\n'> <'\t\tEOF\n'> <'\t\tcheck fill $HELPER <<-\\EOF\n'> <'\t\tprotocol=https\n'> <'\t\thost=example.com\n'> <'\t\tusername=user1\n'> <'\t\t--\n'> <'\t\tprotocol=https\n'> <'\t\thost=example.com\n'> <'\t\tusername=user1\n'> <'\t\tpassword=askpass-password\n'> <'\t\t--\n'> <'\t\taskpass: Password for '> ) (word_part.EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <'https://user1@example.com'>) (word_part.EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <':\n'> <'\t\tEOF\n'> <'\t'>) } ) (C {(test_expect_success)} {(DQ ('helper (') ($ VSub_DollarName '$HELPER') (') remembers other user'))} { (SQ <'\n'> <'\t\tcheck fill $HELPER <<-\\EOF\n'> <'\t\tprotocol=https\n'> <'\t\thost=example.com\n'> <'\t\tusername=user2\n'> <'\t\t--\n'> <'\t\tprotocol=https\n'> <'\t\thost=example.com\n'> <'\t\tusername=user2\n'> <'\t\tpassword=pass2\n'> <'\t\tEOF\n'> <'\t'> ) } ) ] ) ) (command.FuncDef name: helper_test_timeout body: (command.BraceGroup children: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:HELPER) op: Equal rhs: {(DQ ($ VSub_Star '$*'))} ) ] ) (C {(test_expect_success)} {(DQ ('helper (') ($ VSub_DollarName '$HELPER') (') times out'))} { (SQ <'\n'> <'\t\tcheck approve "$HELPER" <<-\\EOF &&\n'> <'\t\tprotocol=https\n'> <'\t\thost=timeout.tld\n'> <'\t\tusername=user\n'> <'\t\tpassword=pass\n'> <'\t\tEOF\n'> <'\t\tsleep 2 &&\n'> <'\t\tcheck fill "$HELPER" <<-\\EOF\n'> <'\t\tprotocol=https\n'> <'\t\thost=timeout.tld\n'> <'\t\t--\n'> <'\t\tprotocol=https\n'> <'\t\thost=timeout.tld\n'> <'\t\tusername=askpass-username\n'> <'\t\tpassword=askpass-password\n'> <'\t\t--\n'> <'\t\taskpass: Username for '> ) (word_part.EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <'https://timeout.tld'>) (word_part.EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <':\n'> <'\t\taskpass: Password for '>) (word_part.EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <'https://askpass-username@timeout.tld'>) (word_part.EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <':\n'> <'\t\tEOF\n'> <'\t'>) } ) ] ) ) (command.SimpleCommand words: [{(write_script)} {(askpass)}] redirects: [ (redir.HereDoc op: <Redir_DLess '<<'> fd: 16777215 here_begin: {(word_part.EscapedLiteralPart token:<Lit_EscapedChar '\\E'>) (OF)} here_end_span_id: 838 stdin_parts: [ ('echo >&2 askpass: $*\n') ('what=$(echo $1 | cut -d" " -f1 | tr A-Z a-z | tr -cd a-z)\n') ('echo "askpass-$what"\n') ] ) ] ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:GIT_ASKPASS) op: Equal rhs: {(DQ ($ VSub_DollarName '$PWD') (/askpass))} ) ] ) (C {(export)} {(GIT_ASKPASS)}) ] )