Commit Diff


commit - a9020babcc81b07cd3b2a94d3a79b0e4af588a34
commit + bb723b7a6cfcf6937e16863096b630f9d5b324b1
blob - b0af089ca9c3bf48bc4d6cca8d4f3808c9c60289
blob + e008ad1795a614874a0787a228a484dd2f61be74
--- 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);