stagit-gopher

static git page generator for gopher (mirror)
git clone git://git.2f30.org/stagit-gopher
Log | Files | Refs | README | LICENSE

commit 92f9bf9f3a5efb6ac7bec3760645f6e4888c5143
parent 22d8f0453a32ca7e9cc13382170fc38234597a88
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Fri, 23 Jun 2017 12:28:12 +0200

cleanup, decrease some fixed buffer sizes, align diffstat files

Diffstat:
Mstagit-gopher-index.c | 8+-------
Mstagit-gopher.c | 21+++++++++++----------
2 files changed, 12 insertions(+), 17 deletions(-)

diff --git a/stagit-gopher-index.c b/stagit-gopher-index.c @@ -111,7 +111,7 @@ printtimeshort(FILE *fp, const git_time *intime) void writeheader(FILE *fp) { - char buf[1024]; + char buf[256]; trim(buf, sizeof(buf), description); if (buf[0] == 't') @@ -123,11 +123,6 @@ writeheader(FILE *fp) fprintf(fp, "%-16.16s\n", "Last commit"); } -void -writefooter(FILE *fp) -{ -} - int writelog(FILE *fp) { @@ -243,7 +238,6 @@ main(int argc, char *argv[]) writelog(stdout); } - writefooter(stdout); /* cleanup */ git_repository_free(repo); diff --git a/stagit-gopher.c b/stagit-gopher.c @@ -535,7 +535,7 @@ printshowfile(FILE *fp, struct commitinfo *ci) const git_diff_line *line; git_patch *patch; size_t nhunks, nhunklines, changed, add, del, total, i, j, k; - char linestr[80]; + char buf[256], filename[256], linestr[32]; printcommit(fp, ci); @@ -554,12 +554,14 @@ printshowfile(FILE *fp, struct commitinfo *ci) fputs("Diffstat:\n", fp); for (i = 0; i < ci->ndeltas; i++) { delta = git_patch_get_delta(ci->deltas[i]->patch); - /* TODO: make file linkable */ - gphtext(fp, delta->old_file.path, strlen(delta->old_file.path)); if (strcmp(delta->old_file.path, delta->new_file.path)) { - fputs(" -> ", fp); - gphtext(fp, delta->new_file.path, strlen(delta->new_file.path)); + snprintf(filename, sizeof(filename), "%s -> %s", + delta->old_file.path, delta->new_file.path); + trim(buf, sizeof(buf), filename); + } else { + trim(buf, sizeof(buf), delta->old_file.path); } + printutf8pad(fp, buf, 35, ' '); add = ci->deltas[i]->addcount; del = ci->deltas[i]->delcount; @@ -574,7 +576,7 @@ printshowfile(FILE *fp, struct commitinfo *ci) memset(&linestr, '+', add); memset(&linestr[add], '-', del); - fprintf(fp, " | %zu ", + fprintf(fp, " | %7zu ", ci->deltas[i]->addcount + ci->deltas[i]->delcount); fwrite(&linestr, 1, add, fp); fwrite(&linestr[add], 1, del, fp); @@ -626,7 +628,7 @@ printshowfile(FILE *fp, struct commitinfo *ci) void writelogline(FILE *fp, struct commitinfo *ci) { - char buf[1024]; + char buf[256]; fputs("[1|", fp); if (ci->author) @@ -857,8 +859,7 @@ writefilestree(FILE *fp, git_tree *tree, const char *path) git_object *obj = NULL; git_off_t filesize; const char *entryname; - char filepath[PATH_MAX], entrypath[PATH_MAX]; - char buf[1024]; + char buf[256], filepath[PATH_MAX], entrypath[PATH_MAX]; size_t count, i; int lc, r, ret; @@ -967,7 +968,7 @@ writerefs(FILE *fp) size_t count, i, j, refcount; const char *titles[] = { "Branches", "Tags" }; const char *name; - char buf[1024]; + char buf[256]; if (git_reference_iterator_new(&it, repo)) return -1;