summaryrefslogtreecommitdiff
path: root/merge-recursive.c
diff options
context:
space:
mode:
authorLibravatar Elijah Newren <newren@gmail.com>2019-08-17 11:41:32 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2019-08-19 10:08:03 -0700
commit724dd767b245db588840d7e9dbd46687ee84020b (patch)
tree73b0cd4f0b2968f4261c8a0000c412a6fadcb323 /merge-recursive.c
parentmerge-recursive: don't force external callers to do our logging (diff)
downloadtgif-724dd767b245db588840d7e9dbd46687ee84020b.tar.xz
cache-tree: share code between functions writing an index as a tree
write_tree_from_memory() appeared to be a merge-recursive special that basically duplicated write_index_as_tree(). The two have a different signature, but the bigger difference was just that write_index_as_tree() would always unconditionally read the index off of disk instead of working on the current in-memory index. So: * split out common code into write_index_as_tree_internal() * rename write_tree_from_memory() to write_inmemory_index_as_tree(), make it call write_index_as_tree_internal(), and move it to cache-tree.c Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'merge-recursive.c')
-rw-r--r--merge-recursive.c34
1 files changed, 2 insertions, 32 deletions
diff --git a/merge-recursive.c b/merge-recursive.c
index fda67dd371..ae509357f7 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -412,37 +412,6 @@ static void unpack_trees_finish(struct merge_options *opt)
clear_unpack_trees_porcelain(&opt->unpack_opts);
}
-struct tree *write_tree_from_memory(struct merge_options *opt)
-{
- struct tree *result = NULL;
- struct index_state *istate = opt->repo->index;
-
- if (unmerged_index(istate)) {
- int i;
- fprintf(stderr, "BUG: There are unmerged index entries:\n");
- for (i = 0; i < istate->cache_nr; i++) {
- const struct cache_entry *ce = istate->cache[i];
- if (ce_stage(ce))
- fprintf(stderr, "BUG: %d %.*s\n", ce_stage(ce),
- (int)ce_namelen(ce), ce->name);
- }
- BUG("unmerged index entries in merge-recursive.c");
- }
-
- if (!istate->cache_tree)
- istate->cache_tree = cache_tree();
-
- if (!cache_tree_fully_valid(istate->cache_tree) &&
- cache_tree_update(istate, 0) < 0) {
- err(opt, _("error building trees"));
- return NULL;
- }
-
- result = lookup_tree(opt->repo, &istate->cache_tree->oid);
-
- return result;
-}
-
static int save_files_dirs(const struct object_id *oid,
struct strbuf *base, const char *path,
unsigned int mode, int stage, void *context)
@@ -3472,7 +3441,8 @@ static int merge_trees_internal(struct merge_options *opt,
unpack_trees_finish(opt);
- if (opt->call_depth && !(*result = write_tree_from_memory(opt)))
+ if (opt->call_depth &&
+ !(*result = write_in_core_index_as_tree(opt->repo)))
return -1;
return clean;