Convert commit_tree() to take strbuf as message
There wan't a way for commit_tree() to notice if the message the caller prepared contained a NUL byte, as it did not take the length of the message as a parameter. Use a pointer to a strbuf instead, so that we can either choose to allow low-level plumbing commands to make commits that contain NUL byte in its message, or forbid NUL everywhere by adding the check in commit_tree(), in later patches. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
6b3c4c0547
commit
13f8b72d8c
@ -913,7 +913,7 @@ static int merge_trivial(struct commit *head)
|
||||
parent->next->item = remoteheads->item;
|
||||
parent->next->next = NULL;
|
||||
prepare_to_commit();
|
||||
if (commit_tree(merge_msg.buf, result_tree, parent, result_commit, NULL))
|
||||
if (commit_tree(&merge_msg, result_tree, parent, result_commit, NULL))
|
||||
die(_("failed to write commit object"));
|
||||
finish(head, result_commit, "In-index merge");
|
||||
drop_save();
|
||||
@ -945,7 +945,7 @@ static int finish_automerge(struct commit *head,
|
||||
strbuf_addch(&merge_msg, '\n');
|
||||
prepare_to_commit();
|
||||
free_commit_list(remoteheads);
|
||||
if (commit_tree(merge_msg.buf, result_tree, parents, result_commit, NULL))
|
||||
if (commit_tree(&merge_msg, result_tree, parents, result_commit, NULL))
|
||||
die(_("failed to write commit object"));
|
||||
strbuf_addf(&buf, "Merge made by the '%s' strategy.", wt_strategy);
|
||||
finish(head, result_commit, buf.buf);
|
||||
|
Reference in New Issue
Block a user