(CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <'git commit\n'> <'\n'> <'Tests for selected commit options.'>)} spids: [13] ) ] spids: [13] ) (C {(.)} {(./test-lib.sh)}) (FuncDef name: commit_msg_is body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:expect) op: Equal rhs: {(commit_msg_is.expect)} spids: [34] ) ] spids: [34] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:actual) op: Equal rhs: {(commit_msg_is.actual)} spids: [38] ) ] spids: [38] ) (AndOr children: [ (SimpleCommand words: [ {(printf)} {(DQ ('%s'))} { (DQ (CommandSubPart command_list: (CommandList children: [ (C {(git)} {(log)} {(--pretty) (Lit_Other '=') (format) (Lit_Other ':') (Lit_Other '%') (s) (Lit_Other '%') (b) } {(-1)} ) ] ) left_token: <Left_CommandSub '$('> spids: [50 65] ) ) } ] redirects: [ (Redir op_id: Redir_Great fd: 16777215 arg_word: {(DQ ($ VSub_Name '$actual'))} spids: [68] ) ] ) (AndOr children: [ (SimpleCommand words: [{(printf)} {(DQ ('%s'))} {(DQ ($ VSub_Number '$1'))}] redirects: [ (Redir op_id: Redir_Great fd: 16777215 arg_word: {(DQ ($ VSub_Name '$expect'))} spids: [86] ) ] ) (C {(test_i18ncmp)} {(DQ ($ VSub_Name '$expect'))} {(DQ ($ VSub_Name '$actual'))}) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] spids: [31] ) spids: [26 30] ) (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'> ) } ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:TEMPLATE) op: Equal rhs: {(DQ ($ VSub_Name '$PWD')) (/template)} spids: [162] ) ] 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'> ) } ) (SimpleCommand words: [{(cat)}] redirects: [ (Redir op_id: Redir_Great fd: 16777215 arg_word: {(DQ ($ VSub_Name '$TEMPLATE'))} spids: [317] ) (HereDoc op_id: Redir_DLess fd: 16777215 body: {('\n') ('\n') ('### template\n') ('\n')} do_expansion: False here_end: EOF was_filled: True spids: [322] ) ] ) (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'> ) } ) (SimpleCommand words: [{(cat)}] redirects: [ (Redir op_id:Redir_Great fd:16777215 arg_word:{(expect)} spids:[391]) (HereDoc op_id: Redir_DLess fd: 16777215 body: {(DQ ('zort\n') ('\n') ('Signed-off-by: C O Mitter <committer@example.com>\n'))} do_expansion: True here_end: EOF was_filled: True spids: [395] ) ] ) (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'> ) } ) (FuncDef name: commit_for_rebase_autosquash_setup body: (BraceGroup children: [ (AndOr children: [ (SimpleCommand words: [{(echo)} {(DQ ('first content line'))}] redirects: [(Redir op_id:Redir_DGreat fd:16777215 arg_word:{(foo)} spids:[567])] ) (AndOr children: [ (C {(git)} {(add)} {(foo)}) (AndOr children: [ (SimpleCommand words: [{(cat)}] redirects: [ (Redir op_id: Redir_Great fd: 16777215 arg_word: {(log)} spids: [584] ) (HereDoc op_id: Redir_DLess fd: 16777215 body: { (DQ ('target message subject line\n') ('\n') ('target message body line 1\n') ('target message body line 2\n') ) } do_expansion: True here_end: EOF was_filled: True spids: [587] ) ] ) (AndOr children: [ (C {(git)} {(commit)} {(-F)} {(log)}) (AndOr children: [ (SimpleCommand words: [{(echo)} {(DQ ('second content line'))}] redirects: [ (Redir op_id: Redir_DGreat fd: 16777215 arg_word: {(foo)} spids: [615] ) ] ) (AndOr children: [ (C {(git)} {(add)} {(foo)}) (AndOr children: [ (C {(git)} {(commit)} {(-m)} {(DQ ('intermediate commit'))}) (AndOr children: [ (SimpleCommand words: [{(echo)} {(DQ ('third content line'))}] redirects: [ (Redir op_id: Redir_DGreat fd: 16777215 arg_word: {(foo)} spids: [649] ) ] ) (C {(git)} {(add)} {(foo)}) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] spids: [558] ) spids: [553 557] ) (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)}) ] )