if-return-early instead of if-else in detect_changed_path()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
diff --git a/lib/commit_graph.c b/lib/commit_graph.c
index 2e7bb67..281577b 100644
--- a/lib/commit_graph.c
+++ b/lib/commit_graph.c
@@ -191,22 +191,23 @@ detect_changed_path(int *changed, struct got_commit_object *commit,
} else
*changed = 1; /* The path was created in this commit. */
free(obj_id);
- } else {
- err = got_object_open_as_tree(&tree, repo, commit->tree_id);
- if (err)
- return err;
+ return err;
+ }
- err = got_object_open_as_commit(&pcommit, repo, pid->id);
- if (err)
- goto done;
+ err = got_object_open_as_tree(&tree, repo, commit->tree_id);
+ if (err)
+ return err;
- err = got_object_open_as_tree(&ptree, repo, pcommit->tree_id);
- if (err)
- goto done;
+ err = got_object_open_as_commit(&pcommit, repo, pid->id);
+ if (err)
+ goto done;
- err = got_object_tree_path_changed(changed, tree, ptree, path,
- repo);
- }
+ err = got_object_open_as_tree(&ptree, repo, pcommit->tree_id);
+ if (err)
+ goto done;
+
+ err = got_object_tree_path_changed(changed, tree, ptree, path,
+ repo);
done:
if (tree)
got_object_tree_close(tree);