Commit 0e9101d513f190e450c8b76491dde10235ee2f3e

Stefan Sperling 2018-11-18T23:37:05

if-return-early instead of if-else in detect_changed_path()

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