stagit

git site generator
Contents

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 , thanks!

Hiltjo Posthuma hiltjo@codemadness.org

commit: 7642526 parent: 66400ca
1 files changed, 7 insertions(+), 8 deletions(-)
Mstagit.c+7-8
M · stagit.c +7, -8
 1@@ -504,15 +504,15 @@ writefooter(FILE *fp)
 2 size_t
 3 writeblobhtml(FILE
*fp, const git_blob *blob)
 4 {
 5- size_t n = 0, i, prev;
 6+ size_t n = 0, i, len,
prev;
 7 const char *nfmt = "<a
href=\"#l%zu\" class=\"line\" id=\"l%zu\">%7zu</a>
";
 8 const char *s =
git_blob_rawcontent(blob);
 9- git_off_t len = git_blob_rawsize(blob);
10
11+ len = git_blob_rawsize(blob);
12 fputs("<pre
id=\"blob\">\n", fp);
13
14 if (len >
0) {
15- for (i = 0, prev = 0; i < (size_t)len; i++) {
16+ for (i = 0, prev = 0;
i < len; i++) {
17 if (s[i] != '\n')
18 continue;
19 n++;
20@@ -886,7 +886,7 @@ writeatom(FILE *fp, int all)
21 }
22
23 size_t
24-writeblob(git_object *obj, const char *fpath, const char *filename, git_off_t filesize)
25+writeblob(git_object
*obj, const char *fpath, const char *filename, size_t filesize)
26 {
27 char
tmp[PATH_MAX] = "", *d;
28 const char *p;
29@@ -910,7 +910,7 @@ writeblob(git_object *obj, const char *fpath, const char *filename, git_off_t
fi
30 writeheader(fp, filename);
31
fputs("<p> ", fp);
32 xmlencode(fp,
filename, strlen(filename));
33- fprintf(fp, " (%juB)", (uintmax_t)filesize);
34+ fprintf(fp, "
(%zuB)", filesize);
35
fputs("</p><hr/>", fp);
36
37 if
(git_blob_is_binary((git_blob *)obj)) {
38@@ -975,10 +975,9 @@ writefilestree(FILE *fp, git_tree *tree, const char *path)
39 {
40 const
git_tree_entry *entry = NULL;
41 git_object *obj =
NULL;
42- git_off_t filesize;
43 const char *entryname;
44 char
filepath[PATH_MAX], entrypath[PATH_MAX], oid[8];
45- size_t count, i, lc;
46+ size_t count, i, lc,
filesize;
47 int r, ret;
48
49 count =
git_tree_entrycount(tree);
50@@ -1023,7 +1022,7 @@ writefilestree(FILE *fp, git_tree *tree, const char *path)
51 if (lc > 0)
52 fprintf(fp,
"%zuL", lc);
53 else
54- fprintf(fp, "%juB", (uintmax_t)filesize);
55+ fprintf(fp,
"%zuB", filesize);
56
fputs("</td></tr>\n", fp);
57
git_object_free(obj);
58 } else if
(git_tree_entry_type(entry) == GIT_OBJ_COMMIT) {