stagit

personal fork of stagit (rnpnr branch)
git clone anongit@rnpnr.xyz:stagit.git
Log | Files | Refs | Feed | README | LICENSE

Commit: e1c0aebde443979a524a944027b81f84f4323ff3
Parent: 66df204c440de3b0cf3442d3a0c719016cdcf9c6
Author: Hiltjo Posthuma
Date:   Sat, 28 Nov 2020 12:28:05 +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.c | 15+++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/stagit.c b/stagit.c @@ -504,15 +504,15 @@ writefooter(FILE *fp) size_t writeblobhtml(FILE *fp, const git_blob *blob) { - size_t n = 0, i, prev; + size_t n = 0, i, len, prev; const char *nfmt = "<a href=\"#l%zu\" class=\"line\" id=\"l%zu\">%7zu</a> "; const char *s = git_blob_rawcontent(blob); - git_off_t len = git_blob_rawsize(blob); + len = git_blob_rawsize(blob); fputs("<pre id=\"blob\">\n", fp); 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++; @@ -886,7 +886,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; const char *p; @@ -910,7 +910,7 @@ writeblob(git_object *obj, const char *fpath, const char *filename, git_off_t fi writeheader(fp, filename); fputs("<p> ", fp); xmlencode(fp, filename, strlen(filename)); - fprintf(fp, " (%juB)", (uintmax_t)filesize); + fprintf(fp, " (%zuB)", filesize); fputs("</p><hr/>", fp); if (git_blob_is_binary((git_blob *)obj)) { @@ -975,10 +975,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 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); @@ -1023,7 +1022,7 @@ writefilestree(FILE *fp, git_tree *tree, const char *path) if (lc > 0) fprintf(fp, "%zuL", lc); else - fprintf(fp, "%juB", (uintmax_t)filesize); + fprintf(fp, "%zuB", filesize); fputs("</td></tr>\n", fp); git_object_free(obj); } else if (git_tree_entry_type(entry) == GIT_OBJ_COMMIT) {