Skip to content

Commit 29f4ad8

Browse files
ydirsonJunio C Hamano
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 817151e commit 29f4ad8

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

git-commit.sh

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -693,13 +693,18 @@ t)
693693
fi
694694
esac
695695

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 |
703708
git-stripspace >"$GIT_DIR"/COMMIT_MSG
704709

705710
if cnt=`grep -v -i '^Signed-off-by' "$GIT_DIR"/COMMIT_MSG |

0 commit comments

Comments
 (0)