aboutsummaryrefslogtreecommitdiff
path: root/cache.h
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-05-12 15:51:38 -0700
committerJunio C Hamano <gitster@pobox.com>2011-05-19 14:22:47 -0700
commit9a4905902230c080f0f6a64ed7f0aaa5777d2f5b (patch)
treef0959edded8645f72edfffef53042d15cace90ee /cache.h
parentb9a62cbeb91e52aea8fc427a84e72f475dfe60cf (diff)
downloadgit-9a4905902230c080f0f6a64ed7f0aaa5777d2f5b.tar.gz
git-9a4905902230c080f0f6a64ed7f0aaa5777d2f5b.tar.xz
sha1_object_info_extended(): expose a bit more info
The original interface for sha1_object_info() takes an object name and gives back a type and its size (the latter is given only when it was asked). The new interface wraps its implementation and exposes a bit more pieces of information that the interface used to discard, namely: - where the object is stored (loose? cached? packed?) - if packed, where in which packfile? Signed-off-by: Junio C Hamano <gitster@pobox.com> --- * In the earlier round, this used u.pack.delta to record the length of the delta chain, but the caller is not necessarily interested in the length of the delta chain per-se, but may only want to know if it is a delta against another object or is stored as a deflated data. Calling packed_object_info_detail() involves walking the reverse index chain to compute the store size of the object and is unnecessarily expensive. We could resurrect the code if a new caller wants to know, but I doubt it.
Diffstat (limited to 'cache.h')
-rw-r--r--cache.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/cache.h b/cache.h
index cdb51120a..9fbc07e97 100644
--- a/cache.h
+++ b/cache.h
@@ -1022,6 +1022,34 @@ extern unsigned long unpack_object_header_buffer(const unsigned char *buf, unsig
extern unsigned long get_size_from_delta(struct packed_git *, struct pack_window **, off_t);
extern int packed_object_info_detail(struct packed_git *, off_t, unsigned long *, unsigned long *, unsigned int *, unsigned char *);
+struct object_info {
+ /* Request */
+ unsigned long *sizep;
+
+ /* Response */
+ enum {
+ OI_CACHED,
+ OI_LOOSE,
+ OI_PACKED
+ } whence;
+ union {
+ /*
+ * struct {
+ * ... Nothing to expose in this case
+ * } cached;
+ * struct {
+ * ... Nothing to expose in this case
+ * } loose;
+ */
+ struct {
+ struct packed_git *pack;
+ off_t offset;
+ unsigned int is_delta;
+ } packed;
+ } u;
+};
+extern int sha1_object_info_extended(const unsigned char *, struct object_info *);
+
/* Dumb servers support */
extern int update_server_info(int);