|
diff --git a/shared.c b/shared.c index bf0581f..f063894 100644 --- a/ shared.c+++ b/ shared.c |
|
@@ -471,49 +471,49 @@ int cgit_diff_files(const unsigned char *old_sha1, |
471 | return 1; |
471 | return 1; |
472 | |
472 | |
473 | diff_params.flags = XDF_NEED_MINIMAL; |
473 | diff_params.flags = XDF_NEED_MINIMAL; |
474 | emit_params.ctxlen = 3; |
474 | emit_params.ctxlen = 3; |
475 | emit_params.flags = XDL_EMIT_FUNCNAMES; |
475 | emit_params.flags = XDL_EMIT_FUNCNAMES; |
476 | emit_params.find_func = NULL; |
476 | emit_params.find_func = NULL; |
477 | emit_cb.outf = filediff_cb; |
477 | emit_cb.outf = filediff_cb; |
478 | emit_cb.priv = fn; |
478 | emit_cb.priv = fn; |
479 | xdl_diff(&file1, &file2, &diff_params, &emit_params, &emit_cb); |
479 | xdl_diff(&file1, &file2, &diff_params, &emit_params, &emit_cb); |
480 | return 0; |
480 | return 0; |
481 | } |
481 | } |
482 | |
482 | |
483 | void cgit_diff_tree(const unsigned char *old_sha1, |
483 | void cgit_diff_tree(const unsigned char *old_sha1, |
484 | const unsigned char *new_sha1, |
484 | const unsigned char *new_sha1, |
485 | filepair_fn fn, const char *prefix) |
485 | filepair_fn fn, const char *prefix) |
486 | { |
486 | { |
487 | struct diff_options opt; |
487 | struct diff_options opt; |
488 | int ret; |
488 | int ret; |
489 | int prefixlen; |
489 | int prefixlen; |
490 | |
490 | |
491 | diff_setup(&opt); |
491 | diff_setup(&opt); |
492 | opt.output_format = DIFF_FORMAT_CALLBACK; |
492 | opt.output_format = DIFF_FORMAT_CALLBACK; |
493 | opt.detect_rename = 1; |
493 | opt.detect_rename = 1; |
494 | opt.rename_limit = cgit_renamelimit; |
494 | opt.rename_limit = cgit_renamelimit; |
495 | opt.recursive = 1; |
495 | DIFF_OPT_SET(&opt, RECURSIVE); |
496 | opt.format_callback = cgit_diff_tree_cb; |
496 | opt.format_callback = cgit_diff_tree_cb; |
497 | opt.format_callback_data = fn; |
497 | opt.format_callback_data = fn; |
498 | if (prefix) { |
498 | if (prefix) { |
499 | opt.nr_paths = 1; |
499 | opt.nr_paths = 1; |
500 | opt.paths = &prefix; |
500 | opt.paths = &prefix; |
501 | prefixlen = strlen(prefix); |
501 | prefixlen = strlen(prefix); |
502 | opt.pathlens = &prefixlen; |
502 | opt.pathlens = &prefixlen; |
503 | } |
503 | } |
504 | diff_setup_done(&opt); |
504 | diff_setup_done(&opt); |
505 | |
505 | |
506 | if (old_sha1 && !is_null_sha1(old_sha1)) |
506 | if (old_sha1 && !is_null_sha1(old_sha1)) |
507 | ret = diff_tree_sha1(old_sha1, new_sha1, "", &opt); |
507 | ret = diff_tree_sha1(old_sha1, new_sha1, "", &opt); |
508 | else |
508 | else |
509 | ret = diff_root_tree_sha1(new_sha1, "", &opt); |
509 | ret = diff_root_tree_sha1(new_sha1, "", &opt); |
510 | diffcore_std(&opt); |
510 | diffcore_std(&opt); |
511 | diff_flush(&opt); |
511 | diff_flush(&opt); |
512 | } |
512 | } |
513 | |
513 | |
514 | void cgit_diff_commit(struct commit *commit, filepair_fn fn) |
514 | void cgit_diff_commit(struct commit *commit, filepair_fn fn) |
515 | { |
515 | { |
516 | unsigned char *old_sha1 = NULL; |
516 | unsigned char *old_sha1 = NULL; |
517 | |
517 | |
518 | if (commit->parents) |
518 | if (commit->parents) |
519 | old_sha1 = commit->parents->item->object.sha1; |
519 | old_sha1 = commit->parents->item->object.sha1; |
|