MCPcopy Create free account
hub / github.com/git/git / reset_tree

Function reset_tree

builtin/checkout.c:754–794  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

752}
753
754static int reset_tree(struct tree *tree, const struct checkout_opts *o,
755 int worktree, int *writeout_error,
756 struct branch_info *info)
757{
758 struct unpack_trees_options opts;
759 struct tree_desc tree_desc;
760
761 memset(&opts, 0, sizeof(opts));
762 opts.head_idx = -1;
763 opts.update = worktree;
764 opts.skip_unmerged = !worktree;
765 opts.reset = o->force ? UNPACK_RESET_OVERWRITE_UNTRACKED :
766 UNPACK_RESET_PROTECT_UNTRACKED;
767 opts.preserve_ignored = (!o->force && !o->overwrite_ignore);
768 opts.merge = 1;
769 opts.fn = oneway_merge;
770 opts.verbose_update = o->show_progress;
771 opts.src_index = the_repository->index;
772 opts.dst_index = the_repository->index;
773 init_checkout_metadata(&opts.meta, info->refname,
774 info->commit ? &info->commit->object.oid : null_oid(the_hash_algo),
775 NULL);
776 if (repo_parse_tree(the_repository, tree) < 0)
777 return 128;
778 init_tree_desc(&tree_desc, &tree->object.oid, tree->buffer, tree->size);
779 switch (unpack_trees(1, &tree_desc, &opts)) {
780 case -2:
781 *writeout_error = 1;
782 /*
783 * We return 0 nevertheless, as the index is all right
784 * and more importantly we have made best efforts to
785 * update paths in the work tree, and we cannot revert
786 * them.
787 */
788 /* fallthrough */
789 case 0:
790 return 0;
791 default:
792 return 128;
793 }
794}
795
796static void setup_branch_path(struct branch_info *branch)
797{

Callers 1

merge_working_treeFunction · 0.70

Calls 5

init_checkout_metadataFunction · 0.85
null_oidFunction · 0.85
repo_parse_treeFunction · 0.85
init_tree_descFunction · 0.85
unpack_treesFunction · 0.85

Tested by

no test coverage detected