separate commitinfo_getstats from commitinfo_getbyoid - stagit-gopher - A git gopher frontend. (mirror)
 (HTM) 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 326c0b91ac136447c1cb3f6cc2dc2053f320a5ee
 (DIR) parent 92f9bf9f3a5efb6ac7bec3760645f6e4888c5143
 (HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
       Date:   Fri, 23 Jun 2017 12:29:11 +0200
       
       separate commitinfo_getstats from commitinfo_getbyoid
       
       diffstat fields are not used in each view, this is faster.
       
       Diffstat:
         M stagit-gopher.c                     |       7 +++++--
       
       1 file changed, 5 insertions(+), 2 deletions(-)
       ---
 (DIR) diff --git a/stagit-gopher.c b/stagit-gopher.c
       @@ -238,8 +238,6 @@ commitinfo_getbyoid(const git_oid *id)
                opts.flags |= GIT_DIFF_DISABLE_PATHSPEC_MATCH;
                if (git_diff_tree_to_tree(&(ci->diff), repo, ci->parent_tree, ci->commit_tree, &opts))
                        goto err;
       -        if (commitinfo_getstats(ci) == -1)
       -                goto err;
        
                return ci;
        
       @@ -678,12 +676,17 @@ writelog(FILE *fp, const git_oid *oid)
        
                        /* check if file exists if so skip it */
                        if (access(path, F_OK)) {
       +                        /* lookup stats: only required here */
       +                        if (commitinfo_getstats(ci) == -1)
       +                                goto err;
       +
                                fpfile = efopen(path, "w");
                                writeheader(fpfile, ci->summary);
                                printshowfile(fpfile, ci);
                                writefooter(fpfile);
                                fclose(fpfile);
                        }
       +err:
                        commitinfo_free(ci);
                }
                git_revwalk_free(w);