Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> --- builtin/index-pack.c | 2 +- cache.h | 3 ++- fast-import.c | 2 +- sha1_file.c | 15 +++++++++------ 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/builtin/index-pack.c b/builtin/index-pack.c index 79dfe47..aab9de5 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -1414,7 +1414,7 @@ static void read_v2_anomalous_offsets(struct packed_git *p, static void read_idx_option(struct pack_idx_option *opts, const char *pack_name) { - struct packed_git *p = add_packed_git(pack_name, strlen(pack_name), 1); + struct packed_git *p = add_packed_git(pack_name, strlen(pack_name), NULL); if (!p) die(_("Cannot open existing pack file '%s'"), pack_name); diff --git a/cache.h b/cache.h index bed403a..dfb78ca 100644 --- a/cache.h +++ b/cache.h @@ -1014,6 +1014,7 @@ struct pack_window { extern struct packed_git { struct packed_git *next; struct pack_window *windows; + struct alternate_object_database *alt; off_t pack_size; const void *index_data; size_t index_size; @@ -1107,7 +1108,7 @@ extern void close_pack_windows(struct packed_git *); extern void unuse_pack(struct pack_window **); extern void free_pack_by_name(const char *); extern void clear_delta_base_cache(void); -extern struct packed_git *add_packed_git(const char *, int, int); +extern struct packed_git *add_packed_git(const char *, int, struct alternate_object_database *); extern const unsigned char *nth_packed_object_sha1(struct packed_git *, uint32_t); extern off_t nth_packed_object_offset(const struct packed_git *, uint32_t); extern off_t find_pack_entry_one(const unsigned char *, struct packed_git *); diff --git a/fast-import.c b/fast-import.c index 8542786..749e9db 100644 --- a/fast-import.c +++ b/fast-import.c @@ -964,7 +964,7 @@ static void end_packfile(void) idx_name = keep_pack(create_index()); /* Register the packfile with core git's machinery. */ - new_p = add_packed_git(idx_name, strlen(idx_name), 1); + new_p = add_packed_git(idx_name, strlen(idx_name), NULL); if (!new_p) die("core git rejected index %s", idx_name); all_packs[pack_id] = new_p; diff --git a/sha1_file.c b/sha1_file.c index d1f44c9..1a744ae 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -958,7 +958,8 @@ static void try_to_free_pack_memory(size_t size) release_pack_memory(size, -1); } -struct packed_git *add_packed_git(const char *path, int path_len, int local) +struct packed_git *add_packed_git(const char *path, int path_len, + struct alternate_object_database *alt) { static int have_set_try_to_free_routine; struct stat st; @@ -994,7 +995,8 @@ struct packed_git *add_packed_git(const char *path, int path_len, int local) * actually mapping the pack file. */ p->pack_size = st.st_size; - p->pack_local = local; + p->pack_local = !alt; + p->alt = alt; p->mtime = st.st_mtime; if (path_len < 40 || get_sha1_hex(path + path_len - 40, p->sha1)) hashclr(p->sha1); @@ -1082,7 +1084,8 @@ static void report_pack_garbage(struct string_list *list) report_helper(list, seen_bits, first, list->nr); } -static void prepare_packed_git_one(char *objdir, int local) +static void prepare_packed_git_one(char *objdir, + struct alternate_object_database *alt) { /* Ensure that this buffer is large enough so that we can append "/pack/" without clobbering the stack even if @@ -1133,7 +1136,7 @@ static void prepare_packed_git_one(char *objdir, int local) * See if it really is a valid .idx file with * corresponding .pack file that we can map. */ - (p = add_packed_git(path, len + namelen, local)) != NULL) + (p = add_packed_git(path, len + namelen, alt)) != NULL) install_packed_git(p); } @@ -1213,11 +1216,11 @@ void prepare_packed_git(void) if (prepare_packed_git_run_once) return; - prepare_packed_git_one(get_object_directory(), 1); + prepare_packed_git_one(get_object_directory(), NULL); prepare_alt_odb(); for (alt = alt_odb_list; alt; alt = alt->next) { alt->name[-1] = 0; - prepare_packed_git_one(alt->base, 0); + prepare_packed_git_one(alt->base, alt); alt->name[-1] = '/'; } rearrange_packed_git(); -- 1.8.2.83.gc99314b -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html