|
|
detect copies and renames based on the threshold of changes - stagit-gopher - static git page generator for gopher |
|
|
 |
git clone git://git.codemadness.org/stagit-gopher (git://git.codemadness.org) |
|
|
 |
Log |
|
|
 |
Files |
|
|
 |
Refs |
|
|
 |
README |
|
|
 |
LICENSE |
|
|
|
--- |
|
|
 |
commit 3a00e5bb2bf0415338ff08d1a7bc9a47b4b751e2 |
|
|
 |
parent 8bad0e073142b1347085d04646fd64e11a7a7c2a |
|
|
 |
Author: Hiltjo Posthuma <hiltjo@codemadness.org> (mailto://) |
application/vnd.lotus-organizer |
|
|
Date: Sun, 11 Nov 2018 18:57:50 +0100 |
|
|
|
|
|
|
|
detect copies and renames based on the threshold of changes |
|
|
|
|
|
|
|
Diffstat: |
|
|
|
M stagit-gopher.c | 9 +++++++++ |
|
|
|
|
|
|
|
1 file changed, 9 insertions(+), 0 deletions(-) |
|
|
|
--- |
|
|
 |
diff --git a/stagit-gopher.c b/stagit-gopher.c |
|
|
|
@@ -140,6 +140,7 @@ commitinfo_getstats(struct commitinfo *ci) |
|
|
|
{ |
|
|
|
struct deltainfo *di; |
|
|
|
git_diff_options opts; |
|
|
|
+ git_diff_find_options fopts; |
|
|
|
const git_diff_delta *delta; |
|
|
|
const git_diff_hunk *hunk; |
|
|
|
const git_diff_line *line; |
|
|
|
@@ -161,6 +162,12 @@ commitinfo_getstats(struct commitinfo *ci) |
|
|
|
if (git_diff_tree_to_tree(&(ci->diff), repo, ci->parent_tree, ci->commit_tree, &opts)) |
|
|
|
goto err; |
|
|
|
|
|
|
|
+ if (git_diff_find_init_options(&fopts, GIT_DIFF_FIND_OPTIONS_VERSION)) |
|
|
|
+ goto err; |
|
|
|
+ fopts.flags |= GIT_DIFF_FIND_RENAMES | GIT_DIFF_FIND_COPIES; |
|
|
|
+ if (git_diff_find_similar(ci->diff, &fopts)) |
|
|
|
+ goto err; |
|
|
|
+ |
|
|
|
ndeltas = git_diff_num_deltas(ci->diff); |
|
|
|
if (ndeltas && !(ci->deltas = calloc(ndeltas, sizeof(struct deltainfo *)))) |
|
|
|
err(1, "calloc"); |
|
|
|
@@ -168,6 +175,7 @@ commitinfo_getstats(struct commitinfo *ci) |
|
|
|
for (i = 0; i < ndeltas; i++) { |
|
|
|
if (git_patch_from_diff(&patch, ci->diff, i)) |
|
|
|
goto err; |
|
|
|
+ |
|
|
|
if (!(di = calloc(1, sizeof(struct deltainfo)))) |
|
|
|
err(1, "calloc"); |
|
|
|
di->patch = patch; |
|
|
|
@@ -567,6 +575,7 @@ printshowfile(FILE *fp, struct commitinfo *ci) |
|
|
|
fputs("Diffstat:\n", fp); |
|
|
|
for (i = 0; i < ci->ndeltas; i++) { |
|
|
|
delta = git_patch_get_delta(ci->deltas[i]->patch); |
|
|
|
+ |
|
|
|
if (strcmp(delta->old_file.path, delta->new_file.path)) { |
|
|
|
snprintf(filename, sizeof(filename), "%s -> %s", |
|
|
|
delta->old_file.path, delta->new_file.path); |
|