stagit-gopher

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

commit 70e0e50a6c4d83f7b809be4338bcf2868c13b49b
parent f1c1f8c810b311b9f786847dda2494c397cc1ddf
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Sun,  6 Dec 2020 17:20:42 +0100

fix warning with libgit2 v0.99+, remain compatible with older versions

git_blob_rawsize now returns with git_object_size_t (unsigned). This was
git_off_t (signed).

In my current version 1.1.0:
        types.h:typedef uint64_t git_object_size_t;

v0.28.5:
https://libgit2.org/libgit2/#v0.28.5/group/blob/git_blob_rawsize

changed from v0.99 onwards:
https://libgit2.org/libgit2/#v0.99.0/group/blob/git_blob_rawsize

Fix: use size_t to remain compatible (with a possible warning in older
versions), since git_object_size_t is a new defined type.
This assumes size_t is atleast uint32_t / uint64_t size.

Adapted from a patch by Augustin Fabre <augustin@augfab.fr>, thanks!

Diffstat:
Mstagit-gopher.c | 15+++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/stagit-gopher.c b/stagit-gopher.c @@ -597,13 +597,13 @@ writefooter(FILE *fp) size_t writeblobgph(FILE *fp, const git_blob *blob) { - size_t n = 0, i, j, prev; + size_t n = 0, i, j, len, prev; const char *nfmt = "%6zu "; const char *s = git_blob_rawcontent(blob); - git_off_t len = git_blob_rawsize(blob); + len = git_blob_rawsize(blob); if (len > 0) { - for (i = 0, prev = 0; i < (size_t)len; i++) { + for (i = 0, prev = 0; i < len; i++) { if (s[i] != '\n') continue; n++; @@ -969,7 +969,7 @@ writeatom(FILE *fp, int all) } size_t -writeblob(git_object *obj, const char *fpath, const char *filename, git_off_t filesize) +writeblob(git_object *obj, const char *fpath, const char *filename, size_t filesize) { char tmp[PATH_MAX] = "", *d; size_t lc = 0; @@ -986,7 +986,7 @@ writeblob(git_object *obj, const char *fpath, const char *filename, git_off_t fi writeheader(fp, filename); fputc('t', fp); gphtext(fp, filename, strlen(filename)); - fprintf(fp, " (%juB)\n", (uintmax_t)filesize); + fprintf(fp, " (%zuB)\n", filesize); fputs("---\n", fp); if (git_blob_is_binary((git_blob *)obj)) { @@ -1049,10 +1049,9 @@ writefilestree(FILE *fp, git_tree *tree, const char *path) { const git_tree_entry *entry = NULL; git_object *obj = NULL; - git_off_t filesize; const char *entryname; char buf[256], filepath[PATH_MAX], entrypath[PATH_MAX], oid[8]; - size_t count, i, lc; + size_t count, i, lc, filesize; int r, ret; count = git_tree_entrycount(tree); @@ -1096,7 +1095,7 @@ writefilestree(FILE *fp, git_tree *tree, const char *path) if (lc > 0) fprintf(fp, "%7zuL", lc); else - fprintf(fp, "%7juB", (uintmax_t)filesize); + fprintf(fp, "%7zuB", filesize); fprintf(fp, "|%s/", relpath); gphlink(fp, filepath, strlen(filepath)); fputs("|server|port]\n", fp);