stagit-gopher

[fork] gopher git frontend
Log | Files | Refs | README | LICENSE

commit 3be1a74e36d2b7bb6064fe671e39fca4b434a655
parent 89e38eb68278966aee0d5597a683a299af2484b1
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Fri, 23 Nov 2018 12:56:05 +0100

in the diffstat prefix the type of change

Diffstat:
Mstagit-gopher.c | 13++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/stagit-gopher.c b/stagit-gopher.c @@ -569,6 +569,7 @@ printshowfile(FILE *fp, struct commitinfo *ci) git_patch *patch; size_t nhunks, nhunklines, changed, add, del, total, i, j, k; char buf[256], filename[256], linestr[32]; + int c; printcommit(fp, ci); @@ -588,6 +589,16 @@ printshowfile(FILE *fp, struct commitinfo *ci) for (i = 0; i < ci->ndeltas; i++) { delta = git_patch_get_delta(ci->deltas[i]->patch); + 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 (strcmp(delta->old_file.path, delta->new_file.path)) { snprintf(filename, sizeof(filename), "%s -> %s", delta->old_file.path, delta->new_file.path); @@ -595,7 +606,7 @@ printshowfile(FILE *fp, struct commitinfo *ci) } else { utf8pad(buf, sizeof(buf), delta->old_file.path, 35, ' '); } - fputs(" ", fp); + fprintf(fp, " %c ", c); gphtext(fp, buf, strlen(buf)); add = ci->deltas[i]->addcount;