Use the right 'struct repository' instead of the_repository

There are a couple of places where 'struct repository' is already passed around, but the_repository is still used. Use the right repo. 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 34e7771bc64475d71430c20937f6828675ebccdb
4 files changed +26 -22
merge-recursive.c
+20 -15
@@ -465,17 +465,18 @@ static void get_files_dirs(struct merge_options *opt, struct tree *tree)
465 {
466 struct pathspec match_all;
467 memset(&match_all, 0, sizeof(match_all));
468 - read_tree_recursive(the_repository, tree, "", 0, 0,
468 + read_tree_recursive(opt->repo, tree, "", 0, 0,
469 &match_all, save_files_dirs, opt);
470 }
471
472 -static int get_tree_entry_if_blob(const struct object_id *tree,
472 +static int get_tree_entry_if_blob(struct repository *r,
473 + const struct object_id *tree,
474 const char *path,
475 struct diff_filespec *dfs)
476 {
477 int ret;
478
478 - ret = get_tree_entry(the_repository, tree, path, &dfs->oid, &dfs->mode);
479 + ret = get_tree_entry(r, tree, path, &dfs->oid, &dfs->mode);
480 if (S_ISDIR(dfs->mode)) {
481 oidcpy(&dfs->oid, &null_oid);
482 dfs->mode = 0;
@@ -487,15 +488,16 @@ static int get_tree_entry_if_blob(const struct object_id *tree,
488 * Returns an index_entry instance which doesn't have to correspond to
489 * a real cache entry in Git's index.
490 */
490 -static struct stage_data *insert_stage_data(const char *path,
491 +static struct stage_data *insert_stage_data(struct repository *r,
492 + const char *path,
493 struct tree *o, struct tree *a, struct tree *b,
494 struct string_list *entries)
495 {
496 struct string_list_item *item;
497 struct stage_data *e = xcalloc(1, sizeof(struct stage_data));
496 - get_tree_entry_if_blob(&o->object.oid, path, &e->stages[1]);
497 - get_tree_entry_if_blob(&a->object.oid, path, &e->stages[2]);
498 - get_tree_entry_if_blob(&b->object.oid, path, &e->stages[3]);
498 + get_tree_entry_if_blob(r, &o->object.oid, path, &e->stages[1]);
499 + get_tree_entry_if_blob(r, &a->object.oid, path, &e->stages[2]);
500 + get_tree_entry_if_blob(r, &b->object.oid, path, &e->stages[3]);
501 item = string_list_insert(entries, path);
502 item->util = e;
503 return e;
@@ -1900,12 +1902,13 @@ static struct diff_queue_struct *get_diffpairs(struct merge_options *opt,
1902 return ret;
1903 }
1904
1903 -static int tree_has_path(struct tree *tree, const char *path)
1905 +static int tree_has_path(struct repository *r, struct tree *tree,
1906 + const char *path)
1907 {
1908 struct object_id hashy;
1909 unsigned short mode_o;
1910
1908 - return !get_tree_entry(the_repository,
1911 + return !get_tree_entry(r,
1912 &tree->object.oid, path,
1913 &hashy, &mode_o);
1914 }
@@ -2057,7 +2060,7 @@ static char *handle_path_level_conflicts(struct merge_options *opt,
2060 */
2061 if (collision_ent->reported_already) {
2062 clean = 0;
2060 - } else if (tree_has_path(tree, new_path)) {
2063 + } else if (tree_has_path(opt->repo, tree, new_path)) {
2064 collision_ent->reported_already = 1;
2065 strbuf_add_separated_string_list(&collision_paths, ", ",
2066 &collision_ent->source_files);
@@ -2135,7 +2138,7 @@ static void handle_directory_level_conflicts(struct merge_options *opt,
2138 string_list_append(&remove_from_merge,
2139 merge_ent->dir)->util = merge_ent;
2140 strbuf_release(&merge_ent->new_dir);
2138 - } else if (tree_has_path(head, head_ent->dir)) {
2141 + } else if (tree_has_path(opt->repo, head, head_ent->dir)) {
2142 /* 2. This wasn't a directory rename after all */
2143 string_list_append(&remove_from_head,
2144 head_ent->dir)->util = head_ent;
@@ -2149,7 +2152,7 @@ static void handle_directory_level_conflicts(struct merge_options *opt,
2152 hashmap_iter_init(dir_re_merge, &iter);
2153 while ((merge_ent = hashmap_iter_next(&iter))) {
2154 head_ent = dir_rename_find_entry(dir_re_head, merge_ent->dir);
2152 - if (tree_has_path(merge, merge_ent->dir)) {
2155 + if (tree_has_path(opt->repo, merge, merge_ent->dir)) {
2156 /* 2. This wasn't a directory rename after all */
2157 string_list_append(&remove_from_merge,
2158 merge_ent->dir)->util = merge_ent;
@@ -2478,7 +2481,7 @@ static void apply_directory_rename_modifications(struct merge_options *opt,
2481 if (pair->status == 'R')
2482 re->dst_entry->processed = 1;
2483
2481 - re->dst_entry = insert_stage_data(new_path,
2484 + re->dst_entry = insert_stage_data(opt->repo, new_path,
2485 o_tree, a_tree, b_tree,
2486 entries);
2487 item = string_list_insert(entries, new_path);
@@ -2587,14 +2590,16 @@ static struct string_list *get_renames(struct merge_options *opt,
2590 re->dir_rename_original_dest = NULL;
2591 item = string_list_lookup(entries, re->pair->one->path);
2592 if (!item)
2590 - re->src_entry = insert_stage_data(re->pair->one->path,
2593 + re->src_entry = insert_stage_data(opt->repo,
2594 + re->pair->one->path,
2595 o_tree, a_tree, b_tree, entries);
2596 else
2597 re->src_entry = item->util;
2598
2599 item = string_list_lookup(entries, re->pair->two->path);
2600 if (!item)
2597 - re->dst_entry = insert_stage_data(re->pair->two->path,
2601 + re->dst_entry = insert_stage_data(opt->repo,
2602 + re->pair->two->path,
2603 o_tree, a_tree, b_tree, entries);
2604 else
2605 re->dst_entry = item->util;
sequencer.c
+2 -2
@@ -3733,7 +3733,7 @@ static int pick_commits(struct repository *r,
3733 unlink(rebase_path_author_script());
3734 unlink(rebase_path_stopped_sha());
3735 unlink(rebase_path_amend());
3736 - unlink(git_path_merge_head(the_repository));
3736 + unlink(git_path_merge_head(r));
3737 delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF);
3738
3739 if (item->command == TODO_BREAK)
@@ -4107,7 +4107,7 @@ static int commit_staged_changes(struct repository *r,
4107 opts, flags))
4108 return error(_("could not commit staged changes."));
4109 unlink(rebase_path_amend());
4110 - unlink(git_path_merge_head(the_repository));
4110 + unlink(git_path_merge_head(r));
4111 if (final_fixup) {
4112 unlink(rebase_path_fixup_msg());
4113 unlink(rebase_path_squash_msg());
sha1-name.c
+2 -4
@@ -478,7 +478,7 @@ static enum get_oid_result get_short_oid(struct repository *r,
478 * or migrated from loose to packed.
479 */
480 if (status == MISSING_OBJECT) {
481 - reprepare_packed_git(the_repository);
481 + reprepare_packed_git(r);
482 find_short_object_filename(&ds);
483 find_short_packed_object(&ds);
484 status = finish_object_disambiguation(&ds, oid);
@@ -1389,9 +1389,7 @@ int repo_get_oid_mb(struct repository *r,
1389 two = lookup_commit_reference_gently(r, &oid_tmp, 0);
1390 if (!two)
1391 return -1;
1392 - if (r != the_repository)
1393 - BUG("sorry get_merge_bases() can't take struct repository yet");
1394 - mbs = get_merge_bases(one, two);
1392 + mbs = repo_get_merge_bases(r, one, two);
1393 if (!mbs || mbs->next)
1394 st = -1;
1395 else {
shallow.c
+2 -1
@@ -248,7 +248,8 @@ static void check_shallow_file_for_update(struct repository *r)
248 if (r->parsed_objects->is_shallow == -1)
249 BUG("shallow must be initialized by now");
250
251 - if (!stat_validity_check(r->parsed_objects->shallow_stat, git_path_shallow(the_repository)))
251 + if (!stat_validity_check(r->parsed_objects->shallow_stat,
252 + git_path_shallow(r)))
253 die("shallow file has changed since we read it");
254 }
255