improve commitinfo_getstats

- reorder: unnecessary allocation when git_patch_from_diff fails.
- no need to free patch object when git_patch_from_diff fails.
This commit is contained in:
Hiltjo Posthuma 2017-04-22 19:07:07 +02:00
parent 8eabe24bdd
commit 8fa0effa98

View file

@ -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;