git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH v2 20/22] pack-*.c: remove the_repository references
Date: Sat, 10 Nov 2018 06:49:08 +0100	[thread overview]
Message-ID: <20181110054910.10568-21-pclouds@gmail.com> (raw)
In-Reply-To: <20181110054910.10568-1-pclouds@gmail.com>

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/pack-objects.c |  2 +-
 pack-bitmap-write.c    |  6 +++---
 pack-bitmap.c          | 13 +++++++------
 pack-bitmap.h          |  3 ++-
 pack-objects.c         |  6 ++++--
 pack-objects.h         |  5 ++++-
 6 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 7812c2b1f3..8abfb69e2d 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -3481,7 +3481,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
 		}
 	}
 
-	prepare_packing_data(&to_pack);
+	prepare_packing_data(the_repository, &to_pack);
 
 	if (progress)
 		progress_state = start_progress(_("Enumerating objects"), 0);
diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c
index 9d1b951697..5566e94abe 100644
--- a/pack-bitmap-write.c
+++ b/pack-bitmap-write.c
@@ -77,7 +77,7 @@ void bitmap_writer_build_type_index(struct packing_data *to_pack,
 			break;
 
 		default:
-			real_type = oid_object_info(the_repository,
+			real_type = oid_object_info(to_pack->repo,
 						    &entry->idx.oid, NULL);
 			break;
 		}
@@ -262,7 +262,7 @@ void bitmap_writer_build(struct packing_data *to_pack)
 	if (writer.show_progress)
 		writer.progress = start_progress("Building bitmaps", writer.selected_nr);
 
-	repo_init_revisions(the_repository, &revs, NULL);
+	repo_init_revisions(to_pack->repo, &revs, NULL);
 	revs.tag_objects = 1;
 	revs.tree_objects = 1;
 	revs.blob_objects = 1;
@@ -363,7 +363,7 @@ static int date_compare(const void *_a, const void *_b)
 void bitmap_writer_reuse_bitmaps(struct packing_data *to_pack)
 {
 	struct bitmap_index *bitmap_git;
-	if (!(bitmap_git = prepare_bitmap_git()))
+	if (!(bitmap_git = prepare_bitmap_git(to_pack->repo)))
 		return;
 
 	writer.reused = kh_init_sha1();
diff --git a/pack-bitmap.c b/pack-bitmap.c
index 5848cc93aa..4695aaf6b4 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -328,14 +328,15 @@ static int load_pack_bitmap(struct bitmap_index *bitmap_git)
 	return -1;
 }
 
-static int open_pack_bitmap(struct bitmap_index *bitmap_git)
+static int open_pack_bitmap(struct repository *r,
+			    struct bitmap_index *bitmap_git)
 {
 	struct packed_git *p;
 	int ret = -1;
 
 	assert(!bitmap_git->map);
 
-	for (p = get_all_packs(the_repository); p; p = p->next) {
+	for (p = get_all_packs(r); p; p = p->next) {
 		if (open_pack_bitmap_1(bitmap_git, p) == 0)
 			ret = 0;
 	}
@@ -343,11 +344,11 @@ static int open_pack_bitmap(struct bitmap_index *bitmap_git)
 	return ret;
 }
 
-struct bitmap_index *prepare_bitmap_git(void)
+struct bitmap_index *prepare_bitmap_git(struct repository *r)
 {
 	struct bitmap_index *bitmap_git = xcalloc(1, sizeof(*bitmap_git));
 
-	if (!open_pack_bitmap(bitmap_git) && !load_pack_bitmap(bitmap_git))
+	if (!open_pack_bitmap(r, bitmap_git) && !load_pack_bitmap(bitmap_git))
 		return bitmap_git;
 
 	free_bitmap_index(bitmap_git);
@@ -690,7 +691,7 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs)
 	struct bitmap_index *bitmap_git = xcalloc(1, sizeof(*bitmap_git));
 	/* try to open a bitmapped pack, but don't parse it yet
 	 * because we may not need to use it */
-	if (open_pack_bitmap(bitmap_git) < 0)
+	if (open_pack_bitmap(revs->repo, bitmap_git) < 0)
 		goto cleanup;
 
 	for (i = 0; i < revs->pending.nr; ++i) {
@@ -955,7 +956,7 @@ void test_bitmap_walk(struct rev_info *revs)
 	struct bitmap_test_data tdata;
 	struct bitmap_index *bitmap_git;
 
-	if (!(bitmap_git = prepare_bitmap_git()))
+	if (!(bitmap_git = prepare_bitmap_git(revs->repo)))
 		die("failed to load bitmap indexes");
 
 	if (revs->pending.nr != 1)
diff --git a/pack-bitmap.h b/pack-bitmap.h
index 189dd68ad3..8418ba8c79 100644
--- a/pack-bitmap.h
+++ b/pack-bitmap.h
@@ -6,6 +6,7 @@
 #include "pack-objects.h"
 
 struct commit;
+struct repository;
 struct rev_info;
 
 struct bitmap_disk_header {
@@ -39,7 +40,7 @@ typedef int (*show_reachable_fn)(
 
 struct bitmap_index;
 
-struct bitmap_index *prepare_bitmap_git(void);
+struct bitmap_index *prepare_bitmap_git(struct repository *r);
 void count_bitmap_commit_list(struct bitmap_index *, uint32_t *commits,
 			      uint32_t *trees, uint32_t *blobs, uint32_t *tags);
 void traverse_bitmap_commit_list(struct bitmap_index *,
diff --git a/pack-objects.c b/pack-objects.c
index b6cdbb0166..9c45842df3 100644
--- a/pack-objects.c
+++ b/pack-objects.c
@@ -99,7 +99,7 @@ static void prepare_in_pack_by_idx(struct packing_data *pdata)
 	 * (i.e. in_pack_idx also zero) should return NULL.
 	 */
 	mapping[cnt++] = NULL;
-	for (p = get_all_packs(the_repository); p; p = p->next, cnt++) {
+	for (p = get_all_packs(pdata->repo); p; p = p->next, cnt++) {
 		if (cnt == nr) {
 			free(mapping);
 			return;
@@ -133,8 +133,10 @@ void oe_map_new_pack(struct packing_data *pack,
 }
 
 /* assume pdata is already zero'd by caller */
-void prepare_packing_data(struct packing_data *pdata)
+void prepare_packing_data(struct repository *r, struct packing_data *pdata)
 {
+	pdata->repo = r;
+
 	if (git_env_bool("GIT_TEST_FULL_IN_PACK_ARRAY", 0)) {
 		/*
 		 * do not initialize in_pack_by_idx[] to force the
diff --git a/pack-objects.h b/pack-objects.h
index 86ee93feb4..9e6af3f24f 100644
--- a/pack-objects.h
+++ b/pack-objects.h
@@ -5,6 +5,8 @@
 #include "thread-utils.h"
 #include "pack.h"
 
+struct repository;
+
 #define DEFAULT_DELTA_CACHE_SIZE (256 * 1024 * 1024)
 
 #define OE_DFS_STATE_BITS	2
@@ -127,6 +129,7 @@ struct object_entry {
 };
 
 struct packing_data {
+	struct repository *repo;
 	struct object_entry *objects;
 	uint32_t nr_objects, nr_alloc;
 
@@ -165,7 +168,7 @@ struct packing_data {
 	unsigned char *layer;
 };
 
-void prepare_packing_data(struct packing_data *pdata);
+void prepare_packing_data(struct repository *r, struct packing_data *pdata);
 
 static inline void packing_data_lock(struct packing_data *pdata)
 {
-- 
2.19.1.1231.g84aef82467


  parent reply	other threads:[~2018-11-10  5:49 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-10  5:48 [PATCH v2 00/22] Kill the_index part 5 Nguyễn Thái Ngọc Duy
2018-11-10  5:48 ` [PATCH v2 01/22] wt-status.c: remove implicit dependency on the_index Nguyễn Thái Ngọc Duy
2018-11-10  5:48 ` [PATCH v2 02/22] wt-status.c: remove implicit dependency the_repository Nguyễn Thái Ngọc Duy
2018-11-10  5:48 ` [PATCH v2 03/22] list-objects-filter.c: remove implicit dependency on the_index Nguyễn Thái Ngọc Duy
2018-11-10  5:48 ` [PATCH v2 04/22] list-objects.c: reduce the_repository references Nguyễn Thái Ngọc Duy
2018-11-10  5:48 ` [PATCH v2 05/22] notes-merge.c: remove implicit dependency on the_index Nguyễn Thái Ngọc Duy
2018-11-10  5:48 ` [PATCH v2 06/22] notes-merge.c: remove implicit dependency the_repository Nguyễn Thái Ngọc Duy
2018-11-10  5:48 ` [PATCH v2 07/22] transport.c: remove implicit dependency on the_index Nguyễn Thái Ngọc Duy
2018-11-10  5:48 ` [PATCH v2 08/22] sequencer.c: " Nguyễn Thái Ngọc Duy
2018-11-10  5:48 ` [PATCH v2 09/22] sequencer.c: remove implicit dependency on the_repository Nguyễn Thái Ngọc Duy
2018-11-10  5:48 ` [PATCH v2 10/22] blame.c: remove implicit dependency the_repository Nguyễn Thái Ngọc Duy
2018-11-10  5:48 ` [PATCH v2 11/22] bisect.c: remove the_repository reference Nguyễn Thái Ngọc Duy
2018-11-10  5:49 ` [PATCH v2 12/22] branch.c: " Nguyễn Thái Ngọc Duy
2018-11-10  5:49 ` [PATCH v2 13/22] bundle.c: remove the_repository references Nguyễn Thái Ngọc Duy
2018-11-10  5:49 ` [PATCH v2 14/22] cache-tree.c: " Nguyễn Thái Ngọc Duy
2018-11-10  5:49 ` [PATCH v2 15/22] delta-islands.c: " Nguyễn Thái Ngọc Duy
2018-11-10  5:49 ` [PATCH v2 16/22] diff-lib.c: " Nguyễn Thái Ngọc Duy
2018-11-10  5:49 ` [PATCH v2 17/22] line-log.c: remove the_repository reference Nguyễn Thái Ngọc Duy
2018-11-10  5:49 ` [PATCH v2 18/22] notes-cache.c: remove the_repository references Nguyễn Thái Ngọc Duy
2018-11-10  5:49 ` [PATCH v2 19/22] pack-check.c: " Nguyễn Thái Ngọc Duy
2018-11-10  5:49 ` Nguyễn Thái Ngọc Duy [this message]
2018-11-10  5:49 ` [PATCH v2 21/22] rerere.c: " Nguyễn Thái Ngọc Duy
2018-11-10  5:49 ` [PATCH v2 22/22] rebase-interactive.c: " Nguyễn Thái Ngọc Duy
2018-11-12  5:53 ` [PATCH v2 00/22] Kill the_index part 5 Junio C Hamano

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=20181110054910.10568-21-pclouds@gmail.com \
    --to=pclouds@gmail.com \
    --cc=git@vger.kernel.org \
    /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).