3 test_description
='git commit porcelain-ish'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8 TEST_PASSES_SANITIZE_LEAK
=true
12 expect
=commit_msg_is.expect
13 actual
=commit_msg_is.actual
15 printf "%s" "$(git log --pretty=format:%s%b -1)" >$actual &&
16 printf "%s" "$1" >$expect &&
17 test_cmp
$expect $actual
20 # Arguments: [<prefix] [<commit message>] [<commit options>]
21 check_summary_oneline
() {
23 git commit
${3+"$3"} -m "$2" >raw
&&
27 SUMMARY_PREFIX
="$(git name-rev --name-only HEAD)" &&
29 # append the "special" prefix, like "root-commit", "detached HEAD"
32 SUMMARY_PREFIX
="$SUMMARY_PREFIX ($1)"
36 SUMMARY_POSTFIX
="$(git log -1 --pretty='format:%h')"
37 echo "[$SUMMARY_PREFIX $SUMMARY_POSTFIX] $2" >exp
&&
42 trailer_commit_base
() {
45 git commit
-s --trailer "Signed-off-by=C1 E1 " \
46 --trailer "Helped-by:C2 E2 " \
47 --trailer "Reported-by=C3 E3" \
48 --trailer "Mentored-by:C4 E4" \
52 test_expect_success
'output summary format' '
56 check_summary_oneline "root-commit" "initial" &&
58 echo change >>file1 &&
62 test_expect_success
'output summary format: root-commit' '
63 check_summary_oneline "" "a change"
66 test_expect_success
'output summary format for commit with an empty diff' '
68 check_summary_oneline "" "empty" "--allow-empty"
71 test_expect_success
'output summary format for merges' '
73 git checkout -b recursive-base &&
74 test_commit base file1 &&
76 git checkout -b recursive-a recursive-base &&
77 test_commit commit-a file1 &&
79 git checkout -b recursive-b recursive-base &&
80 test_commit commit-b file1 &&
83 git checkout recursive-a &&
84 test_must_fail git merge recursive-b &&
85 # resolve the conflict
86 echo commit-a >file1 &&
88 check_summary_oneline "" "Merge"
91 output_tests_cleanup
() {
92 # this is needed for "do not fire editor in the presence of conflicts"
95 # this is needed for the "partial removal" test to pass
97 git commit
-m "cleanup"
100 test_expect_success
'the basics' '
102 output_tests_cleanup &&
104 echo doing partial >"commit is" &&
106 echo very much encouraged but we should >not/forbid &&
107 git add "commit is" not &&
108 echo update added "commit is" file >"commit is" &&
109 echo also update another >not/forbid &&
111 git commit -a -m "initial with -a" &&
113 git cat-file blob HEAD:"commit is" >current.1 &&
114 git cat-file blob HEAD:not/forbid >current.2 &&
116 cmp current.1 "commit is" &&
117 cmp current.2 not/forbid
121 test_expect_success
'partial' '
123 echo another >"commit is" &&
124 echo another >not/forbid &&
126 git commit -m "partial commit to handle a file" "commit is" &&
128 changed=$(git diff-tree --name-only HEAD^ HEAD) &&
129 test "$changed" = "commit is"
133 test_expect_success
'partial modification in a subdirectory' '
136 git commit -m "partial commit to subdirectory" not &&
138 changed=$(git diff-tree -r --name-only HEAD^ HEAD) &&
139 test "$changed" = "not/forbid"
143 test_expect_success
'partial removal' '
146 git commit -m "partial commit to remove not/forbid" not &&
148 changed=$(git diff-tree -r --name-only HEAD^ HEAD) &&
149 test "$changed" = "not/forbid" &&
150 remain=$(git ls-tree -r --name-only HEAD) &&
151 test "$remain" = "commit is"
155 test_expect_success
'sign off' '
159 git commit -s -m "thank you" &&
160 git cat-file commit HEAD >commit.msg &&
161 sed -ne "s/Signed-off-by: //p" commit.msg >actual &&
162 git var GIT_COMMITTER_IDENT >ident &&
163 sed -e "s/>.*/>/" ident >expected &&
164 test_cmp expected actual
168 test_expect_success
'commit --trailer with "="' '
169 trailer_commit_base &&
170 cat >expected <<-\EOF &&
173 Signed-off-by: C O Mitter <committer@example.com>
179 git cat-file commit HEAD >commit.msg &&
180 sed -e "1,/^\$/d" commit.msg >actual &&
181 test_cmp expected actual
184 test_expect_success
'commit --trailer with -c and "replace" as ifexists' '
185 trailer_commit_base &&
186 cat >expected <<-\EOF &&
189 Signed-off-by: C O Mitter <committer@example.com>
195 git -c trailer.ifexists="replace" \
196 commit --trailer "Mentored-by: C4 E4" \
197 --trailer "Helped-by: C3 E3" \
199 git cat-file commit HEAD >commit.msg &&
200 sed -e "1,/^\$/d" commit.msg >actual &&
201 test_cmp expected actual
204 test_expect_success
'commit --trailer with -c and "add" as ifexists' '
205 trailer_commit_base &&
206 cat >expected <<-\EOF &&
209 Signed-off-by: C O Mitter <committer@example.com>
217 git -c trailer.ifexists="add" \
218 commit --trailer "Reported-by: C3 E3" \
219 --trailer "Mentored-by: C4 E4" \
221 git cat-file commit HEAD >commit.msg &&
222 sed -e "1,/^\$/d" commit.msg >actual &&
223 test_cmp expected actual
226 test_expect_success
'commit --trailer with -c and "donothing" as ifexists' '
227 trailer_commit_base &&
228 cat >expected <<-\EOF &&
231 Signed-off-by: C O Mitter <committer@example.com>
238 git -c trailer.ifexists="donothing" \
239 commit --trailer "Mentored-by: C5 E5" \
240 --trailer "Reviewed-by: C6 E6" \
242 git cat-file commit HEAD >commit.msg &&
243 sed -e "1,/^\$/d" commit.msg >actual &&
244 test_cmp expected actual
247 test_expect_success
'commit --trailer with -c and "addIfDifferent" as ifexists' '
248 trailer_commit_base &&
249 cat >expected <<-\EOF &&
252 Signed-off-by: C O Mitter <committer@example.com>
259 git -c trailer.ifexists="addIfDifferent" \
260 commit --trailer "Reported-by: C3 E3" \
261 --trailer "Mentored-by: C5 E5" \
263 git cat-file commit HEAD >commit.msg &&
264 sed -e "1,/^\$/d" commit.msg >actual &&
265 test_cmp expected actual
268 test_expect_success
'commit --trailer with -c and "addIfDifferentNeighbor" as ifexists' '
269 trailer_commit_base &&
270 cat >expected <<-\EOF &&
273 Signed-off-by: C O Mitter <committer@example.com>
280 git -c trailer.ifexists="addIfDifferentNeighbor" \
281 commit --trailer "Mentored-by: C4 E4" \
282 --trailer "Reported-by: C3 E3" \
284 git cat-file commit HEAD >commit.msg &&
285 sed -e "1,/^\$/d" commit.msg >actual &&
286 test_cmp expected actual
289 test_expect_success
'commit --trailer with -c and "end" as where' '
290 trailer_commit_base &&
291 cat >expected <<-\EOF &&
294 Signed-off-by: C O Mitter <committer@example.com>
302 git -c trailer.where="end" \
303 commit --trailer "Reported-by: C3 E3" \
304 --trailer "Mentored-by: C4 E4" \
306 git cat-file commit HEAD >commit.msg &&
307 sed -e "1,/^\$/d" commit.msg >actual &&
308 test_cmp expected actual
311 test_expect_success
'commit --trailer with -c and "start" as where' '
312 trailer_commit_base &&
313 cat >expected <<-\EOF &&
317 Signed-off-by: C O Mitter <committer@example.com>
323 git -c trailer.where="start" \
324 commit --trailer "Signed-off-by: C O Mitter <committer@example.com>" \
325 --trailer "Signed-off-by: C1 E1" \
327 git cat-file commit HEAD >commit.msg &&
328 sed -e "1,/^\$/d" commit.msg >actual &&
329 test_cmp expected actual
332 test_expect_success
'commit --trailer with -c and "after" as where' '
333 trailer_commit_base &&
334 cat >expected <<-\EOF &&
337 Signed-off-by: C O Mitter <committer@example.com>
344 git -c trailer.where="after" \
345 commit --trailer "Mentored-by: C4 E4" \
346 --trailer "Mentored-by: C5 E5" \
348 git cat-file commit HEAD >commit.msg &&
349 sed -e "1,/^\$/d" commit.msg >actual &&
350 test_cmp expected actual
353 test_expect_success
'commit --trailer with -c and "before" as where' '
354 trailer_commit_base &&
355 cat >expected <<-\EOF &&
358 Signed-off-by: C O Mitter <committer@example.com>
366 git -c trailer.where="before" \
367 commit --trailer "Mentored-by: C3 E3" \
368 --trailer "Mentored-by: C2 E2" \
370 git cat-file commit HEAD >commit.msg &&
371 sed -e "1,/^\$/d" commit.msg >actual &&
372 test_cmp expected actual
375 test_expect_success
'commit --trailer with -c and "donothing" as ifmissing' '
376 trailer_commit_base &&
377 cat >expected <<-\EOF &&
380 Signed-off-by: C O Mitter <committer@example.com>
387 git -c trailer.ifmissing="donothing" \
388 commit --trailer "Helped-by: C5 E5" \
389 --trailer "Based-by: C6 E6" \
391 git cat-file commit HEAD >commit.msg &&
392 sed -e "1,/^\$/d" commit.msg >actual &&
393 test_cmp expected actual
396 test_expect_success
'commit --trailer with -c and "add" as ifmissing' '
397 trailer_commit_base &&
398 cat >expected <<-\EOF &&
401 Signed-off-by: C O Mitter <committer@example.com>
409 git -c trailer.ifmissing="add" \
410 commit --trailer "Helped-by: C5 E5" \
411 --trailer "Based-by: C6 E6" \
413 git cat-file commit HEAD >commit.msg &&
414 sed -e "1,/^\$/d" commit.msg >actual &&
415 test_cmp expected actual
418 test_expect_success
'commit --trailer with -c ack.key ' '
419 echo "fun" >>file1 &&
421 cat >expected <<-\EOF &&
426 git -c trailer.ack.key="Acked-by" \
427 commit --trailer "ack = Peff" -m "hello" &&
428 git cat-file commit HEAD >commit.msg &&
429 sed -e "1,/^\$/d" commit.msg >actual &&
430 test_cmp expected actual
433 test_expect_success
'commit --trailer with -c and ":=#" as separators' '
434 echo "fun" >>file1 &&
436 cat >expected <<-\EOF &&
441 git -c trailer.separators=":=#" \
442 -c trailer.bug.key="Bug #" \
443 commit --trailer "bug = 42" -m "I hate bug" &&
444 git cat-file commit HEAD >commit.msg &&
445 sed -e "1,/^\$/d" commit.msg >actual &&
446 test_cmp expected actual
449 test_expect_success
'commit --trailer with -c and command' '
450 trailer_commit_base &&
451 cat >expected <<-\EOF &&
454 Signed-off-by: C O Mitter <committer@example.com>
458 Reported-by: A U Thor <author@example.com>
460 git -c trailer.report.key="Reported-by: " \
461 -c trailer.report.ifexists="replace" \
462 -c trailer.report.command="NAME=\"\$ARG\"; test -n \"\$NAME\" && \
463 git log --author=\"\$NAME\" -1 --format=\"format:%aN <%aE>\" || true" \
464 commit --trailer "report = author" --amend &&
465 git cat-file commit HEAD >commit.msg &&
466 sed -e "1,/^\$/d" commit.msg >actual &&
467 test_cmp expected actual
470 test_expect_success
'commit --trailer not confused by --- separator' '
478 git commit --allow-empty --trailer="my-trailer: value" -F msg &&
482 echo "my-trailer: value"
484 git cat-file commit HEAD >commit.msg &&
485 sed -e "1,/^\$/d" commit.msg >actual &&
486 test_cmp expected actual
489 test_expect_success
'commit --trailer with --verbose' '
495 GIT_EDITOR=: git commit --edit -F msg --allow-empty \
496 --trailer="my-trailer: value" --verbose &&
500 echo "my-trailer: value"
502 git cat-file commit HEAD >commit.msg &&
503 sed -e "1,/^\$/d" commit.msg >actual &&
504 test_cmp expected actual
507 test_expect_success
'multiple -m' '
511 git commit -m "one" -m "two" -m "three" &&
512 actual=$(git cat-file commit HEAD >tmp && sed -e "1,/^\$/d" tmp && rm tmp) &&
513 expected=$(test_write_lines "one" "" "two" "" "three") &&
514 test "z$actual" = "z$expected"
518 test_expect_success
'verbose' '
520 echo minus >negative &&
522 git status -v >raw &&
523 sed -ne "/^diff --git /p" raw >actual &&
524 echo "diff --git a/negative b/negative" >expect &&
525 test_cmp expect actual
529 test_expect_success
'verbose respects diff config' '
531 test_config diff.noprefix true &&
532 git status -v >actual &&
533 grep "diff --git negative negative" actual
536 mesg_with_comment_and_newlines
='
541 test_expect_success
'prepare file with comment line and trailing newlines' '
542 printf "%s" "$mesg_with_comment_and_newlines" >expect
545 test_expect_success
'cleanup commit messages (verbatim option,-t)' '
548 git commit --cleanup=verbatim --no-status -t expect -a &&
549 git cat-file -p HEAD >raw &&
550 sed -e "1,/^\$/d" raw >actual &&
551 test_cmp expect actual
555 test_expect_success
'cleanup commit messages (verbatim option,-F)' '
558 git commit --cleanup=verbatim -F expect -a &&
559 git cat-file -p HEAD >raw &&
560 sed -e "1,/^\$/d" raw >actual &&
561 test_cmp expect actual
565 test_expect_success
'cleanup commit messages (verbatim option,-m)' '
568 git commit --cleanup=verbatim -m "$mesg_with_comment_and_newlines" -a &&
569 git cat-file -p HEAD >raw &&
570 sed -e "1,/^\$/d" raw >actual &&
571 test_cmp expect actual
575 test_expect_success
'cleanup commit messages (whitespace option,-F)' '
578 test_write_lines "" "# text" "" >text &&
579 echo "# text" >expect &&
580 git commit --cleanup=whitespace -F text -a &&
581 git cat-file -p HEAD >raw &&
582 sed -e "1,/^\$/d" raw >actual &&
583 test_cmp expect actual
587 test_expect_success
'cleanup commit messages (scissors option,-F,-e)' '
594 # ------------------------ >8 ------------------------
596 # ------------------------ >8 ------------------------
598 # ------------------------ >8 ------------------------
602 cat >expect <<-\EOF &&
605 # ------------------------ >8 ------------------------
608 git commit --cleanup=scissors -e -F text -a &&
609 git cat-file -p HEAD >raw &&
610 sed -e "1,/^\$/d" raw >actual &&
611 test_cmp expect actual
614 test_expect_success
'cleanup commit messages (scissors option,-F,-e, scissors on first line)' '
618 # ------------------------ >8 ------------------------
621 git commit --cleanup=scissors -e -F text -a --allow-empty-message &&
622 git cat-file -p HEAD >raw &&
623 sed -e "1,/^\$/d" raw >actual &&
624 test_must_be_empty actual
627 test_expect_success
'cleanup commit messages (strip option,-F)' '
630 test_write_lines "" "# text" "sample" "" >text &&
631 echo sample >expect &&
632 git commit --cleanup=strip -F text -a &&
633 git cat-file -p HEAD >raw &&
634 sed -e "1,/^\$/d" raw >actual &&
635 test_cmp expect actual
639 test_expect_success
'cleanup commit messages (strip option,-F,-e)' '
642 test_write_lines "" "sample" "" >text &&
643 git commit -e -F text -a &&
644 head -n 4 .git/COMMIT_EDITMSG >actual
649 # Please enter the commit message for your changes. Lines starting
650 # with '#' will be ignored, and an empty message aborts the commit." >expect
652 test_expect_success
'cleanup commit messages (strip option,-F,-e): output' '
653 test_cmp expect actual
656 test_expect_success
'cleanup commit message (fail on invalid cleanup mode option)' '
657 test_must_fail git commit --cleanup=non-existent
660 test_expect_success
'cleanup commit message (fail on invalid cleanup mode configuration)' '
661 test_must_fail git -c commit.cleanup=non-existent commit
664 test_expect_success
'cleanup commit message (no config and no option uses default)' '
665 echo content >>file &&
668 test_set_editor "$TEST_DIRECTORY"/t7500/add-content-and-comment &&
669 git commit --no-status
671 commit_msg_is "commit message"
674 test_expect_success
'cleanup commit message (option overrides default)' '
675 echo content >>file &&
678 test_set_editor "$TEST_DIRECTORY"/t7500/add-content-and-comment &&
679 git commit --cleanup=whitespace --no-status
681 commit_msg_is "commit message # comment"
684 test_expect_success
'cleanup commit message (config overrides default)' '
685 echo content >>file &&
688 test_set_editor "$TEST_DIRECTORY"/t7500/add-content-and-comment &&
689 git -c commit.cleanup=whitespace commit --no-status
691 commit_msg_is "commit message # comment"
694 test_expect_success
'cleanup commit message (option overrides config)' '
695 echo content >>file &&
698 test_set_editor "$TEST_DIRECTORY"/t7500/add-content-and-comment &&
699 git -c commit.cleanup=whitespace commit --cleanup=default
701 commit_msg_is "commit message"
704 test_expect_success
'cleanup commit message (default, -m)' '
705 echo content >>file &&
707 git commit -m "message #comment " &&
708 commit_msg_is "message #comment"
711 test_expect_success
'cleanup commit message (whitespace option, -m)' '
712 echo content >>file &&
714 git commit --cleanup=whitespace --no-status -m "message #comment " &&
715 commit_msg_is "message #comment"
718 test_expect_success
'cleanup commit message (whitespace config, -m)' '
719 echo content >>file &&
721 git -c commit.cleanup=whitespace commit --no-status -m "message #comment " &&
722 commit_msg_is "message #comment"
725 test_expect_success
'message shows author when it is not equal to committer' '
727 git commit -e -m "sample" -a &&
729 "^# Author: *A U Thor <author@example.com>\$" \
733 test_expect_success
'message shows date when it is explicitly set' '
734 git commit --allow-empty -e -m foo --date="2010-01-02T03:04:05" &&
736 "^# Date: *Sat Jan 2 03:04:05 2010 +0000" \
740 test_expect_success
'message does not have multiple scissors lines' '
741 git commit --cleanup=scissors -v --allow-empty -e -m foo &&
742 test $(grep -c -e "--- >8 ---" .git/COMMIT_EDITMSG) -eq 1
745 test_expect_success AUTOIDENT
'message shows committer when it is automatic' '
749 sane_unset GIT_COMMITTER_EMAIL &&
750 sane_unset GIT_COMMITTER_NAME &&
751 git commit -e -m "sample" -a
753 # the ident is calculated from the system, so we cannot
754 # check the actual value, only that it is there
755 test_grep "^# Committer: " .git/COMMIT_EDITMSG
758 write_script .git
/FAKE_EDITOR
<<EOF
759 echo editor started >"$(pwd)/.git/result"
763 test_expect_success
!FAIL_PREREQS
,!AUTOIDENT
'do not fire editor when committer is bogus' '
768 sane_unset GIT_COMMITTER_EMAIL &&
769 sane_unset GIT_COMMITTER_NAME &&
770 GIT_EDITOR="\"$(pwd)/.git/FAKE_EDITOR\"" &&
772 test_must_fail git commit -e -m sample -a
774 test_must_be_empty .git/result
777 test_expect_success
'do not fire editor if -m <msg> was given' '
780 echo "editor not started" >.git/result &&
781 (GIT_EDITOR="\"$(pwd)/.git/FAKE_EDITOR\"" git commit -m tick) &&
782 test "$(cat .git/result)" = "editor not started"
785 test_expect_success
'do not fire editor if -m "" was given' '
788 echo "editor not started" >.git/result &&
789 (GIT_EDITOR="\"$(pwd)/.git/FAKE_EDITOR\"" \
790 git commit -m "" --allow-empty-message) &&
791 test "$(cat .git/result)" = "editor not started"
794 test_expect_success
'do not fire editor in the presence of conflicts' '
799 git commit -m "add g" &&
804 git commit -m "modify g and add h" &&
805 git checkout second &&
808 git commit -m second &&
809 # Must fail due to conflict
810 test_must_fail git cherry-pick -n main &&
811 echo "editor not started" >.git/result &&
813 GIT_EDITOR="\"$(pwd)/.git/FAKE_EDITOR\"" &&
815 test_must_fail git commit
817 test "$(cat .git/result)" = "editor not started"
820 write_script .git
/FAKE_EDITOR
<<EOF
821 # kill -TERM command added below.
824 test_expect_success EXECKEEPSPID
'a SIGTERM should break locks' '
826 ! "$SHELL_PATH" -c '\''
827 echo kill -TERM $$ >>.git/FAKE_EDITOR
828 GIT_EDITOR=.git/FAKE_EDITOR
830 exec git commit -a'\'' &&
831 test ! -f .git/index.lock
834 rm -f .git
/MERGE_MSG .git
/COMMIT_EDITMSG
837 test_expect_success
'Hand committing of a redundant merge removes dups' '
839 git rev-parse second main >expect &&
840 test_must_fail git merge second main &&
841 git checkout main g &&
842 EDITOR=: git commit -a &&
843 git cat-file commit HEAD >raw &&
844 sed -n -e "s/^parent //p" -e "/^$/q" raw >actual &&
845 test_cmp expect actual
849 test_expect_success
'A single-liner subject with a token plus colon is not a footer' '
852 git commit -s -m "hello: kitty" --allow-empty &&
853 git cat-file commit HEAD >raw &&
854 sed -e "1,/^$/d" raw >actual &&
855 test_line_count = 3 actual
859 test_expect_success
'commit -s places sob on third line after two empty lines' '
860 git commit -s --allow-empty --allow-empty-message &&
861 cat <<-EOF >expect &&
864 Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>
867 sed -e "/^#/d" -e "s/^:.*//" .git/COMMIT_EDITMSG >actual &&
868 test_cmp expect actual
871 write_script .git
/FAKE_EDITOR
<<\EOF
879 echo '## Custom template' >template
884 GIT_EDITOR
=.git
/FAKE_EDITOR git commit
-a $
* $use_template &&
885 case "$use_template" in
887 test_grep
! "^## Custom template" .git
/COMMIT_EDITMSG
;;
889 test_grep
"^## Custom template" .git
/COMMIT_EDITMSG
;;
893 try_commit_status_combo
() {
895 test_expect_success
'commit' '
897 test_grep "^# Changes to be committed:" .git/COMMIT_EDITMSG
900 test_expect_success
'commit --status' '
901 try_commit --status &&
902 test_grep "^# Changes to be committed:" .git/COMMIT_EDITMSG
905 test_expect_success
'commit --no-status' '
906 try_commit --no-status &&
907 test_grep ! "^# Changes to be committed:" .git/COMMIT_EDITMSG
910 test_expect_success
'commit with commit.status = yes' '
911 test_config commit.status yes &&
913 test_grep "^# Changes to be committed:" .git/COMMIT_EDITMSG
916 test_expect_success
'commit with commit.status = no' '
917 test_config commit.status no &&
919 test_grep ! "^# Changes to be committed:" .git/COMMIT_EDITMSG
922 test_expect_success
'commit --status with commit.status = yes' '
923 test_config commit.status yes &&
924 try_commit --status &&
925 test_grep "^# Changes to be committed:" .git/COMMIT_EDITMSG
928 test_expect_success
'commit --no-status with commit.status = yes' '
929 test_config commit.status yes &&
930 try_commit --no-status &&
931 test_grep ! "^# Changes to be committed:" .git/COMMIT_EDITMSG
934 test_expect_success
'commit --status with commit.status = no' '
935 test_config commit.status no &&
936 try_commit --status &&
937 test_grep "^# Changes to be committed:" .git/COMMIT_EDITMSG
940 test_expect_success
'commit --no-status with commit.status = no' '
941 test_config commit.status no &&
942 try_commit --no-status &&
943 test_grep ! "^# Changes to be committed:" .git/COMMIT_EDITMSG
948 try_commit_status_combo
950 use_template
="-t template"
952 try_commit_status_combo
954 test_expect_success
'commit --status with custom comment character' '
955 test_config core.commentchar ";" &&
956 try_commit --status &&
957 test_grep "^; Changes to be committed:" .git/COMMIT_EDITMSG
960 test_expect_success
'switch core.commentchar' '
961 test_commit "#foo" foo &&
962 GIT_EDITOR=.git/FAKE_EDITOR git -c core.commentChar=auto commit --amend &&
963 test_grep "^; Changes to be committed:" .git/COMMIT_EDITMSG
966 test_expect_success
'switch core.commentchar but out of options' '
979 git commit --amend -F text &&
981 test_set_editor .git/FAKE_EDITOR &&
982 test_must_fail git -c core.commentChar=auto commit --amend