summaryrefslogtreecommitdiff
path: root/builtin/log.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-07-16 18:16:38 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-07-16 18:16:38 (GMT)
commit5c18fde0d96cfcbc321caad8f809028b0c63aaeb (patch)
tree0fbc3fd1a5ca630e2eeb6a0aa4484f848455bf5e /builtin/log.c
parent64630d807ae0a9717ae39c87bd1458bf15c62142 (diff)
parent218aa3a6162b80696a82b8745daa38fa826985ae (diff)
downloadgit-5c18fde0d96cfcbc321caad8f809028b0c63aaeb.zip
git-5c18fde0d96cfcbc321caad8f809028b0c63aaeb.tar.gz
git-5c18fde0d96cfcbc321caad8f809028b0c63aaeb.tar.bz2
Merge branch 'jk/commit-buffer-length' into maint
A handful of code paths had to read the commit object more than once when showing header fields that are usually not parsed. The internal data structure to keep track of the contents of the commit object has been updated to reduce the need for this double-reading, and to allow the caller find the length of the object. * 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 'builtin/log.c')
-rw-r--r--builtin/log.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/builtin/log.c b/builtin/log.c
index 3b6a6bb..4f67813 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -345,8 +345,7 @@ static int cmd_log_walk(struct rev_info *rev)
rev->max_count++;
if (!rev->reflog_info) {
/* we allow cycles in reflog ancestry */
- free(commit->buffer);
- commit->buffer = NULL;
+ free_commit_buffer(commit);
}
free_commit_list(commit->parents);
commit->parents = NULL;
@@ -915,9 +914,12 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
log_write_email_headers(rev, head, &pp.subject, &pp.after_subject,
&need_8bit_cte);
- for (i = 0; !need_8bit_cte && i < nr; i++)
- if (has_non_ascii(list[i]->buffer))
+ for (i = 0; !need_8bit_cte && i < nr; i++) {
+ const char *buf = get_commit_buffer(list[i], NULL);
+ if (has_non_ascii(buf))
need_8bit_cte = 1;
+ unuse_commit_buffer(list[i], buf);
+ }
if (!branch_name)
branch_name = find_branch_name(rev);
@@ -1504,8 +1506,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
reopen_stdout(rev.numbered_files ? NULL : commit, NULL, &rev, quiet))
die(_("Failed to create output files"));
shown = log_tree_commit(&rev, commit);
- free(commit->buffer);
- commit->buffer = NULL;
+ free_commit_buffer(commit);
/* We put one extra blank line between formatted
* patches and this flag is used by log-tree code