]> git.armaanb.net Git - stagit.git/commitdiff
in the diffstat prefix the type of change, allow CSS styling
authorHiltjo Posthuma <hiltjo@codemadness.org>
Sun, 18 Nov 2018 17:08:20 +0000 (18:08 +0100)
committerHiltjo Posthuma <hiltjo@codemadness.org>
Sun, 18 Nov 2018 17:08:20 +0000 (18:08 +0100)
stagit.c
style.css

index b2741c047eb5e9562c0ad5fb6865abd6ff3891f8..093cdabb1c8ea7aac953e590522e61b7602192d8 100644 (file)
--- a/stagit.c
+++ b/stagit.c
@@ -461,6 +461,7 @@ printshowfile(FILE *fp, struct commitinfo *ci)
        git_patch *patch;
        size_t nhunks, nhunklines, changed, add, del, total, i, j, k;
        char linestr[80];
+       int c;
 
        printcommit(fp, ci);
 
@@ -480,7 +481,21 @@ printshowfile(FILE *fp, struct commitinfo *ci)
        for (i = 0; i < ci->ndeltas; i++) {
                delta = git_patch_get_delta(ci->deltas[i]->patch);
 
-               fprintf(fp, "<tr><td><a href=\"#h%zu\">", i);
+               switch (delta->status) {
+               case GIT_DELTA_ADDED:      c = 'A'; break;
+               case GIT_DELTA_COPIED:     c = 'C'; break;
+               case GIT_DELTA_DELETED:    c = 'D'; break;
+               case GIT_DELTA_MODIFIED:   c = 'M'; break;
+               case GIT_DELTA_RENAMED:    c = 'R'; break;
+               case GIT_DELTA_TYPECHANGE: c = 'T'; break;
+               default:                   c = ' '; break;
+               }
+               if (c == ' ')
+                       fprintf(fp, "<tr><td>%c", c);
+               else
+                       fprintf(fp, "<tr><td class=\"%c\">%c", c, c);
+
+               fprintf(fp, "</td><td><a href=\"#h%zu\">", i);
                xmlencode(fp, delta->old_file.path, strlen(delta->old_file.path));
                if (strcmp(delta->old_file.path, delta->new_file.path)) {
                        fputs(" -&gt; ", fp);
index 6f5129aa3985380a4a5c7f90bd814bc660be07ca..8065487448bfab07c079d8fdb33b9477356cceaf 100644 (file)
--- a/style.css
+++ b/style.css
@@ -84,11 +84,13 @@ pre a.h {
        color: #00a;
 }
 
+.A,
 span.i,
 pre a.i {
        color: #070;
 }
 
+.D,
 span.d,
 pre a.d {
        color: #e00;