Commit Diff


commit - 5760205b5f9b7d77dda76f98561d2a39e4eac7a9
commit + 971d0123bfde09ec62689dbf7e2d9a68e143f4b6
blob - 326ea521fa760c8c7507f7ebcb14de2cc202defc
blob + 0f43972acc8ee969e3863b582c941b718f58b067
--- got/got.c
+++ got/got.c
@@ -8414,12 +8414,6 @@ commit_path_changed_in_worktree(int *add_logmsg, struc
 	TAILQ_INIT(&paths);
 
 	err = got_object_open_as_commit(&commit, repo, id);
-	if (err)
-		goto done;
-
-	pid = STAILQ_FIRST(got_object_commit_get_parent_ids(commit));
-
-	err = got_object_open_as_commit(&pcommit, repo, &pid->id);
 	if (err)
 		goto done;
 
@@ -8428,10 +8422,17 @@ commit_path_changed_in_worktree(int *add_logmsg, struc
 	if (err)
 		goto done;
 
-	err = got_object_open_as_tree(&ptree, repo,
-	    got_object_commit_get_tree_id(pcommit));
-	if (err)
-		goto done;
+	pid = STAILQ_FIRST(got_object_commit_get_parent_ids(commit));
+	if (pid != NULL) {
+		err = got_object_open_as_commit(&pcommit, repo, &pid->id);
+		if (err)
+			goto done;
+
+		err = got_object_open_as_tree(&ptree, repo,
+		    got_object_commit_get_tree_id(pcommit));
+		if (err)
+			goto done;
+	}
 
 	err = got_diff_tree(ptree, tree, NULL, NULL, -1, -1, "", "", repo,
 	    got_diff_tree_collect_changed_paths, &paths, 0);