[PATCH 07/19] Move write_tree_from_memory() from merge-recursive to cache-tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



No code changes, just moving the function to what seems like a more
logical place.

Signed-off-by: Elijah Newren <newren@xxxxxxxxx>
---
 cache-tree.c      | 30 ++++++++++++++++++++++++++++++
 cache-tree.h      |  2 ++
 merge-recursive.c | 30 ------------------------------
 merge-recursive.h |  1 -
 4 files changed, 32 insertions(+), 31 deletions(-)

diff --git a/cache-tree.c b/cache-tree.c
index 706ffcf188..d2baf6baf5 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -659,6 +659,36 @@ int write_index_as_tree(struct object_id *oid, struct index_state *index_state,
 	return ret;
 }
 
+struct tree *write_tree_from_memory(struct repository *repo)
+{
+	struct tree *result = NULL;
+	struct index_state *istate = 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) {
+		BUG("error building trees");
+	}
+
+	result = lookup_tree(repo, &istate->cache_tree->oid);
+
+	return result;
+}
+
 static void prime_cache_tree_rec(struct repository *r,
 				 struct cache_tree *it,
 				 struct tree *tree)
diff --git a/cache-tree.h b/cache-tree.h
index 757bbc48bc..4d67c237ba 100644
--- a/cache-tree.h
+++ b/cache-tree.h
@@ -47,6 +47,8 @@ void cache_tree_verify(struct repository *, struct index_state *);
 #define WRITE_TREE_PREFIX_ERROR (-3)
 
 int write_index_as_tree(struct object_id *oid, struct index_state *index_state, const char *index_path, int flags, const char *prefix);
+struct tree *write_tree_from_memory(struct repository *repo);
+
 void prime_cache_tree(struct repository *, struct index_state *, struct tree *);
 
 int cache_tree_matches_traversal(struct cache_tree *, struct name_entry *ent, struct traverse_info *info);
diff --git a/merge-recursive.c b/merge-recursive.c
index 1a3c6ab7f3..937a816288 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -412,36 +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 repository *repo)
-{
-	struct tree *result = NULL;
-	struct index_state *istate = 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) {
-		BUG("error building trees");
-	}
-
-	result = lookup_tree(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)
diff --git a/merge-recursive.h b/merge-recursive.h
index 33f3d53c09..973f2729a8 100644
--- a/merge-recursive.h
+++ b/merge-recursive.h
@@ -97,7 +97,6 @@ int merge_recursive_generic(struct merge_options *o,
 
 void init_merge_options(struct merge_options *o,
 			struct repository *repo);
-struct tree *write_tree_from_memory(struct repository *repo);
 
 int parse_merge_opt(struct merge_options *out, const char *s);
 
-- 
2.22.0.559.g28a8880890.dirty




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux