"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Martin Pieuchot <mpi@openbsd.org>
Subject:
Unnecessary check after got_object_id_by_path()
To:
gameoftrees@openbsd.org
Date:
Sun, 19 Jan 2020 14:33:34 +0100

Download raw body.

Thread
To my understanding got_object_id_by_path() always return an error code
if `obj_id' is NULL.  That means the checks below are redundant.

ok?

diff --git got/got.c got/got.c
index 5490ed3..f52a257 100644
--- got/got.c
+++ got/got.c
@@ -2726,10 +2726,6 @@ cmd_blame(int argc, char *argv[])
 	error = got_object_id_by_path(&obj_id, repo, commit_id, in_repo_path);
 	if (error)
 		goto done;
-	if (obj_id == NULL) {
-		error = got_error(GOT_ERR_NO_OBJ);
-		goto done;
-	}
 
 	error = got_object_get_type(&obj_type, repo, obj_id);
 	if (error)
diff --git tog/tog.c tog/tog.c
index fc01887..8892f4b 100644
--- tog/tog.c
+++ tog/tog.c
@@ -3616,8 +3616,6 @@ run_blame(struct tog_blame *blame, struct tog_view *view, int *blame_complete,
 	err = got_object_id_by_path(&obj_id, repo, commit_id, path);
 	if (err)
 		return err;
-	if (obj_id == NULL)
-		return got_error(GOT_ERR_NO_OBJ);
 
 	err = got_object_get_type(&obj_type, repo, obj_id);
 	if (err)