summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7cadf49)
raw | patch | inline | side by side (parent: 7cadf49)
author | Shawn O. Pearce <spearce@spearce.org> | |
Wed, 7 Mar 2007 01:44:30 +0000 (20:44 -0500) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Wed, 7 Mar 2007 19:06:25 +0000 (11:06 -0800) |
Not all platforms have declared 'unsigned long' to be a 64 bit value,
but we want to support a 64 bit packfile (or close enough anyway)
in the near future as some projects are getting large enough that
their packed size exceeds 4 GiB.
By using off_t, the POSIX type that is declared to mean an offset
within a file, we support whatever maximum file size the underlying
operating system will handle. For most modern systems this is up
around 2^60 or higher.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
but we want to support a 64 bit packfile (or close enough anyway)
in the near future as some projects are getting large enough that
their packed size exceeds 4 GiB.
By using off_t, the POSIX type that is declared to mean an offset
within a file, we support whatever maximum file size the underlying
operating system will handle. For most modern systems this is up
around 2^60 or higher.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
cache.h | patch | blob | history | |
fast-import.c | patch | blob | history | |
git-compat-util.h | patch | blob | history | |
pack-check.c | patch | blob | history | |
pack-redundant.c | patch | blob | history | |
sha1_file.c | patch | blob | history |
index 63a093bcfd7970cf3d3edc6e1d81052a34e2afe8..ae25759c433a29caeb8662ef3ccfe4c0f3422bd5 100644 (file)
--- a/cache.h
+++ b/cache.h
} *packed_git;
struct pack_entry {
- unsigned int offset;
+ off_t offset;
unsigned char sha1[20];
struct packed_git *p;
};
struct packed_git *packs);
extern void pack_report(void);
-extern unsigned char* use_pack(struct packed_git *, struct pack_window **, unsigned long, unsigned int *);
+extern unsigned char* use_pack(struct packed_git *, struct pack_window **, off_t, unsigned int *);
extern void unuse_pack(struct pack_window **);
extern struct packed_git *add_packed_git(char *, int, int);
extern uint32_t num_packed_objects(const struct packed_git *p);
extern int nth_packed_object_sha1(const struct packed_git *, uint32_t, unsigned char*);
-extern unsigned long find_pack_entry_one(const unsigned char *, struct packed_git *);
-extern void *unpack_entry(struct packed_git *, unsigned long, enum object_type *, unsigned long *);
+extern off_t find_pack_entry_one(const unsigned char *, struct packed_git *);
+extern void *unpack_entry(struct packed_git *, off_t, enum object_type *, unsigned long *);
extern unsigned long unpack_object_header_gently(const unsigned char *buf, unsigned long len, enum object_type *type, unsigned long *sizep);
-extern const char *packed_object_info_detail(struct packed_git *, unsigned long, unsigned long *, unsigned long *, unsigned int *, unsigned char *);
+extern const char *packed_object_info_detail(struct packed_git *, off_t, unsigned long *, unsigned long *, unsigned int *, unsigned char *);
/* Dumb servers support */
extern int update_server_info(int);
diff --git a/fast-import.c b/fast-import.c
index 132dd9c938fc811b14bd141266afe3cd7c7f4302..a418a174d08b2da1a3994ec8a6f2c8e46e2cd829 100644 (file)
--- a/fast-import.c
+++ b/fast-import.c
#define PACK_ID_BITS 16
#define MAX_PACK_ID ((1<<PACK_ID_BITS)-1)
-#ifndef PRIuMAX
-#define PRIuMAX "llu"
-#endif
-
struct object_entry
{
struct object_entry *next;
diff --git a/git-compat-util.h b/git-compat-util.h
index 56212b2f115d0ef738c5835c42d7bf241db4576a..33b68e463cb17b99de23b731ff47d40d7959c93e 100644 (file)
--- a/git-compat-util.h
+++ b/git-compat-util.h
#define PATH_MAX 4096
#endif
+#ifndef PRIuMAX
+#define PRIuMAX "llu"
+#endif
+
#ifdef __GNUC__
#define NORETURN __attribute__((__noreturn__))
#else
diff --git a/pack-check.c b/pack-check.c
index 7c82f6795e9c7228bed39d4f449ab768abb85551..299c514128b8b6330561a1a2b8ac30324a7ac479 100644 (file)
--- a/pack-check.c
+++ b/pack-check.c
static int verify_packfile(struct packed_git *p,
struct pack_window **w_curs)
{
- unsigned long index_size = p->index_size;
+ off_t index_size = p->index_size;
void *index_base = p->index_base;
SHA_CTX ctx;
unsigned char sha1[20];
- unsigned long offset = 0, pack_sig = p->pack_size - 20;
+ off_t offset = 0, pack_sig = p->pack_size - 20;
uint32_t nr_objects, i;
int err;
unsigned char *in = use_pack(p, w_curs, offset, &remaining);
offset += remaining;
if (offset > pack_sig)
- remaining -= offset - pack_sig;
+ remaining -= (unsigned int)(offset - pack_sig);
SHA1_Update(&ctx, in, remaining);
}
SHA1_Final(sha1, &ctx);
unsigned char sha1[20];
void *data;
enum object_type type;
- unsigned long size, offset;
+ unsigned long size;
+ off_t offset;
if (nth_packed_object_sha1(p, i, sha1))
die("internal error pack-check nth-packed-object");
const char *type;
unsigned long size;
unsigned long store_size;
- unsigned long offset;
+ off_t offset;
unsigned int delta_chain_length;
if (nth_packed_object_sha1(p, i, sha1))
base_sha1);
printf("%s ", sha1_to_hex(sha1));
if (!delta_chain_length)
- printf("%-6s %lu %lu\n", type, size, offset);
+ printf("%-6s %lu %"PRIuMAX"\n",
+ type, size, (uintmax_t)offset);
else {
- printf("%-6s %lu %lu %u %s\n", type, size, offset,
+ printf("%-6s %lu %"PRIuMAX" %u %s\n",
+ type, size, (uintmax_t)offset,
delta_chain_length, sha1_to_hex(base_sha1));
if (delta_chain_length < MAX_CHAIN)
chain_histogram[delta_chain_length]++;
int verify_pack(struct packed_git *p, int verbose)
{
- unsigned long index_size = p->index_size;
+ off_t index_size = p->index_size;
void *index_base = p->index_base;
SHA_CTX ctx;
unsigned char sha1[20];
ret = 0;
/* Verify SHA1 sum of the index file */
SHA1_Init(&ctx);
- SHA1_Update(&ctx, index_base, index_size - 20);
+ SHA1_Update(&ctx, index_base, (unsigned int)(index_size - 20));
SHA1_Final(sha1, &ctx);
if (hashcmp(sha1, (unsigned char *)index_base + index_size - 20))
ret = error("Packfile index for %s SHA1 mismatch",
diff --git a/pack-redundant.c b/pack-redundant.c
index edb5524fc48b49bca5c0dd319caf348c9bda7c23..c8f7d9af7b502e12a3d36fc3b3e796e43b4f2bdb 100644 (file)
--- a/pack-redundant.c
+++ b/pack-redundant.c
return ret;
}
-static inline size_t pack_set_bytecount(struct pack_list *pl)
+static inline off_t pack_set_bytecount(struct pack_list *pl)
{
- size_t ret = 0;
+ off_t ret = 0;
while (pl) {
ret += pl->pack->pack_size;
ret += pl->pack->index_size;
*non_unique = NULL, *min_perm = NULL;
struct pll *perm, *perm_all, *perm_ok = NULL, *new_perm;
struct llist *missing;
- size_t min_perm_size = (size_t)-1, perm_size;
+ off_t min_perm_size = 0, perm_size;
int n;
pl = local_packs;
perm = perm_ok;
while (perm) {
perm_size = pack_set_bytecount(perm->pl);
- if (min_perm_size > perm_size) {
+ if (!min_perm_size || min_perm_size > perm_size) {
min_perm_size = perm_size;
min_perm = perm->pl;
}
diff --git a/sha1_file.c b/sha1_file.c
index 54ffa7c70346306554b17ce1de29f2b5e94a67b2..50d800eea0043b33efb1a199abdcb7cde4132fcb 100644 (file)
--- a/sha1_file.c
+++ b/sha1_file.c
return -1;
}
-static int in_window(struct pack_window *win, unsigned long offset)
+static int in_window(struct pack_window *win, off_t offset)
{
/* We must promise at least 20 bytes (one hash) after the
* offset is available from this window, otherwise the offset
unsigned char* use_pack(struct packed_git *p,
struct pack_window **w_cursor,
- unsigned long offset,
+ off_t offset,
unsigned int *left)
{
struct pack_window *win = *w_cursor;
@@ -1049,14 +1049,14 @@ void * unpack_sha1_file(void *map, unsigned long mapsize, enum object_type *type
return unpack_sha1_rest(&stream, hdr, *size);
}
-static unsigned long get_delta_base(struct packed_git *p,
+static off_t get_delta_base(struct packed_git *p,
struct pack_window **w_curs,
- unsigned long *curpos,
+ off_t *curpos,
enum object_type type,
- unsigned long delta_obj_offset)
+ off_t delta_obj_offset)
{
unsigned char *base_info = use_pack(p, w_curs, *curpos, NULL);
- unsigned long base_offset;
+ off_t base_offset;
/* use_pack() assured us we have [base_info, base_info + 20)
* as a range that we can look at without walking off the
}
/* forward declaration for a mutually recursive function */
-static int packed_object_info(struct packed_git *p, unsigned long offset,
+static int packed_object_info(struct packed_git *p, off_t offset,
unsigned long *sizep);
static int packed_delta_info(struct packed_git *p,
struct pack_window **w_curs,
- unsigned long curpos,
+ off_t curpos,
enum object_type type,
- unsigned long obj_offset,
+ off_t obj_offset,
unsigned long *sizep)
{
- unsigned long base_offset;
+ off_t base_offset;
base_offset = get_delta_base(p, w_curs, &curpos, type, obj_offset);
type = packed_object_info(p, base_offset, NULL);
static int unpack_object_header(struct packed_git *p,
struct pack_window **w_curs,
- unsigned long *curpos,
+ off_t *curpos,
unsigned long *sizep)
{
unsigned char *base;
}
const char *packed_object_info_detail(struct packed_git *p,
- unsigned long obj_offset,
+ off_t obj_offset,
unsigned long *size,
unsigned long *store_size,
unsigned int *delta_chain_length,
unsigned char *base_sha1)
{
struct pack_window *w_curs = NULL;
- unsigned long curpos, dummy;
+ off_t curpos;
+ unsigned long dummy;
unsigned char *next_sha1;
enum object_type type;
}
}
-static int packed_object_info(struct packed_git *p, unsigned long obj_offset,
+static int packed_object_info(struct packed_git *p, off_t obj_offset,
unsigned long *sizep)
{
struct pack_window *w_curs = NULL;
- unsigned long size, curpos = obj_offset;
+ unsigned long size;
+ off_t curpos = obj_offset;
enum object_type type;
type = unpack_object_header(p, &w_curs, &curpos, &size);
static void *unpack_compressed_entry(struct packed_git *p,
struct pack_window **w_curs,
- unsigned long curpos,
+ off_t curpos,
unsigned long size)
{
int st;
static void *unpack_delta_entry(struct packed_git *p,
struct pack_window **w_curs,
- unsigned long curpos,
+ off_t curpos,
unsigned long delta_size,
- unsigned long obj_offset,
+ off_t obj_offset,
enum object_type *type,
unsigned long *sizep)
{
void *delta_data, *result, *base;
- unsigned long base_size, base_offset;
+ unsigned long base_size;
+ off_t base_offset;
base_offset = get_delta_base(p, w_curs, &curpos, *type, obj_offset);
base = unpack_entry(p, base_offset, type, &base_size);
if (!base)
- die("failed to read delta base object at %lu from %s",
- base_offset, p->pack_name);
+ die("failed to read delta base object"
+ " at %"PRIuMAX" from %s",
+ (uintmax_t)base_offset, p->pack_name);
delta_data = unpack_compressed_entry(p, w_curs, curpos, delta_size);
result = patch_delta(base, base_size,
return result;
}
-void *unpack_entry(struct packed_git *p, unsigned long obj_offset,
+void *unpack_entry(struct packed_git *p, off_t obj_offset,
enum object_type *type, unsigned long *sizep)
{
struct pack_window *w_curs = NULL;
- unsigned long curpos = obj_offset;
+ off_t curpos = obj_offset;
void *data;
*type = unpack_object_header(p, &w_curs, &curpos, sizep);
return 0;
}
-unsigned long find_pack_entry_one(const unsigned char *sha1,
+off_t find_pack_entry_one(const unsigned char *sha1,
struct packed_git *p)
{
uint32_t *level1_ofs = p->index_base;
static int find_pack_entry(const unsigned char *sha1, struct pack_entry *e, const char **ignore_packed)
{
struct packed_git *p;
- unsigned long offset;
+ off_t offset;
prepare_packed_git();