git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Brandon Williams <bmwill@google.com>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
	Stefan Beller <sbeller@google.com>,
	Jonathan Nieder <jrnieder@gmail.com>
Subject: Re: [PATCH 10/44] object-store: move packed_git and packed_git_mru to object store
Date: Wed, 21 Mar 2018 15:18:42 -0700	[thread overview]
Message-ID: <20180321221842.GH18406@google.com> (raw)
In-Reply-To: <20180303113637.26518-11-pclouds@gmail.com>

On 03/03, Nguyễn Thái Ngọc Duy wrote:
> From: Stefan Beller <sbeller@google.com>
> 
> In a process with multiple repositories open, packfile accessors
> should be associated to a single repository and not shared globally.
> Move packed_git and packed_git_mru into the_repository and adjust
> callers to reflect this.
> 
> [nd: while at there, wrap access to these two fields in get_packed_git()
> and get_packed_git_mru(). This allows us to lazily initialize these
> fields without caller doing that explicitly]
> 
> Patch generated by
> 
>  1. Moving the struct packed_git declaration to object-store.h
>     and packed_git, packed_git_mru globals to struct object_store.
> 
>  2. Apply the following semantic patch to adjust callers:
>     @@ @@
>     - packed_git
>     + the_repository->objects.packed_git
> 
>     @@ @@
>     - packed_git_mru
>     + the_repository->objects.packed_git_mru

As Jonathan mentioned, this should probably be taken out of the commit
message because it doesn't reflect what the code actually does.  What it
actually does took me a second to figure out.  You're marking packed_git
as "private"...well C has no notion of private vs public fields in a
struct so it might be difficult to keep that convention, it also took me
a second to realize that it was only in the scope of packfile.c where it
was ok to reference it directly.  Maybe it'll be ok?  If we really
wanted something to be private we'd need it to be an opaque type
instead, which may be out of the scope of this code refactor.

> 
>  3. Applying line wrapping fixes from "make style" to break the
>     resulting long lines.
> 
>  4. Adding missing #includes of repository.h where needed.
> 
>  5. As the packfiles are now owned by an objectstore, which is ephemeral
>     unlike globals, we introduce memory leaks. So address them in
>     raw_object_store_clear(). Defer freeing packed_git to the next
>     patch due to the size of this patch.
> 
> Signed-off-by: Stefan Beller <sbeller@google.com>
> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  builtin/count-objects.c  |  5 ++--
>  builtin/fsck.c           |  6 +++--
>  builtin/gc.c             |  3 ++-
>  builtin/pack-objects.c   | 20 ++++++++--------
>  builtin/pack-redundant.c |  5 ++--
>  cache.h                  | 29 ------------------------
>  fast-import.c            |  7 ++++--
>  http-backend.c           |  5 ++--
>  object-store.h           | 28 +++++++++++++++++++++++
>  object.c                 |  7 ++++++
>  pack-bitmap.c            |  3 ++-
>  packfile.c               | 49 ++++++++++++++++++++++++----------------
>  packfile.h               |  3 +++
>  server-info.c            |  5 ++--
>  sha1_name.c              |  5 ++--
>  15 files changed, 107 insertions(+), 73 deletions(-)
> 
> diff --git a/builtin/count-objects.c b/builtin/count-objects.c
> index 33343818c8..5c7c3c6ae3 100644
> --- a/builtin/count-objects.c
> +++ b/builtin/count-objects.c
> @@ -7,6 +7,7 @@
>  #include "cache.h"
>  #include "config.h"
>  #include "dir.h"
> +#include "repository.h"
>  #include "builtin.h"
>  #include "parse-options.h"
>  #include "quote.h"
> @@ -120,9 +121,9 @@ int cmd_count_objects(int argc, const char **argv, const char *prefix)
>  		struct strbuf loose_buf = STRBUF_INIT;
>  		struct strbuf pack_buf = STRBUF_INIT;
>  		struct strbuf garbage_buf = STRBUF_INIT;
> -		if (!packed_git)
> +		if (!get_packed_git(the_repository))
>  			prepare_packed_git();
> -		for (p = packed_git; p; p = p->next) {
> +		for (p = get_packed_git(the_repository); p; p = p->next) {
>  			if (!p->pack_local)
>  				continue;
>  			if (open_pack_index(p))
> diff --git a/builtin/fsck.c b/builtin/fsck.c
> index b284a3a74e..7aca9699f6 100644
> --- a/builtin/fsck.c
> +++ b/builtin/fsck.c
> @@ -729,7 +729,8 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
>  			prepare_packed_git();
>  
>  			if (show_progress) {
> -				for (p = packed_git; p; p = p->next) {
> +				for (p = get_packed_git(the_repository); p;
> +				     p = p->next) {
>  					if (open_pack_index(p))
>  						continue;
>  					total += p->num_objects;
> @@ -737,7 +738,8 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
>  
>  				progress = start_progress(_("Checking objects"), total);
>  			}
> -			for (p = packed_git; p; p = p->next) {
> +			for (p = get_packed_git(the_repository); p;
> +			     p = p->next) {
>  				/* verify gives error messages itself */
>  				if (verify_pack(p, fsck_obj_buffer,
>  						progress, count))
> diff --git a/builtin/gc.c b/builtin/gc.c
> index 77fa720bd0..dd30067ac1 100644
> --- a/builtin/gc.c
> +++ b/builtin/gc.c
> @@ -11,6 +11,7 @@
>   */
>  
>  #include "builtin.h"
> +#include "repository.h"
>  #include "config.h"
>  #include "tempfile.h"
>  #include "lockfile.h"
> @@ -173,7 +174,7 @@ static int too_many_packs(void)
>  		return 0;
>  
>  	prepare_packed_git();
> -	for (cnt = 0, p = packed_git; p; p = p->next) {
> +	for (cnt = 0, p = get_packed_git(the_repository); p; p = p->next) {
>  		if (!p->pack_local)
>  			continue;
>  		if (p->pack_keep)
> diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
> index 83dcbc9773..0e5fde1d6b 100644
> --- a/builtin/pack-objects.c
> +++ b/builtin/pack-objects.c
> @@ -1,5 +1,6 @@
>  #include "builtin.h"
>  #include "cache.h"
> +#include "repository.h"
>  #include "config.h"
>  #include "attr.h"
>  #include "object.h"
> @@ -1025,8 +1026,7 @@ static int want_object_in_pack(const struct object_id *oid,
>  		if (want != -1)
>  			return want;
>  	}
> -
> -	list_for_each(pos, &packed_git_mru) {
> +	list_for_each(pos, get_packed_git_mru(the_repository)) {
>  		struct packed_git *p = list_entry(pos, struct packed_git, mru);
>  		off_t offset;
>  
> @@ -1044,7 +1044,8 @@ static int want_object_in_pack(const struct object_id *oid,
>  			}
>  			want = want_found_object(exclude, p);
>  			if (!exclude && want > 0)
> -				list_move(&p->mru, &packed_git_mru);
> +				list_move(&p->mru,
> +					  get_packed_git_mru(the_repository));
>  			if (want != -1)
>  				return want;
>  		}
> @@ -2673,7 +2674,7 @@ static void add_objects_in_unpacked_packs(struct rev_info *revs)
>  
>  	memset(&in_pack, 0, sizeof(in_pack));
>  
> -	for (p = packed_git; p; p = p->next) {
> +	for (p = get_packed_git(the_repository); p; p = p->next) {
>  		struct object_id oid;
>  		struct object *o;
>  
> @@ -2736,7 +2737,8 @@ static int has_sha1_pack_kept_or_nonlocal(const struct object_id *oid)
>  	static struct packed_git *last_found = (void *)1;
>  	struct packed_git *p;
>  
> -	p = (last_found != (void *)1) ? last_found : packed_git;
> +	p = (last_found != (void *)1) ? last_found :
> +					get_packed_git(the_repository);
>  
>  	while (p) {
>  		if ((!p->pack_local || p->pack_keep) &&
> @@ -2745,7 +2747,7 @@ static int has_sha1_pack_kept_or_nonlocal(const struct object_id *oid)
>  			return 1;
>  		}
>  		if (p == last_found)
> -			p = packed_git;
> +			p = get_packed_git(the_repository);
>  		else
>  			p = p->next;
>  		if (p == last_found)
> @@ -2781,7 +2783,7 @@ static void loosen_unused_packed_objects(struct rev_info *revs)
>  	uint32_t i;
>  	struct object_id oid;
>  
> -	for (p = packed_git; p; p = p->next) {
> +	for (p = get_packed_git(the_repository); p; p = p->next) {
>  		if (!p->pack_local || p->pack_keep)
>  			continue;
>  
> @@ -3152,7 +3154,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
>  	prepare_packed_git();
>  	if (ignore_packed_keep) {
>  		struct packed_git *p;
> -		for (p = packed_git; p; p = p->next)
> +		for (p = get_packed_git(the_repository); p; p = p->next)
>  			if (p->pack_local && p->pack_keep)
>  				break;
>  		if (!p) /* no keep-able packs found */
> @@ -3165,7 +3167,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
>  		 * also covers non-local objects
>  		 */
>  		struct packed_git *p;
> -		for (p = packed_git; p; p = p->next) {
> +		for (p = get_packed_git(the_repository); p; p = p->next) {
>  			if (!p->pack_local) {
>  				have_non_local_packs = 1;
>  				break;
> diff --git a/builtin/pack-redundant.c b/builtin/pack-redundant.c
> index aaa8136322..d6d8a44959 100644
> --- a/builtin/pack-redundant.c
> +++ b/builtin/pack-redundant.c
> @@ -7,6 +7,7 @@
>  */
>  
>  #include "builtin.h"
> +#include "repository.h"
>  #include "packfile.h"
>  
>  #define BLKSIZE 512
> @@ -571,7 +572,7 @@ static struct pack_list * add_pack(struct packed_git *p)
>  
>  static struct pack_list * add_pack_file(const char *filename)
>  {
> -	struct packed_git *p = packed_git;
> +	struct packed_git *p = get_packed_git(the_repository);
>  
>  	if (strlen(filename) < 40)
>  		die("Bad pack filename: %s", filename);
> @@ -586,7 +587,7 @@ static struct pack_list * add_pack_file(const char *filename)
>  
>  static void load_all(void)
>  {
> -	struct packed_git *p = packed_git;
> +	struct packed_git *p = get_packed_git(the_repository);
>  
>  	while (p) {
>  		add_pack(p);
> diff --git a/cache.h b/cache.h
> index 41530d5d16..d3429a0d48 100644
> --- a/cache.h
> +++ b/cache.h
> @@ -1585,35 +1585,6 @@ struct pack_window {
>  	unsigned int inuse_cnt;
>  };
>  
> -extern struct packed_git {
> -	struct packed_git *next;
> -	struct list_head mru;
> -	struct pack_window *windows;
> -	off_t pack_size;
> -	const void *index_data;
> -	size_t index_size;
> -	uint32_t num_objects;
> -	uint32_t num_bad_objects;
> -	unsigned char *bad_object_sha1;
> -	int index_version;
> -	time_t mtime;
> -	int pack_fd;
> -	unsigned pack_local:1,
> -		 pack_keep:1,
> -		 freshened:1,
> -		 do_not_close:1,
> -		 pack_promisor:1;
> -	unsigned char sha1[20];
> -	struct revindex_entry *revindex;
> -	/* something like ".git/objects/pack/xxxxx.pack" */
> -	char pack_name[FLEX_ARRAY]; /* more */
> -} *packed_git;
> -
> -/*
> - * A most-recently-used ordered version of the packed_git list.
> - */
> -extern struct list_head packed_git_mru;
> -
>  struct pack_entry {
>  	off_t offset;
>  	unsigned char sha1[20];
> diff --git a/fast-import.c b/fast-import.c
> index b70ac025e0..0dba555478 100644
> --- a/fast-import.c
> +++ b/fast-import.c
> @@ -154,6 +154,7 @@ Format of STDIN stream:
>  
>  #include "builtin.h"
>  #include "cache.h"
> +#include "repository.h"
>  #include "config.h"
>  #include "lockfile.h"
>  #include "object.h"
> @@ -1110,7 +1111,8 @@ static int store_object(
>  	if (e->idx.offset) {
>  		duplicate_count_by_type[type]++;
>  		return 1;
> -	} else if (find_sha1_pack(oid.hash, packed_git)) {
> +	} else if (find_sha1_pack(oid.hash,
> +				  get_packed_git(the_repository))) {
>  		e->type = type;
>  		e->pack_id = MAX_PACK_ID;
>  		e->idx.offset = 1; /* just not zero! */
> @@ -1305,7 +1307,8 @@ static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark)
>  		duplicate_count_by_type[OBJ_BLOB]++;
>  		truncate_pack(&checkpoint);
>  
> -	} else if (find_sha1_pack(oid.hash, packed_git)) {
> +	} else if (find_sha1_pack(oid.hash,
> +				  get_packed_git(the_repository))) {
>  		e->type = OBJ_BLOB;
>  		e->pack_id = MAX_PACK_ID;
>  		e->idx.offset = 1; /* just not zero! */
> diff --git a/http-backend.c b/http-backend.c
> index f3dc218b2a..22921d169a 100644
> --- a/http-backend.c
> +++ b/http-backend.c
> @@ -1,5 +1,6 @@
>  #include "cache.h"
>  #include "config.h"
> +#include "repository.h"
>  #include "refs.h"
>  #include "pkt-line.h"
>  #include "object.h"
> @@ -518,13 +519,13 @@ static void get_info_packs(struct strbuf *hdr, char *arg)
>  
>  	select_getanyfile(hdr);
>  	prepare_packed_git();
> -	for (p = packed_git; p; p = p->next) {
> +	for (p = get_packed_git(the_repository); p; p = p->next) {
>  		if (p->pack_local)
>  			cnt++;
>  	}
>  
>  	strbuf_grow(&buf, cnt * 53 + 2);
> -	for (p = packed_git; p; p = p->next) {
> +	for (p = get_packed_git(the_repository); p; p = p->next) {
>  		if (p->pack_local)
>  			strbuf_addf(&buf, "P %s\n", p->pack_name + objdirlen + 6);
>  	}
> diff --git a/object-store.h b/object-store.h
> index 0ca9233a85..1f3e66a3b8 100644
> --- a/object-store.h
> +++ b/object-store.h
> @@ -52,6 +52,30 @@ void add_to_alternates_memory(const char *dir);
>   */
>  struct strbuf *alt_scratch_buf(struct alternate_object_database *alt);
>  
> +struct packed_git {
> +	struct packed_git *next;
> +	struct list_head mru;
> +	struct pack_window *windows;
> +	off_t pack_size;
> +	const void *index_data;
> +	size_t index_size;
> +	uint32_t num_objects;
> +	uint32_t num_bad_objects;
> +	unsigned char *bad_object_sha1;
> +	int index_version;
> +	time_t mtime;
> +	int pack_fd;
> +	unsigned pack_local:1,
> +		 pack_keep:1,
> +		 freshened:1,
> +		 do_not_close:1,
> +		 pack_promisor:1;
> +	unsigned char sha1[20];
> +	struct revindex_entry *revindex;
> +	/* something like ".git/objects/pack/xxxxx.pack" */
> +	char pack_name[FLEX_ARRAY]; /* more */
> +};
> +
>  struct raw_object_store {
>  	/*
>  	 * Path to the repository's object store.
> @@ -62,6 +86,10 @@ struct raw_object_store {
>  	/* Path to extra alternate object database if not NULL */
>  	char *alternate_db;
>  
> +	struct packed_git *packed_git; /* private */
> +	/* A most-recently-used ordered version of the packed_git list. */
> +	struct list_head packed_git_mru; /* private */
> +
>  	struct alternate_object_database *alt_odb_list;
>  	struct alternate_object_database **alt_odb_tail;
>  };
> diff --git a/object.c b/object.c
> index a71ab34e69..83be6b1ecb 100644
> --- a/object.c
> +++ b/object.c
> @@ -449,6 +449,7 @@ void clear_commit_marks_all(unsigned int flags)
>  void raw_object_store_init(struct raw_object_store *o)
>  {
>  	memset(o, 0, sizeof(*o));
> +	INIT_LIST_HEAD(&o->packed_git_mru);
>  }
>  
>  static void free_alt_odb(struct alternate_object_database *alt)
> @@ -472,4 +473,10 @@ void raw_object_store_clear(struct raw_object_store *o)
>  
>  	free_alt_odbs(o);
>  	o->alt_odb_tail = NULL;
> +
> +	INIT_LIST_HEAD(&o->packed_git_mru);
> +	/*
> +	 * TODO: call close_all_packs once migrated to
> +	 * take an object store argument
> +	 */
>  }
> diff --git a/pack-bitmap.c b/pack-bitmap.c
> index 9270983e5f..abed43cdb5 100644
> --- a/pack-bitmap.c
> +++ b/pack-bitmap.c
> @@ -10,6 +10,7 @@
>  #include "pack-revindex.h"
>  #include "pack-objects.h"
>  #include "packfile.h"
> +#include "repository.h"
>  
>  /*
>   * An entry on the bitmap index, representing the bitmap for a given
> @@ -335,7 +336,7 @@ static int open_pack_bitmap(void)
>  	assert(!bitmap_git.map && !bitmap_git.loaded);
>  
>  	prepare_packed_git();
> -	for (p = packed_git; p; p = p->next) {
> +	for (p = get_packed_git(the_repository); p; p = p->next) {
>  		if (open_pack_bitmap_1(p) == 0)
>  			ret = 0;
>  	}
> diff --git a/packfile.c b/packfile.c
> index 216ea836ee..d3c4a12ae0 100644
> --- a/packfile.c
> +++ b/packfile.c
> @@ -45,8 +45,6 @@ static unsigned int pack_open_fds;
>  static unsigned int pack_max_fds;
>  static size_t peak_pack_mapped;
>  static size_t pack_mapped;
> -struct packed_git *packed_git;
> -LIST_HEAD(packed_git_mru);
>  
>  #define SZ_FMT PRIuMAX
>  static inline uintmax_t sz_fmt(size_t s) { return s; }
> @@ -246,7 +244,7 @@ static int unuse_one_window(struct packed_git *current)
>  
>  	if (current)
>  		scan_windows(current, &lru_p, &lru_w, &lru_l);
> -	for (p = packed_git; p; p = p->next)
> +	for (p = the_repository->objects.packed_git; p; p = p->next)
>  		scan_windows(p, &lru_p, &lru_w, &lru_l);
>  	if (lru_p) {
>  		munmap(lru_w->base, lru_w->len);
> @@ -316,7 +314,7 @@ void close_all_packs(void)
>  {
>  	struct packed_git *p;
>  
> -	for (p = packed_git; p; p = p->next)
> +	for (p = the_repository->objects.packed_git; p; p = p->next)
>  		if (p->do_not_close)
>  			die("BUG: want to close pack marked 'do-not-close'");
>  		else
> @@ -384,7 +382,7 @@ static int close_one_pack(void)
>  	struct pack_window *mru_w = NULL;
>  	int accept_windows_inuse = 1;
>  
> -	for (p = packed_git; p; p = p->next) {
> +	for (p = the_repository->objects.packed_git; p; p = p->next) {
>  		if (p->pack_fd == -1)
>  			continue;
>  		find_lru_pack(p, &lru_p, &mru_w, &accept_windows_inuse);
> @@ -686,8 +684,8 @@ void install_packed_git(struct packed_git *pack)
>  	if (pack->pack_fd != -1)
>  		pack_open_fds++;
>  
> -	pack->next = packed_git;
> -	packed_git = pack;
> +	pack->next = the_repository->objects.packed_git;
> +	the_repository->objects.packed_git = pack;
>  }
>  
>  void (*report_garbage)(unsigned seen_bits, const char *path);
> @@ -769,7 +767,8 @@ static void prepare_packed_git_one(char *objdir, int local)
>  		base_len = path.len;
>  		if (strip_suffix_mem(path.buf, &base_len, ".idx")) {
>  			/* Don't reopen a pack we already have. */
> -			for (p = packed_git; p; p = p->next) {
> +			for (p = the_repository->objects.packed_git; p;
> +			     p = p->next) {
>  				size_t len;
>  				if (strip_suffix(p->pack_name, ".pack", &len) &&
>  				    len == base_len &&
> @@ -820,7 +819,7 @@ unsigned long approximate_object_count(void)
>  
>  		prepare_packed_git();
>  		count = 0;
> -		for (p = packed_git; p; p = p->next) {
> +		for (p = the_repository->objects.packed_git; p; p = p->next) {
>  			if (open_pack_index(p))
>  				continue;
>  			count += p->num_objects;
> @@ -869,18 +868,19 @@ static int sort_pack(const void *a_, const void *b_)
>  
>  static void rearrange_packed_git(void)
>  {
> -	packed_git = llist_mergesort(packed_git, get_next_packed_git,
> -				     set_next_packed_git, sort_pack);
> +	the_repository->objects.packed_git = llist_mergesort(
> +		the_repository->objects.packed_git, get_next_packed_git,
> +		set_next_packed_git, sort_pack);
>  }
>  
>  static void prepare_packed_git_mru(void)
>  {
>  	struct packed_git *p;
>  
> -	INIT_LIST_HEAD(&packed_git_mru);
> +	INIT_LIST_HEAD(&the_repository->objects.packed_git_mru);
>  
> -	for (p = packed_git; p; p = p->next)
> -		list_add_tail(&p->mru, &packed_git_mru);
> +	for (p = the_repository->objects.packed_git; p; p = p->next)
> +		list_add_tail(&p->mru, &the_repository->objects.packed_git_mru);
>  }
>  
>  static int prepare_packed_git_run_once = 0;
> @@ -906,6 +906,16 @@ void reprepare_packed_git(void)
>  	prepare_packed_git();
>  }
>  
> +struct packed_git *get_packed_git(struct repository *r)
> +{
> +	return r->objects.packed_git;
> +}
> +
> +struct list_head *get_packed_git_mru(struct repository *r)
> +{
> +	return &r->objects.packed_git_mru;
> +}
> +
>  unsigned long unpack_object_header_buffer(const unsigned char *buf,
>  		unsigned long len, enum object_type *type, unsigned long *sizep)
>  {
> @@ -1014,7 +1024,7 @@ const struct packed_git *has_packed_and_bad(const unsigned char *sha1)
>  	struct packed_git *p;
>  	unsigned i;
>  
> -	for (p = packed_git; p; p = p->next)
> +	for (p = the_repository->objects.packed_git; p; p = p->next)
>  		for (i = 0; i < p->num_bad_objects; i++)
>  			if (!hashcmp(sha1, p->bad_object_sha1 + 20 * i))
>  				return p;
> @@ -1845,13 +1855,14 @@ int find_pack_entry(const unsigned char *sha1, struct pack_entry *e)
>  	struct list_head *pos;
>  
>  	prepare_packed_git();
> -	if (!packed_git)
> +	if (!the_repository->objects.packed_git)
>  		return 0;
>  
> -	list_for_each(pos, &packed_git_mru) {
> +	list_for_each(pos, &the_repository->objects.packed_git_mru) {
>  		struct packed_git *p = list_entry(pos, struct packed_git, mru);
>  		if (fill_pack_entry(sha1, e, p)) {
> -			list_move(&p->mru, &packed_git_mru);
> +			list_move(&p->mru,
> +				  &the_repository->objects.packed_git_mru);
>  			return 1;
>  		}
>  	}
> @@ -1898,7 +1909,7 @@ int for_each_packed_object(each_packed_object_fn cb, void *data, unsigned flags)
>  	int pack_errors = 0;
>  
>  	prepare_packed_git();
> -	for (p = packed_git; p; p = p->next) {
> +	for (p = the_repository->objects.packed_git; p; p = p->next) {
>  		if ((flags & FOR_EACH_OBJECT_LOCAL_ONLY) && !p->pack_local)
>  			continue;
>  		if ((flags & FOR_EACH_OBJECT_PROMISOR_ONLY) &&
> diff --git a/packfile.h b/packfile.h
> index a7fca598d6..76496226bb 100644
> --- a/packfile.h
> +++ b/packfile.h
> @@ -38,6 +38,9 @@ extern void prepare_packed_git(void);
>  extern void reprepare_packed_git(void);
>  extern void install_packed_git(struct packed_git *pack);
>  
> +struct packed_git *get_packed_git(struct repository *r);
> +struct list_head *get_packed_git_mru(struct repository *r);
> +
>  /*
>   * Give a rough count of objects in the repository. This sacrifices accuracy
>   * for speed.
> diff --git a/server-info.c b/server-info.c
> index 26a6c20b7d..6fe64ede17 100644
> --- a/server-info.c
> +++ b/server-info.c
> @@ -1,4 +1,5 @@
>  #include "cache.h"
> +#include "repository.h"
>  #include "refs.h"
>  #include "object.h"
>  #include "commit.h"
> @@ -200,7 +201,7 @@ static void init_pack_info(const char *infofile, int force)
>  	objdirlen = strlen(objdir);
>  
>  	prepare_packed_git();
> -	for (p = packed_git; p; p = p->next) {
> +	for (p = get_packed_git(the_repository); p; p = p->next) {
>  		/* we ignore things on alternate path since they are
>  		 * not available to the pullers in general.
>  		 */
> @@ -210,7 +211,7 @@ static void init_pack_info(const char *infofile, int force)
>  	}
>  	num_pack = i;
>  	info = xcalloc(num_pack, sizeof(struct pack_info *));
> -	for (i = 0, p = packed_git; p; p = p->next) {
> +	for (i = 0, p = get_packed_git(the_repository); p; p = p->next) {
>  		if (!p->pack_local)
>  			continue;
>  		info[i] = xcalloc(1, sizeof(struct pack_info));
> diff --git a/sha1_name.c b/sha1_name.c
> index 957ce25680..bd4d7352ce 100644
> --- a/sha1_name.c
> +++ b/sha1_name.c
> @@ -196,7 +196,8 @@ static void find_short_packed_object(struct disambiguate_state *ds)
>  	struct packed_git *p;
>  
>  	prepare_packed_git();
> -	for (p = packed_git; p && !ds->ambiguous; p = p->next)
> +	for (p = get_packed_git(the_repository); p && !ds->ambiguous;
> +	     p = p->next)
>  		unique_in_pack(p, ds);
>  }
>  
> @@ -566,7 +567,7 @@ static void find_abbrev_len_packed(struct min_abbrev_data *mad)
>  	struct packed_git *p;
>  
>  	prepare_packed_git();
> -	for (p = packed_git; p; p = p->next)
> +	for (p = get_packed_git(the_repository); p; p = p->next)
>  		find_abbrev_len_for_pack(p, mad);
>  }
>  
> -- 
> 2.16.1.435.g8f24da2e1a
> 

-- 
Brandon Williams

  parent reply	other threads:[~2018-03-21 22:18 UTC|newest]

Thread overview: 135+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-03  2:54 [PATCH 00/11] Moving global state into the repository object (part 2) Duy Nguyen
2018-03-03 11:35 ` [PATCH 00/44] reroll nd/remove-ignore-env.. sb/object-store and sb/packfiles Nguyễn Thái Ngọc Duy
2018-03-03 11:35   ` [PATCH 01/44] repository: initialize the_repository in main() Nguyễn Thái Ngọc Duy
2018-03-21 21:46     ` Brandon Williams
2018-03-03 11:35   ` [PATCH 02/44] repository.c: move env-related setup code back to environment.c Nguyễn Thái Ngọc Duy
2018-03-19 18:07     ` Jonathan Tan
2018-03-19 18:56       ` Duy Nguyen
2018-03-21 21:53         ` Brandon Williams
2018-03-03 11:35   ` [PATCH 03/44] repository.c: delete dead functions Nguyễn Thái Ngọc Duy
2018-03-21 21:57     ` Brandon Williams
2018-03-03 11:35   ` [PATCH 04/44] sha1_file.c: move delayed getenv(altdb) back to setup_git_env() Nguyễn Thái Ngọc Duy
2018-03-21 21:59     ` Brandon Williams
2018-03-03 11:35   ` [PATCH 05/44] repository: delete ignore_env member Nguyễn Thái Ngọc Duy
2018-03-21 21:59     ` Brandon Williams
2018-03-03 11:35   ` [PATCH 06/44] repository: introduce raw object store field Nguyễn Thái Ngọc Duy
2018-03-04  2:19     ` Eric Sunshine
2018-03-21 22:04     ` Brandon Williams
2018-03-03 11:36   ` [PATCH 07/44] object-store: migrate alternates struct and functions from cache.h Nguyễn Thái Ngọc Duy
2018-03-03 11:36   ` [PATCH 08/44] object-store: move alt_odb_list and alt_odb_tail to object store Nguyễn Thái Ngọc Duy
2018-03-03 11:36   ` [PATCH 09/44] object-store: free alt_odb_list Nguyễn Thái Ngọc Duy
2018-03-04  2:37     ` Eric Sunshine
2018-03-05  9:54       ` Duy Nguyen
2018-03-21 22:10       ` Brandon Williams
2018-03-03 11:36   ` [PATCH 10/44] object-store: move packed_git and packed_git_mru to object store Nguyễn Thái Ngọc Duy
2018-03-19 19:39     ` Jonathan Tan
2018-03-23 16:57       ` Duy Nguyen
2018-03-21 22:18     ` Brandon Williams [this message]
2018-03-23 17:03       ` Duy Nguyen
2018-03-23 17:07         ` Duy Nguyen
2018-03-23 18:28           ` Brandon Williams
2018-03-03 11:36   ` [PATCH 11/44] object-store: close all packs upon clearing the " Nguyễn Thái Ngọc Duy
2018-03-21 22:19     ` Brandon Williams
2018-03-03 11:36   ` [PATCH 12/44] pack: move prepare_packed_git_run_once to " Nguyễn Thái Ngọc Duy
2018-03-21 22:25     ` Brandon Williams
2018-03-03 11:36   ` [PATCH 13/44] pack: move approximate object count " Nguyễn Thái Ngọc Duy
2018-03-04  2:47     ` Eric Sunshine
2018-03-04  3:41       ` Duy Nguyen
2018-03-21 22:26         ` Brandon Williams
2018-03-03 11:36   ` [PATCH 14/44] sha1_file: add raw_object_store argument to alt_odb_usable Nguyễn Thái Ngọc Duy
2018-03-03 11:36   ` [PATCH 15/44] sha1_file: add repository argument to link_alt_odb_entry Nguyễn Thái Ngọc Duy
2018-03-03 11:36   ` [PATCH 16/44] sha1_file: add repository argument to read_info_alternates Nguyễn Thái Ngọc Duy
2018-03-03 11:36   ` [PATCH 17/44] sha1_file: add repository argument to link_alt_odb_entries Nguyễn Thái Ngọc Duy
2018-03-03 11:36   ` [PATCH 18/44] sha1_file: add repository argument to prepare_alt_odb Nguyễn Thái Ngọc Duy
2018-03-03 11:36   ` [PATCH 19/44] sha1_file: allow link_alt_odb_entries to handle arbitrary repositories Nguyễn Thái Ngọc Duy
2018-03-21 22:30     ` Brandon Williams
2018-03-03 11:36   ` [PATCH 20/44] sha1_file: allow prepare_alt_odb " Nguyễn Thái Ngọc Duy
2018-03-03 11:36   ` [PATCH 21/44] sha1_file: add repository argument to sha1_file_name Nguyễn Thái Ngọc Duy
2018-03-03 11:36   ` [PATCH 22/44] sha1_file: add repository argument to stat_sha1_file Nguyễn Thái Ngọc Duy
2018-03-03 11:36   ` [PATCH 23/44] sha1_file: add repository argument to open_sha1_file Nguyễn Thái Ngọc Duy
2018-03-03 11:36   ` [PATCH 24/44] sha1_file: add repository argument to map_sha1_file_1 Nguyễn Thái Ngọc Duy
2018-03-03 11:36   ` [PATCH 25/44] sha1_file: add repository argument to map_sha1_file Nguyễn Thái Ngọc Duy
2018-03-03 11:36   ` [PATCH 26/44] sha1_file: add repository argument to sha1_loose_object_info Nguyễn Thái Ngọc Duy
2018-03-03 11:36   ` [PATCH 27/44] sha1_file: allow sha1_file_name to handle arbitrary repositories Nguyễn Thái Ngọc Duy
2018-03-03 11:36   ` [PATCH 28/44] sha1_file: allow stat_sha1_file " Nguyễn Thái Ngọc Duy
2018-03-03 11:36   ` [PATCH 29/44] sha1_file: allow open_sha1_file " Nguyễn Thái Ngọc Duy
2018-03-03 11:36   ` [PATCH 30/44] sha1_file: allow map_sha1_file_1 " Nguyễn Thái Ngọc Duy
2018-03-03 11:36   ` [PATCH 31/44] sha1_file: allow map_sha1_file " Nguyễn Thái Ngọc Duy
2018-03-03 11:36   ` [PATCH 32/44] sha1_file: allow sha1_loose_object_info " Nguyễn Thái Ngọc Duy
2018-03-21 22:34     ` Brandon Williams
2018-03-03 11:36   ` [PATCH 33/44] packfile: allow prepare_packed_git_mru " Nguyễn Thái Ngọc Duy
2018-03-03 11:36   ` [PATCH 34/44] packfile: allow rearrange_packed_git " Nguyễn Thái Ngọc Duy
2018-03-03 11:36   ` [PATCH 35/44] packfile: allow install_packed_git " Nguyễn Thái Ngọc Duy
2018-03-03 11:36   ` [PATCH 36/44] packfile: add repository argument to prepare_packed_git_one Nguyễn Thái Ngọc Duy
2018-03-03 11:36   ` [PATCH 37/44] packfile: add repository argument to prepare_packed_git Nguyễn Thái Ngọc Duy
2018-03-04  3:03     ` Eric Sunshine
2018-03-03 11:36   ` [PATCH 38/44] packfile: add repository argument to reprepare_packed_git Nguyễn Thái Ngọc Duy
2018-03-03 11:36   ` [PATCH 39/44] packfile: allow prepare_packed_git_one to handle arbitrary repositories Nguyễn Thái Ngọc Duy
2018-03-19 20:10     ` Jonathan Tan
2018-03-03 11:36   ` [PATCH 40/44] packfile: allow prepare_packed_git " Nguyễn Thái Ngọc Duy
2018-03-21 22:39     ` Brandon Williams
2018-03-22  1:47       ` Junio C Hamano
2018-03-03 11:36   ` [PATCH 41/44] packfile: allow reprepare_packed_git " Nguyễn Thái Ngọc Duy
2018-03-03 11:36   ` [PATCH 42/44] packfile: add repository argument to find_pack_entry Nguyễn Thái Ngọc Duy
2018-03-03 11:36   ` [PATCH 43/44] packfile: allow find_pack_entry to handle arbitrary repositories Nguyễn Thái Ngọc Duy
2018-03-03 11:36   ` [PATCH 44/44] packfile: keep prepare_packed_git() private Nguyễn Thái Ngọc Duy
2018-03-19 20:34     ` Jonathan Tan
2018-03-21 22:42     ` Brandon Williams
2018-03-05 19:13   ` [PATCH 00/44] reroll nd/remove-ignore-env.. sb/object-store and sb/packfiles Junio C Hamano
2018-03-21 22:43   ` Brandon Williams
2018-03-23 15:55   ` [PATCH 0/1] nd/remove-ignore-env-field updates Nguyễn Thái Ngọc Duy
2018-03-23 15:55     ` [PATCH 1/1] repository.h: add comment and clarify repo_set_gitdir Nguyễn Thái Ngọc Duy
2018-03-26 21:04       ` Stefan Beller
2018-03-26 21:05         ` Stefan Beller
2018-03-23 17:20   ` [PATCH 00/27] sb/object-store updates Nguyễn Thái Ngọc Duy
2018-03-23 17:20     ` [PATCH 01/27] repository: introduce raw object store field Nguyễn Thái Ngọc Duy
2018-03-23 17:20     ` [PATCH 02/27] object-store: migrate alternates struct and functions from cache.h Nguyễn Thái Ngọc Duy
2018-03-23 17:20     ` [PATCH 03/27] object-store: move alt_odb_list and alt_odb_tail to object store Nguyễn Thái Ngọc Duy
2018-03-23 17:20     ` [PATCH 04/27] object-store: free alt_odb_list Nguyễn Thái Ngọc Duy
2018-03-23 18:43       ` Brandon Williams
2018-03-23 17:20     ` [PATCH 05/27] object-store: move packed_git and packed_git_mru to object store Nguyễn Thái Ngọc Duy
2018-03-23 17:21     ` [PATCH 06/27] object-store: close all packs upon clearing the " Nguyễn Thái Ngọc Duy
2018-03-23 17:21     ` [PATCH 07/27] pack: move prepare_packed_git_run_once to " Nguyễn Thái Ngọc Duy
2018-03-23 17:21     ` [PATCH 08/27] pack: move approximate object count " Nguyễn Thái Ngọc Duy
2018-03-23 17:21     ` [PATCH 09/27] sha1_file: add raw_object_store argument to alt_odb_usable Nguyễn Thái Ngọc Duy
2018-03-23 17:21     ` [PATCH 10/27] sha1_file: add repository argument to link_alt_odb_entry Nguyễn Thái Ngọc Duy
2018-03-23 17:21     ` [PATCH 11/27] sha1_file: add repository argument to read_info_alternates Nguyễn Thái Ngọc Duy
2018-03-23 17:21     ` [PATCH 12/27] sha1_file: add repository argument to link_alt_odb_entries Nguyễn Thái Ngọc Duy
2018-03-23 17:21     ` [PATCH 13/27] sha1_file: add repository argument to prepare_alt_odb Nguyễn Thái Ngọc Duy
2018-03-23 17:21     ` [PATCH 14/27] sha1_file: allow link_alt_odb_entries to handle arbitrary repositories Nguyễn Thái Ngọc Duy
2018-03-23 17:21     ` [PATCH 15/27] sha1_file: allow prepare_alt_odb " Nguyễn Thái Ngọc Duy
2018-03-23 17:21     ` [PATCH 16/27] sha1_file: add repository argument to sha1_file_name Nguyễn Thái Ngọc Duy
2018-03-23 17:21     ` [PATCH 17/27] sha1_file: add repository argument to stat_sha1_file Nguyễn Thái Ngọc Duy
2018-03-23 17:21     ` [PATCH 18/27] sha1_file: add repository argument to open_sha1_file Nguyễn Thái Ngọc Duy
2018-03-23 17:21     ` [PATCH 19/27] sha1_file: add repository argument to map_sha1_file_1 Nguyễn Thái Ngọc Duy
2018-03-23 17:21     ` [PATCH 20/27] sha1_file: add repository argument to map_sha1_file Nguyễn Thái Ngọc Duy
2018-03-23 17:21     ` [PATCH 21/27] sha1_file: add repository argument to sha1_loose_object_info Nguyễn Thái Ngọc Duy
2018-03-23 17:21     ` [PATCH 22/27] sha1_file: allow sha1_file_name to handle arbitrary repositories Nguyễn Thái Ngọc Duy
2018-03-23 17:21     ` [PATCH 23/27] sha1_file: allow stat_sha1_file " Nguyễn Thái Ngọc Duy
2018-03-23 17:21     ` [PATCH 24/27] sha1_file: allow open_sha1_file " Nguyễn Thái Ngọc Duy
2018-03-23 17:21     ` [PATCH 25/27] sha1_file: allow map_sha1_file_1 " Nguyễn Thái Ngọc Duy
2018-03-23 17:21     ` [PATCH 26/27] sha1_file: allow map_sha1_file " Nguyễn Thái Ngọc Duy
2018-03-23 17:21     ` [PATCH 27/27] sha1_file: allow sha1_loose_object_info " Nguyễn Thái Ngọc Duy
2018-03-23 18:35     ` [PATCH 00/27] sb/object-store updates Brandon Williams
2018-03-23 18:50       ` Brandon Williams
2018-03-23 21:31         ` Junio C Hamano
2018-03-23 18:58       ` Duy Nguyen
2018-03-23 22:07     ` Eric Sunshine
2018-03-24  5:31       ` Duy Nguyen
2018-03-26 17:45         ` Stefan Beller
2018-03-26 18:09           ` Junio C Hamano
2018-03-26 19:27             ` Junio C Hamano
2018-03-23 17:45   ` [PATCH 00/12] sb/packfiles-in-repository updates Nguyễn Thái Ngọc Duy
2018-03-23 17:45     ` [PATCH 01/12] packfile: allow prepare_packed_git_mru to handle arbitrary repositories Nguyễn Thái Ngọc Duy
2018-03-23 17:45     ` [PATCH 02/12] packfile: allow rearrange_packed_git " Nguyễn Thái Ngọc Duy
2018-03-23 17:45     ` [PATCH 03/12] packfile: allow install_packed_git " Nguyễn Thái Ngọc Duy
2018-03-23 17:45     ` [PATCH 04/12] packfile: add repository argument to prepare_packed_git_one Nguyễn Thái Ngọc Duy
2018-03-23 17:45     ` [PATCH 05/12] packfile: add repository argument to prepare_packed_git Nguyễn Thái Ngọc Duy
2018-03-23 17:45     ` [PATCH 06/12] packfile: add repository argument to reprepare_packed_git Nguyễn Thái Ngọc Duy
2018-03-23 17:45     ` [PATCH 07/12] packfile: allow prepare_packed_git_one to handle arbitrary repositories Nguyễn Thái Ngọc Duy
2018-03-23 17:45     ` [PATCH 08/12] packfile: allow prepare_packed_git " Nguyễn Thái Ngọc Duy
2018-03-23 17:45     ` [PATCH 09/12] packfile: allow reprepare_packed_git " Nguyễn Thái Ngọc Duy
2018-03-23 17:45     ` [PATCH 10/12] packfile: add repository argument to find_pack_entry Nguyễn Thái Ngọc Duy
2018-03-23 17:45     ` [PATCH 11/12] packfile: allow find_pack_entry to handle arbitrary repositories Nguyễn Thái Ngọc Duy
2018-03-23 17:45     ` [PATCH 12/12] packfile: keep prepare_packed_git() private Nguyễn Thái Ngọc Duy
2018-03-23 20:15     ` [PATCH 00/12] sb/packfiles-in-repository updates Brandon Williams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180321221842.GH18406@google.com \
    --to=bmwill@google.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jrnieder@gmail.com \
    --cc=pclouds@gmail.com \
    --cc=sbeller@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).