(command.CommandList children: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:test_description) op: Equal rhs: {(SQ <'git commit\n'> <'\n'> <'Tests for selected commit options.'>)} ) ] ) (C {(.)} {(./test-lib.sh)}) (command.FuncDef name: commit_msg_is body: (command.BraceGroup children: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:expect) op: Equal rhs: {(commit_msg_is.expect)} ) ] ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:actual) op: Equal rhs: {(commit_msg_is.actual)} ) ] ) (command.AndOr ops: [Op_DAmp Op_DAmp] children: [ (command.SimpleCommand words: [ {(printf)} {(DQ ('%s'))} { (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 '$('> ) ) } ] redirects: [ (redir.Redir op: <Redir_Great '>'> fd: 16777215 arg_word: {(DQ ($ VSub_DollarName '$actual'))} ) ] ) (command.SimpleCommand words: [{(printf)} {(DQ ('%s'))} {(DQ ($ VSub_Number '$1'))}] redirects: [ (redir.Redir op: <Redir_Great '>'> fd: 16777215 arg_word: {(DQ ($ VSub_DollarName '$expect'))} ) ] ) (C {(test_i18ncmp)} {(DQ ($ VSub_DollarName '$expect'))} {(DQ ($ 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.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:TEMPLATE) op: Equal rhs: {(DQ ($ VSub_DollarName '$PWD')) (/template)} ) ] ) (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.SimpleCommand words: [{(cat)}] redirects: [ (redir.Redir op: <Redir_Great '>'> fd: 16777215 arg_word: {(DQ ($ VSub_DollarName '$TEMPLATE'))} ) (redir.HereDoc op: <Redir_DLess '<<'> fd: 16777215 here_begin: {(word_part.EscapedLiteralPart token:<Lit_EscapedChar '\\E'>) (OF)} here_end_span_id: 330 stdin_parts: [('\n') ('\n') ('### template\n') ('\n')] ) ] ) (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.SimpleCommand words: [{(cat)}] redirects: [ (redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expect)}) (redir.HereDoc op: <Redir_DLess '<<'> fd: 16777215 here_begin: {(EOF)} here_end_span_id: 408 stdin_parts: [('zort\n') ('\n') ('Signed-off-by: C O Mitter <committer@example.com>\n')] ) ] ) (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.FuncDef name: commit_for_rebase_autosquash_setup body: (command.BraceGroup children: [ (command.AndOr ops: [Op_DAmp Op_DAmp Op_DAmp Op_DAmp Op_DAmp Op_DAmp Op_DAmp Op_DAmp] children: [ (command.SimpleCommand words: [{(echo)} {(DQ ('first content line'))}] redirects: [(redir.Redir op:<Redir_DGreat '>>'> fd:16777215 arg_word:{(foo)})] ) (C {(git)} {(add)} {(foo)}) (command.SimpleCommand words: [{(cat)}] redirects: [ (redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(log)}) (redir.HereDoc op: <Redir_DLess '<<'> fd: 16777215 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') ] ) ] ) (C {(git)} {(commit)} {(-F)} {(log)}) (command.SimpleCommand words: [{(echo)} {(DQ ('second content line'))}] redirects: [(redir.Redir op:<Redir_DGreat '>>'> fd:16777215 arg_word:{(foo)})] ) (C {(git)} {(add)} {(foo)}) (C {(git)} {(commit)} {(-m)} {(DQ ('intermediate commit'))}) (command.SimpleCommand words: [{(echo)} {(DQ ('third content line'))}] redirects: [(redir.Redir op:<Redir_DGreat '>>'> fd:16777215 arg_word:{(foo)})] ) (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)}) ] )