(command.CommandList children: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:test_description spids:[12]) op: Equal rhs: {(SQ <'commit-msg hook'>)} spids: [12] ) ] spids: [12] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(SQ <'with no hook'>)} { (SQ <'\n'> <'\n'> <'\techo "foo" > file &&\n'> <'\tgit add file &&\n'> <'\tgit commit -m "first"\n'> <'\n'> ) } ) (command.SimpleCommand words: [{(cat)}] redirects: [ (redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(fake-editor)}) (redir.HereDoc op: <Redir_DLess '<<'> fd: 16777215 here_begin: {(SQ <EOF>)} here_end_span_id: 56 stdin_parts: [('#!/bin/sh\n') ('cp FAKE_MSG "$1"\n') ('exit 0\n')] ) ] ) (C {(chmod)} {(Lit_Other '+') (x)} {(fake-editor)}) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:FAKE_EDITOR spids:[71]) op: Equal rhs: { (DQ (word_part.CommandSubPart command_list: (command.CommandList children:[(C {(pwd)})]) left_token: <Left_CommandSub '$('> spids: [73 75] ) (/fake-editor) ) } spids: [71] ) ] spids: [71] ) (C {(export)} {(FAKE_EDITOR)}) (C {(test_expect_success)} {(SQ <'with no hook (editor)'>)} { (SQ <'\n'> <'\n'> <'\techo "more foo" >> file &&\n'> <'\tgit add file &&\n'> <'\techo "more foo" > FAKE_MSG &&\n'> <'\tGIT_EDITOR="\\"\\$FAKE_EDITOR\\"" git commit\n'> <'\n'> ) } ) (C {(test_expect_success)} {(SQ <'--no-verify with no hook'>)} { (SQ <'\n'> <'\n'> <'\techo "bar" > file &&\n'> <'\tgit add file &&\n'> <'\tgit commit --no-verify -m "bar"\n'> <'\n'> ) } ) (C {(test_expect_success)} {(SQ <'--no-verify with no hook (editor)'>)} { (SQ <'\n'> <'\n'> <'\techo "more bar" > file &&\n'> <'\tgit add file &&\n'> <'\techo "more bar" > FAKE_MSG &&\n'> <'\tGIT_EDITOR="\\"\\$FAKE_EDITOR\\"" git commit --no-verify\n'> <'\n'> ) } ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:HOOKDIR spids:[137]) op: Equal rhs: { (DQ (word_part.CommandSubPart command_list: (command.CommandList children: [(C {(git)} {(rev-parse)} {(--git-dir)})] ) left_token: <Left_CommandSub '$('> spids: [139 145] ) (/hooks) ) } spids: [137] ) ] spids: [137] ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:HOOK spids:[149]) op: Equal rhs: {(DQ ($ VSub_Name '$HOOKDIR') (/commit-msg))} spids: [149] ) ] spids: [149] ) (C {(mkdir)} {(-p)} {(DQ ($ VSub_Name '$HOOKDIR'))}) (command.SimpleCommand words: [{(cat)}] redirects: [ (redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(DQ ($ VSub_Name '$HOOK'))}) (redir.HereDoc op: <Redir_DLess '<<'> fd: 16777215 here_begin: {(EOF)} here_end_span_id: 177 stdin_parts: [('#!/bin/sh\n') ('exit 0\n')] ) ] ) (C {(chmod)} {(Lit_Other '+') (x)} {(DQ ($ VSub_Name '$HOOK'))}) (C {(test_expect_success)} {(SQ <'with succeeding hook'>)} { (SQ <'\n'> <'\n'> <'\techo "more" >> file &&\n'> <'\tgit add file &&\n'> <'\tgit commit -m "more"\n'> <'\n'> ) } ) (C {(test_expect_success)} {(SQ <'with succeeding hook (editor)'>)} { (SQ <'\n'> <'\n'> <'\techo "more more" >> file &&\n'> <'\tgit add file &&\n'> <'\techo "more more" > FAKE_MSG &&\n'> <'\tGIT_EDITOR="\\"\\$FAKE_EDITOR\\"" git commit\n'> <'\n'> ) } ) (C {(test_expect_success)} {(SQ <'--no-verify with succeeding hook'>)} { (SQ <'\n'> <'\n'> <'\techo "even more" >> file &&\n'> <'\tgit add file &&\n'> <'\tgit commit --no-verify -m "even more"\n'> <'\n'> ) } ) (C {(test_expect_success)} {(SQ <'--no-verify with succeeding hook (editor)'>)} { (SQ <'\n'> <'\n'> <'\techo "even more more" >> file &&\n'> <'\tgit add file &&\n'> <'\techo "even more more" > FAKE_MSG &&\n'> <'\tGIT_EDITOR="\\"\\$FAKE_EDITOR\\"" git commit --no-verify\n'> <'\n'> ) } ) (command.SimpleCommand words: [{(cat)}] redirects: [ (redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(DQ ($ VSub_Name '$HOOK'))}) (redir.HereDoc op: <Redir_DLess '<<'> fd: 16777215 here_begin: {(EOF)} here_end_span_id: 271 stdin_parts: [('#!/bin/sh\n') ('exit 1\n')] ) ] ) (C {(test_expect_success)} {(SQ <'with failing hook'>)} { (SQ <'\n'> <'\n'> <'\techo "another" >> file &&\n'> <'\tgit add file &&\n'> <'\ttest_must_fail git commit -m "another"\n'> <'\n'> ) } ) (C {(test_expect_success)} {(SQ <'with failing hook (editor)'>)} { (SQ <'\n'> <'\n'> <'\techo "more another" >> file &&\n'> <'\tgit add file &&\n'> <'\techo "more another" > FAKE_MSG &&\n'> <'\t! (GIT_EDITOR="\\"\\$FAKE_EDITOR\\"" git commit)\n'> <'\n'> ) } ) (C {(test_expect_success)} {(SQ <'--no-verify with failing hook'>)} { (SQ <'\n'> <'\n'> <'\techo "stuff" >> file &&\n'> <'\tgit add file &&\n'> <'\tgit commit --no-verify -m "stuff"\n'> <'\n'> ) } ) (C {(test_expect_success)} {(SQ <'--no-verify with failing hook (editor)'>)} { (SQ <'\n'> <'\n'> <'\techo "more stuff" >> file &&\n'> <'\tgit add file &&\n'> <'\techo "more stuff" > FAKE_MSG &&\n'> <'\tGIT_EDITOR="\\"\\$FAKE_EDITOR\\"" git commit --no-verify\n'> <'\n'> ) } ) (C {(chmod)} {(-x)} {(DQ ($ VSub_Name '$HOOK'))}) (C {(test_expect_success)} {(POSIXPERM)} {(SQ <'with non-executable hook'>)} { (SQ <'\n'> <'\n'> <'\techo "content" >> file &&\n'> <'\tgit add file &&\n'> <'\tgit commit -m "content"\n'> <'\n'> ) } ) (C {(test_expect_success)} {(POSIXPERM)} {(SQ <'with non-executable hook (editor)'>)} { (SQ <'\n'> <'\n'> <'\techo "content again" >> file &&\n'> <'\tgit add file &&\n'> <'\techo "content again" > FAKE_MSG &&\n'> <'\tGIT_EDITOR="\\"\\$FAKE_EDITOR\\"" git commit -m "content again"\n'> <'\n'> ) } ) (C {(test_expect_success)} {(POSIXPERM)} {(SQ <'--no-verify with non-executable hook'>)} { (SQ <'\n'> <'\n'> <'\techo "more content" >> file &&\n'> <'\tgit add file &&\n'> <'\tgit commit --no-verify -m "more content"\n'> <'\n'> ) } ) (C {(test_expect_success)} {(POSIXPERM)} {(SQ <'--no-verify with non-executable hook (editor)'>)} { (SQ <'\n'> <'\n'> <'\techo "even more content" >> file &&\n'> <'\tgit add file &&\n'> <'\techo "even more content" > FAKE_MSG &&\n'> <'\tGIT_EDITOR="\\"\\$FAKE_EDITOR\\"" git commit --no-verify\n'> <'\n'> ) } ) (command.SimpleCommand words: [{(cat)}] redirects: [ (redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(DQ ($ VSub_Name '$HOOK'))}) (redir.HereDoc op: <Redir_DLess '<<'> fd: 16777215 here_begin: {(SQ <EOF>)} here_end_span_id: 440 stdin_parts: [('#!/bin/sh\n') ('echo "new message" > "$1"\n') ('exit 0\n')] ) ] ) (C {(chmod)} {(Lit_Other '+') (x)} {(DQ ($ VSub_Name '$HOOK'))}) (command.FuncDef name: commit_msg_is body: (command.BraceGroup children: [ (C {(test)} { (DQ (word_part.CommandSubPart command_list: (command.CommandList children: [ (C {(git)} {(log)} {(--pretty) (Lit_Other '=') (format) (Lit_Other ':') (Lit_Other '%') (s) (Lit_Other '%') (b) } {(-1)} ) ] ) left_token: <Left_CommandSub '$('> spids: [462 477] ) ) } {(Lit_Other '=')} {(DQ ($ VSub_Number '$1'))} ) ] spids: [456] ) spids: [451 455] ) (C {(test_expect_success)} {(SQ <'hook edits commit message'>)} { (SQ <'\n'> <'\n'> <'\techo "additional" >> file &&\n'> <'\tgit add file &&\n'> <'\tgit commit -m "additional" &&\n'> <'\tcommit_msg_is "new message"\n'> <'\n'> ) } ) (C {(test_expect_success)} {(SQ <'hook edits commit message (editor)'>)} { (SQ <'\n'> <'\n'> <'\techo "additional content" >> file &&\n'> <'\tgit add file &&\n'> <'\techo "additional content" > FAKE_MSG &&\n'> <'\tGIT_EDITOR="\\"\\$FAKE_EDITOR\\"" git commit &&\n'> <'\tcommit_msg_is "new message"\n'> <'\n'> ) } ) (C {(test_expect_success)} {(DQ ("hook doesn't edit commit message"))} { (SQ <'\n'> <'\n'> <'\techo "plus" >> file &&\n'> <'\tgit add file &&\n'> <'\tgit commit --no-verify -m "plus" &&\n'> <'\tcommit_msg_is "plus"\n'> <'\n'> ) } ) (C {(test_expect_success)} {(DQ ("hook doesn't edit commit message (editor)"))} { (SQ <'\n'> <'\n'> <'\techo "more plus" >> file &&\n'> <'\tgit add file &&\n'> <'\techo "more plus" > FAKE_MSG &&\n'> <'\tGIT_EDITOR="\\"\\$FAKE_EDITOR\\"" git commit --no-verify &&\n'> <'\tcommit_msg_is "more plus"\n'> <'\n'> ) } ) (C {(test_done)}) ] )