(CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"prepare-commit-msg hook">)} spids: [4] ) ] spids: [4] ) (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"> ) } ) (SimpleCommand words: [{(cat)}] redirects: [ (Redir op_id:Redir_Great fd:-1 arg_word:{(fake-editor)} spids:[36]) (HereDoc op_id: Redir_DLess fd: -1 body: {("#!/bin/sh\n") ("exit 0\n")} do_expansion: False here_end: EOF was_filled: True spids: [40] ) ] ) (C {(chmod)} {(Lit_Other "+") (x)} {(fake-editor)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:FAKE_EDITOR) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children:[(C {(pwd)})]) left_token: <Left_CommandSub "$("> spids: [61 63] ) (/fake-editor) ) } spids: [59] ) ] spids: [59] ) (C {(export)} {(FAKE_EDITOR)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:HOOKDIR) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children:[(C {(git)} {(rev-parse)} {(--git-dir)})]) left_token: <Left_CommandSub "$("> spids: [77 83] ) (/hooks) ) } spids: [75] ) ] spids: [75] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:HOOK) op: Equal rhs: {(DQ ($ VSub_Name "$HOOKDIR") (/prepare-commit-msg))} spids: [87] ) ] spids: [87] ) (C {(mkdir)} {(-p)} {(DQ ($ VSub_Name "$HOOKDIR"))}) (SimpleCommand words: [{(echo)} {(DQ ("#!") ($ VSub_Name "$SHELL_PATH"))}] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(DQ ($ VSub_Name "$HOOK"))} spids:[108])] ) (SimpleCommand words: [{(cat)}] redirects: [ (Redir op_id:Redir_DGreat fd:-1 arg_word:{(DQ ($ VSub_Name "$HOOK"))} spids:[116]) (HereDoc op_id: Redir_DLess fd: -1 body: {("\n") ("if test \"$2\" = commit; then\n") (" source=$(git rev-parse \"$3\")\n") ("else\n") (" source=${2-default}\n") ("fi\n") ("if test \"$GIT_EDITOR\" = :; then\n") (" sed -e \"1s/.*/$source (no editor)/\" \"$1\" > msg.tmp\n") ("else\n") (" sed -e \"1s/.*/$source/\" \"$1\" > msg.tmp\n") ("fi\n") ("mv msg.tmp \"$1\"\n") ("exit 0\n") } do_expansion: False here_end: EOF was_filled: True spids: [122] ) ] ) (C {(chmod)} {(Lit_Other "+") (x)} {(DQ ($ VSub_Name "$HOOK"))}) (SimpleCommand words: [{(echo)} {(dummy)} {(template)}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: { (DQ (CommandSubPart command_list: (CommandList children:[(C {(git)} {(rev-parse)} {(--git-dir)})]) left_token: <Left_CommandSub "$("> spids: [146 152] ) (/template) ) } spids: [143] ) ] ) (C {(test_expect_success)} {(SQ <"with hook (-m)">)} { (SQ <"\n"> <"\n"> <"\techo \"more\" >> file &&\n"> <"\tgit add file &&\n"> <"\tgit commit -m \"more\" &&\n"> <"\ttest \"$(git log -1 --pretty=format:%s)\" = \"message (no editor)\"\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"with hook (-m editor)">)} { (SQ <"\n"> <"\n"> <"\techo \"more\" >> file &&\n"> <"\tgit add file &&\n"> <"\tGIT_EDITOR=\"\\\"\\$FAKE_EDITOR\\\"\" git commit -e -m \"more more\" &&\n"> <"\ttest \"$(git log -1 --pretty=format:%s)\" = message\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"with hook (-t)">)} { (SQ <"\n"> <"\n"> <"\techo \"more\" >> file &&\n"> <"\tgit add file &&\n"> <"\tgit commit -t \"$(git rev-parse --git-dir)/template\" &&\n"> <"\ttest \"$(git log -1 --pretty=format:%s)\" = template\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"with hook (-F)">)} { (SQ <"\n"> <"\n"> <"\techo \"more\" >> file &&\n"> <"\tgit add file &&\n"> <"\t(echo more | git commit -F -) &&\n"> <"\ttest \"$(git log -1 --pretty=format:%s)\" = \"message (no editor)\"\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"with hook (-F editor)">)} { (SQ <"\n"> <"\n"> <"\techo \"more\" >> file &&\n"> <"\tgit add file &&\n"> <"\t(echo more more | GIT_EDITOR=\"\\\"\\$FAKE_EDITOR\\\"\" git commit -e -F -) &&\n"> <"\ttest \"$(git log -1 --pretty=format:%s)\" = message\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"with hook (-C)">)} { (SQ <"\n"> <"\n"> <"\thead=$(git rev-parse HEAD) &&\n"> <"\techo \"more\" >> file &&\n"> <"\tgit add file &&\n"> <"\tgit commit -C $head &&\n"> <"\ttest \"$(git log -1 --pretty=format:%s)\" = \"$head (no editor)\"\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"with hook (editor)">)} { (SQ <"\n"> <"\n"> <"\techo \"more more\" >> file &&\n"> <"\tgit add file &&\n"> <"\tGIT_EDITOR=\"\\\"\\$FAKE_EDITOR\\\"\" git commit &&\n"> <"\ttest \"$(git log -1 --pretty=format:%s)\" = default\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"with hook (--amend)">)} { (SQ <"\n"> <"\n"> <"\thead=$(git rev-parse HEAD) &&\n"> <"\techo \"more\" >> file &&\n"> <"\tgit add file &&\n"> <"\tGIT_EDITOR=\"\\\"\\$FAKE_EDITOR\\\"\" git commit --amend &&\n"> <"\ttest \"$(git log -1 --pretty=format:%s)\" = \"$head\"\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"with hook (-c)">)} { (SQ <"\n"> <"\n"> <"\thead=$(git rev-parse HEAD) &&\n"> <"\techo \"more\" >> file &&\n"> <"\tgit add file &&\n"> <"\tGIT_EDITOR=\"\\\"\\$FAKE_EDITOR\\\"\" git commit -c $head &&\n"> <"\ttest \"$(git log -1 --pretty=format:%s)\" = \"$head\"\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"with hook (merge)">)} { (SQ <"\n"> <"\n"> <"\ttest_when_finished \"git checkout -f master\" &&\n"> <"\tgit checkout -B other HEAD@{1} &&\n"> <"\techo \"more\" >>file &&\n"> <"\tgit add file &&\n"> <"\tgit commit -m other &&\n"> <"\tgit checkout - &&\n"> <"\tgit merge --no-ff other &&\n"> <"\ttest \"$(git log -1 --pretty=format:%s)\" = \"merge (no editor)\"\n"> ) } ) (C {(test_expect_success)} {(SQ <"with hook and editor (merge)">)} { (SQ <"\n"> <"\n"> <"\ttest_when_finished \"git checkout -f master\" &&\n"> <"\tgit checkout -B other HEAD@{1} &&\n"> <"\techo \"more\" >>file &&\n"> <"\tgit add file &&\n"> <"\tgit commit -m other &&\n"> <"\tgit checkout - &&\n"> <"\tenv GIT_EDITOR=\"\\\"\\$FAKE_EDITOR\\\"\" git merge --no-ff -e other &&\n"> <"\ttest \"$(git log -1 --pretty=format:%s)\" = \"merge\"\n"> ) } ) (SimpleCommand words: [{(cat)}] redirects: [ (Redir op_id:Redir_Great fd:-1 arg_word:{(DQ ($ VSub_Name "$HOOK"))} spids:[355]) (HereDoc op_id: Redir_DLess fd: -1 body: {("#!/bin/sh\n") ("exit 1\n")} do_expansion: False here_end: EOF was_filled: True spids: [361] ) ] ) (C {(test_expect_success)} {(SQ <"with failing hook">)} { (SQ <"\n"> <"\n"> <"\ttest_when_finished \"git checkout -f master\" &&\n"> <"\thead=$(git rev-parse HEAD) &&\n"> <"\techo \"more\" >> file &&\n"> <"\tgit add file &&\n"> <"\ttest_must_fail env GIT_EDITOR=\"\\\"\\$FAKE_EDITOR\\\"\" git commit -c $head\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"with failing hook (--no-verify)">)} { (SQ <"\n"> <"\n"> <"\ttest_when_finished \"git checkout -f master\" &&\n"> <"\thead=$(git rev-parse HEAD) &&\n"> <"\techo \"more\" >> file &&\n"> <"\tgit add file &&\n"> < "\ttest_must_fail env GIT_EDITOR=\"\\\"\\$FAKE_EDITOR\\\"\" git commit --no-verify -c $head\n" > <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"with failing hook (merge)">)} { (SQ <"\n"> <"\n"> <"\ttest_when_finished \"git checkout -f master\" &&\n"> <"\tgit checkout -B other HEAD@{1} &&\n"> <"\techo \"more\" >> file &&\n"> <"\tgit add file &&\n"> <"\trm -f \"$HOOK\" &&\n"> <"\tgit commit -m other &&\n"> <"\twrite_script \"$HOOK\" <<-EOF &&\n"> <"\texit 1\n"> <"\tEOF\n"> <"\tgit checkout - &&\n"> <"\ttest_must_fail git merge --no-ff other\n"> <"\n"> ) } ) (C {(test_done)}) ] )