(CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"Test the update hook infrastructure.">)} spids: [13] ) ] spids: [13] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(setup)} { (SQ <"\n"> <"\techo This is a test. >a &&\n"> <"\tgit update-index --add a &&\n"> <"\ttree0=$(git write-tree) &&\n"> <"\tcommit0=$(echo setup | git commit-tree $tree0) &&\n"> <"\techo We hope it works. >a &&\n"> <"\tgit update-index a &&\n"> <"\ttree1=$(git write-tree) &&\n"> <"\tcommit1=$(echo modify | git commit-tree $tree1 -p $commit0) &&\n"> <"\tgit update-ref refs/heads/master $commit0 &&\n"> <"\tgit update-ref refs/heads/tofail $commit1 &&\n"> <"\tgit clone --bare ./. victim.git &&\n"> <"\tGIT_DIR=victim.git git update-ref refs/heads/tofail $commit1 &&\n"> <"\tgit update-ref refs/heads/master $commit1 &&\n"> <"\tgit update-ref refs/heads/tofail $commit0\n"> ) } ) (SimpleCommand words: [{(cat)}] redirects: [ (Redir op_id:Redir_Great fd:-1 arg_word:{(victim.git/hooks/pre-receive)} spids:[48]) (HereDoc op_id: Redir_DLess fd: -1 body: {("#!/bin/sh\n") ("printf %s \"$@\" >>$GIT_DIR/pre-receive.args\n") ("cat - >$GIT_DIR/pre-receive.stdin\n") ("echo STDOUT pre-receive\n") ("echo STDERR pre-receive >&2\n") } do_expansion: False here_end: EOF was_filled: True spids: [51] ) ] ) (C {(chmod)} {(u) (Lit_Other "+") (x)} {(victim.git/hooks/pre-receive)}) (SimpleCommand words: [{(cat)}] redirects: [ (Redir op_id:Redir_Great fd:-1 arg_word:{(victim.git/hooks/update)} spids:[67]) (HereDoc op_id: Redir_DLess fd: -1 body: {("#!/bin/sh\n") ("echo \"$@\" >>$GIT_DIR/update.args\n") ("read x; printf %s \"$x\" >$GIT_DIR/update.stdin\n") ("echo STDOUT update $1\n") ("echo STDERR update $1 >&2\n") ("test \"$1\" = refs/heads/master || exit\n") } do_expansion: False here_end: EOF was_filled: True spids: [70] ) ] ) (C {(chmod)} {(u) (Lit_Other "+") (x)} {(victim.git/hooks/update)}) (SimpleCommand words: [{(cat)}] redirects: [ (Redir op_id:Redir_Great fd:-1 arg_word:{(victim.git/hooks/post-receive)} spids:[86]) (HereDoc op_id: Redir_DLess fd: -1 body: {("#!/bin/sh\n") ("printf %s \"$@\" >>$GIT_DIR/post-receive.args\n") ("cat - >$GIT_DIR/post-receive.stdin\n") ("echo STDOUT post-receive\n") ("echo STDERR post-receive >&2\n") } do_expansion: False here_end: EOF was_filled: True spids: [89] ) ] ) (C {(chmod)} {(u) (Lit_Other "+") (x)} {(victim.git/hooks/post-receive)}) (SimpleCommand words: [{(cat)}] redirects: [ (Redir op_id:Redir_Great fd:-1 arg_word:{(victim.git/hooks/post-update)} spids:[105]) (HereDoc op_id: Redir_DLess fd: -1 body: {("#!/bin/sh\n") ("echo \"$@\" >>$GIT_DIR/post-update.args\n") ("read x; printf %s \"$x\" >$GIT_DIR/post-update.stdin\n") ("echo STDOUT post-update\n") ("echo STDERR post-update >&2\n") } do_expansion: False here_end: EOF was_filled: True spids: [108] ) ] ) (C {(chmod)} {(u) (Lit_Other "+") (x)} {(victim.git/hooks/post-update)}) (C {(test_expect_success)} {(push)} { (SQ <"\n"> <"\ttest_must_fail git send-pack --force ./victim.git \\\n"> <"\t\tmaster tofail >send.out 2>send.err\n"> ) } ) (C {(test_expect_success)} {(SQ <"updated as expected">)} { (SQ <"\n"> <"\ttest $(GIT_DIR=victim.git git rev-parse master) = $commit1 &&\n"> <"\ttest $(GIT_DIR=victim.git git rev-parse tofail) = $commit1\n"> ) } ) (C {(test_expect_success)} {(SQ <"hooks ran">)} { (SQ <"\n"> <"\ttest -f victim.git/pre-receive.args &&\n"> <"\ttest -f victim.git/pre-receive.stdin &&\n"> <"\ttest -f victim.git/update.args &&\n"> <"\ttest -f victim.git/update.stdin &&\n"> <"\ttest -f victim.git/post-receive.args &&\n"> <"\ttest -f victim.git/post-receive.stdin &&\n"> <"\ttest -f victim.git/post-update.args &&\n"> <"\ttest -f victim.git/post-update.stdin\n"> ) } ) (C {(test_expect_success)} {(SQ <"pre-receive hook input">)} { (SQ <"\n"> <"\t(echo $commit0 $commit1 refs/heads/master;\n"> <"\t echo $commit1 $commit0 refs/heads/tofail\n"> <"\t) | test_cmp - victim.git/pre-receive.stdin\n"> ) } ) (C {(test_expect_success)} {(SQ <"update hook arguments">)} { (SQ <"\n"> <"\t(echo refs/heads/master $commit0 $commit1;\n"> <"\t echo refs/heads/tofail $commit1 $commit0\n"> <"\t) | test_cmp - victim.git/update.args\n"> ) } ) (C {(test_expect_success)} {(SQ <"post-receive hook input">)} { (SQ <"\n"> <"\techo $commit0 $commit1 refs/heads/master |\n"> <"\ttest_cmp - victim.git/post-receive.stdin\n"> ) } ) (C {(test_expect_success)} {(SQ <"post-update hook arguments">)} {(SQ <"\n"> <"\techo refs/heads/master |\n"> <"\ttest_cmp - victim.git/post-update.args\n">)} ) (C {(test_expect_success)} {(SQ <"all hook stdin is /dev/null">)} { (SQ <"\n"> <"\t! test -s victim.git/update.stdin &&\n"> <"\t! test -s victim.git/post-update.stdin\n"> ) } ) (C {(test_expect_success)} {(SQ <"all *-receive hook args are empty">)} { (SQ <"\n"> <"\t! test -s victim.git/pre-receive.args &&\n"> <"\t! test -s victim.git/post-receive.args\n"> ) } ) (C {(test_expect_success)} {(SQ <"send-pack produced no output">)} {(SQ <"\n"> <"\t! test -s send.out\n">)} ) (SimpleCommand words: [{(cat)}] redirects: [ (HereDoc op_id: Redir_DLess fd: -1 body: { (DQ ("remote: STDOUT pre-receive\n") ("remote: STDERR pre-receive\n") ("remote: STDOUT update refs/heads/master\n") ("remote: STDERR update refs/heads/master\n") ("remote: STDOUT update refs/heads/tofail\n") ("remote: STDERR update refs/heads/tofail\n") ("remote: error: hook declined to update refs/heads/tofail\n") ("remote: STDOUT post-receive\n") ("remote: STDERR post-receive\n") ("remote: STDOUT post-update\n") ("remote: STDERR post-update\n") ) } do_expansion: True here_end: EOF was_filled: True spids: [259] ) (Redir op_id:Redir_Great fd:-1 arg_word:{(expect)} spids:[262]) ] ) (C {(test_expect_success)} {(SQ <"send-pack stderr contains hook messages">)} { (SQ <"\n"> <"\tgrep ^remote: send.err | sed \"s/ *\\$//\" >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"pre-receive hook that forgets to read its input">)} { (SQ <"\n"> <"\twrite_script victim.git/hooks/pre-receive <<-\\EOF &&\n"> <"\texit 0\n"> <"\tEOF\n"> <"\trm -f victim.git/hooks/update victim.git/hooks/post-update &&\n"> <"\n"> <"\tfor v in $(test_seq 100 999)\n"> <"\tdo\n"> <"\t\tgit branch branch_$v master || return\n"> <"\tdone &&\n"> <"\tgit push ./victim.git \"+refs/heads/*:refs/heads/*\"\n"> ) } ) (C {(test_done)}) ] )