Skip to content

Commit 34e7771

Browse files
pcloudsgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 90d3405 commit 34e7771

File tree

4 files changed

+26
-22
lines changed

4 files changed

+26
-22
lines changed

merge-recursive.c

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -465,17 +465,18 @@ static void get_files_dirs(struct merge_options *opt, struct tree *tree)
465465
{
466466
struct pathspec match_all;
467467
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,
469469
&match_all, save_files_dirs, opt);
470470
}
471471

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,
473474
const char *path,
474475
struct diff_filespec *dfs)
475476
{
476477
int ret;
477478

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);
479480
if (S_ISDIR(dfs->mode)) {
480481
oidcpy(&dfs->oid, &null_oid);
481482
dfs->mode = 0;
@@ -487,15 +488,16 @@ static int get_tree_entry_if_blob(const struct object_id *tree,
487488
* Returns an index_entry instance which doesn't have to correspond to
488489
* a real cache entry in Git's index.
489490
*/
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,
491493
struct tree *o, struct tree *a, struct tree *b,
492494
struct string_list *entries)
493495
{
494496
struct string_list_item *item;
495497
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]);
499501
item = string_list_insert(entries, path);
500502
item->util = e;
501503
return e;
@@ -1900,12 +1902,13 @@ static struct diff_queue_struct *get_diffpairs(struct merge_options *opt,
19001902
return ret;
19011903
}
19021904

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)
19041907
{
19051908
struct object_id hashy;
19061909
unsigned short mode_o;
19071910

1908-
return !get_tree_entry(the_repository,
1911+
return !get_tree_entry(r,
19091912
&tree->object.oid, path,
19101913
&hashy, &mode_o);
19111914
}
@@ -2057,7 +2060,7 @@ static char *handle_path_level_conflicts(struct merge_options *opt,
20572060
*/
20582061
if (collision_ent->reported_already) {
20592062
clean = 0;
2060-
} else if (tree_has_path(tree, new_path)) {
2063+
} else if (tree_has_path(opt->repo, tree, new_path)) {
20612064
collision_ent->reported_already = 1;
20622065
strbuf_add_separated_string_list(&collision_paths, ", ",
20632066
&collision_ent->source_files);
@@ -2135,7 +2138,7 @@ static void handle_directory_level_conflicts(struct merge_options *opt,
21352138
string_list_append(&remove_from_merge,
21362139
merge_ent->dir)->util = merge_ent;
21372140
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)) {
21392142
/* 2. This wasn't a directory rename after all */
21402143
string_list_append(&remove_from_head,
21412144
head_ent->dir)->util = head_ent;
@@ -2149,7 +2152,7 @@ static void handle_directory_level_conflicts(struct merge_options *opt,
21492152
hashmap_iter_init(dir_re_merge, &iter);
21502153
while ((merge_ent = hashmap_iter_next(&iter))) {
21512154
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)) {
21532156
/* 2. This wasn't a directory rename after all */
21542157
string_list_append(&remove_from_merge,
21552158
merge_ent->dir)->util = merge_ent;
@@ -2478,7 +2481,7 @@ static void apply_directory_rename_modifications(struct merge_options *opt,
24782481
if (pair->status == 'R')
24792482
re->dst_entry->processed = 1;
24802483

2481-
re->dst_entry = insert_stage_data(new_path,
2484+
re->dst_entry = insert_stage_data(opt->repo, new_path,
24822485
o_tree, a_tree, b_tree,
24832486
entries);
24842487
item = string_list_insert(entries, new_path);
@@ -2587,14 +2590,16 @@ static struct string_list *get_renames(struct merge_options *opt,
25872590
re->dir_rename_original_dest = NULL;
25882591
item = string_list_lookup(entries, re->pair->one->path);
25892592
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,
25912595
o_tree, a_tree, b_tree, entries);
25922596
else
25932597
re->src_entry = item->util;
25942598

25952599
item = string_list_lookup(entries, re->pair->two->path);
25962600
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,
25982603
o_tree, a_tree, b_tree, entries);
25992604
else
26002605
re->dst_entry = item->util;

sequencer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3733,7 +3733,7 @@ static int pick_commits(struct repository *r,
37333733
unlink(rebase_path_author_script());
37343734
unlink(rebase_path_stopped_sha());
37353735
unlink(rebase_path_amend());
3736-
unlink(git_path_merge_head(the_repository));
3736+
unlink(git_path_merge_head(r));
37373737
delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF);
37383738

37393739
if (item->command == TODO_BREAK)
@@ -4107,7 +4107,7 @@ static int commit_staged_changes(struct repository *r,
41074107
opts, flags))
41084108
return error(_("could not commit staged changes."));
41094109
unlink(rebase_path_amend());
4110-
unlink(git_path_merge_head(the_repository));
4110+
unlink(git_path_merge_head(r));
41114111
if (final_fixup) {
41124112
unlink(rebase_path_fixup_msg());
41134113
unlink(rebase_path_squash_msg());

sha1-name.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ static enum get_oid_result get_short_oid(struct repository *r,
478478
* or migrated from loose to packed.
479479
*/
480480
if (status == MISSING_OBJECT) {
481-
reprepare_packed_git(the_repository);
481+
reprepare_packed_git(r);
482482
find_short_object_filename(&ds);
483483
find_short_packed_object(&ds);
484484
status = finish_object_disambiguation(&ds, oid);
@@ -1389,9 +1389,7 @@ int repo_get_oid_mb(struct repository *r,
13891389
two = lookup_commit_reference_gently(r, &oid_tmp, 0);
13901390
if (!two)
13911391
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);
13951393
if (!mbs || mbs->next)
13961394
st = -1;
13971395
else {

shallow.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,8 @@ static void check_shallow_file_for_update(struct repository *r)
248248
if (r->parsed_objects->is_shallow == -1)
249249
BUG("shallow must be initialized by now");
250250

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)))
252253
die("shallow file has changed since we read it");
253254
}
254255

0 commit comments

Comments
 (0)