On Thu, Jun 7, 2018 at 7:02 PM Derrick Stolee wrote:
>
> Signed-off-by: Derrick Stolee
> ---
> midx.c | 22 ++
> midx.h | 2 ++
> object-store.h | 7 +++
> packfile.c | 6 +-
> 4 files changed, 36 insertions(+), 1 deletion(-)
>
> diff --git a/midx.c b/midx.c
> index a49300bf75..5e9290ca8f 100644
> --- a/midx.c
> +++ b/midx.c
> @@ -175,6 +175,28 @@ struct midxed_git *load_midxed_git(const char
> *object_dir)
> exit(1);
> }
>
> +int prepare_midxed_git_one(struct repository *r, const char *object_dir)
> +{
> + struct midxed_git *m = r->objects->midxed_git;
> + struct midxed_git *m_search;
> +
> + if (!core_midx)
> + return 0;
> +
> + for (m_search = m; m_search; m_search = m_search->next)
> + if (!strcmp(object_dir, m_search->object_dir))
> + return 1;
> +
> + r->objects->midxed_git = load_midxed_git(object_dir);
> +
> + if (r->objects->midxed_git) {
> + r->objects->midxed_git->next = m;
> + return 1;
> + }
> +
> + return 0;
> +}
> +
> static size_t write_midx_header(struct hashfile *f,
> unsigned char num_chunks,
> uint32_t num_packs)
> diff --git a/midx.h b/midx.h
> index a1d18ed991..793203fc4a 100644
> --- a/midx.h
> +++ b/midx.h
> @@ -5,8 +5,10 @@
> #include "cache.h"
> #include "object-store.h"
> #include "packfile.h"
> +#include "repository.h"
>
> struct midxed_git *load_midxed_git(const char *object_dir);
> +int prepare_midxed_git_one(struct repository *r, const char *object_dir);
>
> int write_midx_file(const char *object_dir);
>
> diff --git a/object-store.h b/object-store.h
> index 9b671f1b0a..7908d46e34 100644
> --- a/object-store.h
> +++ b/object-store.h
> @@ -130,6 +130,13 @@ struct raw_object_store {
> */
> struct oidmap *replace_map;
>
> + /*
> +* private data
> +*
> +* should only be accessed directly by packfile.c and midx.c
> +*/
> + struct midxed_git *midxed_git;
> +
> /*
> * private data
> *
> diff --git a/packfile.c b/packfile.c
> index 1a714fbde9..b91ca9b9f5 100644
> --- a/packfile.c
> +++ b/packfile.c
> @@ -15,6 +15,7 @@
> #include "tree-walk.h"
> #include "tree.h"
> #include "object-store.h"
> +#include "midx.h"
>
> char *odb_pack_name(struct strbuf *buf,
> const unsigned char *sha1,
> @@ -893,10 +894,13 @@ static void prepare_packed_git(struct repository *r)
>
> if (r->objects->packed_git_initialized)
> return;
> + prepare_midxed_git_one(r, r->objects->objectdir);
> prepare_packed_git_one(r, r->objects->objectdir, 1);
> prepare_alt_odb(r);
> - for (alt = r->objects->alt_odb_list; alt; alt = alt->next)
> + for (alt = r->objects->alt_odb_list; alt; alt = alt->next) {
> + prepare_midxed_git_one(r, alt->path);
> prepare_packed_git_one(r, alt->path, 0);
> + }
Ah, so the object path and the linked list in midxed_git is for
alternates. Makes sense. Would have saved me the trouble if you only
introduced those fields now, when they are actually used (and become
self explanatory)
> rearrange_packed_git(r);
> prepare_packed_git_mru(r);
> r->objects->packed_git_initialized = 1;
> --
> 2.18.0.rc1
>
--
Duy