Skip to content

Commit 19be71d

Browse files
pks-tgitster
authored andcommitted
delta-islands: stop depending on the_repository
There are multiple sites in "delta-islands.c" where we use the global `the_repository` variable, either explicitly or implicitly by using `the_hash_algo`. Refactor the code to stop using `the_repository`. In most cases this is trivial because we already had a repository available in the calling context, with the only exception being `propagate_island_marks()`. Adapt it so that the repository gets passed in via a parameter. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f6e174b commit 19be71d

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

builtin/pack-objects.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3847,7 +3847,7 @@ static void show_commit(struct commit *commit, void *data UNUSED)
38473847
index_commit_for_bitmap(commit);
38483848

38493849
if (use_delta_islands)
3850-
propagate_island_marks(commit);
3850+
propagate_island_marks(the_repository, commit);
38513851
}
38523852

38533853
static void show_object(struct object *obj, const char *name,

delta-islands.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#define USE_THE_REPOSITORY_VARIABLE
21
#define DISABLE_SIGN_COMPARE_WARNINGS
32

43
#include "git-compat-util.h"
@@ -267,8 +266,7 @@ void resolve_tree_islands(struct repository *r,
267266
QSORT(todo, nr, tree_depth_compare);
268267

269268
if (progress)
270-
progress_state = start_progress(the_repository,
271-
_("Propagating island marks"), nr);
269+
progress_state = start_progress(r, _("Propagating island marks"), nr);
272270

273271
for (i = 0; i < nr; i++) {
274272
struct object_entry *ent = todo[i].entry;
@@ -490,9 +488,9 @@ void load_delta_islands(struct repository *r, int progress)
490488

491489
island_marks = kh_init_oid_map();
492490

493-
git_config(island_config_callback, &ild);
491+
repo_config(r, island_config_callback, &ild);
494492
ild.remote_islands = kh_init_str();
495-
refs_for_each_ref(get_main_ref_store(the_repository),
493+
refs_for_each_ref(get_main_ref_store(r),
496494
find_island_for_ref, &ild);
497495
free_config_regexes(&ild);
498496
deduplicate_islands(ild.remote_islands, r);
@@ -502,16 +500,16 @@ void load_delta_islands(struct repository *r, int progress)
502500
fprintf(stderr, _("Marked %d islands, done.\n"), island_counter);
503501
}
504502

505-
void propagate_island_marks(struct commit *commit)
503+
void propagate_island_marks(struct repository *r, struct commit *commit)
506504
{
507505
khiter_t pos = kh_get_oid_map(island_marks, commit->object.oid);
508506

509507
if (pos < kh_end(island_marks)) {
510508
struct commit_list *p;
511509
struct island_bitmap *root_marks = kh_value(island_marks, pos);
512510

513-
repo_parse_commit(the_repository, commit);
514-
set_island_marks(&repo_get_commit_tree(the_repository, commit)->object,
511+
repo_parse_commit(r, commit);
512+
set_island_marks(&repo_get_commit_tree(r, commit)->object,
515513
root_marks);
516514
for (p = commit->parents; p; p = p->next)
517515
set_island_marks(&p->item->object, root_marks);

delta-islands.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ void resolve_tree_islands(struct repository *r,
1212
int progress,
1313
struct packing_data *to_pack);
1414
void load_delta_islands(struct repository *r, int progress);
15-
void propagate_island_marks(struct commit *commit);
15+
void propagate_island_marks(struct repository *r, struct commit *commit);
1616
int compute_pack_layers(struct packing_data *to_pack);
1717
void free_island_marks(void);
1818

0 commit comments

Comments
 (0)