Commit Diff


commit - 75c3234010be6c6e1e48ed26894773b5f3c91808
commit + c8f60bffbe10a8ddb0e951e2a9d884663c946e8f
blob - db7cd78480ab95d45d3163ddb9490ff30a3d886f
blob + 050df20309f8ea292c70f9ab2a3c42a5ceb53d16
--- tog/tog.c
+++ tog/tog.c
@@ -344,6 +344,7 @@ queue_commits(struct got_commit_graph *graph, struct c
 	struct got_object_id *id;
 	struct commit_queue_entry *entry;
 	int nfetched, nqueued = 0, found_obj = 0;
+	int is_root_path = strcmp(path, "/") == 0;
 
 	err = got_commit_graph_iter_start(graph, start_id);
 	if (err)
@@ -387,13 +388,14 @@ queue_commits(struct got_commit_graph *graph, struct c
 		if (err)
 			break;
 
-		if (path) {
+		if (!is_root_path) {
 			struct got_object *obj;
 			struct got_object_qid *pid;
 			int changed = 0;
 
 			err = got_object_open_by_path(&obj, repo, id, path);
 			if (err) {
+				got_object_commit_close(commit);
 				if (err->code == GOT_ERR_NO_OBJ &&
 				    (found_obj || !init)) {
 					/* History stops here. */
@@ -411,6 +413,7 @@ queue_commits(struct got_commit_graph *graph, struct c
 				if (err) {
 					if (err->code != GOT_ERR_NO_OBJ) {
 						got_object_close(obj);
+						got_object_commit_close(commit);
 						break;
 					}
 					err = NULL;
@@ -420,12 +423,16 @@ queue_commits(struct got_commit_graph *graph, struct c
 					id = got_object_get_id(obj);
 					if (id == NULL) {
 						err = got_error_from_errno();
+						got_object_close(obj);
+						got_object_close(pobj);
 						break;
 					}
 					pid = got_object_get_id(pobj);
 					if (pid == NULL) {
 						err = got_error_from_errno();
 						free(id);
+						got_object_close(obj);
+						got_object_close(pobj);
 						break;
 					}
 					changed =
@@ -435,6 +442,7 @@ queue_commits(struct got_commit_graph *graph, struct c
 					free(pid);
 				}
 			}
+			got_object_close(obj);
 			if (!changed) {
 				got_object_commit_close(commit);
 				continue;