summaryrefslogtreecommitdiff
path: root/notes-cache.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2011-12-15 13:47:22 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-12-15 18:46:42 (GMT)
commit13f8b72d8c8e24215a3dd7771592b30083f1c740 (patch)
tree090da017d258dc9d29af8c270d287f61d44b150a /notes-cache.c
parent6b3c4c05475d206fafd650d8d27c82a8b051ac30 (diff)
downloadgit-13f8b72d8c8e24215a3dd7771592b30083f1c740.zip
git-13f8b72d8c8e24215a3dd7771592b30083f1c740.tar.gz
git-13f8b72d8c8e24215a3dd7771592b30083f1c740.tar.bz2
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>
Diffstat (limited to 'notes-cache.c')
-rw-r--r--notes-cache.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/notes-cache.c b/notes-cache.c
index 4c8984e..bea013e 100644
--- a/notes-cache.c
+++ b/notes-cache.c
@@ -48,6 +48,7 @@ int notes_cache_write(struct notes_cache *c)
{
unsigned char tree_sha1[20];
unsigned char commit_sha1[20];
+ struct strbuf msg = STRBUF_INIT;
if (!c || !c->tree.initialized || !c->tree.ref || !*c->tree.ref)
return -1;
@@ -56,7 +57,9 @@ int notes_cache_write(struct notes_cache *c)
if (write_notes_tree(&c->tree, tree_sha1))
return -1;
- if (commit_tree(c->validity, tree_sha1, NULL, commit_sha1, NULL) < 0)
+ strbuf_attach(&msg, c->validity,
+ strlen(c->validity), strlen(c->validity) + 1);
+ if (commit_tree(&msg, tree_sha1, NULL, commit_sha1, NULL) < 0)
return -1;
if (update_ref("update notes cache", c->tree.ref, commit_sha1, NULL,
0, QUIET_ON_ERR) < 0)