match-trees.c: remove the_repo from shift_tree*()

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Jun 27, 2019 at 16:28 UTC 90d3405196cfe5d3c63185a33dcee57fb6ea7e8a
4 files changed +12 -10
cache.h
+2 -2
@@ -1786,8 +1786,8 @@ int add_files_to_cache(const char *prefix, const struct pathspec *pathspec, int
1786 extern int diff_auto_refresh_index;
1787
1788 /* match-trees.c */
1789 -void shift_tree(const struct object_id *, const struct object_id *, struct object_id *, int);
1790 -void shift_tree_by(const struct object_id *, const struct object_id *, struct object_id *, const char *);
1789 +void shift_tree(struct repository *, const struct object_id *, const struct object_id *, struct object_id *, int);
1790 +void shift_tree_by(struct repository *, const struct object_id *, const struct object_id *, struct object_id *, const char *);
1791
1792 /*
1793 * whitespace rules.
match-trees.c
+7 -5
@@ -248,7 +248,8 @@ static int splice_tree(const struct object_id *oid1, const char *prefix,
248 * other hand, it could cover tree one and we might need to pick a
249 * subtree of it.
250 */
251 -void shift_tree(const struct object_id *hash1,
251 +void shift_tree(struct repository *r,
252 + const struct object_id *hash1,
253 const struct object_id *hash2,
254 struct object_id *shifted,
255 int depth_limit)
@@ -290,7 +291,7 @@ void shift_tree(const struct object_id *hash1,
291 if (!*del_prefix)
292 return;
293
293 - if (get_tree_entry(the_repository, hash2, del_prefix, shifted, &mode))
294 + if (get_tree_entry(r, hash2, del_prefix, shifted, &mode))
295 die("cannot find path %s in tree %s",
296 del_prefix, oid_to_hex(hash2));
297 return;
@@ -307,7 +308,8 @@ void shift_tree(const struct object_id *hash1,
308 * Unfortunately we cannot fundamentally tell which one to
309 * be prefixed, as recursive merge can work in either direction.
310 */
310 -void shift_tree_by(const struct object_id *hash1,
311 +void shift_tree_by(struct repository *r,
312 + const struct object_id *hash1,
313 const struct object_id *hash2,
314 struct object_id *shifted,
315 const char *shift_prefix)
@@ -317,12 +319,12 @@ void shift_tree_by(const struct object_id *hash1,
319 unsigned candidate = 0;
320
321 /* Can hash2 be a tree at shift_prefix in tree hash1? */
320 - if (!get_tree_entry(the_repository, hash1, shift_prefix, &sub1, &mode1) &&
322 + if (!get_tree_entry(r, hash1, shift_prefix, &sub1, &mode1) &&
323 S_ISDIR(mode1))
324 candidate |= 1;
325
326 /* Can hash1 be a tree at shift_prefix in tree hash2? */
325 - if (!get_tree_entry(the_repository, hash2, shift_prefix, &sub2, &mode2) &&
327 + if (!get_tree_entry(r, hash2, shift_prefix, &sub2, &mode2) &&
328 S_ISDIR(mode2))
329 candidate |= 2;
330
merge-recursive.c
+2 -2
@@ -153,9 +153,9 @@ static struct tree *shift_tree_object(struct repository *repo,
153 struct object_id shifted;
154
155 if (!*subtree_shift) {
156 - shift_tree(&one->object.oid, &two->object.oid, &shifted, 0);
156 + shift_tree(repo, &one->object.oid, &two->object.oid, &shifted, 0);
157 } else {
158 - shift_tree_by(&one->object.oid, &two->object.oid, &shifted,
158 + shift_tree_by(repo, &one->object.oid, &two->object.oid, &shifted,
159 subtree_shift);
160 }
161 if (oideq(&two->object.oid, &shifted))
t/helper/test-match-trees.c
+1 -1
@@ -20,7 +20,7 @@ int cmd__match_trees(int ac, const char **av)
20 if (!two)
21 die("not a tree-ish %s", av[2]);
22
23 - shift_tree(&one->object.oid, &two->object.oid, &shifted, -1);
23 + shift_tree(the_repository, &one->object.oid, &two->object.oid, &shifted, -1);
24 printf("shifted: %s\n", oid_to_hex(&shifted));
25
26 exit(0);