(command.CommandList children: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:test_description spids:[12]) op: Equal rhs: {(SQ <'check pre-push hooks'>)} spids: [12] ) ] spids: [12] ) (C {(.)} {(./test-lib.sh)}) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:HOOKDIR spids:[25]) op: Equal rhs: { (DQ (word_part.CommandSubPart command_list: (command.CommandList children: [(C {(git)} {(rev-parse)} {(--git-dir)})] ) left_token: <Left_CommandSub '$('> spids: [27 33] ) (/hooks) ) } spids: [25] ) ] spids: [25] ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:HOOK spids:[37]) op: Equal rhs: {(DQ ($ VSub_Name '$HOOKDIR') (/pre-push))} spids: [37] ) ] spids: [37] ) (C {(mkdir)} {(-p)} {(DQ ($ VSub_Name '$HOOKDIR'))}) (command.SimpleCommand words: [{(write_script)} {(DQ ($ VSub_Name '$HOOK'))}] redirects: [ (redir.HereDoc op: <Redir_DLess '<<'> fd: 16777215 here_begin: {(EOF)} here_end_span_id: 63 stdin_parts: [('cat >/dev/null\n') ('exit 0\n')] ) ] ) (C {(test_expect_success)} {(SQ <setup>)} { (SQ <'\n'> <'\tgit config push.default upstream &&\n'> <'\tgit init --bare repo1 &&\n'> <'\tgit remote add parent1 repo1 &&\n'> <'\ttest_commit one &&\n'> <'\tgit push parent1 HEAD:foreign\n'> ) } ) (command.SimpleCommand words: [{(write_script)} {(DQ ($ VSub_Name '$HOOK'))}] redirects: [ (redir.HereDoc op: <Redir_DLess '<<'> fd: 16777215 here_begin: {(EOF)} here_end_span_id: 92 stdin_parts: [('cat >/dev/null\n') ('exit 1\n')] ) ] ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:COMMIT1 spids:[94]) op: Equal rhs: { (DQ (word_part.CommandSubPart command_list: (command.CommandList children:[(C {(git)} {(rev-parse)} {(HEAD)})]) left_token: <Left_CommandSub '$('> spids: [96 102] ) ) } spids: [94] ) ] spids: [94] ) (C {(export)} {(COMMIT1)}) (C {(test_expect_success)} {(SQ <'push with failing hook'>)} {(SQ <'\n'> <'\ttest_commit two &&\n'> <'\ttest_must_fail git push parent1 HEAD\n'>)} ) (C {(test_expect_success)} {(SQ <'--no-verify bypasses hook'>)} {(SQ <'\n'> <'\tgit push --no-verify parent1 HEAD\n'>)} ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:COMMIT2 spids:[135]) op: Equal rhs: { (DQ (word_part.CommandSubPart command_list: (command.CommandList children:[(C {(git)} {(rev-parse)} {(HEAD)})]) left_token: <Left_CommandSub '$('> spids: [137 143] ) ) } spids: [135] ) ] spids: [135] ) (C {(export)} {(COMMIT2)}) (command.SimpleCommand words: [{(write_script)} {(DQ ($ VSub_Name '$HOOK'))}] redirects: [ (redir.HereDoc op: <Redir_DLess '<<'> fd: 16777215 here_begin: {(SQ <EOF>)} here_end_span_id: 165 stdin_parts: [('echo "$1" >actual\n') ('echo "$2" >>actual\n') ('cat >>actual\n')] ) ] ) (command.SimpleCommand words: [{(cat)}] redirects: [ (redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expected)}) (redir.HereDoc op: <Redir_DLess '<<'> fd: 16777215 here_begin: {(EOF)} here_end_span_id: 183 stdin_parts: [ ('parent1\n') ('repo1\n') ('refs/heads/master ') ($ VSub_Name '$COMMIT2') (' refs/heads/foreign ') ($ VSub_Name '$COMMIT1') ('\n') ] ) ] ) (C {(test_expect_success)} {(SQ <'push with hook'>)} {(SQ <'\n'> <'\tgit push parent1 master:foreign &&\n'> <'\tdiff expected actual\n'>)} ) (C {(test_expect_success)} {(SQ <'add a branch'>)} {(SQ <'\n'> <'\tgit checkout -b other parent1/foreign &&\n'> <'\ttest_commit three\n'>)} ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:COMMIT3 spids:[211]) op: Equal rhs: { (DQ (word_part.CommandSubPart command_list: (command.CommandList children:[(C {(git)} {(rev-parse)} {(HEAD)})]) left_token: <Left_CommandSub '$('> spids: [213 219] ) ) } spids: [211] ) ] spids: [211] ) (C {(export)} {(COMMIT3)}) (command.SimpleCommand words: [{(cat)}] redirects: [ (redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expected)}) (redir.HereDoc op: <Redir_DLess '<<'> fd: 16777215 here_begin: {(EOF)} here_end_span_id: 243 stdin_parts: [ ('parent1\n') ('repo1\n') ('refs/heads/other ') ($ VSub_Name '$COMMIT3') (' refs/heads/foreign ') ($ VSub_Name '$COMMIT2') ('\n') ] ) ] ) (C {(test_expect_success)} {(SQ <'push to default'>)} {(SQ <'\n'> <'\tgit push &&\n'> <'\tdiff expected actual\n'>)} ) (command.SimpleCommand words: [{(cat)}] redirects: [ (redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expected)}) (redir.HereDoc op: <Redir_DLess '<<'> fd: 16777215 here_begin: {(EOF)} here_end_span_id: 279 stdin_parts: [ ('parent1\n') ('repo1\n') ('refs/tags/one ') ($ VSub_Name '$COMMIT1') (' refs/tags/tag1 ') ($ VSub_Name '$_z40') ('\n') ('HEAD~ ') ($ VSub_Name '$COMMIT2') (' refs/heads/prev ') ($ VSub_Name '$_z40') ('\n') ] ) ] ) (C {(test_expect_success)} {(SQ <'push non-branches'>)} { (SQ <'\n'> <'\tgit push parent1 one:tag1 HEAD~:refs/heads/prev &&\n'> <'\tdiff expected actual\n'> ) } ) (command.SimpleCommand words: [{(cat)}] redirects: [ (redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expected)}) (redir.HereDoc op: <Redir_DLess '<<'> fd: 16777215 here_begin: {(EOF)} here_end_span_id: 310 stdin_parts: [ ('parent1\n') ('repo1\n') ('(delete) ') ($ VSub_Name '$_z40') (' refs/heads/prev ') ($ VSub_Name '$COMMIT2') ('\n') ] ) ] ) (C {(test_expect_success)} {(SQ <'push delete'>)} {(SQ <'\n'> <'\tgit push parent1 :prev &&\n'> <'\tdiff expected actual\n'>)} ) (command.SimpleCommand words: [{(cat)}] redirects: [ (redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expected)}) (redir.HereDoc op: <Redir_DLess '<<'> fd: 16777215 here_begin: {(EOF)} here_end_span_id: 341 stdin_parts: [ ('repo1\n') ('repo1\n') ('HEAD ') ($ VSub_Name '$COMMIT3') (' refs/heads/other ') ($ VSub_Name '$_z40') ('\n') ] ) ] ) (C {(test_expect_success)} {(SQ <'push to URL'>)} {(SQ <'\n'> <'\tgit push repo1 HEAD &&\n'> <'\tdiff expected actual\n'>)} ) (C {(test_expect_success)} {(SQ <'set up many-ref tests'>)} { (SQ <'\n'> <'\t{\n'> <'\t\tnr=1000\n'> <'\t\twhile test $nr -lt 2000\n'> <'\t\tdo\n'> <'\t\t\tnr=$(( $nr + 1 ))\n'> <'\t\t\techo "create refs/heads/b/$nr $COMMIT3"\n'> <'\t\tdone\n'> <'\t} | git update-ref --stdin\n'> ) } ) (C {(test_expect_success)} {(SQ <'sigpipe does not cause pre-push hook failure'>)} { (SQ <'\n'> <'\techo "exit 0" | write_script "$HOOK" &&\n'> <'\tgit push parent1 "refs/heads/b/*:refs/heads/b/*"\n'> ) } ) (C {(test_done)}) ] )