diff options
author | Junio C Hamano <gitster@pobox.com> | 2014-07-02 12:53:02 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-07-02 12:53:02 -0700 |
commit | 8061ae8b4618d69a67ff6cfb687d7044964d4b04 (patch) | |
tree | fd75c5ef40caf10107f15e320bbb9501017ba695 /revision.c | |
parent | 95acfc2479967ba5f3e2ddfee1fa2eb89b386c4f (diff) | |
parent | 218aa3a6162b80696a82b8745daa38fa826985ae (diff) | |
download | git-8061ae8b4618d69a67ff6cfb687d7044964d4b04.tar.gz git-8061ae8b4618d69a67ff6cfb687d7044964d4b04.tar.xz |
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
Diffstat (limited to 'revision.c')
-rw-r--r-- | revision.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/revision.c b/revision.c index 8351e794d..2571ada6b 100644 --- a/revision.c +++ b/revision.c @@ -2791,7 +2791,7 @@ static int commit_match(struct commit *commit, struct rev_info *opt) { int retval; const char *encoding; - char *message; + const char *message; struct strbuf buf = STRBUF_INIT; if (!opt->grep_filter.pattern_list && !opt->grep_filter.header_list) @@ -2833,14 +2833,21 @@ static int commit_match(struct commit *commit, struct rev_info *opt) format_display_notes(commit->object.sha1, &buf, encoding, 1); } - /* Find either in the original commit message, or in the temporary */ + /* + * Find either in the original commit message, or in the temporary. + * Note that we cast away the constness of "message" here. It is + * const because it may come from the cached commit buffer. That's OK, + * because we know that it is modifiable heap memory, and that while + * grep_buffer may modify it for speed, it will restore any + * changes before returning. + */ if (buf.len) retval = grep_buffer(&opt->grep_filter, buf.buf, buf.len); else retval = grep_buffer(&opt->grep_filter, - message, strlen(message)); + (char *)message, strlen(message)); strbuf_release(&buf); - logmsg_free(message, commit); + unuse_commit_buffer(commit, message); return retval; } |