git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Stefan Beller <sbeller@google.com>
To: sbeller@google.com
Cc: bmwill@google.com, git@vger.kernel.org, gitster@pobox.com,
	jonathantanmy@google.com, sandals@crustytoothpaste.net,
	Jonathan Nieder <jrnieder@gmail.com>
Subject: [PATCHv3 7/9] packfile: add repository argument to unpack_entry
Date: Wed, 25 Apr 2018 11:21:04 -0700	[thread overview]
Message-ID: <20180425182106.162972-8-sbeller@google.com> (raw)
In-Reply-To: <20180425182106.162972-1-sbeller@google.com>

Add a repository argument to allow the callers of unpack_entry
to be more specific about which repository to act on. This is a small
mechanical change; it doesn't change the implementation to handle
repositories other than the_repository yet.

As with the previous commits, use a macro to catch callers passing a
repository other than the_repository at compile time.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
---
 fast-import.c | 2 +-
 pack-check.c  | 3 ++-
 packfile.c    | 7 ++++---
 packfile.h    | 3 ++-
 4 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/fast-import.c b/fast-import.c
index afe06bd7c1..b009353e93 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -1376,7 +1376,7 @@ static void *gfi_unpack_entry(
 		 */
 		p->pack_size = pack_size + the_hash_algo->rawsz;
 	}
-	return unpack_entry(p, oe->idx.offset, &type, sizep);
+	return unpack_entry(the_repository, p, oe->idx.offset, &type, sizep);
 }
 
 static const char *get_mode(const char *str, uint16_t *modep)
diff --git a/pack-check.c b/pack-check.c
index 385d964bdd..d3a57df34f 100644
--- a/pack-check.c
+++ b/pack-check.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "repository.h"
 #include "pack.h"
 #include "pack-revindex.h"
 #include "progress.h"
@@ -134,7 +135,7 @@ static int verify_packfile(struct packed_git *p,
 			data = NULL;
 			data_valid = 0;
 		} else {
-			data = unpack_entry(p, entries[i].offset, &type, &size);
+			data = unpack_entry(the_repository, p, entries[i].offset, &type, &size);
 			data_valid = 1;
 		}
 
diff --git a/packfile.c b/packfile.c
index 2876e04bb1..d5ac48ef18 100644
--- a/packfile.c
+++ b/packfile.c
@@ -1279,7 +1279,7 @@ static void *cache_or_unpack_entry(struct packed_git *p, off_t base_offset,
 
 	ent = get_delta_base_cache_entry(p, base_offset);
 	if (!ent)
-		return unpack_entry(p, base_offset, type, base_size);
+		return unpack_entry(the_repository, p, base_offset, type, base_size);
 
 	if (type)
 		*type = ent->type;
@@ -1485,8 +1485,9 @@ static void *read_object_the_repository(const struct object_id *oid,
 	return content;
 }
 
-void *unpack_entry(struct packed_git *p, off_t obj_offset,
-		   enum object_type *final_type, unsigned long *final_size)
+void *unpack_entry_the_repository(struct packed_git *p, off_t obj_offset,
+				  enum object_type *final_type,
+				  unsigned long *final_size)
 {
 	struct pack_window *w_curs = NULL;
 	off_t curpos = obj_offset;
diff --git a/packfile.h b/packfile.h
index bc8d840b1b..1efa57a90e 100644
--- a/packfile.h
+++ b/packfile.h
@@ -115,7 +115,8 @@ extern off_t nth_packed_object_offset(const struct packed_git *, uint32_t n);
 extern off_t find_pack_entry_one(const unsigned char *sha1, struct packed_git *);
 
 extern int is_pack_valid(struct packed_git *);
-extern void *unpack_entry(struct packed_git *, off_t, enum object_type *, unsigned long *);
+#define unpack_entry(r, p, of, ot, s) unpack_entry_##r(p, of, ot, s)
+extern void *unpack_entry_the_repository(struct packed_git *, off_t, enum object_type *, unsigned long *);
 extern unsigned long unpack_object_header_buffer(const unsigned char *buf, unsigned long len, enum object_type *type, unsigned long *sizep);
 extern unsigned long get_size_from_delta(struct packed_git *, struct pack_window **, off_t);
 extern int unpack_object_header(struct packed_git *, struct pack_window **, off_t *, unsigned long *);
-- 
2.17.0.441.gb46fe60e1d-goog


  parent reply	other threads:[~2018-04-25 18:24 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-24 21:59 [PATCHv2 0/9] object store: oid_object_info is the next contender Stefan Beller
2018-04-24 21:59 ` [PATCHv2 1/9] cache.h: add repository argument to oid_object_info_extended Stefan Beller
2018-04-24 21:59 ` [PATCHv2 2/9] cache.h: add repository argument to oid_object_info Stefan Beller
2018-04-24 21:59 ` [PATCHv2 3/9] packfile: add repository argument to retry_bad_packed_offset Stefan Beller
2018-04-24 21:59 ` [PATCHv2 4/9] packfile: add repository argument to packed_to_object_type Stefan Beller
2018-04-24 21:59 ` [PATCHv2 5/9] packfile: add repository argument to packed_object_info Stefan Beller
2018-04-24 21:59 ` [PATCHv2 6/9] packfile: add repository argument to read_object Stefan Beller
2018-04-24 21:59 ` [PATCHv2 7/9] packfile: add repository argument to unpack_entry Stefan Beller
2018-04-24 21:59 ` [PATCHv2 8/9] packfile: add repository argument to cache_or_unpack_entry Stefan Beller
2018-04-24 21:59 ` [PATCHv2 9/9] cache.h: allow oid_object_info to handle arbitrary repositories Stefan Beller
2018-04-24 22:49   ` Jonathan Tan
2018-04-24 21:59 ` [PATCHv2 9/9] cache.h: allow sha1_object_info " Stefan Beller
2018-04-25 18:20 ` [PATCHv3 0/9] object store: oid_object_info is the next contender Stefan Beller
2018-04-25 18:20   ` [PATCHv3 1/9] cache.h: add repository argument to oid_object_info_extended Stefan Beller
2018-04-25 18:20   ` [PATCHv3 2/9] cache.h: add repository argument to oid_object_info Stefan Beller
2018-04-25 18:21   ` [PATCHv3 3/9] packfile: add repository argument to retry_bad_packed_offset Stefan Beller
2018-04-25 18:21   ` [PATCHv3 4/9] packfile: add repository argument to packed_to_object_type Stefan Beller
2018-04-25 18:21   ` [PATCHv3 5/9] packfile: add repository argument to packed_object_info Stefan Beller
2018-04-25 18:21   ` [PATCHv3 6/9] packfile: add repository argument to read_object Stefan Beller
2018-04-25 18:21   ` Stefan Beller [this message]
2018-04-25 18:21   ` [PATCHv3 8/9] packfile: add repository argument to cache_or_unpack_entry Stefan Beller
2018-04-25 18:21   ` [PATCHv3 9/9] cache.h: allow oid_object_info to handle arbitrary repositories Stefan Beller
2018-04-25 20:37   ` [PATCHv3 0/9] object store: oid_object_info is the next contender Jonathan Tan
2018-04-26 16:30   ` 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=20180425182106.162972-8-sbeller@google.com \
    --to=sbeller@google.com \
    --cc=bmwill@google.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jonathantanmy@google.com \
    --cc=jrnieder@gmail.com \
    --cc=sandals@crustytoothpaste.net \
    /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).