path: root/builtin/fmt-merge-msg.c
diff options
authorJeff King <>2014-06-10 21:44:13 (GMT)
committerJunio C Hamano <>2014-06-13 19:09:38 (GMT)
commit8597ea3afea067b39ba7d4adae7ec6c1ee0e7c91 (patch)
tree01419168b4f08949baeabe5b8650066e6a92732c /builtin/fmt-merge-msg.c
parentc1b3c71f4b4571abb2b2a457122fd100dc9f7eb0 (diff)
commit: record buffer length in cache
Most callsites which use the commit buffer try to use the cached version attached to the commit, rather than re-reading from disk. Unfortunately, that interface provides only a pointer to the NUL-terminated buffer, with no indication of the original length. For the most part, this doesn't matter. People do not put NULs in their commit messages, and the log code is happy to treat it all as a NUL-terminated string. However, some code paths do care. For example, when checking signatures, we want to be very careful that we verify all the bytes to avoid malicious trickery. This patch just adds an optional "size" out-pointer to get_commit_buffer and friends. The existing callers all pass NULL (there did not seem to be any obvious sites where we could avoid an immediate strlen() call, though perhaps with some further refactoring we could). Signed-off-by: Jeff King <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'builtin/fmt-merge-msg.c')
1 files changed, 1 insertions, 1 deletions
diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c
index 01f6d59..ef8b254 100644
--- a/builtin/fmt-merge-msg.c
+++ b/builtin/fmt-merge-msg.c
@@ -236,7 +236,7 @@ static void record_person(int which, struct string_list *people,
const char *field;
field = (which == 'a') ? "\nauthor " : "\ncommitter ";
- buffer = get_commit_buffer(commit);
+ buffer = get_commit_buffer(commit, NULL);
name = strstr(buffer, field);
if (!name)