diff mbox series

[4/7] merge-ort: move cmp_cache_name_compare() from tree.c

Message ID 20210306193458.20633-5-avarab@gmail.com (mailing list archive)
State Superseded
Headers show
Series Move the read_tree() function to its only user | expand

Commit Message

Ævar Arnfjörð Bjarmason March 6, 2021, 7:34 p.m. UTC
Move the cmp_cache_name_compare() function from tree.c. Now that we've
stopped using it in builtin/ls-files.c the merge-ort.c code is its
only user, let's just have it own it instead of having this API which
straddles tree.h and cache-tree.h in tree.c itself.

See these commits for its recent introduction in merge-ort.c::

 - 70912f66de7 (tree: enable cmp_cache_name_compare() to be used
   elsewhere, 2020-12-13)

 - ef2b3693870 (merge-ort: add implementation of
   record_conflicted_index_entries(), 2020-12-13)

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 merge-ort.c | 10 ++++++++++
 tree.c      | 11 -----------
 tree.h      |  2 --
 3 files changed, 10 insertions(+), 13 deletions(-)
diff mbox series

Patch

diff --git a/merge-ort.c b/merge-ort.c
index 603d30c5217..d7b3ced1bec 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -3099,6 +3099,16 @@  static int checkout(struct merge_options *opt,
 	return ret;
 }
 
+static int cmp_cache_name_compare(const void *a_, const void *b_)
+{
+	const struct cache_entry *ce1, *ce2;
+
+	ce1 = *((const struct cache_entry **)a_);
+	ce2 = *((const struct cache_entry **)b_);
+	return cache_name_stage_compare(ce1->name, ce1->ce_namelen, ce_stage(ce1),
+				  ce2->name, ce2->ce_namelen, ce_stage(ce2));
+}
+
 static int record_conflicted_index_entries(struct merge_options *opt,
 					   struct index_state *index,
 					   struct strmap *paths,
diff --git a/tree.c b/tree.c
index a6c12f2745a..c1bde9314d0 100644
--- a/tree.c
+++ b/tree.c
@@ -1,5 +1,4 @@ 
 #include "cache.h"
-#include "cache-tree.h"
 #include "tree.h"
 #include "object-store.h"
 #include "blob.h"
@@ -96,16 +95,6 @@  int read_tree_recursive(struct repository *r,
 	return ret;
 }
 
-int cmp_cache_name_compare(const void *a_, const void *b_)
-{
-	const struct cache_entry *ce1, *ce2;
-
-	ce1 = *((const struct cache_entry **)a_);
-	ce2 = *((const struct cache_entry **)b_);
-	return cache_name_stage_compare(ce1->name, ce1->ce_namelen, ce_stage(ce1),
-				  ce2->name, ce2->ce_namelen, ce_stage(ce2));
-}
-
 struct tree *lookup_tree(struct repository *r, const struct object_id *oid)
 {
 	struct object *obj = lookup_object(r, oid);
diff --git a/tree.h b/tree.h
index 84d66b45538..34549c86c9f 100644
--- a/tree.h
+++ b/tree.h
@@ -28,8 +28,6 @@  void free_tree_buffer(struct tree *tree);
 /* Parses and returns the tree in the given ent, chasing tags and commits. */
 struct tree *parse_tree_indirect(const struct object_id *oid);
 
-int cmp_cache_name_compare(const void *a_, const void *b_);
-
 #define READ_TREE_RECURSIVE 1
 typedef int (*read_tree_fn_t)(const struct object_id *, struct strbuf *, const char *, unsigned int, int, void *);