summaryrefslogtreecommitdiff
path: root/stagit.c
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2018-11-18 18:08:20 +0100
committerHiltjo Posthuma <hiltjo@codemadness.org>2018-11-18 18:08:20 +0100
commit3a151527e1d72aa75d9461ee9918bda3bd08bcb1 (patch)
tree4b01d84a58dcc7a5c54cedee7fa663a6b8df1921 /stagit.c
parent608593b0f875012875f13d28fbccd533d1266fd2 (diff)
in the diffstat prefix the type of change, allow CSS styling
Diffstat (limited to 'stagit.c')
-rw-r--r--stagit.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/stagit.c b/stagit.c
index b2741c0..093cdab 100644
--- 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);