sha1_file: add repository argument to prepare_alt_odb
See previous patch for explanation. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
93d8d1e29d
commit
0b20903405
@ -719,7 +719,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
|
|||||||
|
|
||||||
fsck_object_dir(get_object_directory());
|
fsck_object_dir(get_object_directory());
|
||||||
|
|
||||||
prepare_alt_odb();
|
prepare_alt_odb(the_repository);
|
||||||
alt_odb_list = the_repository->objects->alt_odb_list;
|
alt_odb_list = the_repository->objects->alt_odb_list;
|
||||||
for (alt = alt_odb_list; alt; alt = alt->next)
|
for (alt = alt_odb_list; alt; alt = alt->next)
|
||||||
fsck_object_dir(alt->path);
|
fsck_object_dir(alt->path);
|
||||||
|
@ -20,7 +20,8 @@ struct alternate_object_database {
|
|||||||
|
|
||||||
char path[FLEX_ARRAY];
|
char path[FLEX_ARRAY];
|
||||||
};
|
};
|
||||||
void prepare_alt_odb(void);
|
#define prepare_alt_odb(r) prepare_alt_odb_##r()
|
||||||
|
void prepare_alt_odb_the_repository(void);
|
||||||
char *compute_alternate_path(const char *path, struct strbuf *err);
|
char *compute_alternate_path(const char *path, struct strbuf *err);
|
||||||
typedef int alt_odb_fn(struct alternate_object_database *, void *);
|
typedef int alt_odb_fn(struct alternate_object_database *, void *);
|
||||||
int foreach_alt_odb(alt_odb_fn, void*);
|
int foreach_alt_odb(alt_odb_fn, void*);
|
||||||
|
@ -890,7 +890,7 @@ void prepare_packed_git(void)
|
|||||||
if (the_repository->objects->packed_git_initialized)
|
if (the_repository->objects->packed_git_initialized)
|
||||||
return;
|
return;
|
||||||
prepare_packed_git_one(get_object_directory(), 1);
|
prepare_packed_git_one(get_object_directory(), 1);
|
||||||
prepare_alt_odb();
|
prepare_alt_odb(the_repository);
|
||||||
for (alt = the_repository->objects->alt_odb_list; alt; alt = alt->next)
|
for (alt = the_repository->objects->alt_odb_list; alt; alt = alt->next)
|
||||||
prepare_packed_git_one(alt->path, 0);
|
prepare_packed_git_one(alt->path, 0);
|
||||||
rearrange_packed_git();
|
rearrange_packed_git();
|
||||||
|
12
sha1_file.c
12
sha1_file.c
@ -582,7 +582,7 @@ void add_to_alternates_memory(const char *reference)
|
|||||||
* Make sure alternates are initialized, or else our entry may be
|
* Make sure alternates are initialized, or else our entry may be
|
||||||
* overwritten when they are.
|
* overwritten when they are.
|
||||||
*/
|
*/
|
||||||
prepare_alt_odb();
|
prepare_alt_odb(the_repository);
|
||||||
|
|
||||||
link_alt_odb_entries(the_repository, reference,
|
link_alt_odb_entries(the_repository, reference,
|
||||||
'\n', NULL, 0);
|
'\n', NULL, 0);
|
||||||
@ -668,7 +668,7 @@ int foreach_alt_odb(alt_odb_fn fn, void *cb)
|
|||||||
struct alternate_object_database *ent;
|
struct alternate_object_database *ent;
|
||||||
int r = 0;
|
int r = 0;
|
||||||
|
|
||||||
prepare_alt_odb();
|
prepare_alt_odb(the_repository);
|
||||||
for (ent = the_repository->objects->alt_odb_list; ent; ent = ent->next) {
|
for (ent = the_repository->objects->alt_odb_list; ent; ent = ent->next) {
|
||||||
r = fn(ent, cb);
|
r = fn(ent, cb);
|
||||||
if (r)
|
if (r)
|
||||||
@ -677,7 +677,7 @@ int foreach_alt_odb(alt_odb_fn fn, void *cb)
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
void prepare_alt_odb(void)
|
void prepare_alt_odb_the_repository(void)
|
||||||
{
|
{
|
||||||
if (the_repository->objects->alt_odb_tail)
|
if (the_repository->objects->alt_odb_tail)
|
||||||
return;
|
return;
|
||||||
@ -728,7 +728,7 @@ static int check_and_freshen_local(const unsigned char *sha1, int freshen)
|
|||||||
static int check_and_freshen_nonlocal(const unsigned char *sha1, int freshen)
|
static int check_and_freshen_nonlocal(const unsigned char *sha1, int freshen)
|
||||||
{
|
{
|
||||||
struct alternate_object_database *alt;
|
struct alternate_object_database *alt;
|
||||||
prepare_alt_odb();
|
prepare_alt_odb(the_repository);
|
||||||
for (alt = the_repository->objects->alt_odb_list; alt; alt = alt->next) {
|
for (alt = the_repository->objects->alt_odb_list; alt; alt = alt->next) {
|
||||||
const char *path = alt_sha1_path(alt, sha1);
|
const char *path = alt_sha1_path(alt, sha1);
|
||||||
if (check_and_freshen_file(path, freshen))
|
if (check_and_freshen_file(path, freshen))
|
||||||
@ -887,7 +887,7 @@ static int stat_sha1_file(const unsigned char *sha1, struct stat *st,
|
|||||||
if (!lstat(*path, st))
|
if (!lstat(*path, st))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
prepare_alt_odb();
|
prepare_alt_odb(the_repository);
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
for (alt = the_repository->objects->alt_odb_list; alt; alt = alt->next) {
|
for (alt = the_repository->objects->alt_odb_list; alt; alt = alt->next) {
|
||||||
*path = alt_sha1_path(alt, sha1);
|
*path = alt_sha1_path(alt, sha1);
|
||||||
@ -918,7 +918,7 @@ static int open_sha1_file(const unsigned char *sha1, const char **path)
|
|||||||
return fd;
|
return fd;
|
||||||
most_interesting_errno = errno;
|
most_interesting_errno = errno;
|
||||||
|
|
||||||
prepare_alt_odb();
|
prepare_alt_odb(the_repository);
|
||||||
for (alt = the_repository->objects->alt_odb_list; alt; alt = alt->next) {
|
for (alt = the_repository->objects->alt_odb_list; alt; alt = alt->next) {
|
||||||
*path = alt_sha1_path(alt, sha1);
|
*path = alt_sha1_path(alt, sha1);
|
||||||
fd = git_open(*path);
|
fd = git_open(*path);
|
||||||
|
@ -354,7 +354,7 @@ static int init_object_disambiguation(const char *name, int len,
|
|||||||
|
|
||||||
ds->len = len;
|
ds->len = len;
|
||||||
ds->hex_pfx[len] = '\0';
|
ds->hex_pfx[len] = '\0';
|
||||||
prepare_alt_odb();
|
prepare_alt_odb(the_repository);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user