use got_object_tree_find_entry() instead of local copy in diff.c
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
diff --git a/lib/diff.c b/lib/diff.c
index e2adb32..1c51bb9 100644
--- a/lib/diff.c
+++ b/lib/diff.c
@@ -214,20 +214,6 @@ got_diff_free_changes(struct got_diff_changes *changes)
free(changes);
}
-static struct got_tree_entry *
-match_entry_by_name(struct got_tree_entry *te1, struct got_tree_object *tree2)
-{
- struct got_tree_entry *te2;
- const struct got_tree_entries *entries2;
-
- entries2 = got_object_tree_get_entries(tree2);
- SIMPLEQ_FOREACH(te2, &entries2->head, entry) {
- if (strcmp(te1->name, te2->name) == 0)
- return te2;
- }
- return NULL;
-}
-
static const struct got_error *
diff_added_blob(struct got_object_id *id, const char *label,
int diff_context, struct got_repository *repo, FILE *outfile)
@@ -448,9 +434,9 @@ diff_kind_mismatch(struct got_object_id *id1, struct got_object_id *id2,
}
static const struct got_error *
-diff_entry_old_new(struct got_tree_entry *te1, struct got_tree_entry *te2,
- const char *label1, const char *label2, int diff_context,
- struct got_repository *repo, FILE *outfile)
+diff_entry_old_new(const struct got_tree_entry *te1,
+ const struct got_tree_entry *te2, const char *label1, const char *label2,
+ int diff_context, struct got_repository *repo, FILE *outfile)
{
const struct got_error *err = NULL;
int id_match;
@@ -483,9 +469,9 @@ diff_entry_old_new(struct got_tree_entry *te1, struct got_tree_entry *te2,
}
static const struct got_error *
-diff_entry_new_old(struct got_tree_entry *te2, struct got_tree_entry *te1,
- const char *label2, int diff_context, struct got_repository *repo,
- FILE *outfile)
+diff_entry_new_old(const struct got_tree_entry *te2,
+ const struct got_tree_entry *te1, const char *label2, int diff_context,
+ struct got_repository *repo, FILE *outfile)
{
if (te1 != NULL) /* handled by diff_entry_old_new() */
return NULL;
@@ -526,9 +512,10 @@ got_diff_tree(struct got_tree_object *tree1, struct got_tree_object *tree2,
do {
if (te1) {
- struct got_tree_entry *te = NULL;
+ const struct got_tree_entry *te = NULL;
if (tree2)
- te = match_entry_by_name(te1, tree2);
+ te = got_object_tree_find_entry(tree2,
+ te1->name);
if (te) {
free(l2);
l2 = NULL;
@@ -544,9 +531,10 @@ got_diff_tree(struct got_tree_object *tree1, struct got_tree_object *tree2,
}
if (te2) {
- struct got_tree_entry *te = NULL;
+ const struct got_tree_entry *te = NULL;
if (tree1)
- te = match_entry_by_name(te2, tree1);
+ te = got_object_tree_find_entry(tree1,
+ te2->name);
free(l2);
if (te) {
if (asprintf(&l2, "%s%s%s", label2,