tPrint the number of remaining commits - stagit - [fork] customized build of stagit, the static git page generator
(HTM) git clone git://src.adamsgaard.dk/stagit
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit ad4f39870db9f6b93865f4e46dfda175e87c1f53
(DIR) parent ba27f14e8534a17b383c09c63d509aa5a5655f20
(HTM) Author: Quentin Rameau <quinq@fifth.space>
Date: Tue, 16 Nov 2021 18:17:45 +0100
Print the number of remaining commits
Diffstat:
M stagit.c | 27 ++++++++++++++++-----------
1 file changed, 16 insertions(+), 11 deletions(-)
---
(DIR) diff --git a/stagit.c b/stagit.c
t@@ -74,7 +74,7 @@ static char *licensefiles[] = { "HEAD:LICENSE", "HEAD:LICENSE.md", "HEAD:LICENSE
static char *license;
static char *readmefiles[] = { "HEAD:README", "HEAD:README.md", "HEAD:README.rst", "HEAD:README.txt" };
static char *readme;
-static long long nlogcommits = -1; /* < 0 indicates not used */
+static long long nlogcommits = -1; /* -1 indicates not used */
/* cache */
static git_oid lastoid;
t@@ -777,6 +777,7 @@ writelog(FILE *fp, const git_oid *oid)
git_oid id;
char path[PATH_MAX], oidstr[GIT_OID_HEXSZ + 1];
FILE *fpfile;
+ size_t remcommits = 0;
int r;
git_revwalk_new(&w, repo);
t@@ -796,8 +797,11 @@ writelog(FILE *fp, const git_oid *oid)
/* optimization: if there are no log lines to write and
the commit file already exists: skip the diffstat */
- if (!nlogcommits && !r)
- continue;
+ if (!nlogcommits) {
+ remcommits++;
+ if (!r)
+ continue;
+ }
if (!(ci = commitinfo_getbyoid(&id)))
break;
t@@ -805,15 +809,10 @@ writelog(FILE *fp, const git_oid *oid)
if (commitinfo_getstats(ci) == -1)
goto err;
- if (nlogcommits < 0) {
+ if (nlogcommits != 0) {
writelogline(fp, ci);
- } else if (nlogcommits > 0) {
- writelogline(fp, ci);
- nlogcommits--;
- if (!nlogcommits && ci->parentoid[0])
- fputs("<tr><td></td><td colspan=\"5\">"
- "More commits remaining [...]</td>"
- "</tr>\n", fp);
+ if (nlogcommits > 0)
+ nlogcommits--;
}
if (cachefile)
t@@ -835,6 +834,12 @@ err:
}
git_revwalk_free(w);
+ if (nlogcommits == 0 && remcommits != 0) {
+ fprintf(fp, "<tr><td></td><td colspan=\"5\">"
+ "%zu more commits remaining, fetch the repository"
+ "</td></tr>\n", remcommits);
+ }
+
relpath = "";
return 0;