packfile: add repository argument to unpack_entry
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> Reviewed-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Stefan Beller committed
Apr 25, 2018 at 11:21 UTC
57a6a500be8d8ee903a1dc9ea607063a1bc88a0b
4 files changed
+9
-6
fast-import.c
+1
-1
@@ -1376,7 +1376,7 @@ static void *gfi_unpack_entry(
1376
*/
1377
p->pack_size = pack_size + the_hash_algo->rawsz;
1378
}
1379
- return unpack_entry(p, oe->idx.offset, &type, sizep);
1379
+ return unpack_entry(the_repository, p, oe->idx.offset, &type, sizep);
1380
}
1381
1382
static const char *get_mode(const char *str, uint16_t *modep)
pack-check.c
+2
-1
@@ -1,4 +1,5 @@
1
#include "cache.h"
2
+#include "repository.h"
3
#include "pack.h"
4
#include "pack-revindex.h"
5
#include "progress.h"
@@ -134,7 +135,7 @@ static int verify_packfile(struct packed_git *p,
135
data = NULL;
136
data_valid = 0;
137
} else {
137
- data = unpack_entry(p, entries[i].offset, &type, &size);
138
+ data = unpack_entry(the_repository, p, entries[i].offset, &type, &size);
139
data_valid = 1;
140
}
141
packfile.c
+4
-3
@@ -1279,7 +1279,7 @@ static void *cache_or_unpack_entry(struct packed_git *p, off_t base_offset,
1279
1280
ent = get_delta_base_cache_entry(p, base_offset);
1281
if (!ent)
1282
- return unpack_entry(p, base_offset, type, base_size);
1282
+ return unpack_entry(the_repository, p, base_offset, type, base_size);
1283
1284
if (type)
1285
*type = ent->type;
@@ -1485,8 +1485,9 @@ static void *read_object_the_repository(const struct object_id *oid,
1485
return content;
1486
}
1487
1488
-void *unpack_entry(struct packed_git *p, off_t obj_offset,
1489
- enum object_type *final_type, unsigned long *final_size)
1488
+void *unpack_entry_the_repository(struct packed_git *p, off_t obj_offset,
1489
+ enum object_type *final_type,
1490
+ unsigned long *final_size)
1491
{
1492
struct pack_window *w_curs = NULL;
1493
off_t curpos = obj_offset;
packfile.h
+2
-1
@@ -115,7 +115,8 @@ extern off_t nth_packed_object_offset(const struct packed_git *, uint32_t n);
115
extern off_t find_pack_entry_one(const unsigned char *sha1, struct packed_git *);
116
117
extern int is_pack_valid(struct packed_git *);
118
-extern void *unpack_entry(struct packed_git *, off_t, enum object_type *, unsigned long *);
118
+#define unpack_entry(r, p, of, ot, s) unpack_entry_##r(p, of, ot, s)
119
+extern void *unpack_entry_the_repository(struct packed_git *, off_t, enum object_type *, unsigned long *);
120
extern unsigned long unpack_object_header_buffer(const unsigned char *buf, unsigned long len, enum object_type *type, unsigned long *sizep);
121
extern unsigned long get_size_from_delta(struct packed_git *, struct pack_window **, off_t);
122
extern int unpack_object_header(struct packed_git *, struct pack_window **, off_t *, unsigned long *);