aboutsummaryrefslogtreecommitdiff
path: root/builtin/log.c
diff options
context:
space:
mode:
authorJonathan Nieder <jrnieder@gmail.com>2011-03-16 02:12:48 -0500
committerJunio C Hamano <gitster@pobox.com>2011-03-16 12:54:44 -0700
commita3a32e7f083cdd3b8e68419d2f012b5561a9ccde (patch)
treee2197a0199beceeeee8d6747acb9915471cd3828 /builtin/log.c
parent6e0332ec3ea74e635258a30d360bd2e00a51730e (diff)
downloadgit-a3a32e7f083cdd3b8e68419d2f012b5561a9ccde.tar.gz
git-a3a32e7f083cdd3b8e68419d2f012b5561a9ccde.tar.xz
cherry: split off function to print output lines
Readers uninterested in the details of "git cherry"'s output format can see print_commit('-', commit, verbose, abbrev); and ignore the details. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/log.c')
-rw-r--r--builtin/log.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/builtin/log.c b/builtin/log.c
index d8c6c28d2..0f43d2ec7 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1352,6 +1352,23 @@ static const char * const cherry_usage[] = {
NULL
};
+static void print_commit(char sign, struct commit *commit, int verbose,
+ int abbrev)
+{
+ if (!verbose) {
+ printf("%c %s\n", sign,
+ find_unique_abbrev(commit->object.sha1, abbrev));
+ } else {
+ struct strbuf buf = STRBUF_INIT;
+ struct pretty_print_context ctx = {0};
+ pretty_print_commit(CMIT_FMT_ONELINE, commit, &buf, &ctx);
+ printf("%c %s %s\n", sign,
+ find_unique_abbrev(commit->object.sha1, abbrev),
+ buf.buf);
+ strbuf_release(&buf);
+ }
+}
+
int cmd_cherry(int argc, const char **argv, const char *prefix)
{
struct rev_info revs;
@@ -1436,22 +1453,7 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
commit = list->item;
if (has_commit_patch_id(commit, &ids))
sign = '-';
-
- if (verbose) {
- struct strbuf buf = STRBUF_INIT;
- struct pretty_print_context ctx = {0};
- pretty_print_commit(CMIT_FMT_ONELINE, commit,
- &buf, &ctx);
- printf("%c %s %s\n", sign,
- find_unique_abbrev(commit->object.sha1, abbrev),
- buf.buf);
- strbuf_release(&buf);
- }
- else {
- printf("%c %s\n", sign,
- find_unique_abbrev(commit->object.sha1, abbrev));
- }
-
+ print_commit(sign, commit, verbose, abbrev);
list = list->next;
}