stagit

git site generator
Contents

detect copies and renames based on the threshold of changes

Hiltjo Posthuma hiltjo@codemadness.org

commit: cda576d parent: f30beaa
1 files changed, 9 insertions(+), 0 deletions(-)
Mstagit.c+9-0
M · stagit.c +9, -0
 1@@ -92,6 +92,7 @@ commitinfo_getstats(struct commitinfo *ci)
 2 {
 3 struct deltainfo
*di;
 4 git_diff_options
opts;
 5+ git_diff_find_options fopts;
 6 const git_diff_delta *delta;
 7 const
git_diff_hunk *hunk;
 8 const
git_diff_line *line;
 9@@ -113,6 +114,12 @@ commitinfo_getstats(struct commitinfo *ci)
10 if (git_diff_tree_to_tree(&(ci->diff),
repo, ci->parent_tree, ci->commit_tree, &opts))
11 goto err;
12
13+ if (git_diff_find_init_options(&fopts, GIT_DIFF_FIND_OPTIONS_VERSION))
14+ goto err;
15+ fopts.flags |=
GIT_DIFF_FIND_RENAMES | GIT_DIFF_FIND_COPIES;
16+ if
(git_diff_find_similar(ci->diff, &fopts))
17+ goto err;
18+
19 ndeltas = git_diff_num_deltas(ci->diff);
20 if (ndeltas
&& !(ci->deltas = calloc(ndeltas, sizeof(struct deltainfo *))))
21 err(1,
"calloc");
22@@ -120,6 +127,7 @@ commitinfo_getstats(struct commitinfo *ci)
23 for (i = 0; i < ndeltas; i++) {
24 if
(git_patch_from_diff(&patch, ci->diff, i))
25 goto err;
26+
27 if (!(di = calloc(1, sizeof(struct deltainfo))))
28 err(1,
"calloc");
29 di->patch
= patch;
30@@ -460,6 +468,7 @@ printshowfile(FILE *fp, struct commitinfo *ci)
31
fputs("<b>Diffstat:</b>\n<table>", fp);
32 for (i = 0; i
< ci->ndeltas; i++) {
33 delta =
git_patch_get_delta(ci->deltas[i]->patch);
34+
35 fprintf(fp,
"<tr><td><a href=\"#h%zu\">", i);
36 xmlencode(fp,
delta->old_file.path, strlen(delta->old_file.path));
37 if
(strcmp(delta->old_file.path, delta->new_file.path)) {