git-commit: filter out log message lines only when editor was run.
The current behaviour strips out lines starting with a # even when fed through stdin or -m. This is particularly bad when importing history from another SCM (tailor 0.9.23 uses git-commit). In the best cases all lines are stripped and the commit fails with a confusing "empty log message" error, but in many cases the commit is done, with loss of information. Note that it is quite peculiar to just have "#" handled as a leading comment char here. One commonly meet CVS: or CG: or STG: as prefixes, and using GIT: would be more robust as well as consistent with other commit tools. However, that would break any tool relying on the # (if any). Signed-off-by: Yann Dirson <ydirson@altern.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Yann Dirson committed
Jun 24, 2006 at 00:04 UTC
29f4ad867cd15f4029c280c417f4a0866d5229a9
1 file changed
+12
-7
git-commit.sh
+12
-7
@@ -693,13 +693,18 @@ t)
693
fi
694
esac
695
696
-sed -e '
697
- /^diff --git a\/.*/{
698
- s///
699
- q
700
- }
701
- /^#/d
702
-' "$GIT_DIR"/COMMIT_EDITMSG |
696
+if test -z "$no_edit"
697
+then
698
+ sed -e '
699
+ /^diff --git a\/.*/{
700
+ s///
701
+ q
702
+ }
703
+ /^#/d
704
+ ' "$GIT_DIR"/COMMIT_EDITMSG
705
+else
706
+ cat "$GIT_DIR"/COMMIT_EDITMSG
707
+fi |
708
git-stripspace >"$GIT_DIR"/COMMIT_MSG
709
710
if cnt=`grep -v -i '^Signed-off-by' "$GIT_DIR"/COMMIT_MSG |