summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5b38456)
raw | patch | inline | side by side (parent: 5b38456)
author | Jeff King <peff@peff.net> | |
Thu, 26 May 2011 22:27:24 +0000 (18:27 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 26 May 2011 22:47:20 +0000 (15:47 -0700) |
Many callers don't actually care about the pretty print
context at all; let's just give them a simple way of
pretty-printing a commit without having to create a context
struct.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
context at all; let's just give them a simple way of
pretty-printing a commit without having to create a context
struct.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/branch.c | patch | blob | history | |
builtin/checkout.c | patch | blob | history | |
builtin/log.c | patch | blob | history | |
builtin/shortlog.c | patch | blob | history | |
builtin/show-branch.c | patch | blob | history | |
commit.h | patch | blob | history | |
pretty.c | patch | blob | history |
diff --git a/builtin/branch.c b/builtin/branch.c
index 9e546e4a83d07dd6dd4d4b0cb7d23a02c82747fb..d8f15221ed5b7f67875549685fe7aad92909a1d4 100644 (file)
--- a/builtin/branch.c
+++ b/builtin/branch.c
commit = item->commit;
if (commit && !parse_commit(commit)) {
- struct pretty_print_context ctx = {0};
- pretty_print_commit(CMIT_FMT_ONELINE, commit,
- &subject, &ctx);
+ pp_commit_easy(CMIT_FMT_ONELINE, commit, &subject);
sub = subject.buf;
}
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 757f9a08ddbaf102726a781b06d7294a4638984e..c1759dc3a44c7d4df4d9bed03f22ab7be8df2257 100644 (file)
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
static void describe_detached_head(char *msg, struct commit *commit)
{
struct strbuf sb = STRBUF_INIT;
- struct pretty_print_context ctx = {0};
parse_commit(commit);
- pretty_print_commit(CMIT_FMT_ONELINE, commit, &sb, &ctx);
+ pp_commit_easy(CMIT_FMT_ONELINE, commit, &sb);
fprintf(stderr, "%s %s... %s\n", msg,
find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV), sb.buf);
strbuf_release(&sb);
diff --git a/builtin/log.c b/builtin/log.c
index d8c6c28d2fcc3bd0744f071da536215141dc0d0b..cedfdb6d42b36f352545a5933ef0764ca362b948 100644 (file)
--- a/builtin/log.c
+++ b/builtin/log.c
if (verbose) {
struct strbuf buf = STRBUF_INIT;
- struct pretty_print_context ctx = {0};
- pretty_print_commit(CMIT_FMT_ONELINE, commit,
- &buf, &ctx);
+ pp_commit_easy(CMIT_FMT_ONELINE, commit, &buf);
printf("%c %s %s\n", sign,
find_unique_abbrev(commit->object.sha1, abbrev),
buf.buf);
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index 1a21e4b0538565f7a64488ed7b3a5c317e559699..90877b5fe26eb642b62a305989feb630b3377e5e 100644 (file)
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
const char *author = NULL, *buffer;
struct strbuf buf = STRBUF_INIT;
struct strbuf ufbuf = STRBUF_INIT;
- struct pretty_print_context ctx = {0};
- pretty_print_commit(CMIT_FMT_RAW, commit, &buf, &ctx);
+ pp_commit_easy(CMIT_FMT_RAW, commit, &buf);
buffer = buf.buf;
while (*buffer && *buffer != '\n') {
const char *eol = strchr(buffer, '\n');
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index da695815e26c281cbacfbf865dfa72da44df9f19..a5fc2aa88426b584945b132a21d2cc97176a0993 100644 (file)
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
struct commit_name *name = commit->util;
if (commit->object.parsed) {
- struct pretty_print_context ctx = {0};
- pretty_print_commit(CMIT_FMT_ONELINE, commit, &pretty, &ctx);
+ pp_commit_easy(CMIT_FMT_ONELINE, commit, &pretty);
pretty_str = pretty.buf;
}
if (!prefixcmp(pretty_str, "[PATCH] "))
diff --git a/commit.h b/commit.h
index eb6c5af1f6b18546b3b3f1683142b15bb0ae9e34..3e733be1acabda35066d05cf767da52e38bc54d6 100644 (file)
--- a/commit.h
+++ b/commit.h
extern void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit,
struct strbuf *sb,
const struct pretty_print_context *context);
+extern void pp_commit_easy(enum cmit_fmt fmt, const struct commit *commit,
+ struct strbuf *sb);
void pp_user_info(const char *what, enum cmit_fmt fmt, struct strbuf *sb,
const char *line, enum date_mode dmode,
const char *encoding);
diff --git a/pretty.c b/pretty.c
index 305ff85d744e40ce00879fd087205567c156bc51..75a9a416a4b1bc59725ff6cf93d5ec9baad9ede0 100644 (file)
--- a/pretty.c
+++ b/pretty.c
free(reencoded);
}
+
+void pp_commit_easy(enum cmit_fmt fmt, const struct commit *commit,
+ struct strbuf *sb)
+{
+ struct pretty_print_context pp = {0};
+ pretty_print_commit(fmt, commit, sb, &pp);
+}