(command.CommandList children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:test_description) op: assign_op.Equal rhs: {(SQ <'git commit\n'> <'\n'> <'Tests for selected commit options.'>)} spids: [13] ) ] ) (C {<.>} {<'./test-lib.sh'>}) (command.ShFunction name: commit_msg_is body: (BraceGroup children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:expect) op: assign_op.Equal rhs: {<commit_msg_is.expect>} spids: [34] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:actual) op: assign_op.Equal rhs: {<commit_msg_is.actual>} spids: [38] ) ] ) (command.AndOr ops: [Id.Op_DAmp Id.Op_DAmp] children: [ (command.Simple words: [ {<printf>} {(DQ <'%s'>)} { (DQ (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {<git>} {<log>} {<--pretty> <Id.Lit_Equals '='> <format> <Id.Lit_Colon ':'> <Id.Lit_Other '%'> <s> <Id.Lit_Other '%'> <b> } {<-1>} ) ) ) } ] redirects: [ (redir op: <Id.Redir_Great '>'> loc: (redir_loc.Fd fd:1) arg: {(DQ ($ Id.VSub_DollarName '$actual'))} ) ] do_fork: T ) (command.Simple words: [{<printf>} {(DQ <'%s'>)} {(DQ ($ Id.VSub_Number '$1'))}] redirects: [ (redir op: <Id.Redir_Great '>'> loc: (redir_loc.Fd fd:1) arg: {(DQ ($ Id.VSub_DollarName '$expect'))} ) ] do_fork: T ) (C {<test_i18ncmp>} {(DQ ($ Id.VSub_DollarName '$expect'))} {(DQ ($ Id.VSub_DollarName '$actual'))} ) ] ) ] ) ) (C {<test_expect_success>} {(SQ <'a basic commit in an empty tree should succeed'>)} { (SQ <'\n'> <'\techo content > foo &&\n'> <'\tgit add foo &&\n'> <'\tgit commit -m "initial commit"\n'> ) } ) (C {<test_expect_success>} {(SQ <'nonexistent template file should return error'>)} { (SQ <'\n'> <'\techo changes >> foo &&\n'> <'\tgit add foo &&\n'> <'\t(\n'> <'\t\tGIT_EDITOR="echo hello >\\"\\$1\\"" &&\n'> <'\t\texport GIT_EDITOR &&\n'> <'\t\ttest_must_fail git commit --template "$PWD"/notexist\n'> <'\t)\n'> ) } ) (C {<test_expect_success>} {(SQ <'nonexistent template file in config should return error'>)} { (SQ <'\n'> <'\ttest_config commit.template "$PWD"/notexist &&\n'> <'\t(\n'> <'\t\tGIT_EDITOR="echo hello >\\"\\$1\\"" &&\n'> <'\t\texport GIT_EDITOR &&\n'> <'\t\ttest_must_fail git commit\n'> <'\t)\n'> ) } ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:TEMPLATE) op: assign_op.Equal rhs: {(DQ ($ Id.VSub_DollarName '$PWD')) <'/template'>} spids: [162] ) ] ) (C {<test_expect_success>} {(SQ <'unedited template should not commit'>)} { (SQ <'\n'> <'\techo "template line" > "$TEMPLATE" &&\n'> <'\ttest_must_fail git commit --template "$TEMPLATE"\n'> ) } ) (C {<test_expect_success>} {(SQ <'unedited template with comments should not commit'>)} { (SQ <'\n'> <'\techo "# comment in template" >> "$TEMPLATE" &&\n'> <'\ttest_must_fail git commit --template "$TEMPLATE"\n'> ) } ) (C {<test_expect_success>} {(SQ <'a Signed-off-by line by itself should not commit'>)} { (SQ <'\n'> <'\t(\n'> <'\t\ttest_set_editor "$TEST_DIRECTORY"/t7500/add-signed-off &&\n'> <'\t\ttest_must_fail git commit --template "$TEMPLATE"\n'> <'\t)\n'> ) } ) (C {<test_expect_success>} {(SQ <'adding comments to a template should not commit'>)} { (SQ <'\n'> <'\t(\n'> <'\t\ttest_set_editor "$TEST_DIRECTORY"/t7500/add-comments &&\n'> <'\t\ttest_must_fail git commit --template "$TEMPLATE"\n'> <'\t)\n'> ) } ) (C {<test_expect_success>} {(SQ <'adding real content to a template should commit'>)} { (SQ <'\n'> <'\t(\n'> <'\t\ttest_set_editor "$TEST_DIRECTORY"/t7500/add-content &&\n'> <'\t\tgit commit --template "$TEMPLATE"\n'> <'\t) &&\n'> <'\tcommit_msg_is "template linecommit message"\n'> ) } ) (C {<test_expect_success>} {(SQ <'-t option should be short for --template'>)} { (SQ <'\n'> <'\techo "short template" > "$TEMPLATE" &&\n'> <'\techo "new content" >> foo &&\n'> <'\tgit add foo &&\n'> <'\t(\n'> <'\t\ttest_set_editor "$TEST_DIRECTORY"/t7500/add-content &&\n'> <'\t\tgit commit -t "$TEMPLATE"\n'> <'\t) &&\n'> <'\tcommit_msg_is "short templatecommit message"\n'> ) } ) (C {<test_expect_success>} {(SQ <'config-specified template should commit'>)} { (SQ <'\n'> <'\techo "new template" > "$TEMPLATE" &&\n'> <'\ttest_config commit.template "$TEMPLATE" &&\n'> <'\techo "more content" >> foo &&\n'> <'\tgit add foo &&\n'> <'\t(\n'> <'\t\ttest_set_editor "$TEST_DIRECTORY"/t7500/add-content &&\n'> <'\t\tgit commit\n'> <'\t) &&\n'> <'\tcommit_msg_is "new templatecommit message"\n'> ) } ) (C {<test_expect_success>} {(SQ <'explicit commit message should override template'>)} { (SQ <'\n'> <'\techo "still more content" >> foo &&\n'> <'\tgit add foo &&\n'> < '\tGIT_EDITOR="$TEST_DIRECTORY"/t7500/add-content git commit --template "$TEMPLATE" \\\n' > <'\t\t-m "command line msg" &&\n'> <'\tcommit_msg_is "command line msg"\n'> ) } ) (C {<test_expect_success>} {(SQ <'commit message from file should override template'>)} { (SQ <'\n'> <'\techo "content galore" >> foo &&\n'> <'\tgit add foo &&\n'> <'\techo "standard input msg" |\n'> <'\t(\n'> <'\t\ttest_set_editor "$TEST_DIRECTORY"/t7500/add-content &&\n'> <'\t\tgit commit --template "$TEMPLATE" --file -\n'> <'\t) &&\n'> <'\tcommit_msg_is "standard input msg"\n'> ) } ) (command.Simple words: [{<cat>}] redirects: [ (redir op: <Id.Redir_Great '>'> loc: (redir_loc.Fd fd:1) arg: {(DQ ($ Id.VSub_DollarName '$TEMPLATE'))} ) (redir op: <Id.Redir_DLess '<<'> loc: (redir_loc.Fd fd:0) arg: (redir_param.HereDoc here_begin: {(word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\E'>) <OF>} here_end_span_id: 330 stdin_parts: [<'\n'> <'\n'> <'### template\n'> <'\n'>] ) ) ] do_fork: T ) (C {<test_expect_success>} {(SQ <'commit message from template with whitespace issue'>)} { (SQ <'\n'> <'\techo "content galore" >>foo &&\n'> <'\tgit add foo &&\n'> <'\tGIT_EDITOR="$TEST_DIRECTORY"/t7500/add-whitespaced-content git commit \\\n'> <'\t\t--template "$TEMPLATE" &&\n'> <'\tcommit_msg_is "commit message"\n'> ) } ) (C {<test_expect_success>} {(SQ <'using alternate GIT_INDEX_FILE (1)'>)} { (SQ <'\n'> <'\n'> <'\tcp .git/index saved-index &&\n'> <'\t(\n'> <'\t\techo some new content >file &&\n'> <'\t GIT_INDEX_FILE=.git/another_index &&\n'> <'\t\texport GIT_INDEX_FILE &&\n'> <'\t\tgit add file &&\n'> <'\t\tgit commit -m "commit using another index" &&\n'> <'\t\tgit diff-index --exit-code HEAD &&\n'> <'\t\tgit diff-files --exit-code\n'> <'\t) &&\n'> <'\tcmp .git/index saved-index >/dev/null\n'> <'\n'> ) } ) (C {<test_expect_success>} {(SQ <'using alternate GIT_INDEX_FILE (2)'>)} { (SQ <'\n'> <'\n'> <'\tcp .git/index saved-index &&\n'> <'\t(\n'> <'\t\trm -f .git/no-such-index &&\n'> <'\t\tGIT_INDEX_FILE=.git/no-such-index &&\n'> <'\t\texport GIT_INDEX_FILE &&\n'> <'\t\tgit commit -m "commit using nonexistent index" &&\n'> <'\t\ttest -z "$(git ls-files)" &&\n'> <'\t\ttest -z "$(git ls-tree HEAD)"\n'> <'\n'> <'\t) &&\n'> <'\tcmp .git/index saved-index >/dev/null\n'> ) } ) (command.Simple words: [{<cat>}] redirects: [ (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect>}) (redir op: <Id.Redir_DLess '<<'> loc: (redir_loc.Fd fd:0) arg: (redir_param.HereDoc here_begin: {<EOF>} here_end_span_id: 408 stdin_parts: [<'zort\n'> <'\n'> <'Signed-off-by: C O Mitter <committer@example.com>\n'>] ) ) ] do_fork: T ) (C {<test_expect_success>} {(SQ <--signoff>)} { (SQ <'\n'> <'\techo "yet another content *narf*" >> foo &&\n'> <'\techo "zort" | git commit -s -F - foo &&\n'> <'\tgit cat-file commit HEAD | sed "1,/^\\$/d" > output &&\n'> <'\ttest_cmp expect output\n'> ) } ) (C {<test_expect_success>} {(SQ <'commit message from file (1)'>)} { (SQ <'\n'> <'\tmkdir subdir &&\n'> <'\techo "Log in top directory" >log &&\n'> <'\techo "Log in sub directory" >subdir/log &&\n'> <'\t(\n'> <'\t\tcd subdir &&\n'> <'\t\tgit commit --allow-empty -F log\n'> <'\t) &&\n'> <'\tcommit_msg_is "Log in sub directory"\n'> ) } ) (C {<test_expect_success>} {(SQ <'commit message from file (2)'>)} { (SQ <'\n'> <'\trm -f log &&\n'> <'\techo "Log in sub directory" >subdir/log &&\n'> <'\t(\n'> <'\t\tcd subdir &&\n'> <'\t\tgit commit --allow-empty -F log\n'> <'\t) &&\n'> <'\tcommit_msg_is "Log in sub directory"\n'> ) } ) (C {<test_expect_success>} {(SQ <'commit message from stdin'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd subdir &&\n'> <'\t\techo "Log with foo word" | git commit --allow-empty -F -\n'> <'\t) &&\n'> <'\tcommit_msg_is "Log with foo word"\n'> ) } ) (C {<test_expect_success>} {(SQ <'commit -F overrides -t'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd subdir &&\n'> <'\t\techo "-F log" > f.log &&\n'> <'\t\techo "-t template" > t.template &&\n'> <'\t\tgit commit --allow-empty -F f.log -t t.template\n'> <'\t) &&\n'> <'\tcommit_msg_is "-F log"\n'> ) } ) (C {<test_expect_success>} {(SQ <'Commit without message is allowed with --allow-empty-message'>)} { (SQ <'\n'> <'\techo "more content" >>foo &&\n'> <'\tgit add foo &&\n'> <'\t>empty &&\n'> <'\tgit commit --allow-empty-message <empty &&\n'> <'\tcommit_msg_is "" &&\n'> <'\tgit tag empty-message-commit\n'> ) } ) (C {<test_expect_success>} {(SQ <'Commit without message is no-no without --allow-empty-message'>)} { (SQ <'\n'> <'\techo "more content" >>foo &&\n'> <'\tgit add foo &&\n'> <'\t>empty &&\n'> <'\ttest_must_fail git commit <empty\n'> ) } ) (C {<test_expect_success>} {(SQ <'Commit a message with --allow-empty-message'>)} { (SQ <'\n'> <'\techo "even more content" >>foo &&\n'> <'\tgit add foo &&\n'> <'\tgit commit --allow-empty-message -m"hello there" &&\n'> <'\tcommit_msg_is "hello there"\n'> ) } ) (C {<test_expect_success>} {(SQ <'commit -C empty respects --allow-empty-message'>)} { (SQ <'\n'> <'\techo more >>foo &&\n'> <'\tgit add foo &&\n'> <'\ttest_must_fail git commit -C empty-message-commit &&\n'> <'\tgit commit -C empty-message-commit --allow-empty-message &&\n'> <'\tcommit_msg_is ""\n'> ) } ) (command.ShFunction name: commit_for_rebase_autosquash_setup body: (BraceGroup children: [ (command.AndOr ops: [Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp] children: [ (command.Simple words: [{<echo>} {(DQ <'first content line'>)}] redirects: [(redir op:<Id.Redir_DGreat '>>'> loc:(redir_loc.Fd fd:1) arg:{<foo>})] do_fork: T ) (C {<git>} {<add>} {<foo>}) (command.Simple words: [{<cat>}] redirects: [ (redir op: <Id.Redir_Great '>'> loc: (redir_loc.Fd fd:1) arg: {<log>} ) (redir op: <Id.Redir_DLess '<<'> loc: (redir_loc.Fd fd:0) arg: (redir_param.HereDoc here_begin: {<EOF>} here_end_span_id: 603 stdin_parts: [ <'target message subject line\n'> <'\n'> <'target message body line 1\n'> <'target message body line 2\n'> ] ) ) ] do_fork: T ) (C {<git>} {<commit>} {<-F>} {<log>}) (command.Simple words: [{<echo>} {(DQ <'second content line'>)}] redirects: [(redir op:<Id.Redir_DGreat '>>'> loc:(redir_loc.Fd fd:1) arg:{<foo>})] do_fork: T ) (C {<git>} {<add>} {<foo>}) (C {<git>} {<commit>} {<-m>} {(DQ <'intermediate commit'>)}) (command.Simple words: [{<echo>} {(DQ <'third content line'>)}] redirects: [(redir op:<Id.Redir_DGreat '>>'> loc:(redir_loc.Fd fd:1) arg:{<foo>})] do_fork: T ) (C {<git>} {<add>} {<foo>}) ] ) ] ) ) (C {<test_expect_success>} {(SQ <'commit --fixup provides correct one-line commit message'>)} { (SQ <'\n'> <'\tcommit_for_rebase_autosquash_setup &&\n'> <'\tgit commit --fixup HEAD~1 &&\n'> <'\tcommit_msg_is "fixup! target message subject line"\n'> ) } ) (C {<test_expect_success>} {(SQ <'commit --squash works with -F'>)} { (SQ <'\n'> <'\tcommit_for_rebase_autosquash_setup &&\n'> <'\techo "log message from file" >msgfile &&\n'> <'\tgit commit --squash HEAD~1 -F msgfile &&\n'> <'\tcommit_msg_is "squash! target message subject linelog message from file"\n'> ) } ) (C {<test_expect_success>} {(SQ <'commit --squash works with -m'>)} { (SQ <'\n'> <'\tcommit_for_rebase_autosquash_setup &&\n'> <'\tgit commit --squash HEAD~1 -m "foo bar\\nbaz" &&\n'> <'\tcommit_msg_is "squash! target message subject linefoo bar\\nbaz"\n'> ) } ) (C {<test_expect_success>} {(SQ <'commit --squash works with -C'>)} { (SQ <'\n'> <'\tcommit_for_rebase_autosquash_setup &&\n'> <'\tgit commit --squash HEAD~1 -C HEAD &&\n'> <'\tcommit_msg_is "squash! target message subject lineintermediate commit"\n'> ) } ) (C {<test_expect_success>} {(SQ <'commit --squash works with -c'>)} { (SQ <'\n'> <'\tcommit_for_rebase_autosquash_setup &&\n'> <'\ttest_set_editor "$TEST_DIRECTORY"/t7500/edit-content &&\n'> <'\tgit commit --squash HEAD~1 -c HEAD &&\n'> <'\tcommit_msg_is "squash! target message subject lineedited commit"\n'> ) } ) (C {<test_expect_success>} {(SQ <'commit --squash works with -C for same commit'>)} { (SQ <'\n'> <'\tcommit_for_rebase_autosquash_setup &&\n'> <'\tgit commit --squash HEAD -C HEAD &&\n'> <'\tcommit_msg_is "squash! intermediate commit"\n'> ) } ) (C {<test_expect_success>} {(SQ <'commit --squash works with -c for same commit'>)} { (SQ <'\n'> <'\tcommit_for_rebase_autosquash_setup &&\n'> <'\ttest_set_editor "$TEST_DIRECTORY"/t7500/edit-content &&\n'> <'\tgit commit --squash HEAD -c HEAD &&\n'> <'\tcommit_msg_is "squash! edited commit"\n'> ) } ) (C {<test_expect_success>} {(SQ <'commit --squash works with editor'>)} { (SQ <'\n'> <'\tcommit_for_rebase_autosquash_setup &&\n'> <'\ttest_set_editor "$TEST_DIRECTORY"/t7500/add-content &&\n'> <'\tgit commit --squash HEAD~1 &&\n'> <'\tcommit_msg_is "squash! target message subject linecommit message"\n'> ) } ) (C {<test_expect_success>} {(SQ <'invalid message options when using --fixup'>)} { (SQ <'\n'> <'\techo changes >>foo &&\n'> <'\techo "message" >log &&\n'> <'\tgit add foo &&\n'> <'\ttest_must_fail git commit --fixup HEAD~1 --squash HEAD~2 &&\n'> <'\ttest_must_fail git commit --fixup HEAD~1 -C HEAD~2 &&\n'> <'\ttest_must_fail git commit --fixup HEAD~1 -c HEAD~2 &&\n'> <'\ttest_must_fail git commit --fixup HEAD~1 -m "cmdline message" &&\n'> <'\ttest_must_fail git commit --fixup HEAD~1 -F log\n'> ) } ) (C {<test_done>}) ] )