Skip to content

Commit 93e3475

Browse files
committed
Merge branch 'sb/object-store' into next
Refactoring the internal global data structure to make it possible to open multiple repositories, work with and then close them. Rerolled by Duy on top of a separate preliminary clean-up topic. The resulting structure of the topics looked very sensible. * sb/object-store: (27 commits) sha1_file: allow sha1_loose_object_info to handle arbitrary repositories sha1_file: allow map_sha1_file to handle arbitrary repositories sha1_file: allow map_sha1_file_1 to handle arbitrary repositories sha1_file: allow open_sha1_file to handle arbitrary repositories sha1_file: allow stat_sha1_file to handle arbitrary repositories sha1_file: allow sha1_file_name to handle arbitrary repositories sha1_file: add repository argument to sha1_loose_object_info sha1_file: add repository argument to map_sha1_file sha1_file: add repository argument to map_sha1_file_1 sha1_file: add repository argument to open_sha1_file sha1_file: add repository argument to stat_sha1_file sha1_file: add repository argument to sha1_file_name sha1_file: allow prepare_alt_odb to handle arbitrary repositories sha1_file: allow link_alt_odb_entries to handle arbitrary repositories sha1_file: add repository argument to prepare_alt_odb sha1_file: add repository argument to link_alt_odb_entries sha1_file: add repository argument to read_info_alternates sha1_file: add repository argument to link_alt_odb_entry sha1_file: add raw_object_store argument to alt_odb_usable pack: move approximate object count to object store ...
2 parents ea73d57 + 4a7c05f commit 93e3475

39 files changed

+393
-233
lines changed

builtin/am.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1862,7 +1862,7 @@ static void am_run(struct am_state *state, int resume)
18621862
*/
18631863
if (!state->rebasing) {
18641864
am_destroy(state);
1865-
close_all_packs();
1865+
close_all_packs(the_repository->objects);
18661866
run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
18671867
}
18681868
}

builtin/clone.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "connected.h"
2828
#include "packfile.h"
2929
#include "list-objects-filter-options.h"
30+
#include "object-store.h"
3031

3132
/*
3233
* Overall FIXMEs:
@@ -1217,7 +1218,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
12171218
transport_disconnect(transport);
12181219

12191220
if (option_dissociate) {
1220-
close_all_packs();
1221+
close_all_packs(the_repository->objects);
12211222
dissociate_from_references();
12221223
}
12231224

builtin/count-objects.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
#include "cache.h"
88
#include "config.h"
99
#include "dir.h"
10+
#include "repository.h"
1011
#include "builtin.h"
1112
#include "parse-options.h"
1213
#include "quote.h"
1314
#include "packfile.h"
15+
#include "object-store.h"
1416

1517
static unsigned long garbage;
1618
static off_t size_garbage;
@@ -120,9 +122,9 @@ int cmd_count_objects(int argc, const char **argv, const char *prefix)
120122
struct strbuf loose_buf = STRBUF_INIT;
121123
struct strbuf pack_buf = STRBUF_INIT;
122124
struct strbuf garbage_buf = STRBUF_INIT;
123-
if (!packed_git)
125+
if (!get_packed_git(the_repository))
124126
prepare_packed_git();
125-
for (p = packed_git; p; p = p->next) {
127+
for (p = get_packed_git(the_repository); p; p = p->next) {
126128
if (!p->pack_local)
127129
continue;
128130
if (open_pack_index(p))

builtin/fetch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1533,7 +1533,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
15331533

15341534
string_list_clear(&list, 0);
15351535

1536-
close_all_packs();
1536+
close_all_packs(the_repository->objects);
15371537

15381538
argv_array_pushl(&argv_gc_auto, "gc", "--auto", NULL);
15391539
if (verbosity < 0)

builtin/fsck.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "builtin.h"
22
#include "cache.h"
3+
#include "repository.h"
34
#include "config.h"
45
#include "commit.h"
56
#include "tree.h"
@@ -16,6 +17,7 @@
1617
#include "streaming.h"
1718
#include "decorate.h"
1819
#include "packfile.h"
20+
#include "object-store.h"
1921

2022
#define REACHABLE 0x0001
2123
#define SEEN 0x0002
@@ -719,9 +721,12 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
719721
for_each_loose_object(mark_loose_for_connectivity, NULL, 0);
720722
for_each_packed_object(mark_packed_for_connectivity, NULL, 0);
721723
} else {
724+
struct alternate_object_database *alt_odb_list;
725+
722726
fsck_object_dir(get_object_directory());
723727

724-
prepare_alt_odb();
728+
prepare_alt_odb(the_repository);
729+
alt_odb_list = the_repository->objects->alt_odb_list;
725730
for (alt = alt_odb_list; alt; alt = alt->next)
726731
fsck_object_dir(alt->path);
727732

@@ -733,15 +738,17 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
733738
prepare_packed_git();
734739

735740
if (show_progress) {
736-
for (p = packed_git; p; p = p->next) {
741+
for (p = get_packed_git(the_repository); p;
742+
p = p->next) {
737743
if (open_pack_index(p))
738744
continue;
739745
total += p->num_objects;
740746
}
741747

742748
progress = start_progress(_("Checking objects"), total);
743749
}
744-
for (p = packed_git; p; p = p->next) {
750+
for (p = get_packed_git(the_repository); p;
751+
p = p->next) {
745752
/* verify gives error messages itself */
746753
if (verify_pack(p, fsck_obj_buffer,
747754
progress, count))

builtin/gc.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
*/
1212

1313
#include "builtin.h"
14+
#include "repository.h"
1415
#include "config.h"
1516
#include "tempfile.h"
1617
#include "lockfile.h"
@@ -20,6 +21,7 @@
2021
#include "argv-array.h"
2122
#include "commit.h"
2223
#include "packfile.h"
24+
#include "object-store.h"
2325

2426
#define FAILED_RUN "failed to run %s"
2527

@@ -173,7 +175,7 @@ static int too_many_packs(void)
173175
return 0;
174176

175177
prepare_packed_git();
176-
for (cnt = 0, p = packed_git; p; p = p->next) {
178+
for (cnt = 0, p = get_packed_git(the_repository); p; p = p->next) {
177179
if (!p->pack_local)
178180
continue;
179181
if (p->pack_keep)

builtin/grep.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "pathspec.h"
2323
#include "submodule.h"
2424
#include "submodule-config.h"
25+
#include "object-store.h"
2526

2627
static char const * const grep_usage[] = {
2728
N_("git grep [<options>] [-e] <pattern> [<rev>...] [[--] <path>...]"),
@@ -439,7 +440,7 @@ static int grep_submodule(struct grep_opt *opt, struct repository *superproject,
439440
* object.
440441
*/
441442
grep_read_lock();
442-
add_to_alternates_memory(submodule.objectdir);
443+
add_to_alternates_memory(submodule.objects->objectdir);
443444
grep_read_unlock();
444445

445446
if (oid) {

builtin/index-pack.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "streaming.h"
1414
#include "thread-utils.h"
1515
#include "packfile.h"
16+
#include "object-store.h"
1617

1718
static const char index_pack_usage[] =
1819
"git index-pack [-v] [-o <index-file>] [--keep | --keep=<msg>] [--verify] [--strict] (<pack-file> | --stdin [--fix-thin] [<pack-file>])";

builtin/merge.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ static void finish(struct commit *head_commit,
412412
* We ignore errors in 'gc --auto', since the
413413
* user should see them.
414414
*/
415-
close_all_packs();
415+
close_all_packs(the_repository->objects);
416416
run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
417417
}
418418
}

builtin/pack-objects.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "builtin.h"
22
#include "cache.h"
3+
#include "repository.h"
34
#include "config.h"
45
#include "attr.h"
56
#include "object.h"
@@ -28,6 +29,7 @@
2829
#include "argv-array.h"
2930
#include "list.h"
3031
#include "packfile.h"
32+
#include "object-store.h"
3133

3234
static const char *pack_usage[] = {
3335
N_("git pack-objects --stdout [<options>...] [< <ref-list> | < <object-list>]"),
@@ -1023,8 +1025,7 @@ static int want_object_in_pack(const struct object_id *oid,
10231025
if (want != -1)
10241026
return want;
10251027
}
1026-
1027-
list_for_each(pos, &packed_git_mru) {
1028+
list_for_each(pos, get_packed_git_mru(the_repository)) {
10281029
struct packed_git *p = list_entry(pos, struct packed_git, mru);
10291030
off_t offset;
10301031

@@ -1042,7 +1043,8 @@ static int want_object_in_pack(const struct object_id *oid,
10421043
}
10431044
want = want_found_object(exclude, p);
10441045
if (!exclude && want > 0)
1045-
list_move(&p->mru, &packed_git_mru);
1046+
list_move(&p->mru,
1047+
get_packed_git_mru(the_repository));
10461048
if (want != -1)
10471049
return want;
10481050
}
@@ -2669,7 +2671,7 @@ static void add_objects_in_unpacked_packs(struct rev_info *revs)
26692671

26702672
memset(&in_pack, 0, sizeof(in_pack));
26712673

2672-
for (p = packed_git; p; p = p->next) {
2674+
for (p = get_packed_git(the_repository); p; p = p->next) {
26732675
struct object_id oid;
26742676
struct object *o;
26752677

@@ -2732,7 +2734,8 @@ static int has_sha1_pack_kept_or_nonlocal(const struct object_id *oid)
27322734
static struct packed_git *last_found = (void *)1;
27332735
struct packed_git *p;
27342736

2735-
p = (last_found != (void *)1) ? last_found : packed_git;
2737+
p = (last_found != (void *)1) ? last_found :
2738+
get_packed_git(the_repository);
27362739

27372740
while (p) {
27382741
if ((!p->pack_local || p->pack_keep) &&
@@ -2741,7 +2744,7 @@ static int has_sha1_pack_kept_or_nonlocal(const struct object_id *oid)
27412744
return 1;
27422745
}
27432746
if (p == last_found)
2744-
p = packed_git;
2747+
p = get_packed_git(the_repository);
27452748
else
27462749
p = p->next;
27472750
if (p == last_found)
@@ -2777,7 +2780,7 @@ static void loosen_unused_packed_objects(struct rev_info *revs)
27772780
uint32_t i;
27782781
struct object_id oid;
27792782

2780-
for (p = packed_git; p; p = p->next) {
2783+
for (p = get_packed_git(the_repository); p; p = p->next) {
27812784
if (!p->pack_local || p->pack_keep)
27822785
continue;
27832786

@@ -3148,7 +3151,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
31483151
prepare_packed_git();
31493152
if (ignore_packed_keep) {
31503153
struct packed_git *p;
3151-
for (p = packed_git; p; p = p->next)
3154+
for (p = get_packed_git(the_repository); p; p = p->next)
31523155
if (p->pack_local && p->pack_keep)
31533156
break;
31543157
if (!p) /* no keep-able packs found */
@@ -3161,7 +3164,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
31613164
* also covers non-local objects
31623165
*/
31633166
struct packed_git *p;
3164-
for (p = packed_git; p; p = p->next) {
3167+
for (p = get_packed_git(the_repository); p; p = p->next) {
31653168
if (!p->pack_local) {
31663169
have_non_local_packs = 1;
31673170
break;

builtin/pack-redundant.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
*/
88

99
#include "builtin.h"
10+
#include "repository.h"
1011
#include "packfile.h"
12+
#include "object-store.h"
1113

1214
#define BLKSIZE 512
1315

@@ -571,7 +573,7 @@ static struct pack_list * add_pack(struct packed_git *p)
571573

572574
static struct pack_list * add_pack_file(const char *filename)
573575
{
574-
struct packed_git *p = packed_git;
576+
struct packed_git *p = get_packed_git(the_repository);
575577

576578
if (strlen(filename) < 40)
577579
die("Bad pack filename: %s", filename);
@@ -586,7 +588,7 @@ static struct pack_list * add_pack_file(const char *filename)
586588

587589
static void load_all(void)
588590
{
589-
struct packed_git *p = packed_git;
591+
struct packed_git *p = get_packed_git(the_repository);
590592

591593
while (p) {
592594
add_pack(p);

builtin/receive-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2033,7 +2033,7 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
20332033
proc.git_cmd = 1;
20342034
proc.argv = argv_gc_auto;
20352035

2036-
close_all_packs();
2036+
close_all_packs(the_repository->objects);
20372037
if (!start_command(&proc)) {
20382038
if (use_sideband)
20392039
copy_to_sideband(proc.err, -1, NULL);

builtin/submodule--helper.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "revision.h"
1717
#include "diffcore.h"
1818
#include "diff.h"
19+
#include "object-store.h"
1920

2021
#define OPT_QUIET (1 << 0)
2122
#define OPT_CACHED (1 << 1)

0 commit comments

Comments
 (0)