| 752 | } |
| 753 | |
| 754 | static 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 | |
| 796 | static void setup_branch_path(struct branch_info *branch) |
| 797 | { |
no test coverage detected