Merge branch 'gc/parse-tree-indirect-errors'
Check the return value from parse_tree_indirect() to turn segfaults into calls to die(). * gc/parse-tree-indirect-errors: checkout, clone: die if tree cannot be parsedmaint
commit
bde1e3e80a
|
@ -738,6 +738,7 @@ static int merge_working_tree(const struct checkout_opts *opts,
|
||||||
struct tree_desc trees[2];
|
struct tree_desc trees[2];
|
||||||
struct tree *tree;
|
struct tree *tree;
|
||||||
struct unpack_trees_options topts;
|
struct unpack_trees_options topts;
|
||||||
|
const struct object_id *old_commit_oid;
|
||||||
|
|
||||||
memset(&topts, 0, sizeof(topts));
|
memset(&topts, 0, sizeof(topts));
|
||||||
topts.head_idx = -1;
|
topts.head_idx = -1;
|
||||||
|
@ -765,9 +766,15 @@ static int merge_working_tree(const struct checkout_opts *opts,
|
||||||
&new_branch_info->commit->object.oid :
|
&new_branch_info->commit->object.oid :
|
||||||
&new_branch_info->oid, NULL);
|
&new_branch_info->oid, NULL);
|
||||||
topts.preserve_ignored = !opts->overwrite_ignore;
|
topts.preserve_ignored = !opts->overwrite_ignore;
|
||||||
tree = parse_tree_indirect(old_branch_info->commit ?
|
|
||||||
|
old_commit_oid = old_branch_info->commit ?
|
||||||
&old_branch_info->commit->object.oid :
|
&old_branch_info->commit->object.oid :
|
||||||
the_hash_algo->empty_tree);
|
the_hash_algo->empty_tree;
|
||||||
|
tree = parse_tree_indirect(old_commit_oid);
|
||||||
|
if (!tree)
|
||||||
|
die(_("unable to parse commit %s"),
|
||||||
|
oid_to_hex(old_commit_oid));
|
||||||
|
|
||||||
init_tree_desc(&trees[0], tree->buffer, tree->size);
|
init_tree_desc(&trees[0], tree->buffer, tree->size);
|
||||||
parse_tree(new_tree);
|
parse_tree(new_tree);
|
||||||
tree = new_tree;
|
tree = new_tree;
|
||||||
|
|
|
@ -700,6 +700,8 @@ static int checkout(int submodule_progress, int filter_submodules)
|
||||||
init_checkout_metadata(&opts.meta, head, &oid, NULL);
|
init_checkout_metadata(&opts.meta, head, &oid, NULL);
|
||||||
|
|
||||||
tree = parse_tree_indirect(&oid);
|
tree = parse_tree_indirect(&oid);
|
||||||
|
if (!tree)
|
||||||
|
die(_("unable to parse commit %s"), oid_to_hex(&oid));
|
||||||
parse_tree(tree);
|
parse_tree(tree);
|
||||||
init_tree_desc(&t, tree->buffer, tree->size);
|
init_tree_desc(&t, tree->buffer, tree->size);
|
||||||
if (unpack_trees(1, &t, &opts) < 0)
|
if (unpack_trees(1, &t, &opts) < 0)
|
||||||
|
|
Loading…
Reference in New Issue