Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Habouzit <madcoder@debian.org>2007-09-10 14:35:06 +0400
committerJunio C Hamano <gitster@pobox.com>2007-09-10 23:49:50 +0400
commit674d1727305211f7ade4ade70440220f74f55162 (patch)
tree9b47dc4f9045516f181e3fc134b34d6ea1f45d5c /builtin-branch.c
parent4acfd1b799acf43642a28a22cc794266c25129ef (diff)
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-branch.c')
-rw-r--r--builtin-branch.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/builtin-branch.c b/builtin-branch.c
index 5f5c1823cb..3da8b55b8f 100644
--- a/builtin-branch.c
+++ b/builtin-branch.c
@@ -268,23 +268,22 @@ static void print_ref_item(struct ref_item *item, int maxwidth, int verbose,
}
if (verbose) {
- char *subject = NULL;
- unsigned long subject_len = 0;
+ struct strbuf subject;
const char *sub = " **** invalid ref ****";
+ strbuf_init(&subject, 0);
+
commit = lookup_commit(item->sha1);
if (commit && !parse_commit(commit)) {
- pretty_print_commit(CMIT_FMT_ONELINE, commit, ~0,
- &subject, &subject_len, 0,
- NULL, NULL, 0);
- sub = subject;
+ pretty_print_commit(CMIT_FMT_ONELINE, commit,
+ &subject, 0, NULL, NULL, 0);
+ sub = subject.buf;
}
printf("%c %s%-*s%s %s %s\n", c, branch_get_color(color),
maxwidth, item->name,
branch_get_color(COLOR_BRANCH_RESET),
find_unique_abbrev(item->sha1, abbrev), sub);
- if (subject)
- free(subject);
+ strbuf_release(&subject);
} else {
printf("%c %s%s%s\n", c, branch_get_color(color), item->name,
branch_get_color(COLOR_BRANCH_RESET));