summaryrefslogtreecommitdiff
path: root/cache.h
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-12-13 21:28:54 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-12-13 21:28:54 (GMT)
commit721cc4314cb593e799213ad5f926a1e9fc5779b0 (patch)
treeffa71b39724a9eed8dc7c653cafb4e1211e7820d /cache.h
parent95ec6b1b3393eb6e26da40c565520a8db9796e9f (diff)
parentc250e02e2c6de8c116f4320a48ce44bbdb43015c (diff)
downloadgit-721cc4314cb593e799213ad5f926a1e9fc5779b0.zip
git-721cc4314cb593e799213ad5f926a1e9fc5779b0.tar.gz
git-721cc4314cb593e799213ad5f926a1e9fc5779b0.tar.bz2
Merge branch 'bc/hash-algo'
An infrastructure to define what hash function is used in Git is introduced, and an effort to plumb that throughout various codepaths has been started. * bc/hash-algo: repository: fix a sparse 'using integer as NULL pointer' warning Switch empty tree and blob lookups to use hash abstraction Integrate hash algorithm support with repo setup Add structure representing hash algorithm setup: expose enumerated repo info
Diffstat (limited to 'cache.h')
-rw-r--r--cache.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/cache.h b/cache.h
index cb5db7b..d3e2402 100644
--- a/cache.h
+++ b/cache.h
@@ -14,6 +14,7 @@
#include "hash.h"
#include "path.h"
#include "sha1-array.h"
+#include "repository.h"
#ifndef platform_SHA_CTX
/*
@@ -77,6 +78,8 @@ struct object_id {
unsigned char hash[GIT_MAX_RAWSZ];
};
+#define the_hash_algo the_repository->hash_algo
+
#if defined(DT_UNKNOWN) && !defined(NO_D_TYPE_IN_DIRENT)
#define DTYPE(de) ((de)->d_type)
#else
@@ -907,6 +910,7 @@ struct repository_format {
int version;
int precious_objects;
int is_bare;
+ int hash_algo;
char *work_tree;
struct string_list unknown_extensions;
};
@@ -1039,22 +1043,22 @@ extern const struct object_id empty_blob_oid;
static inline int is_empty_blob_sha1(const unsigned char *sha1)
{
- return !hashcmp(sha1, EMPTY_BLOB_SHA1_BIN);
+ return !hashcmp(sha1, the_hash_algo->empty_blob->hash);
}
static inline int is_empty_blob_oid(const struct object_id *oid)
{
- return !hashcmp(oid->hash, EMPTY_BLOB_SHA1_BIN);
+ return !oidcmp(oid, the_hash_algo->empty_blob);
}
static inline int is_empty_tree_sha1(const unsigned char *sha1)
{
- return !hashcmp(sha1, EMPTY_TREE_SHA1_BIN);
+ return !hashcmp(sha1, the_hash_algo->empty_tree->hash);
}
static inline int is_empty_tree_oid(const struct object_id *oid)
{
- return !hashcmp(oid->hash, EMPTY_TREE_SHA1_BIN);
+ return !oidcmp(oid, the_hash_algo->empty_tree);
}
/* set default permissions by passing mode arguments to open(2) */