diff options
author | Pierre Habouzit <madcoder@debian.org> | 2007-09-10 12:35:06 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2007-09-10 12:49:50 -0700 |
commit | 674d1727305211f7ade4ade70440220f74f55162 (patch) | |
tree | 9b47dc4f9045516f181e3fc134b34d6ea1f45d5c /builtin-log.c | |
parent | 4acfd1b799acf43642a28a22cc794266c25129ef (diff) | |
download | git-674d1727305211f7ade4ade70440220f74f55162.tar.gz |
Rework pretty_print_commit to use strbufs instead of custom buffers.
Also remove the "len" parameter, as:
(1) it was used as a max boundary, and every caller used ~0u
(2) we check for final NUL no matter what, so it doesn't help for speed.
As a result most of the pp_* function takes 3 arguments less, and we need
a lot less local variables, this makes the code way more readable, and
easier to extend if needed.
This patch also fixes some spacing and cosmetic issues.
This patch also fixes (as a side effect) a memory leak intoruced in
builtin-archive.c at commit df4a394f (fmt was xmalloc'ed and not free'd)
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-log.c')
-rw-r--r-- | builtin-log.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/builtin-log.c b/builtin-log.c index fa81c25920..e1d3e7d74b 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -763,13 +763,13 @@ int cmd_cherry(int argc, const char **argv, const char *prefix) sign = '-'; if (verbose) { - char *buf = NULL; - unsigned long buflen = 0; - pretty_print_commit(CMIT_FMT_ONELINE, commit, ~0, - &buf, &buflen, 0, NULL, NULL, 0); + struct strbuf buf; + strbuf_init(&buf, 0); + pretty_print_commit(CMIT_FMT_ONELINE, commit, + &buf, 0, NULL, NULL, 0); printf("%c %s %s\n", sign, - sha1_to_hex(commit->object.sha1), buf); - free(buf); + sha1_to_hex(commit->object.sha1), buf.buf); + strbuf_release(&buf); } else { printf("%c %s\n", sign, |