diff options
author | Derrick Stolee <dstolee@microsoft.com> | 2018-01-17 20:08:23 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-01-19 20:04:56 +0100 |
commit | ad622a256f0dd0be44ca17f58b3f5b43cedb4320 (patch) | |
tree | aa26cd44a6bada37277730382febb9505b167731 /pack-revindex.c | |
parent | Git 2.16 (diff) | |
download | git-ad622a256f0dd0be44ca17f58b3f5b43cedb4320.tar.xz git-ad622a256f0dd0be44ca17f58b3f5b43cedb4320.zip |
packfile: use get_be64() for large offsets
The pack-index version 2 format uses two 4-byte integers in
network-byte order to represent one 8-byte value. The current
implementation has several code clones for stitching these integers
together.
Use get_be64() to create an 8-byte integer from two 4-byte integers
represented this way.
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pack-revindex.c')
-rw-r--r-- | pack-revindex.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/pack-revindex.c b/pack-revindex.c index 1b7ebd8d7e..ff5f62c033 100644 --- a/pack-revindex.c +++ b/pack-revindex.c @@ -134,10 +134,8 @@ static void create_pack_revindex(struct packed_git *p) if (!(off & 0x80000000)) { p->revindex[i].offset = off; } else { - p->revindex[i].offset = - ((uint64_t)ntohl(*off_64++)) << 32; - p->revindex[i].offset |= - ntohl(*off_64++); + p->revindex[i].offset = get_be64(off_64); + off_64 += 2; } p->revindex[i].nr = i; } |