Merge branch 'jc/history-missing-tree-errorfix'

Running "git history" in a corrupt repository can (unsurprisingly)
segfault when a necessary tree object is not found.

* jc/history-missing-tree-errorfix:
  history: do not dereference NULL when parent tree is missing
main
Junio C Hamano 2026-09-13 21:53:30 -07:00
commit d7e8ff8565
1 changed files with 4 additions and 0 deletions

View File

@ -786,6 +786,10 @@ static int write_ondisk_index(struct repository *repo,
opts.dst_index = &index;

tree = repo_parse_tree_indirect(repo, oid);
if (!tree) {
ret = error(_("unable to parse tree %s"), oid_to_hex(oid));
goto out;
}
init_tree_desc(&tree_desc, &tree->object.oid, tree->buffer, tree->size);

if (unpack_trees(1, &tree_desc, &opts)) {