(command.CommandList children: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:test_description) op: Equal rhs: {(SQ <'commit-msg hook'>)} ) ] ) (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: 48 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) op: Equal rhs: { (DQ (word_part.CommandSubPart command_list: (command.CommandList children:[(C {(pwd)})]) left_token: <Left_CommandSub '$('> ) (/fake-editor) ) } ) ] ) (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) op: Equal rhs: { (DQ (word_part.CommandSubPart command_list: (command.CommandList children: [(C {(git)} {(rev-parse)} {(--git-dir)})] ) left_token: <Left_CommandSub '$('> ) (/hooks) ) } ) ] ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:HOOK) op: Equal rhs: {(DQ ($ VSub_DollarName '$HOOKDIR') (/commit-msg))} ) ] ) (C {(mkdir)} {(-p)} {(DQ ($ VSub_DollarName '$HOOKDIR'))}) (command.SimpleCommand words: [{(cat)}] redirects: [ (redir.Redir op: <Redir_Great '>'> fd: 16777215 arg_word: {(DQ ($ VSub_DollarName '$HOOK'))} ) (redir.HereDoc op: <Redir_DLess '<<'> fd: 16777215 here_begin: {(EOF)} here_end_span_id: 169 stdin_parts: [('#!/bin/sh\n') ('exit 0\n')] ) ] ) (C {(chmod)} {(Lit_Other '+') (x)} {(DQ ($ VSub_DollarName '$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_DollarName '$HOOK'))} ) (redir.HereDoc op: <Redir_DLess '<<'> fd: 16777215 here_begin: {(EOF)} here_end_span_id: 263 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_DollarName '$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_DollarName '$HOOK'))} ) (redir.HereDoc op: <Redir_DLess '<<'> fd: 16777215 here_begin: {(SQ <EOF>)} here_end_span_id: 432 stdin_parts: [('#!/bin/sh\n') ('echo "new message" > "$1"\n') ('exit 0\n')] ) ] ) (C {(chmod)} {(Lit_Other '+') (x)} {(DQ ($ VSub_DollarName '$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 '$('> ) ) } {(Lit_Other '=')} {(DQ ($ VSub_Number '$1'))} ) ] ) ) (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)}) ] )