All of lore.kernel.org
 help / color / mirror / 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 13/22] bundle.c: remove the_repository references
Date: Sat, 10 Nov 2018 06:49:01 +0100	[thread overview]
Message-ID: <20181110054910.10568-14-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/bundle.c |  7 ++++---
 bundle.c         | 26 ++++++++++++++------------
 bundle.h         |  9 +++++----
 transport.c      |  2 +-
 4 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/builtin/bundle.c b/builtin/bundle.c
index d0de59b94f..9e9c65d9c6 100644
--- a/builtin/bundle.c
+++ b/builtin/bundle.c
@@ -40,7 +40,7 @@ int cmd_bundle(int argc, const char **argv, const char *prefix)
 			usage(builtin_bundle_usage);
 			return 1;
 		}
-		if (verify_bundle(&header, 1))
+		if (verify_bundle(the_repository, &header, 1))
 			return 1;
 		fprintf(stderr, _("%s is okay\n"), bundle_file);
 		return 0;
@@ -56,11 +56,12 @@ int cmd_bundle(int argc, const char **argv, const char *prefix)
 		}
 		if (!startup_info->have_repository)
 			die(_("Need a repository to create a bundle."));
-		return !!create_bundle(&header, bundle_file, argc, argv);
+		return !!create_bundle(the_repository, &header,
+				       bundle_file, argc, argv);
 	} else if (!strcmp(cmd, "unbundle")) {
 		if (!startup_info->have_repository)
 			die(_("Need a repository to unbundle."));
-		return !!unbundle(&header, bundle_fd, 0) ||
+		return !!unbundle(the_repository, &header, bundle_fd, 0) ||
 			list_bundle_refs(&header, argc, argv);
 	} else
 		usage(builtin_bundle_usage);
diff --git a/bundle.c b/bundle.c
index 1ef584b93b..b94992675a 100644
--- a/bundle.c
+++ b/bundle.c
@@ -127,7 +127,9 @@ static int list_refs(struct ref_list *r, int argc, const char **argv)
 /* Remember to update object flag allocation in object.h */
 #define PREREQ_MARK (1u<<16)
 
-int verify_bundle(struct bundle_header *header, int verbose)
+int verify_bundle(struct repository *r,
+		  struct bundle_header *header,
+		  int verbose)
 {
 	/*
 	 * Do fast check, then if any prereqs are missing then go line by line
@@ -140,10 +142,10 @@ int verify_bundle(struct bundle_header *header, int verbose)
 	int i, ret = 0, req_nr;
 	const char *message = _("Repository lacks these prerequisite commits:");
 
-	repo_init_revisions(the_repository, &revs, NULL);
+	repo_init_revisions(r, &revs, NULL);
 	for (i = 0; i < p->nr; i++) {
 		struct ref_list_entry *e = p->list + i;
-		struct object *o = parse_object(the_repository, &e->oid);
+		struct object *o = parse_object(r, &e->oid);
 		if (o) {
 			o->flags |= PREREQ_MARK;
 			add_pending_object(&revs, o, e->name);
@@ -168,7 +170,7 @@ int verify_bundle(struct bundle_header *header, int verbose)
 
 	for (i = 0; i < p->nr; i++) {
 		struct ref_list_entry *e = p->list + i;
-		struct object *o = parse_object(the_repository, &e->oid);
+		struct object *o = parse_object(r, &e->oid);
 		assert(o); /* otherwise we'd have returned early */
 		if (o->flags & SHOWN)
 			continue;
@@ -180,7 +182,7 @@ int verify_bundle(struct bundle_header *header, int verbose)
 	/* Clean up objects used, as they will be reused. */
 	for (i = 0; i < p->nr; i++) {
 		struct ref_list_entry *e = p->list + i;
-		commit = lookup_commit_reference_gently(the_repository, &e->oid, 1);
+		commit = lookup_commit_reference_gently(r, &e->oid, 1);
 		if (commit)
 			clear_commit_marks(commit, ALL_REV_FLAGS);
 	}
@@ -375,8 +377,7 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
 			 * in terms of a tag (e.g. v2.0 from the range
 			 * "v1.0..v2.0")?
 			 */
-			struct commit *one = lookup_commit_reference(the_repository,
-								     &oid);
+			struct commit *one = lookup_commit_reference(revs->repo, &oid);
 			struct object *obj;
 
 			if (e->item == &(one->object)) {
@@ -409,8 +410,8 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
 	return ref_count;
 }
 
-int create_bundle(struct bundle_header *header, const char *path,
-		  int argc, const char **argv)
+int create_bundle(struct repository *r, struct bundle_header *header,
+		  const char *path, int argc, const char **argv)
 {
 	struct lock_file lock = LOCK_INIT;
 	int bundle_fd = -1;
@@ -441,7 +442,7 @@ int create_bundle(struct bundle_header *header, const char *path,
 
 	/* init revs to list objects for pack-objects later */
 	save_commit_buffer = 0;
-	repo_init_revisions(the_repository, &revs, NULL);
+	repo_init_revisions(r, &revs, NULL);
 
 	/* write prerequisites */
 	if (compute_and_write_prerequisites(bundle_fd, &revs, argc, argv))
@@ -482,7 +483,8 @@ int create_bundle(struct bundle_header *header, const char *path,
 	return -1;
 }
 
-int unbundle(struct bundle_header *header, int bundle_fd, int flags)
+int unbundle(struct repository *r, struct bundle_header *header,
+	     int bundle_fd, int flags)
 {
 	const char *argv_index_pack[] = {"index-pack",
 					 "--fix-thin", "--stdin", NULL, NULL};
@@ -491,7 +493,7 @@ int unbundle(struct bundle_header *header, int bundle_fd, int flags)
 	if (flags & BUNDLE_VERBOSE)
 		argv_index_pack[3] = "-v";
 
-	if (verify_bundle(header, 0))
+	if (verify_bundle(r, header, 0))
 		return -1;
 	ip.argv = argv_index_pack;
 	ip.in = bundle_fd;
diff --git a/bundle.h b/bundle.h
index e9a4cb6a74..781e6f5c3a 100644
--- a/bundle.h
+++ b/bundle.h
@@ -18,11 +18,12 @@ struct bundle_header {
 
 int is_bundle(const char *path, int quiet);
 int read_bundle_header(const char *path, struct bundle_header *header);
-int create_bundle(struct bundle_header *header, const char *path,
-		int argc, const char **argv);
-int verify_bundle(struct bundle_header *header, int verbose);
+int create_bundle(struct repository *r, struct bundle_header *header,
+		  const char *path, int argc, const char **argv);
+int verify_bundle(struct repository *r, struct bundle_header *header, int verbose);
 #define BUNDLE_VERBOSE 1
-int unbundle(struct bundle_header *header, int bundle_fd, int flags);
+int unbundle(struct repository *r, struct bundle_header *header,
+	     int bundle_fd, int flags);
 int list_bundle_refs(struct bundle_header *header,
 		int argc, const char **argv);
 
diff --git a/transport.c b/transport.c
index 71f663743f..f6e54f6412 100644
--- a/transport.c
+++ b/transport.c
@@ -154,7 +154,7 @@ static int fetch_refs_from_bundle(struct transport *transport,
 			       int nr_heads, struct ref **to_fetch)
 {
 	struct bundle_transport_data *data = transport->data;
-	return unbundle(&data->header, data->fd,
+	return unbundle(the_repository, &data->header, data->fd,
 			transport->progress ? BUNDLE_VERBOSE : 0);
 }
 
-- 
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 ` Nguyễn Thái Ngọc Duy [this message]
2018-11-10  5:49 ` [PATCH v2 14/22] cache-tree.c: remove the_repository references 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 ` [PATCH v2 20/22] pack-*.c: " Nguyễn Thái Ngọc Duy
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

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

  git send-email \
    --in-reply-to=20181110054910.10568-14-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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.