commit_tree: take a pointer/len pair rather than a const strbuf
While strbufs are pretty common throughout our code, it is
more flexible for functions to take a pointer/len pair than
a strbuf. It's easy to turn a strbuf into such a pair (by
dereferencing its members), but less easy to go the other
way (you can strbuf_attach, but that has implications about
memory ownership).
This patch teaches commit_tree (and its associated callers
and sub-functions) to take such a pair for the commit
message rather than a strbuf. This makes passing the buffer
around slightly more verbose, but means we can get rid of
some dangerous strbuf_attach calls in the next patch.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff --git a/notes-merge.c b/notes-merge.c
index 94a1a8a..9d94210 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -644,7 +644,8 @@
struct commit_list *parents = NULL;
commit_list_insert(remote, &parents); /* LIFO order */
commit_list_insert(local, &parents);
- create_notes_commit(local_tree, parents, &o->commit_msg,
+ create_notes_commit(local_tree, parents,
+ o->commit_msg.buf, o->commit_msg.len,
result_sha1);
}
@@ -720,7 +721,8 @@
}
strbuf_attach(&sb_msg, msg, strlen(msg), strlen(msg) + 1);
- create_notes_commit(partial_tree, partial_commit->parents, &sb_msg,
+ create_notes_commit(partial_tree, partial_commit->parents,
+ sb_msg.buf, sb_msg.len,
result_sha1);
if (o->verbosity >= 4)
printf("Finalized notes merge commit: %s\n",