mirror of
https://github.com/git/git.git
synced 2026-01-09 01:34:00 +00:00
hex: introduce parse_oid_hex
Introduce a function, parse_oid_hex, which parses a hexadecimal object ID and if successful, sets a pointer to just beyond the last character. This allows for simpler, more robust parsing without needing to hard-code integer values throughout the codebase. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
5588dbffbd
commit
605f430efb
8
hex.c
8
hex.c
@@ -53,6 +53,14 @@ int get_oid_hex(const char *hex, struct object_id *oid)
|
||||
return get_sha1_hex(hex, oid->hash);
|
||||
}
|
||||
|
||||
int parse_oid_hex(const char *hex, struct object_id *oid, const char **end)
|
||||
{
|
||||
int ret = get_oid_hex(hex, oid);
|
||||
if (!ret)
|
||||
*end = hex + GIT_SHA1_HEXSZ;
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *sha1_to_hex_r(char *buffer, const unsigned char *sha1)
|
||||
{
|
||||
static const char hex[] = "0123456789abcdef";
|
||||
|
||||
Reference in New Issue
Block a user