]> git.armaanb.net Git - stagit.git/commitdiff
separate getstats from getbyoid: slightly faster
authorHiltjo Posthuma <hiltjo@codemadness.org>
Fri, 23 Jun 2017 11:53:46 +0000 (13:53 +0200)
committerHiltjo Posthuma <hiltjo@codemadness.org>
Fri, 23 Jun 2017 11:53:46 +0000 (13:53 +0200)
stagit.c

index d10c88cae584c4eb23bc771f3541ae1382e0e6a5..3362fe5fca417fab35719c2580ebbd8d8b336bdf 100644 (file)
--- a/stagit.c
+++ b/stagit.c
@@ -208,8 +208,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;
 
@@ -575,6 +573,9 @@ writelog(FILE *fp, const git_oid *oid)
                        break;
                if (!(ci = commitinfo_getbyoid(&id)))
                        break;
+               /* lookup stats: only required here */
+               if (commitinfo_getstats(ci) == -1)
+                       goto err;
 
                writelogline(fp, ci);
                if (cachefile)
@@ -596,6 +597,7 @@ writelog(FILE *fp, const git_oid *oid)
                        writefooter(fpfile);
                        fclose(fpfile);
                }
+err:
                commitinfo_free(ci);
        }
        git_revwalk_free(w);