summaryrefslogtreecommitdiff
path: root/cache.h
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-04-20 04:37:13 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-04-20 04:37:13 (GMT)
commitb1081e4004091947b6c6a806625addd1cbba61b7 (patch)
tree2cf8dfc6a5e33499b5dbcc8b3e94dbe311e2acfa /cache.h
parentc703555cc89cf6aedf549a1233b242d8cb8e0f20 (diff)
parente239dabb1465d3ff927840b4fff15150a2170b4e (diff)
downloadgit-b1081e4004091947b6c6a806625addd1cbba61b7.zip
git-b1081e4004091947b6c6a806625addd1cbba61b7.tar.gz
git-b1081e4004091947b6c6a806625addd1cbba61b7.tar.bz2
Merge branch 'bc/object-id'
Conversion from unsigned char [40] to struct object_id continues. * bc/object-id: Documentation: update and rename api-sha1-array.txt Rename sha1_array to oid_array Convert sha1_array_for_each_unique and for_each_abbrev to object_id Convert sha1_array_lookup to take struct object_id Convert remaining callers of sha1_array_lookup to object_id Make sha1_array_append take a struct object_id * sha1-array: convert internal storage for struct sha1_array to object_id builtin/pull: convert to struct object_id submodule: convert check_for_new_submodule_commits to object_id sha1_name: convert disambiguate_hint_fn to take object_id sha1_name: convert struct disambiguate_state to object_id test-sha1-array: convert most code to struct object_id parse-options-cb: convert sha1_array_append caller to struct object_id fsck: convert init_skiplist to struct object_id builtin/receive-pack: convert portions to struct object_id builtin/pull: convert portions to struct object_id builtin/diff: convert to struct object_id Convert GIT_SHA1_RAWSZ used for allocation to GIT_MAX_RAWSZ Convert GIT_SHA1_HEXSZ used for allocation to GIT_MAX_HEXSZ Define new hash-size constants for allocating memory
Diffstat (limited to 'cache.h')
-rw-r--r--cache.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/cache.h b/cache.h
index 556468c..ba27595 100644
--- a/cache.h
+++ b/cache.h
@@ -66,8 +66,12 @@ unsigned long git_deflate_bound(git_zstream *, unsigned long);
#define GIT_SHA1_RAWSZ 20
#define GIT_SHA1_HEXSZ (2 * GIT_SHA1_RAWSZ)
+/* The length in byte and in hex digits of the largest possible hash value. */
+#define GIT_MAX_RAWSZ GIT_SHA1_RAWSZ
+#define GIT_MAX_HEXSZ GIT_SHA1_HEXSZ
+
struct object_id {
- unsigned char hash[GIT_SHA1_RAWSZ];
+ unsigned char hash[GIT_MAX_RAWSZ];
};
#if defined(DT_UNKNOWN) && !defined(NO_D_TYPE_IN_DIRENT)
@@ -978,7 +982,7 @@ extern char *sha1_pack_index_name(const unsigned char *sha1);
extern const char *find_unique_abbrev(const unsigned char *sha1, int len);
extern int find_unique_abbrev_r(char *hex, const unsigned char *sha1, int len);
-extern const unsigned char null_sha1[GIT_SHA1_RAWSZ];
+extern const unsigned char null_sha1[GIT_MAX_RAWSZ];
extern const struct object_id null_oid;
static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2)
@@ -1360,7 +1364,7 @@ extern int get_sha1_with_context(const char *str, unsigned flags, unsigned char
extern int get_oid(const char *str, struct object_id *oid);
-typedef int each_abbrev_fn(const unsigned char *sha1, void *);
+typedef int each_abbrev_fn(const struct object_id *oid, void *);
extern int for_each_abbrev(const char *prefix, each_abbrev_fn, void *);
extern int set_disambiguate_hint_config(const char *var, const char *value);