Merge branch 'jk/commit-buffer-length'
Move "commit->buffer" out of the in-core commit object and keep track of their lengths. Use this to optimize the code paths to validate GPG signatures in commit objects. * jk/commit-buffer-length: reuse cached commit buffer when parsing signatures commit: record buffer length in cache commit: convert commit->buffer to a slab commit-slab: provide a static initializer use get_commit_buffer everywhere convert logmsg_reencode to get_commit_buffer use get_commit_buffer to avoid duplicate code use get_cached_commit_buffer where appropriate provide helpers to access the commit buffer provide a helper to set the commit buffer provide a helper to free commit buffer sequencer: use logmsg_reencode in get_message logmsg_reencode: return const buffer do not create "struct commit" with xcalloc commit: push commit_index update into alloc_commit_node alloc: include any-object allocations in alloc_report replace dangerous uses of strbuf_attach commit_tree: take a pointer/len pair rather than a const strbuf
This commit is contained in:
@ -4,7 +4,8 @@
|
||||
#include "notes-utils.h"
|
||||
|
||||
void create_notes_commit(struct notes_tree *t, struct commit_list *parents,
|
||||
const struct strbuf *msg, unsigned char *result_sha1)
|
||||
const char *msg, size_t msg_len,
|
||||
unsigned char *result_sha1)
|
||||
{
|
||||
unsigned char tree_sha1[20];
|
||||
|
||||
@ -25,7 +26,7 @@ void create_notes_commit(struct notes_tree *t, struct commit_list *parents,
|
||||
/* else: t->ref points to nothing, assume root/orphan commit */
|
||||
}
|
||||
|
||||
if (commit_tree(msg, tree_sha1, parents, result_sha1, NULL, NULL))
|
||||
if (commit_tree(msg, msg_len, tree_sha1, parents, result_sha1, NULL, NULL))
|
||||
die("Failed to commit notes tree to database");
|
||||
}
|
||||
|
||||
@ -46,7 +47,7 @@ void commit_notes(struct notes_tree *t, const char *msg)
|
||||
if (buf.buf[buf.len - 1] != '\n')
|
||||
strbuf_addch(&buf, '\n'); /* Make sure msg ends with newline */
|
||||
|
||||
create_notes_commit(t, NULL, &buf, commit_sha1);
|
||||
create_notes_commit(t, NULL, buf.buf, buf.len, commit_sha1);
|
||||
strbuf_insert(&buf, 0, "notes: ", 7); /* commit message starts at index 7 */
|
||||
update_ref(buf.buf, t->ref, commit_sha1, NULL, 0,
|
||||
UPDATE_REFS_DIE_ON_ERR);
|
||||
|
||||
Reference in New Issue
Block a user