about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJohn Keeping2014-10-05 10:59:04 +0100
committerLukas Fleischer2014-12-13 12:38:42 +0100
commit1830271c5958526425f92ae2b369646b54e3c370 (patch)
tree545cca72fa7f672fe0a728f25a545dce10961d1d
parentui-shared: remove toggle_ssdiff arg to cgit_diff_link() (diff)
downloadcgit-1830271c5958526425f92ae2b369646b54e3c370.tar.gz
cgit-1830271c5958526425f92ae2b369646b54e3c370.zip
Change "ss" diff flag to an enum
This will allow us to introduce a new "stat only" diff mode without
needing an explosion of mutually incompatible flags.

The old "ss" query parameter is still accepted in order to avoid
breaking saved links, but we no longer generate any URIs using it;
instead the new "dt" (diff type) parameter is used.

Signed-off-by: John Keeping <john@keeping.me.uk>
-rw-r--r--cgit.c12
-rw-r--r--cgit.h10
-rw-r--r--ui-diff.c8
-rw-r--r--ui-shared.c8
4 files changed, 24 insertions, 14 deletions
diff --git a/cgit.c b/cgit.c index 8c4517d..db60107 100644 --- a/cgit.c +++ b/cgit.c
@@ -237,7 +237,7 @@ static void config_cb(const char *name, const char *value)
237 else if (!strcmp(name, "summary-tags")) 237 else if (!strcmp(name, "summary-tags"))
238 ctx.cfg.summary_tags = atoi(value); 238 ctx.cfg.summary_tags = atoi(value);
239 else if (!strcmp(name, "side-by-side-diffs")) 239 else if (!strcmp(name, "side-by-side-diffs"))
240 ctx.cfg.ssdiff = atoi(value); 240 ctx.cfg.difftype = atoi(value) ? DIFF_SSDIFF : DIFF_UNIFIED;
241 else if (!strcmp(name, "agefile")) 241 else if (!strcmp(name, "agefile"))
242 ctx.cfg.agefile = xstrdup(value); 242 ctx.cfg.agefile = xstrdup(value);
243 else if (!strcmp(name, "mimetype-file")) 243 else if (!strcmp(name, "mimetype-file"))
@@ -312,9 +312,13 @@ static void querystring_cb(const char *name, const char *value)
312 ctx.qry.showmsg = atoi(value); 312 ctx.qry.showmsg = atoi(value);
313 } else if (!strcmp(name, "period")) { 313 } else if (!strcmp(name, "period")) {
314 ctx.qry.period = xstrdup(value); 314 ctx.qry.period = xstrdup(value);
315 } else if (!strcmp(name, "dt")) {
316 ctx.qry.difftype = atoi(value);
317 ctx.qry.has_difftype = 1;
315 } else if (!strcmp(name, "ss")) { 318 } else if (!strcmp(name, "ss")) {
316 ctx.qry.ssdiff = atoi(value); 319 /* No longer generated, but there may be links out there. */
317 ctx.qry.has_ssdiff = 1; 320 ctx.qry.difftype = atoi(value) ? DIFF_SSDIFF : DIFF_UNIFIED;
321 ctx.qry.has_difftype = 1;
318 } else if (!strcmp(name, "all")) { 322 } else if (!strcmp(name, "all")) {
319 ctx.qry.show_all = atoi(value); 323 ctx.qry.show_all = atoi(value);
320 } else if (!strcmp(name, "context")) { 324 } else if (!strcmp(name, "context")) {
@@ -372,7 +376,7 @@ static void prepare_context(void)
372 ctx.cfg.summary_log = 10; 376 ctx.cfg.summary_log = 10;
373 ctx.cfg.summary_tags = 10; 377 ctx.cfg.summary_tags = 10;
374 ctx.cfg.max_atom_items = 10; 378 ctx.cfg.max_atom_items = 10;
375 ctx.cfg.ssdiff = 0; 379 ctx.cfg.difftype = DIFF_UNIFIED;
376 ctx.env.cgit_config = getenv("CGIT_CONFIG"); 380 ctx.env.cgit_config = getenv("CGIT_CONFIG");
377 ctx.env.http_host = getenv("HTTP_HOST"); 381 ctx.env.http_host = getenv("HTTP_HOST");
378 ctx.env.https = getenv("HTTPS"); 382 ctx.env.https = getenv("HTTPS");
diff --git a/cgit.h b/cgit.h index 0badc64..0eb5ed5 100644 --- a/cgit.h +++ b/cgit.h
@@ -53,6 +53,10 @@ typedef void (*filepair_fn)(struct diff_filepair *pair);
53typedef void (*linediff_fn)(char *line, int len); 53typedef void (*linediff_fn)(char *line, int len);
54 54
55typedef enum { 55typedef enum {
56 DIFF_UNIFIED, DIFF_SSDIFF
57} diff_type;
58
59typedef enum {
56 ABOUT, COMMIT, SOURCE, EMAIL, AUTH 60 ABOUT, COMMIT, SOURCE, EMAIL, AUTH
57} filter_type; 61} filter_type;
58 62
@@ -150,7 +154,7 @@ struct reflist {
150struct cgit_query { 154struct cgit_query {
151 int has_symref; 155 int has_symref;
152 int has_sha1; 156 int has_sha1;
153 int has_ssdiff; 157 int has_difftype;
154 char *raw; 158 char *raw;
155 char *repo; 159 char *repo;
156 char *page; 160 char *page;
@@ -168,7 +172,7 @@ struct cgit_query {
168 int nohead; 172 int nohead;
169 char *sort; 173 char *sort;
170 int showmsg; 174 int showmsg;
171 int ssdiff; 175 diff_type difftype;
172 int show_all; 176 int show_all;
173 int context; 177 int context;
174 int ignorews; 178 int ignorews;
@@ -245,7 +249,7 @@ struct cgit_config {
245 int summary_branches; 249 int summary_branches;
246 int summary_log; 250 int summary_log;
247 int summary_tags; 251 int summary_tags;
248 int ssdiff; 252 diff_type difftype;
249 int branch_sort; 253 int branch_sort;
250 int commit_sort; 254 int commit_sort;
251 struct string_list mimetypes; 255 struct string_list mimetypes;
diff --git a/ui-diff.c b/ui-diff.c index 49bd748..a4ade4d 100644 --- a/ui-diff.c +++ b/ui-diff.c
@@ -345,8 +345,8 @@ void cgit_print_diff_ctrls()
345 html("</tr><tr>"); 345 html("</tr><tr>");
346 html("<td class='label'>mode:</td>"); 346 html("<td class='label'>mode:</td>");
347 html("<td class='ctrl'>"); 347 html("<td class='ctrl'>");
348 html("<select name='ss' onchange='this.form.submit();'>"); 348 html("<select name='dt' onchange='this.form.submit();'>");
349 curr = ctx.qry.has_ssdiff ? ctx.qry.ssdiff : ctx.cfg.ssdiff; 349 curr = ctx.qry.has_difftype ? ctx.qry.difftype : ctx.cfg.difftype;
350 html_intoption(0, "unified", curr); 350 html_intoption(0, "unified", curr);
351 html_intoption(1, "ssdiff", curr); 351 html_intoption(1, "ssdiff", curr);
352 html("</select></td></tr>"); 352 html("</select></td></tr>");
@@ -362,6 +362,7 @@ void cgit_print_diff(const char *new_rev, const char *old_rev,
362{ 362{
363 struct commit *commit, *commit2; 363 struct commit *commit, *commit2;
364 const unsigned char *old_tree_sha1, *new_tree_sha1; 364 const unsigned char *old_tree_sha1, *new_tree_sha1;
365 diff_type difftype;
365 366
366 if (!new_rev) 367 if (!new_rev)
367 new_rev = ctx.qry.head; 368 new_rev = ctx.qry.head;
@@ -420,7 +421,8 @@ void cgit_print_diff(const char *new_rev, const char *old_rev,
420 return; 421 return;
421 } 422 }
422 423
423 use_ssdiff = ctx.qry.has_ssdiff ? ctx.qry.ssdiff : ctx.cfg.ssdiff; 424 difftype = ctx.qry.has_difftype ? ctx.qry.difftype : ctx.cfg.difftype;
425 use_ssdiff = difftype == DIFF_SSDIFF;
424 426
425 if (show_ctrls) 427 if (show_ctrls)
426 cgit_print_diff_ctrls(); 428 cgit_print_diff_ctrls();
diff --git a/ui-shared.c b/ui-shared.c index 68e0d7c..6243d1b 100644 --- a/ui-shared.c +++ b/ui-shared.c
@@ -346,9 +346,9 @@ void cgit_commit_link(char *name, const char *title, const char *class,
346 html_url_arg(rev); 346 html_url_arg(rev);
347 delim = "&amp;"; 347 delim = "&amp;";
348 } 348 }
349 if (ctx.qry.ssdiff) { 349 if (ctx.qry.difftype) {
350 html(delim); 350 html(delim);
351 html("ss=1"); 351 htmlf("dt=%d", ctx.qry.difftype);
352 delim = "&amp;"; 352 delim = "&amp;";
353 } 353 }
354 if (ctx.qry.context > 0 && ctx.qry.context != 3) { 354 if (ctx.qry.context > 0 && ctx.qry.context != 3) {
@@ -402,9 +402,9 @@ void cgit_diff_link(const char *name, const char *title, const char *class,
402 html_url_arg(old_rev); 402 html_url_arg(old_rev);
403 delim = "&amp;"; 403 delim = "&amp;";
404 } 404 }
405 if (ctx.qry.ssdiff) { 405 if (ctx.qry.difftype) {
406 html(delim); 406 html(delim);
407 html("ss=1"); 407 htmlf("dt=%d", ctx.qry.difftype);
408 delim = "&amp;"; 408 delim = "&amp;";
409 } 409 }
410 if (ctx.qry.context > 0 && ctx.qry.context != 3) { 410 if (ctx.qry.context > 0 && ctx.qry.context != 3) {