(CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description spids:[4]) 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:<Redir_Great '>'> fd:16777215 arg_word:{(fake-editor)}) (HereDoc op: <Redir_DLess '<<'> fd: 16777215 here_begin: {(SQ <EOF>)} here_end_span_id: 47 stdin_parts: [('#!/bin/sh\n') ('exit 0\n')] ) ] ) (C {(chmod)} {(Lit_Other '+') (x)} {(fake-editor)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:FAKE_EDITOR spids:[62]) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children:[(C {(pwd)})]) left_token: <Left_CommandSub '$('> spids: [64 66] ) (/fake-editor) ) } spids: [62] ) ] spids: [62] ) (C {(export)} {(FAKE_EDITOR)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:HOOKDIR spids:[78]) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children:[(C {(git)} {(rev-parse)} {(--git-dir)})]) left_token: <Left_CommandSub '$('> spids: [80 86] ) (/hooks) ) } spids: [78] ) ] spids: [78] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:HOOK spids:[90]) op: Equal rhs: {(DQ ($ VSub_Name '$HOOKDIR') (/prepare-commit-msg))} spids: [90] ) ] spids: [90] ) (C {(mkdir)} {(-p)} {(DQ ($ VSub_Name '$HOOKDIR'))}) (SimpleCommand words: [{(echo)} {(DQ ('#!') ($ VSub_Name '$SHELL_PATH'))}] redirects: [(Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(DQ ($ VSub_Name '$HOOK'))})] ) (SimpleCommand words: [{(cat)}] redirects: [ (Redir op:<Redir_DGreat '>>'> fd:16777215 arg_word:{(DQ ($ VSub_Name '$HOOK'))}) (HereDoc op: <Redir_DLess '<<'> fd: 16777215 here_begin: {(SQ <EOF>)} here_end_span_id: 143 stdin_parts: [ ('\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') ] ) ] ) (C {(chmod)} {(Lit_Other '+') (x)} {(DQ ($ VSub_Name '$HOOK'))}) (SimpleCommand words: [{(echo)} {(dummy)} {(template)}] redirects: [ (Redir op: <Redir_Great '>'> fd: 16777215 arg_word: { (DQ (CommandSubPart command_list: (CommandList children:[(C {(git)} {(rev-parse)} {(--git-dir)})]) left_token: <Left_CommandSub '$('> spids: [163 169] ) (/template) ) } ) ] ) (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:<Redir_Great '>'> fd:16777215 arg_word:{(DQ ($ VSub_Name '$HOOK'))}) (HereDoc op: <Redir_DLess '<<'> fd: 16777215 here_begin: {(SQ <EOF>)} here_end_span_id: 385 stdin_parts: [('#!/bin/sh\n') ('exit 1\n')] ) ] ) (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)}) ] )