aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuentin Rameau <[email protected]>2021-11-16 18:17:45 +0100
committerHiltjo Posthuma <[email protected]>2021-11-16 18:18:32 +0100
commit67e5e6c5e74117b478c150480c282a03543fe887 (patch)
tree6a789564db9087067133cceb3e38c965b78fec0a
parent5f78d89d591ad26b902947288625b90528954372 (diff)
downloadstagit-67e5e6c5e74117b478c150480c282a03543fe887.tar.gz
stagit-67e5e6c5e74117b478c150480c282a03543fe887.zip
Print the number of remaining commits
-rw-r--r--stagit.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/stagit.c b/stagit.c
index b9c0d37..6e0c15e 100644
--- a/stagit.c
+++ b/stagit.c
@@ -71,7 +71,7 @@ static char *licensefiles[] = { "HEAD:LICENSE", "HEAD:LICENSE.md", "HEAD:COPYING
static char *license;
static char *readmefiles[] = { "HEAD:README", "HEAD:README.md" };
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;
@@ -764,6 +764,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);
@@ -783,8 +784,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;
@@ -792,15 +796,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)
@@ -822,6 +821,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;