Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
sha1_object_info_extended(): hint about objects in delta-base cache
author
Junio C Hamano
<gitster@pobox.com>
Fri, 13 May 2011 20:20:43 +0000
(13:20 -0700)
committer
Junio C Hamano
<gitster@pobox.com>
Sat, 21 May 2011 01:38:50 +0000
(18:38 -0700)
An object found in the delta-base cache is not guaranteed to
stay there, but we know it came from a pack and it is likely
to give us a quick access if we read_sha1_file() it right now,
which is a piece of useful information.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
cache.h
patch
|
blob
|
history
sha1_file.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (from parent 1:
9a49059
)
diff --git
a/cache.h
b/cache.h
index 9fbc07e976e1fc904f4e53072ddab74b20277588..3a1af9d958bfc5c6c0dbdd1dd1a5907c032a032d 100644
(file)
--- a/
cache.h
+++ b/
cache.h
@@
-1030,7
+1030,8
@@
struct object_info {
enum {
OI_CACHED,
OI_LOOSE,
enum {
OI_CACHED,
OI_LOOSE,
- OI_PACKED
+ OI_PACKED,
+ OI_DBCACHED
} whence;
union {
/*
} whence;
union {
/*
diff --git
a/sha1_file.c
b/sha1_file.c
index 7eed3166717f9ec1606cc683b916027474e83007..1d6f93d5d323818753c81b790dc48469f21ef8a5 100644
(file)
--- a/
sha1_file.c
+++ b/
sha1_file.c
@@
-1697,6
+1697,13
@@
static unsigned long pack_entry_hash(struct packed_git *p, off_t base_offset)
return hash % MAX_DELTA_CACHE;
}
return hash % MAX_DELTA_CACHE;
}
+static int in_delta_base_cache(struct packed_git *p, off_t base_offset)
+{
+ unsigned long hash = pack_entry_hash(p, base_offset);
+ struct delta_base_cache_entry *ent = delta_base_cache + hash;
+ return (ent->data && ent->p == p && ent->base_offset == base_offset);
+}
+
static void *cache_or_unpack_entry(struct packed_git *p, off_t base_offset,
unsigned long *base_size, enum object_type *type, int keep_cache)
{
static void *cache_or_unpack_entry(struct packed_git *p, off_t base_offset,
unsigned long *base_size, enum object_type *type, int keep_cache)
{
@@
-2128,6
+2135,8
@@
int sha1_object_info_extended(const unsigned char *sha1, struct object_info *oi)
if (status < 0) {
mark_bad_packed_object(e.p, sha1);
status = sha1_object_info_extended(sha1, oi);
if (status < 0) {
mark_bad_packed_object(e.p, sha1);
status = sha1_object_info_extended(sha1, oi);
+ } else if (in_delta_base_cache(e.p, e.offset)) {
+ oi->whence = OI_DBCACHED;
} else {
oi->whence = OI_PACKED;
oi->u.packed.offset = e.offset;
} else {
oi->whence = OI_PACKED;
oi->u.packed.offset = e.offset;