Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2022-05-21 02:17:41 +0300
committerJunio C Hamano <gitster@pobox.com>2022-05-27 01:48:26 +0300
commitd9fef9d90d27b6794350ec3bc622042b79397088 (patch)
tree9543ec7910dadddc189e91ef723c49c44590e901 /pack-write.c
parent1c573cdd7219db5600fb2b5249f7c8835c8d416d (diff)
chunk-format.h: extract oid_version()
There are three definitions of an identical function which converts `the_hash_algo` into either 1 (for SHA-1) or 2 (for SHA-256). There is a copy of this function for writing both the commit-graph and multi-pack-index file, and another inline definition used to write the .rev header. Consolidate these into a single definition in chunk-format.h. It's not clear that this is the best header to define this function in, but it should do for now. (Worth noting, the .rev caller expects a 4-byte unsigned, but the other two callers work with a single unsigned byte. The consolidated version uses the latter type, and lets the compiler widen it when required). Another caller will be added in a subsequent patch. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pack-write.c')
-rw-r--r--pack-write.c15
1 files changed, 2 insertions, 13 deletions
diff --git a/pack-write.c b/pack-write.c
index a2adc565f4..27b171e440 100644
--- a/pack-write.c
+++ b/pack-write.c
@@ -2,6 +2,7 @@
#include "pack.h"
#include "csum-file.h"
#include "remote.h"
+#include "chunk-format.h"
void reset_pack_idx_option(struct pack_idx_option *opts)
{
@@ -181,21 +182,9 @@ static int pack_order_cmp(const void *va, const void *vb, void *ctx)
static void write_rev_header(struct hashfile *f)
{
- uint32_t oid_version;
- switch (hash_algo_by_ptr(the_hash_algo)) {
- case GIT_HASH_SHA1:
- oid_version = 1;
- break;
- case GIT_HASH_SHA256:
- oid_version = 2;
- break;
- default:
- die("write_rev_header: unknown hash version");
- }
-
hashwrite_be32(f, RIDX_SIGNATURE);
hashwrite_be32(f, RIDX_VERSION);
- hashwrite_be32(f, oid_version);
+ hashwrite_be32(f, oid_version(the_hash_algo));
}
static void write_rev_index_positions(struct hashfile *f,