|
diff --git a/shared.c b/shared.c index 67eb67b..800c06a 100644 --- a/ shared.c+++ b/ shared.c |
|
@@ -450,32 +450,59 @@ void cgit_diff_tree(const unsigned char *old_sha1, |
450 | |
450 | |
451 | diff_setup(&opt); |
451 | diff_setup(&opt); |
452 | opt.output_format = DIFF_FORMAT_CALLBACK; |
452 | opt.output_format = DIFF_FORMAT_CALLBACK; |
453 | opt.detect_rename = 1; |
453 | opt.detect_rename = 1; |
454 | opt.rename_limit = ctx.cfg.renamelimit; |
454 | opt.rename_limit = ctx.cfg.renamelimit; |
455 | DIFF_OPT_SET(&opt, RECURSIVE); |
455 | DIFF_OPT_SET(&opt, RECURSIVE); |
456 | opt.format_callback = cgit_diff_tree_cb; |
456 | opt.format_callback = cgit_diff_tree_cb; |
457 | opt.format_callback_data = fn; |
457 | opt.format_callback_data = fn; |
458 | if (prefix) { |
458 | if (prefix) { |
459 | opt.nr_paths = 1; |
459 | opt.nr_paths = 1; |
460 | opt.paths = &prefix; |
460 | opt.paths = &prefix; |
461 | prefixlen = strlen(prefix); |
461 | prefixlen = strlen(prefix); |
462 | opt.pathlens = &prefixlen; |
462 | opt.pathlens = &prefixlen; |
463 | } |
463 | } |
464 | diff_setup_done(&opt); |
464 | diff_setup_done(&opt); |
465 | |
465 | |
466 | if (old_sha1 && !is_null_sha1(old_sha1)) |
466 | if (old_sha1 && !is_null_sha1(old_sha1)) |
467 | ret = diff_tree_sha1(old_sha1, new_sha1, "", &opt); |
467 | ret = diff_tree_sha1(old_sha1, new_sha1, "", &opt); |
468 | else |
468 | else |
469 | ret = diff_root_tree_sha1(new_sha1, "", &opt); |
469 | ret = diff_root_tree_sha1(new_sha1, "", &opt); |
470 | diffcore_std(&opt); |
470 | diffcore_std(&opt); |
471 | diff_flush(&opt); |
471 | diff_flush(&opt); |
472 | } |
472 | } |
473 | |
473 | |
474 | void cgit_diff_commit(struct commit *commit, filepair_fn fn) |
474 | void cgit_diff_commit(struct commit *commit, filepair_fn fn) |
475 | { |
475 | { |
476 | unsigned char *old_sha1 = NULL; |
476 | unsigned char *old_sha1 = NULL; |
477 | |
477 | |
478 | if (commit->parents) |
478 | if (commit->parents) |
479 | old_sha1 = commit->parents->item->object.sha1; |
479 | old_sha1 = commit->parents->item->object.sha1; |
480 | cgit_diff_tree(old_sha1, commit->object.sha1, fn, NULL); |
480 | cgit_diff_tree(old_sha1, commit->object.sha1, fn, NULL); |
481 | } |
481 | } |
| |
482 | |
| |
483 | int cgit_parse_snapshots_mask(const char *str) |
| |
484 | { |
| |
485 | const struct cgit_snapshot_format *f; |
| |
486 | static const char *delim = " \t,:/|;"; |
| |
487 | int tl, sl, rv = 0; |
| |
488 | |
| |
489 | /* favor legacy setting */ |
| |
490 | if(atoi(str)) |
| |
491 | return 1; |
| |
492 | for(;;) { |
| |
493 | str += strspn(str,delim); |
| |
494 | tl = strcspn(str,delim); |
| |
495 | if (!tl) |
| |
496 | break; |
| |
497 | for (f = cgit_snapshot_formats; f->suffix; f++) { |
| |
498 | sl = strlen(f->suffix); |
| |
499 | if((tl == sl && !strncmp(f->suffix, str, tl)) || |
| |
500 | (tl == sl-1 && !strncmp(f->suffix+1, str, tl-1))) { |
| |
501 | rv |= f->bit; |
| |
502 | break; |
| |
503 | } |
| |
504 | } |
| |
505 | str += tl; |
| |
506 | } |
| |
507 | return rv; |
| |
508 | } |
|