git-commit: do not muck with commit message when no_edit is set.
Spotted by Linus and Darrin Thompson. When we took a commit message from -F <file> with an incomplete line, we appended "git status" output, which ended up attaching a lone "#" at the end. We still need the "do we have anything to commit?" check by running "status" (which has to know what to do in different cases with -i/-o/-a), but there is no point appending its output to the proposed commit message given by the user. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Apr 12, 2006 at 11:45 UTC
475443c8489d9167b944367d8ec8bfef77bee0a5
1 file changed
+12
-5
git-commit.sh
+12
-5
@@ -537,7 +537,7 @@ t)
537
;;
538
esac
539
540
-if [ -f "$GIT_DIR/MERGE_HEAD" ]; then
540
+if test -f "$GIT_DIR/MERGE_HEAD" && test -z "$no_edit"; then
541
echo "#"
542
echo "# It looks like you may be committing a MERGE."
543
echo "# If this is not correct, please remove the file"
@@ -605,16 +605,23 @@ else
605
current=
606
fi
607
608
-{
609
- test -z "$only_include_assumed" || echo "$only_include_assumed"
610
- run_status
611
-} >>"$GIT_DIR"/COMMIT_EDITMSG
608
+if test -z "$no_edit"
609
+then
610
+ {
611
+ test -z "$only_include_assumed" || echo "$only_include_assumed"
612
+ run_status
613
+ } >>"$GIT_DIR"/COMMIT_EDITMSG
614
+else
615
+ # we need to check if there is anything to commit
616
+ run_status >/dev/null
617
+fi
618
if [ "$?" != "0" -a ! -f "$GIT_DIR/MERGE_HEAD" -a -z "$amend" ]
619
then
620
rm -f "$GIT_DIR/COMMIT_EDITMSG"
621
run_status
622
exit 1
623
fi
624
+
625
case "$no_edit" in
626
'')
627
case "${VISUAL:-$EDITOR},$TERM" in