(command.CommandList children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:test_description) op: assign_op.Equal rhs: {(SQ <'prepare-commit-msg hook'>)} 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'> ) } ) (command.Simple words: [{<cat>}] redirects: [ (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<fake-editor>}) (redir op: <Id.Redir_DLess '<<'> loc: (redir_loc.Fd fd:0) arg: (redir_param.MultiLine here_begin: {(SQ <EOF>)} here_end_span_id: 47 stdin_parts: [<'#!/bin/sh\n'> <'exit 0\n'>] ) ) ] do_fork: T ) (C {<chmod>} {<Id.Lit_Other '+'> <x>} {<fake-editor>}) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:FAKE_EDITOR) op: assign_op.Equal rhs: { (DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<pwd>})) <'/fake-editor'> ) } spids: [62] ) ] ) (C {<export>} {<FAKE_EDITOR>}) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:HOOKDIR) op: assign_op.Equal rhs: { (DQ (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {<git>} {<rev-parse>} {<--git-dir>}) ) <'/hooks'> ) } spids: [78] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:HOOK) op: assign_op.Equal rhs: {(DQ ($ Id.VSub_DollarName '$HOOKDIR') <'/prepare-commit-msg'>)} spids: [90] ) ] ) (C {<mkdir>} {<-p>} {(DQ ($ Id.VSub_DollarName '$HOOKDIR'))}) (command.Simple words: [{<echo>} {(DQ <'#!'> ($ Id.VSub_DollarName '$SHELL_PATH'))}] redirects: [ (redir op: <Id.Redir_Great '>'> loc: (redir_loc.Fd fd:1) arg: {(DQ ($ Id.VSub_DollarName '$HOOK'))} ) ] do_fork: T ) (command.Simple words: [{<cat>}] redirects: [ (redir op: <Id.Redir_DGreat '>>'> loc: (redir_loc.Fd fd:1) arg: {(DQ ($ Id.VSub_DollarName '$HOOK'))} ) (redir op: <Id.Redir_DLess '<<'> loc: (redir_loc.Fd fd:0) arg: (redir_param.MultiLine 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'> ] ) ) ] do_fork: T ) (C {<chmod>} {<Id.Lit_Other '+'> <x>} {(DQ ($ Id.VSub_DollarName '$HOOK'))}) (command.Simple words: [{<echo>} {<dummy>} {<template>}] redirects: [ (redir op: <Id.Redir_Great '>'> loc: (redir_loc.Fd fd:1) arg: { (DQ (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {<git>} {<rev-parse>} {<--git-dir>}) ) <'/template'> ) } ) ] do_fork: T ) (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'> ) } ) (command.Simple words: [{<cat>}] redirects: [ (redir op: <Id.Redir_Great '>'> loc: (redir_loc.Fd fd:1) arg: {(DQ ($ Id.VSub_DollarName '$HOOK'))} ) (redir op: <Id.Redir_DLess '<<'> loc: (redir_loc.Fd fd:0) arg: (redir_param.MultiLine here_begin: {(SQ <EOF>)} here_end_span_id: 385 stdin_parts: [<'#!/bin/sh\n'> <'exit 1\n'>] ) ) ] do_fork: T ) (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>}) ] )