]> git.armaanb.net Git - stagit.git/commitdiff
improve commitinfo_getstats
authorHiltjo Posthuma <hiltjo@codemadness.org>
Sat, 22 Apr 2017 17:07:07 +0000 (19:07 +0200)
committerHiltjo Posthuma <hiltjo@codemadness.org>
Sun, 7 May 2017 10:05:47 +0000 (12:05 +0200)
- reorder: unnecessary allocation when git_patch_from_diff fails.
- no need to free patch object when git_patch_from_diff fails.

stagit.c

index f280542de6281741999ed2eba1d24b6d164f47d0..5eb5f1c6d198ffb4109ddae54a43080cdad76415 100644 (file)
--- a/stagit.c
+++ b/stagit.c
@@ -110,13 +110,10 @@ commitinfo_getstats(struct commitinfo *ci)
                err(1, "calloc");
 
        for (i = 0; i < ndeltas; i++) {
+               if (git_patch_from_diff(&patch, ci->diff, i))
+                       goto err;
                if (!(di = calloc(1, sizeof(struct deltainfo))))
                        err(1, "calloc");
-               if (git_patch_from_diff(&patch, ci->diff, i)) {
-                       git_patch_free(patch);
-                       free(di);
-                       goto err;
-               }
                di->patch = patch;
                ci->deltas[i] = di;