- commit
- 8c45dfc58edc069a3787224f522c7f62da501a80
- parent
- 175094899d7c453786857d0e5a7d2e634611aea4
- Author
- Hiltjo Posthuma <hiltjo@codemadness.org>
- Date
- 2018-11-11 17:09
detect copies and renames based on the threshold of changes
Diffstat
M | stagit.c | 9 | +++++++++ |
1 files changed, 9 insertions, 0 deletions
diff --git a/stagit.c b/stagit.c
@@ -92,6 +92,7 @@ commitinfo_getstats(struct commitinfo *ci) 92 92 { 93 93 struct deltainfo *di; 94 94 git_diff_options opts; -1 95 git_diff_find_options fopts; 95 96 const git_diff_delta *delta; 96 97 const git_diff_hunk *hunk; 97 98 const git_diff_line *line; @@ -113,6 +114,12 @@ commitinfo_getstats(struct commitinfo *ci) 113 114 if (git_diff_tree_to_tree(&(ci->diff), repo, ci->parent_tree, ci->commit_tree, &opts)) 114 115 goto err; 115 116 -1 117 if (git_diff_find_init_options(&fopts, GIT_DIFF_FIND_OPTIONS_VERSION)) -1 118 goto err; -1 119 fopts.flags |= GIT_DIFF_FIND_RENAMES | GIT_DIFF_FIND_COPIES; -1 120 if (git_diff_find_similar(ci->diff, &fopts)) -1 121 goto err; -1 122 116 123 ndeltas = git_diff_num_deltas(ci->diff); 117 124 if (ndeltas && !(ci->deltas = calloc(ndeltas, sizeof(struct deltainfo *)))) 118 125 err(1, "calloc"); @@ -120,6 +127,7 @@ commitinfo_getstats(struct commitinfo *ci) 120 127 for (i = 0; i < ndeltas; i++) { 121 128 if (git_patch_from_diff(&patch, ci->diff, i)) 122 129 goto err; -1 130 123 131 if (!(di = calloc(1, sizeof(struct deltainfo)))) 124 132 err(1, "calloc"); 125 133 di->patch = patch; @@ -460,6 +468,7 @@ printshowfile(FILE *fp, struct commitinfo *ci) 460 468 fputs("<b>Diffstat:</b>\n<table>", fp); 461 469 for (i = 0; i < ci->ndeltas; i++) { 462 470 delta = git_patch_get_delta(ci->deltas[i]->patch); -1 471 463 472 fprintf(fp, "<tr><td><a href=\"#h%zu\">", i); 464 473 xmlencode(fp, delta->old_file.path, strlen(delta->old_file.path)); 465 474 if (strcmp(delta->old_file.path, delta->new_file.path)) {