From 6180e6169d6e87a3bea7e4da835dca17f93e5cfd Mon Sep 17 00:00:00 2001 From: Johan Herland Date: Thu, 10 Jun 2010 20:15:27 +0200 Subject: Add URL parameter 'context' for changing the number of context lines in diffs The new ctx.qry.context variable is picked up by cgit_print_diff(), and passed via cgit_diff_files() to Git's diff machinery. Signed-off-by: Johan Herland Signed-off-by: Lars Hjemli --- ui-diff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ui-diff.c') diff --git a/ui-diff.c b/ui-diff.c index fb836df..d3a3b2c 100644 --- a/ui-diff.c +++ b/ui-diff.c @@ -127,7 +127,7 @@ static void inspect_filepair(struct diff_filepair *pair) lines_added = 0; 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) slots = 4; @@ -288,7 +288,7 @@ static void filepair_cb(struct diff_filepair *pair) return; } 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) { if (use_ssdiff) -- cgit 1.4.1 From d20313e3daf855ee5d4808e050f54614c200d7b1 Mon Sep 17 00:00:00 2001 From: Johan Herland Date: Thu, 10 Jun 2010 20:15:51 +0200 Subject: ui-diff: Add links to increase/decrease number of context lines in diffs Add two links to the "Diffstat" line to show more/less context lines in the generated diff. To support this, cgit_commit_link() and cgit_diff_link() has learned to preserve the ctx.qry.context variable. Signed-off-by: Johan Herland Signed-off-by: Lars Hjemli --- ui-diff.c | 10 +++++++++- ui-shared.c | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) (limited to 'ui-diff.c') diff --git a/ui-diff.c b/ui-diff.c index d3a3b2c..e0a72f7 100644 --- a/ui-diff.c +++ b/ui-diff.c @@ -156,13 +156,21 @@ static void inspect_filepair(struct diff_filepair *pair) 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("
"); cgit_diff_link("Diffstat", NULL, NULL, ctx.qry.head, ctx.qry.sha1, ctx.qry.sha2, NULL, 0); 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("
"); html(""); max_changes = 0; diff --git a/ui-shared.c b/ui-shared.c index e991799..c99bcec 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -341,6 +341,13 @@ void cgit_commit_link(char *name, const char *title, const char *class, if ((ctx.qry.ssdiff && !toggle_ssdiff) || (!ctx.qry.ssdiff && toggle_ssdiff)) { 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("'>"); html_txt(name); @@ -382,6 +389,13 @@ void cgit_diff_link(const char *name, const char *title, const char *class, if ((ctx.qry.ssdiff && !toggle_ssdiff) || (!ctx.qry.ssdiff && toggle_ssdiff)) { 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("'>"); html_txt(name); -- cgit 1.4.1 option
Lars Hjemli
This new option is used to specify an external command which will be executed when displaying blob content in the tree view. Blob content will be written to STDIN of the filter and STDOUT from the filter will be included verbatim in the html output from cgit. The file name of the blob will be passed as the only argument to the filter command. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-07-31ui-snapshot: use cgit_{open|close}_filter() to execute compressorsLars Hjemli
This simplifies the code in ui-snapshot.c and makes the test-suite verify the new filter-functions. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-07-31Add generic filter/plugin infrastructureLars Hjemli
The functions cgit_open_filter() and cgit_close_filter() can be used to execute filters on the output stream from cgit. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-07-25cgit.h: keep config flags sortedLars Hjemli
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-07-25cgitrc.5.txt: document 'embedded' and 'noheader'Lars Hjemli
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-07-25Add support for 'noheader' optionLars Hjemli
This option can be used to disable the standard cgit page header, which might be useful in combination with the 'embedded' option. Suggested-by: Mark Constable <markc@renta.net> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-07-25cgitrc.5.txt: document 'head-include'Lars Hjemli
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-07-25ui-blob: return 'application/octet-stream' for binary blobsLars Hjemli
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-07-25ui-plain: Return 'application/octet-stream' for binary files.Remko Tronçon
Signed-off-by: Remko Tronçon <git@el-tramo.be> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-06-11use cgit_httpscheme() for atom feedDiego Ongaro
2009-06-11add cgit_httpscheme() -> http:// or https://Diego Ongaro
2009-06-07Return http statuscode 404 on unknown branchLars Hjemli
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-06-07Add head-include configuration option.Mark Lodato
This patch adds an option to the configuration file, "head-include", which works just like "header" or "footer", except the content is put into the HTML's <head> tag.
2009-03-15CGIT 0.8.2.1Lars Hjemli
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-03-15Fix doc-related glitches in Makefile and .gitignoreLars Hjemli
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-03-15ui-snapshot: avoid segfault when no filename is specifiedLars Hjemli
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-03-15fix segfault when displaying empty blobsEric Wong
When size is zero, subtracting one from it turns it into ULONG_MAX which causes an out-of-bounds access on buf. Signed-off-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-02-19Add support for HEAD requestsLars Hjemli
This is a quick 'n dirty hack which makes cgit honor HEAD requests. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-02-19Add support for ETag in 'plain' viewLars Hjemli
When downloading a blob identified by its path, the client might want to know if the blob has been modified since a previous download of the same path. To this end, an ETag containing the blob SHA1 seems to be ideal. Todo: add support for HEAD requests... Suggested-by: Owen Taylor <otaylor@redhat.com> Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-02-12ui-tree: escape ascii-text properly in hexdump viewLars Hjemli
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
2009-02-12Makefile: add doc-related targetsLars Hjemli