diff options
author | Jeff King <peff@peff.net> | 2014-06-10 17:41:39 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-06-13 12:08:17 -0700 |
commit | b66103c3baa593a39b8b0751213b9fce60e94de4 (patch) | |
tree | 3bdd4603011427fe37e0d9a90d3a910860e22238 /builtin | |
parent | use get_commit_buffer to avoid duplicate code (diff) | |
download | tgif-b66103c3baa593a39b8b0751213b9fce60e94de4.tar.xz |
convert logmsg_reencode to get_commit_buffer
Like the callsites in the previous commit, logmsg_reencode
already falls back to read_sha1_file when necessary.
However, I split its conversion out into its own commit
because it's a bit more complex.
We return either:
1. The original commit->buffer
2. A newly allocated buffer from read_sha1_file
3. A reencoded buffer (based on either 1 or 2 above).
while trying to do as few extra reads/allocations as
possible. Callers currently free the result with
logmsg_free, but we can simplify this by pointing them
straight to unuse_commit_buffer. This is a slight layering
violation, in that we may be passing a buffer from (3).
However, since the end result is to free() anything except
(1), which is unlikely to change, and because this makes the
interface much simpler, it's a reasonable bending of the
rules.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/blame.c | 4 | ||||
-rw-r--r-- | builtin/reset.c | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/builtin/blame.c b/builtin/blame.c index 38784ab9d6..857d98a324 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -1416,7 +1416,7 @@ static void get_commit_info(struct commit *commit, &ret->author_time, &ret->author_tz); if (!detailed) { - logmsg_free(message, commit); + unuse_commit_buffer(commit, message); return; } @@ -1430,7 +1430,7 @@ static void get_commit_info(struct commit *commit, else strbuf_addf(&ret->summary, "(%s)", sha1_to_hex(commit->object.sha1)); - logmsg_free(message, commit); + unuse_commit_buffer(commit, message); } /* diff --git a/builtin/reset.c b/builtin/reset.c index b5312c4c65..6bd6245821 100644 --- a/builtin/reset.c +++ b/builtin/reset.c @@ -109,7 +109,7 @@ static void print_new_head_line(struct commit *commit) } else printf("\n"); - logmsg_free(msg, commit); + unuse_commit_buffer(commit, msg); } static void update_index_from_diff(struct diff_queue_struct *q, |