make file in diff a link, make hunk and link anchor
authorHiltjo Posthuma <hiltjo@codemadness.org>
Mon, 7 Dec 2015 18:00:16 +0000 (19:00 +0100)
committerHiltjo Posthuma <hiltjo@codemadness.org>
Mon, 7 Dec 2015 18:00:16 +0000 (19:00 +0100)
urmoms.c

index 26a4d057949542ec6deb4254c94954dedf5ffdac..ec3b00ab2c87893f804626f64fa7d0ef53d5f2a3 100644 (file)
--- a/urmoms.c
+++ b/urmoms.c
@@ -259,7 +259,7 @@ printshowfile(git_commit *commit)
                }
 
                delta = git_patch_get_delta(patch);
-               fprintf(fp, "diff --git a/<a href=\"%s%s\">%s</a> b/<a href=\"%s%s\">%s</a>\n",
+               fprintf(fp, "diff --git a/<a href=\"%sfile/%s\">%s</a> b/<a href=\"%sfile/%s\">%s</a>\n",
                        relpath, delta->old_file.path, delta->old_file.path,
                        relpath, delta->new_file.path, delta->new_file.path);
 
@@ -285,12 +285,16 @@ printshowfile(git_commit *commit)
                                if (git_patch_get_line_in_hunk(&line, patch, j, k))
                                        break;
                                if (line->old_lineno == -1)
-                                       fputc('+', fp);
+                                       fprintf(fp, "<span class=\"i\"><a href=\"#h%zu-%zu\" id=\"h%zu-%zu\">+",
+                                               j, k, j, k);
                                else if (line->new_lineno == -1)
-                                       fputc('-', fp);
+                                       fprintf(fp, "<span class=\"d\"><a href=\"#h%zu-%zu\" id=\"h%zu-%zu\">-",
+                                               j, k, j, k);
                                else
                                        fputc(' ', fp);
                                xmlencode(fp, line->content, line->content_len);
+                               if (line->old_lineno == -1 || line->new_lineno == -1)
+                                       fputs("</a></span>", fp);
                        }
                }
                git_patch_free(patch);