Skip to content

Commit dc89b7d

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 912d475 commit dc89b7d

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

hex.h

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313
* input, so it is safe to pass this function an arbitrary
1414
* null-terminated string.
1515
*/
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. */
2016
int get_oid_hex_algop(const char *hex, struct object_id *oid, const struct git_hash_algo *algop);
2117

2218
/*
@@ -35,7 +31,6 @@ int get_oid_hex_algop(const char *hex, struct object_id *oid, const struct git_h
3531
char *hash_to_hex_algop_r(char *buffer, const unsigned char *hash, const struct git_hash_algo *);
3632
char *oid_to_hex_r(char *out, const struct object_id *oid);
3733
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 */
3934
char *oid_to_hex(const struct object_id *oid); /* same static buffer */
4035

4136
/*
@@ -45,13 +40,9 @@ char *oid_to_hex(const struct object_id *oid); /* same static buffer */
4540
* other invalid character. end is only updated on success; otherwise, it is
4641
* unmodified.
4742
*/
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. */
5143
int parse_oid_hex_algop(const char *hex, struct object_id *oid, const char **end,
5244
const struct git_hash_algo *algo);
5345

54-
5546
/*
5647
* These functions work like get_oid_hex and parse_oid_hex, but they will parse
5748
* a hex value for any algorithm. The algorithm is detected based on the length
@@ -61,4 +52,19 @@ int parse_oid_hex_algop(const char *hex, struct object_id *oid, const char **end
6152
int get_oid_hex_any(const char *hex, struct object_id *oid);
6253
int parse_oid_hex_any(const char *hex, struct object_id *oid, const char **end);
6354

64-
#endif
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 */

0 commit comments

Comments
 (0)