diff --git a/commit.c b/commit.c
index b78127403be65f5c26e35e53a59b91860396194a..44bc96d44d391209d3a60e9e8c1b98ed209e6b4a 100644 (file)
--- a/commit.c
+++ b/commit.c
}
}
}
}
-int commit_tree(const char *msg, unsigned char *tree,
+int commit_tree(const struct strbuf *msg, unsigned char *tree,
struct commit_list *parents, unsigned char *ret,
const char *author)
{
struct commit_list *parents, unsigned char *ret,
const char *author)
{
"You may want to amend it after fixing the message, or set the config\n"
"variable i18n.commitencoding to the encoding your project uses.\n";
"You may want to amend it after fixing the message, or set the config\n"
"variable i18n.commitencoding to the encoding your project uses.\n";
-int commit_tree_extended(const char *msg, unsigned char *tree,
+int commit_tree_extended(const struct strbuf *msg, unsigned char *tree,
struct commit_list *parents, unsigned char *ret,
const char *author, struct commit_extra_header *extra)
{
struct commit_list *parents, unsigned char *ret,
const char *author, struct commit_extra_header *extra)
{
assert_sha1_type(tree, OBJ_TREE);
assert_sha1_type(tree, OBJ_TREE);
+ if (memchr(msg->buf, '\0', msg->len))
+ return error("a NUL byte in commit log message not allowed.");
+
/* Not having i18n.commitencoding is the same as having utf-8 */
encoding_is_utf8 = is_encoding_utf8(git_commit_encoding);
/* Not having i18n.commitencoding is the same as having utf-8 */
encoding_is_utf8 = is_encoding_utf8(git_commit_encoding);
strbuf_addch(&buffer, '\n');
/* And add the comment */
strbuf_addch(&buffer, '\n');
/* And add the comment */
- strbuf_addstr(&buffer, msg);
+ strbuf_addbuf(&buffer, msg);
/* And check the encoding */
if (encoding_is_utf8 && !is_utf8(buffer.buf))
/* And check the encoding */
if (encoding_is_utf8 && !is_utf8(buffer.buf))