From: Mark Jamsek Subject: check we have a parent commit it commit_path_changed_in_worktree() To: Game of Trees Date: Sat, 28 Jan 2023 17:37:53 +1100 This fixes an invalid assumption in commit_path_changed_in_worktree(); namely, that we always have a parent commit. diff /home/mark/src/got commit - 22d6be814cfc21a663987c0dcb547f99e48a9860 path + /home/mark/src/got blob - 326ea521fa760c8c7507f7ebcb14de2cc202defc file + got/got.c --- got/got.c +++ got/got.c @@ -8418,21 +8418,22 @@ commit_path_changed_in_worktree(int *add_logmsg, struc 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_commit(&pcommit, repo, &pid->id); - if (err) - goto done; + err = got_object_open_as_tree(&tree, repo, + got_object_commit_get_tree_id(commit)); + if (err) + goto done; - err = got_object_open_as_tree(&tree, repo, - got_object_commit_get_tree_id(commit)); - 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_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); if (err) -- Mark Jamsek GPG: F2FF 13DE 6A06 C471 CA80 E6E2 2930 DC66 86EE CF68