make file in diff a link, make hunk and link anchor
1 files changed, 7 insertions(+), 3 deletions(-) | |||
---|---|---|---|
M | urmoms.c | +7 | -3 |
1@@ -259,7 +259,7 @@ printshowfile(git_commit *commit)
2 }
3
4 delta = git_patch_get_delta(patch);
5- fprintf(fp, "diff --git a/<a href=\"%s%s\">%s</a> b/<a href=\"%s%s\">%s</a>\n",
6+ fprintf(fp, "diff --git a/<a href=\"%sfile/%s\">%s</a> b/<a href=\"%sfile/%s\">%s</a>\n",
7 relpath, delta->old_file.path, delta->old_file.path,
8 relpath, delta->new_file.path, delta->new_file.path);
9
10@@ -285,12 +285,16 @@ printshowfile(git_commit *commit)
11 if (git_patch_get_line_in_hunk(&line, patch, j, k))
12 break;
13 if (line->old_lineno == -1)
14- fputc('+', fp);
15+ fprintf(fp, "<span class=\"i\"><a href=\"#h%zu-%zu\" id=\"h%zu-%zu\">+",
16+ j, k, j, k);
17 else if (line->new_lineno == -1)
18- fputc('-', fp);
19+ fprintf(fp, "<span class=\"d\"><a href=\"#h%zu-%zu\" id=\"h%zu-%zu\">-",
20+ j, k, j, k);
21 else
22 fputc(' ', fp);
23 xmlencode(fp, line->content, line->content_len);
24+ if (line->old_lineno == -1 || line->new_lineno == -1)
25+ fputs("</a></span>", fp);
26 }
27 }
28 git_patch_free(patch);