diff options
author | Hiltjo Posthuma <hiltjo@codemadness.org> | 2017-04-22 19:07:07 +0200 |
---|---|---|
committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2017-05-07 12:05:47 +0200 |
commit | 8fa0effa9846a18a60d3b6a7c96db42a2775a7c6 (patch) | |
tree | c7cf24ad47acce90c05cb8d1ff9c9ee6efc5ca24 /stagit.c | |
parent | 8eabe24bdda7003453bbd034d82ebc479e2c76bc (diff) |
improve commitinfo_getstats
- reorder: unnecessary allocation when git_patch_from_diff fails.
- no need to free patch object when git_patch_from_diff fails.
Diffstat (limited to 'stagit.c')
-rw-r--r-- | stagit.c | 7 |
1 files changed, 2 insertions, 5 deletions
@@ -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; |