Git fork

hex: guard declarations with `USE_THE_REPOSITORY_VARIABLE`

Guard declarations of functions that implicitly use `the_repository`
with `USE_THE_REPOSITORY_VARIABLE` such that callers don't accidentally
rely on that global variable.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Patrick Steinhardt and committed by
Junio C Hamano
dc89b7d5 912d4756

+16 -10
+16 -10
hex.h
··· 13 * input, so it is safe to pass this function an arbitrary 14 * null-terminated string. 15 */ 16 - int get_hash_hex(const char *hex, unsigned char *hash); 17 - int get_oid_hex(const char *hex, struct object_id *oid); 18 - 19 - /* Like get_oid_hex, but for an arbitrary hash algorithm. */ 20 int get_oid_hex_algop(const char *hex, struct object_id *oid, const struct git_hash_algo *algop); 21 22 /* ··· 35 char *hash_to_hex_algop_r(char *buffer, const unsigned char *hash, const struct git_hash_algo *); 36 char *oid_to_hex_r(char *out, const struct object_id *oid); 37 char *hash_to_hex_algop(const unsigned char *hash, const struct git_hash_algo *); /* static buffer result! */ 38 - char *hash_to_hex(const unsigned char *hash); /* same static buffer */ 39 char *oid_to_hex(const struct object_id *oid); /* same static buffer */ 40 41 /* ··· 45 * other invalid character. end is only updated on success; otherwise, it is 46 * unmodified. 47 */ 48 - int parse_oid_hex(const char *hex, struct object_id *oid, const char **end); 49 - 50 - /* Like parse_oid_hex, but for an arbitrary hash algorithm. */ 51 int parse_oid_hex_algop(const char *hex, struct object_id *oid, const char **end, 52 const struct git_hash_algo *algo); 53 - 54 55 /* 56 * These functions work like get_oid_hex and parse_oid_hex, but they will parse ··· 61 int get_oid_hex_any(const char *hex, struct object_id *oid); 62 int parse_oid_hex_any(const char *hex, struct object_id *oid, const char **end); 63 64 - #endif
··· 13 * input, so it is safe to pass this function an arbitrary 14 * null-terminated string. 15 */ 16 int get_oid_hex_algop(const char *hex, struct object_id *oid, const struct git_hash_algo *algop); 17 18 /* ··· 31 char *hash_to_hex_algop_r(char *buffer, const unsigned char *hash, const struct git_hash_algo *); 32 char *oid_to_hex_r(char *out, const struct object_id *oid); 33 char *hash_to_hex_algop(const unsigned char *hash, const struct git_hash_algo *); /* static buffer result! */ 34 char *oid_to_hex(const struct object_id *oid); /* same static buffer */ 35 36 /* ··· 40 * other invalid character. end is only updated on success; otherwise, it is 41 * unmodified. 42 */ 43 int parse_oid_hex_algop(const char *hex, struct object_id *oid, const char **end, 44 const struct git_hash_algo *algo); 45 46 /* 47 * These functions work like get_oid_hex and parse_oid_hex, but they will parse ··· 52 int get_oid_hex_any(const char *hex, struct object_id *oid); 53 int parse_oid_hex_any(const char *hex, struct object_id *oid, const char **end); 54 55 + #ifdef USE_THE_REPOSITORY_VARIABLE 56 + 57 + /* Like get_oid_hex_algop, but for `the_hash_algo`. */ 58 + int get_hash_hex(const char *hex, unsigned char *hash); 59 + int get_oid_hex(const char *hex, struct object_id *oid); 60 + 61 + /* Like parse_oid_hex_algop, but uses `the_hash_algo`. */ 62 + int parse_oid_hex(const char *hex, struct object_id *oid, const char **end); 63 + 64 + /* 65 + * Same as `hash_to_hex_algop()`, but uses `the_hash_algo`. 66 + */ 67 + char *hash_to_hex(const unsigned char *hash); 68 + 69 + #endif /* USE_THE_REPOSITORY_VARIABLE */ 70 + #endif /* HEX_H */