URI: 
       Print the number of remaining commits - stagit-gopher - A git gopher frontend. (mirror)
  HTML git clone git://bitreich.org/stagit-gopher/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/stagit-gopher/
   DIR Log
   DIR Files
   DIR Refs
   DIR Tags
   DIR README
   DIR LICENSE
       ---
   DIR commit 42613555baad830fd0fe65798e22ac65c18129e9
   DIR parent 9d738c87ca291d354f215c45469a6ba983474f73
  HTML Author: Quentin Rameau <quinq@fifth.space>
       Date:   Tue, 16 Nov 2021 21:10:02 +0100
       
       Print the number of remaining commits
       
       Diffstat:
         M stagit-gopher.c                     |      25 ++++++++++++++++---------
       
       1 file changed, 16 insertions(+), 9 deletions(-)
       ---
   DIR diff --git a/stagit-gopher.c b/stagit-gopher.c
       @@ -75,7 +75,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;
       @@ -832,6 +832,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);
       @@ -849,19 +850,19 @@ 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;
        
       -                if (nlogcommits < 0) {
       +                if (nlogcommits != 0) {
                                writelogline(fp, ci);
       -                } else if (nlogcommits > 0) {
       -                        writelogline(fp, ci);
       -                        nlogcommits--;
       -                        if (!nlogcommits && ci->parentoid[0])
       -                                fprintf(fp, "%16.16s  More commits remaining [...]\n", "");
       +                        if (nlogcommits > 0)
       +                                nlogcommits--;
                        }
        
                        if (cachefile)
       @@ -884,6 +885,12 @@ err:
                }
                git_revwalk_free(w);
        
       +        if (nlogcommits == 0 && remcommits != 0) {
       +                fprintf(fp, "%16.16s  "
       +                        "%zu more commits remaining, fetch the repository\n",
       +                        "", remcommits);
       +        }
       +
                return 0;
        }