author | Lars Hjemli <hjemli@gmail.com> | 2010-06-22 14:16:12 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2010-06-22 14:16:12 (UTC) |
commit | 6f92f332e6a9ee3e16051bda9fe148607af67f65 (patch) (side-by-side diff) | |
tree | 49cb7d145fbf40793b220efdc92cd80ab2c6ca05 | |
parent | 37a24e4e39737edaa5cdde501346a65eeb280e63 (diff) | |
parent | d20313e3daf855ee5d4808e050f54614c200d7b1 (diff) | |
download | cgit-6f92f332e6a9ee3e16051bda9fe148607af67f65.zip cgit-6f92f332e6a9ee3e16051bda9fe148607af67f65.tar.gz cgit-6f92f332e6a9ee3e16051bda9fe148607af67f65.tar.bz2 |
Merge branch 'jh/context-lines'
Conflicts:
cgit.c
cgit.h
-rw-r--r-- | cgit.c | 2 | ||||
-rw-r--r-- | cgit.h | 3 | ||||
-rw-r--r-- | shared.c | 5 | ||||
-rw-r--r-- | ui-diff.c | 14 | ||||
-rw-r--r-- | ui-log.c | 2 | ||||
-rw-r--r-- | ui-patch.c | 2 | ||||
-rw-r--r-- | ui-shared.c | 14 |
7 files changed, 34 insertions, 8 deletions
@@ -259,4 +259,6 @@ static void querystring_cb(const char *name, const char *value) } else if (!strcmp(name, "all")) { ctx.qry.show_all = atoi(value); + } else if (!strcmp(name, "context")) { + ctx.qry.context = atoi(value); } } @@ -148,4 +148,5 @@ struct cgit_query { int ssdiff; int show_all; + int context; char *vpath; }; @@ -279,5 +280,5 @@ extern int cgit_diff_files(const unsigned char *old_sha1, const unsigned char *new_sha1, unsigned long *old_size, unsigned long *new_size, - int *binary, linediff_fn fn); + int *binary, int context, linediff_fn fn); extern void cgit_diff_tree(const unsigned char *old_sha1, @@ -264,5 +264,6 @@ int filediff_cb(void *priv, mmbuffer_t *mb, int nbuf) int cgit_diff_files(const unsigned char *old_sha1, const unsigned char *new_sha1, unsigned long *old_size, - unsigned long *new_size, int *binary, linediff_fn fn) + unsigned long *new_size, int *binary, int context, + linediff_fn fn) { mmfile_t file1, file2; @@ -291,5 +292,5 @@ int cgit_diff_files(const unsigned char *old_sha1, memset(&emit_cb, 0, sizeof(emit_cb)); diff_params.flags = XDF_NEED_MINIMAL; - emit_params.ctxlen = 3; + emit_params.ctxlen = context > 0 ? context : 3; emit_params.flags = XDL_EMIT_FUNCNAMES; emit_cb.outf = filediff_cb; @@ -128,5 +128,5 @@ static void inspect_filepair(struct diff_filepair *pair) lines_removed = 0; cgit_diff_files(pair->one->sha1, pair->two->sha1, &old_size, &new_size, - &binary, count_diff_lines); + &binary, 0, count_diff_lines); if (files >= slots) { if (slots == 0) @@ -157,5 +157,5 @@ void cgit_print_diffstat(const unsigned char *old_sha1, const unsigned char *new_sha1, const char *prefix) { - int i; + int i, save_context = ctx.qry.context; html("<div class='diffstat-header'>"); @@ -164,4 +164,12 @@ void cgit_print_diffstat(const unsigned char *old_sha1, if (prefix) htmlf(" (limited to '%s')", prefix); + html(" ("); + ctx.qry.context = (save_context > 0 ? save_context : 3) << 1; + cgit_self_link("more", NULL, NULL, &ctx); + html("/"); + ctx.qry.context = (save_context > 3 ? save_context : 3) >> 1; + cgit_self_link("less", NULL, NULL, &ctx); + ctx.qry.context = save_context; + html(" context)"); html("</div>"); html("<table summary='diffstat' class='diffstat'>"); @@ -289,5 +297,5 @@ static void filepair_cb(struct diff_filepair *pair) } if (cgit_diff_files(pair->one->sha1, pair->two->sha1, &old_size, - &new_size, &binary, print_line_fn)) + &new_size, &binary, ctx.qry.context, print_line_fn)) cgit_print_error("Error running diff"); if (binary) { @@ -34,5 +34,5 @@ void inspect_files(struct diff_filepair *pair) if (ctx.repo->enable_log_linecount) cgit_diff_files(pair->one->sha1, pair->two->sha1, &old_size, - &new_size, &binary, count_lines); + &new_size, &binary, 0, count_lines); } @@ -72,5 +72,5 @@ static void filepair_cb(struct diff_filepair *pair) } if (cgit_diff_files(pair->one->sha1, pair->two->sha1, &old_size, - &new_size, &binary, print_line)) + &new_size, &binary, 0, print_line)) html("Error running diff"); if (binary) diff --git a/ui-shared.c b/ui-shared.c index e991799..c99bcec 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -342,4 +342,11 @@ void cgit_commit_link(char *name, const char *title, const char *class, html(delim); html("ss=1"); + delim = "&"; + } + if (ctx.qry.context > 0 && ctx.qry.context != 3) { + html(delim); + html("context="); + htmlf("%d", ctx.qry.context); + delim = "&"; } html("'>"); @@ -383,4 +390,11 @@ void cgit_diff_link(const char *name, const char *title, const char *class, html(delim); html("ss=1"); + delim = "&"; + } + if (ctx.qry.context > 0 && ctx.qry.context != 3) { + html(delim); + html("context="); + htmlf("%d", ctx.qry.context); + delim = "&"; } html("'>"); |