match-trees.c: remove the_repo from shift_tree*()
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Thu, 27 Jun 2019 09:28:51 +0000 (16:28 +0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 27 Jun 2019 19:45:17 +0000 (12:45 -0700)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
cache.h
match-trees.c
merge-recursive.c
t/helper/test-match-trees.c
diff --git a/cache.h b/cache.h
index cd84cc9bbe1e6c6c3b6df55c9cdd7305af818589..ddefda2bb6f130fce73a7ad3708d8eb33c7c3d80 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -1786,8 +1786,8 @@ int add_files_to_cache(const char *prefix, const struct pathspec *pathspec, int
 extern int diff_auto_refresh_index;
 
 /* match-trees.c */
-void shift_tree(const struct object_id *, const struct object_id *, struct object_id *, int);
-void shift_tree_by(const struct object_id *, const struct object_id *, struct object_id *, const char *);
+void shift_tree(struct repository *, const struct object_id *, const struct object_id *, struct object_id *, int);
+void shift_tree_by(struct repository *, const struct object_id *, const struct object_id *, struct object_id *, const char *);
 
 /*
  * whitespace rules.
index de7e8a6783148f8dde8c41a7a80e6930804149aa..f6c194c1cca6bd64489b5dc1e90e5525da25d873 100644 (file)
@@ -248,7 +248,8 @@ static int splice_tree(const struct object_id *oid1, const char *prefix,
  * other hand, it could cover tree one and we might need to pick a
  * subtree of it.
  */
-void shift_tree(const struct object_id *hash1,
+void shift_tree(struct repository *r,
+               const struct object_id *hash1,
                const struct object_id *hash2,
                struct object_id *shifted,
                int depth_limit)
@@ -290,7 +291,7 @@ void shift_tree(const struct object_id *hash1,
                if (!*del_prefix)
                        return;
 
-               if (get_tree_entry(the_repository, hash2, del_prefix, shifted, &mode))
+               if (get_tree_entry(r, hash2, del_prefix, shifted, &mode))
                        die("cannot find path %s in tree %s",
                            del_prefix, oid_to_hex(hash2));
                return;
@@ -307,7 +308,8 @@ void shift_tree(const struct object_id *hash1,
  * Unfortunately we cannot fundamentally tell which one to
  * be prefixed, as recursive merge can work in either direction.
  */
-void shift_tree_by(const struct object_id *hash1,
+void shift_tree_by(struct repository *r,
+                  const struct object_id *hash1,
                   const struct object_id *hash2,
                   struct object_id *shifted,
                   const char *shift_prefix)
@@ -317,12 +319,12 @@ void shift_tree_by(const struct object_id *hash1,
        unsigned candidate = 0;
 
        /* Can hash2 be a tree at shift_prefix in tree hash1? */
-       if (!get_tree_entry(the_repository, hash1, shift_prefix, &sub1, &mode1) &&
+       if (!get_tree_entry(r, hash1, shift_prefix, &sub1, &mode1) &&
            S_ISDIR(mode1))
                candidate |= 1;
 
        /* Can hash1 be a tree at shift_prefix in tree hash2? */
-       if (!get_tree_entry(the_repository, hash2, shift_prefix, &sub2, &mode2) &&
+       if (!get_tree_entry(r, hash2, shift_prefix, &sub2, &mode2) &&
            S_ISDIR(mode2))
                candidate |= 2;
 
index b051066795303b73098de3af91c2f42cea118a87..6d772eb0ebf1cb023f2816d918bddf1a9986ea1f 100644 (file)
@@ -153,9 +153,9 @@ static struct tree *shift_tree_object(struct repository *repo,
        struct object_id shifted;
 
        if (!*subtree_shift) {
-               shift_tree(&one->object.oid, &two->object.oid, &shifted, 0);
+               shift_tree(repo, &one->object.oid, &two->object.oid, &shifted, 0);
        } else {
-               shift_tree_by(&one->object.oid, &two->object.oid, &shifted,
+               shift_tree_by(repo, &one->object.oid, &two->object.oid, &shifted,
                              subtree_shift);
        }
        if (oideq(&two->object.oid, &shifted))
index 96857f26ac8540cf22e74aed72bbd30bc8147f00..b9fd427571e6265dbc3be8b6e93acbb6eba61c56 100644 (file)
@@ -20,7 +20,7 @@ int cmd__match_trees(int ac, const char **av)
        if (!two)
                die("not a tree-ish %s", av[2]);
 
-       shift_tree(&one->object.oid, &two->object.oid, &shifted, -1);
+       shift_tree(the_repository, &one->object.oid, &two->object.oid, &shifted, -1);
        printf("shifted: %s\n", oid_to_hex(&shifted));
 
        exit(0);