Print the number of remaining commits
1 files changed, 16 insertions(+), 11 deletions(-) | |||
---|---|---|---|
M | stagit.c | +16 | -11 |
1@@ -71,7 +71,7 @@ static char *licensefiles[] = { "HEAD:LICENSE", "HEAD:LICENSE.md", "HEAD:COPYING
2 static char *license;
3 static char *readmefiles[] = { "HEAD:README", "HEAD:README.md" };
4 static char *readme;
5-static long long nlogcommits = -1; /* < 0 indicates not used */
6+static long long nlogcommits = -1; /* -1 indicates not used */
7
8 /* cache */
9 static git_oid lastoid;
10@@ -764,6 +764,7 @@ writelog(FILE *fp, const git_oid *oid)
11 git_oid id;
12 char path[PATH_MAX], oidstr[GIT_OID_HEXSZ + 1];
13 FILE *fpfile;
14+ size_t remcommits = 0;
15 int r;
16
17 git_revwalk_new(&w, repo);
18@@ -783,8 +784,11 @@ writelog(FILE *fp, const git_oid *oid)
19
20 /* optimization: if there are no log lines to write and
21 the commit file already exists: skip the diffstat */
22- if (!nlogcommits && !r)
23- continue;
24+ if (!nlogcommits) {
25+ remcommits++;
26+ if (!r)
27+ continue;
28+ }
29
30 if (!(ci = commitinfo_getbyoid(&id)))
31 break;
32@@ -792,15 +796,10 @@ writelog(FILE *fp, const git_oid *oid)
33 if (commitinfo_getstats(ci) == -1)
34 goto err;
35
36- if (nlogcommits < 0) {
37+ if (nlogcommits != 0) {
38 writelogline(fp, ci);
39- } else if (nlogcommits > 0) {
40- writelogline(fp, ci);
41- nlogcommits--;
42- if (!nlogcommits && ci->parentoid[0])
43- fputs("<tr><td></td><td colspan=\"5\">"
44- "More commits remaining [...]</td>"
45- "</tr>\n", fp);
46+ if (nlogcommits > 0)
47+ nlogcommits--;
48 }
49
50 if (cachefile)
51@@ -822,6 +821,12 @@ err:
52 }
53 git_revwalk_free(w);
54
55+ if (nlogcommits == 0 && remcommits != 0) {
56+ fprintf(fp, "<tr><td></td><td colspan=\"5\">"
57+ "%zu more commits remaining, fetch the repository"
58+ "</td></tr>\n", remcommits);
59+ }
60+
61 relpath = "";
62
63 return 0;