From 03de8b68f17396d7710d2584c6a6fc786c26279f Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Sat, 22 Mar 2014 18:05:42 -0700 Subject: Add support for log output minus another branch This lets you do the equivalent of git log ^ref1 ref2 by adding an id2 parameter to a log url --- cmd.c | 6 +++--- ui-log.c | 14 +++++++++++--- ui-log.h | 4 ++-- ui-summary.c | 2 +- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/cmd.c b/cmd.c index 188cd56..253cbc3 100644 --- a/cmd.c +++ b/cmd.c @@ -71,9 +71,9 @@ static void info_fn(void) static void log_fn(void) { - cgit_print_log(ctx.qry.sha1, ctx.qry.ofs, ctx.cfg.max_commit_count, - ctx.qry.grep, ctx.qry.search, ctx.qry.path, 1, - ctx.repo->enable_commit_graph, + cgit_print_log(ctx.qry.sha1, ctx.qry.sha2, ctx.qry.ofs, + ctx.cfg.max_commit_count, ctx.qry.grep, ctx.qry.search, + ctx.qry.path, 1, ctx.repo->enable_commit_graph, ctx.repo->commit_sort); } diff --git a/ui-log.c b/ui-log.c index 499534c..824da02 100644 --- a/ui-log.c +++ b/ui-log.c @@ -285,18 +285,24 @@ static char *next_token(char **src) return result; } -void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern, - char *path, int pager, int commit_graph, int commit_sort) +void cgit_print_log(const char *tip, const char *from, int ofs, int cnt, + char *grep, char *pattern, char *path, int pager, + int commit_graph, int commit_sort) { struct rev_info rev; struct commit *commit; struct argv_array rev_argv = ARGV_ARRAY_INIT; int i, columns = commit_graph ? 4 : 3; - int must_free_tip = 0; + int must_free_tip = 0, must_free_from = 0; /* rev_argv.argv[0] will be ignored by setup_revisions */ argv_array_push(&rev_argv, "log_rev_setup"); + if (from) { + from = disambiguate_ref(from, &must_free_from); + argv_array_pushf(&rev_argv, "^%s", from); + } + if (!tip) tip = ctx.qry.head; tip = disambiguate_ref(tip, &must_free_tip); @@ -430,4 +436,6 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern /* If we allocated tip then it is safe to cast away const. */ if (must_free_tip) free((char*) tip); + if (must_free_from) + free((char*) from); } diff --git a/ui-log.h b/ui-log.h index d324c92..7f55044 100644 --- a/ui-log.h +++ b/ui-log.h @@ -1,8 +1,8 @@ #ifndef UI_LOG_H #define UI_LOG_H -extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, - char *pattern, char *path, int pager, +extern void cgit_print_log(const char *tip, const char *from, int ofs, int cnt, + char *grep, char *pattern, char *path, int pager, int commit_graph, int commit_sort); extern void show_commit_decorations(struct commit *commit); diff --git a/ui-summary.c b/ui-summary.c index ddd8f1b..2c41cff 100644 --- a/ui-summary.c +++ b/ui-summary.c @@ -85,7 +85,7 @@ void cgit_print_summary() cgit_print_tags(ctx.cfg.summary_tags); if (ctx.cfg.summary_log > 0) { htmlf(" ", columns); - cgit_print_log(ctx.qry.head, 0, ctx.cfg.summary_log, NULL, + cgit_print_log(ctx.qry.head, NULL, 0, ctx.cfg.summary_log, NULL, NULL, NULL, 0, 0, 0); } if (ctx.repo->clone_url) -- cgit v1.2.3