Skip to content

Commit b3c7eef

Browse files
pcloudsgitster
authored andcommitted
revision.c: reduce implicit dependency the_repository
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2abf350 commit b3c7eef

File tree

3 files changed

+29
-25
lines changed

3 files changed

+29
-25
lines changed

list-objects.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ static void mark_edge_parents_uninteresting(struct commit *commit,
196196
struct commit *parent = parents->item;
197197
if (!(parent->object.flags & UNINTERESTING))
198198
continue;
199-
mark_tree_uninteresting(get_commit_tree(parent));
199+
mark_tree_uninteresting(revs->repo, get_commit_tree(parent));
200200
if (revs->edge_hint && !(parent->object.flags & SHOWN)) {
201201
parent->object.flags |= SHOWN;
202202
show_edge(parent);
@@ -213,7 +213,8 @@ void mark_edges_uninteresting(struct rev_info *revs, show_edge_fn show_edge)
213213
struct commit *commit = list->item;
214214

215215
if (commit->object.flags & UNINTERESTING) {
216-
mark_tree_uninteresting(get_commit_tree(commit));
216+
mark_tree_uninteresting(revs->repo,
217+
get_commit_tree(commit));
217218
if (revs->edge_hint_aggressive && !(commit->object.flags & SHOWN)) {
218219
commit->object.flags |= SHOWN;
219220
show_edge(commit);
@@ -228,7 +229,8 @@ void mark_edges_uninteresting(struct rev_info *revs, show_edge_fn show_edge)
228229
struct commit *commit = (struct commit *)obj;
229230
if (obj->type != OBJ_COMMIT || !(obj->flags & UNINTERESTING))
230231
continue;
231-
mark_tree_uninteresting(get_commit_tree(commit));
232+
mark_tree_uninteresting(revs->repo,
233+
get_commit_tree(commit));
232234
if (!(obj->flags & SHOWN)) {
233235
obj->flags |= SHOWN;
234236
show_edge(commit);

revision.c

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ static void mark_blob_uninteresting(struct blob *blob)
5151
blob->object.flags |= UNINTERESTING;
5252
}
5353

54-
static void mark_tree_contents_uninteresting(struct tree *tree)
54+
static void mark_tree_contents_uninteresting(struct repository *r,
55+
struct tree *tree)
5556
{
5657
struct tree_desc desc;
5758
struct name_entry entry;
@@ -63,10 +64,10 @@ static void mark_tree_contents_uninteresting(struct tree *tree)
6364
while (tree_entry(&desc, &entry)) {
6465
switch (object_type(entry.mode)) {
6566
case OBJ_TREE:
66-
mark_tree_uninteresting(lookup_tree(the_repository, entry.oid));
67+
mark_tree_uninteresting(r, lookup_tree(r, entry.oid));
6768
break;
6869
case OBJ_BLOB:
69-
mark_blob_uninteresting(lookup_blob(the_repository, entry.oid));
70+
mark_blob_uninteresting(lookup_blob(r, entry.oid));
7071
break;
7172
default:
7273
/* Subproject commit - not in this repository */
@@ -81,7 +82,7 @@ static void mark_tree_contents_uninteresting(struct tree *tree)
8182
free_tree_buffer(tree);
8283
}
8384

84-
void mark_tree_uninteresting(struct tree *tree)
85+
void mark_tree_uninteresting(struct repository *r, struct tree *tree)
8586
{
8687
struct object *obj;
8788

@@ -92,7 +93,7 @@ void mark_tree_uninteresting(struct tree *tree)
9293
if (obj->flags & UNINTERESTING)
9394
return;
9495
obj->flags |= UNINTERESTING;
95-
mark_tree_contents_uninteresting(tree);
96+
mark_tree_contents_uninteresting(r, tree);
9697
}
9798

9899
struct commit_stack {
@@ -198,7 +199,7 @@ void add_head_to_pending(struct rev_info *revs)
198199
struct object *obj;
199200
if (get_oid("HEAD", &oid))
200201
return;
201-
obj = parse_object(the_repository, &oid);
202+
obj = parse_object(revs->repo, &oid);
202203
if (!obj)
203204
return;
204205
add_pending_object(revs, obj, "HEAD");
@@ -210,7 +211,7 @@ static struct object *get_reference(struct rev_info *revs, const char *name,
210211
{
211212
struct object *object;
212213

213-
object = parse_object(the_repository, oid);
214+
object = parse_object(revs->repo, oid);
214215
if (!object) {
215216
if (revs->ignore_missing)
216217
return object;
@@ -247,7 +248,7 @@ static struct commit *handle_commit(struct rev_info *revs,
247248
add_pending_object(revs, object, tag->tag);
248249
if (!tag->tagged)
249250
die("bad tag");
250-
object = parse_object(the_repository, &tag->tagged->oid);
251+
object = parse_object(revs->repo, &tag->tagged->oid);
251252
if (!object) {
252253
if (revs->ignore_missing_links || (flags & UNINTERESTING))
253254
return NULL;
@@ -297,7 +298,7 @@ static struct commit *handle_commit(struct rev_info *revs,
297298
if (!revs->tree_objects)
298299
return NULL;
299300
if (flags & UNINTERESTING) {
300-
mark_tree_contents_uninteresting(tree);
301+
mark_tree_contents_uninteresting(revs->repo, tree);
301302
return NULL;
302303
}
303304
add_pending_object_with_path(revs, object, name, mode, path);
@@ -1253,7 +1254,7 @@ static void handle_one_reflog_commit(struct object_id *oid, void *cb_data)
12531254
{
12541255
struct all_refs_cb *cb = cb_data;
12551256
if (!is_null_oid(oid)) {
1256-
struct object *o = parse_object(the_repository, oid);
1257+
struct object *o = parse_object(cb->all_revs->repo, oid);
12571258
if (o) {
12581259
o->flags |= cb->all_flags;
12591260
/* ??? CMDLINEFLAGS ??? */
@@ -1312,7 +1313,7 @@ void add_reflogs_to_pending(struct rev_info *revs, unsigned flags)
13121313

13131314
cb.all_revs = revs;
13141315
cb.all_flags = flags;
1315-
cb.refs = get_main_ref_store(the_repository);
1316+
cb.refs = get_main_ref_store(revs->repo);
13161317
for_each_reflog(handle_one_reflog, &cb);
13171318

13181319
if (!revs->single_worktree)
@@ -1326,7 +1327,7 @@ static void add_cache_tree(struct cache_tree *it, struct rev_info *revs,
13261327
int i;
13271328

13281329
if (it->entry_count >= 0) {
1329-
struct tree *tree = lookup_tree(the_repository, &it->oid);
1330+
struct tree *tree = lookup_tree(revs->repo, &it->oid);
13301331
add_pending_object_with_path(revs, &tree->object, "",
13311332
040000, path->buf);
13321333
}
@@ -1352,7 +1353,7 @@ static void do_add_index_objects_to_pending(struct rev_info *revs,
13521353
if (S_ISGITLINK(ce->ce_mode))
13531354
continue;
13541355

1355-
blob = lookup_blob(the_repository, &ce->oid);
1356+
blob = lookup_blob(revs->repo, &ce->oid);
13561357
if (!blob)
13571358
die("unable to add index blob to traversal");
13581359
add_pending_object_with_path(revs, &blob->object, "",
@@ -1585,8 +1586,8 @@ static int handle_dotdot_1(const char *arg, char *dotdot,
15851586
*dotdot = '\0';
15861587
}
15871588

1588-
a_obj = parse_object(the_repository, &a_oid);
1589-
b_obj = parse_object(the_repository, &b_oid);
1589+
a_obj = parse_object(revs->repo, &a_oid);
1590+
b_obj = parse_object(revs->repo, &b_oid);
15901591
if (!a_obj || !b_obj)
15911592
return dotdot_missing(arg, dotdot, revs, symmetric);
15921593

@@ -1599,8 +1600,8 @@ static int handle_dotdot_1(const char *arg, char *dotdot,
15991600
struct commit *a, *b;
16001601
struct commit_list *exclude;
16011602

1602-
a = lookup_commit_reference(the_repository, &a_obj->oid);
1603-
b = lookup_commit_reference(the_repository, &b_obj->oid);
1603+
a = lookup_commit_reference(revs->repo, &a_obj->oid);
1604+
b = lookup_commit_reference(revs->repo, &b_obj->oid);
16041605
if (!a || !b)
16051606
return dotdot_missing(arg, dotdot, revs, symmetric);
16061607

@@ -2208,7 +2209,7 @@ static int handle_revision_pseudo_opt(const char *submodule,
22082209
BUG("--single-worktree cannot be used together with submodule");
22092210
refs = get_submodule_ref_store(submodule);
22102211
} else
2211-
refs = get_main_ref_store(the_repository);
2212+
refs = get_main_ref_store(revs->repo);
22122213

22132214
/*
22142215
* NOTE!
@@ -2889,9 +2890,10 @@ void reset_revision_walk(void)
28892890
static int mark_uninteresting(const struct object_id *oid,
28902891
struct packed_git *pack,
28912892
uint32_t pos,
2892-
void *unused)
2893+
void *cb)
28932894
{
2894-
struct object *o = parse_object(the_repository, oid);
2895+
struct rev_info *revs = cb;
2896+
struct object *o = parse_object(revs->repo, oid);
28952897
o->flags |= UNINTERESTING | SEEN;
28962898
return 0;
28972899
}
@@ -2924,7 +2926,7 @@ int prepare_revision_walk(struct rev_info *revs)
29242926
revs->treesame.name = "treesame";
29252927

29262928
if (revs->exclude_promisor_objects) {
2927-
for_each_packed_object(mark_uninteresting, NULL,
2929+
for_each_packed_object(mark_uninteresting, revs,
29282930
FOR_EACH_OBJECT_PROMISOR_ONLY);
29292931
}
29302932

revision.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ void put_revision_mark(const struct rev_info *revs,
280280
const struct commit *commit);
281281

282282
void mark_parents_uninteresting(struct commit *commit);
283-
void mark_tree_uninteresting(struct tree *tree);
283+
void mark_tree_uninteresting(struct repository *r, struct tree *tree);
284284

285285
void show_object_with_name(FILE *, struct object *, const char *);
286286

0 commit comments

Comments
 (0)