Skip to content

Commit 57a6a50

Browse files
stefanbellergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Stefan Beller <[email protected]> Reviewed-by: Jonathan Tan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5da6534 commit 57a6a50

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

fast-import.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1376,7 +1376,7 @@ static void *gfi_unpack_entry(
13761376
*/
13771377
p->pack_size = pack_size + the_hash_algo->rawsz;
13781378
}
1379-
return unpack_entry(p, oe->idx.offset, &type, sizep);
1379+
return unpack_entry(the_repository, p, oe->idx.offset, &type, sizep);
13801380
}
13811381

13821382
static const char *get_mode(const char *str, uint16_t *modep)

pack-check.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "cache.h"
2+
#include "repository.h"
23
#include "pack.h"
34
#include "pack-revindex.h"
45
#include "progress.h"
@@ -134,7 +135,7 @@ static int verify_packfile(struct packed_git *p,
134135
data = NULL;
135136
data_valid = 0;
136137
} else {
137-
data = unpack_entry(p, entries[i].offset, &type, &size);
138+
data = unpack_entry(the_repository, p, entries[i].offset, &type, &size);
138139
data_valid = 1;
139140
}
140141

packfile.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,7 +1279,7 @@ static void *cache_or_unpack_entry(struct packed_git *p, off_t base_offset,
12791279

12801280
ent = get_delta_base_cache_entry(p, base_offset);
12811281
if (!ent)
1282-
return unpack_entry(p, base_offset, type, base_size);
1282+
return unpack_entry(the_repository, p, base_offset, type, base_size);
12831283

12841284
if (type)
12851285
*type = ent->type;
@@ -1485,8 +1485,9 @@ static void *read_object_the_repository(const struct object_id *oid,
14851485
return content;
14861486
}
14871487

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)
14901491
{
14911492
struct pack_window *w_curs = NULL;
14921493
off_t curpos = obj_offset;

packfile.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ extern off_t nth_packed_object_offset(const struct packed_git *, uint32_t n);
115115
extern off_t find_pack_entry_one(const unsigned char *sha1, struct packed_git *);
116116

117117
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 *);
119120
extern unsigned long unpack_object_header_buffer(const unsigned char *buf, unsigned long len, enum object_type *type, unsigned long *sizep);
120121
extern unsigned long get_size_from_delta(struct packed_git *, struct pack_window **, off_t);
121122
extern int unpack_object_header(struct packed_git *, struct pack_window **, off_t *, unsigned long *);

0 commit comments

Comments
 (0)