hex: add oid_to_hex_r()

This function works just like sha1_to_hex_r, except that it takes a pointer to struct object_id instead of a pointer to unsigned char. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed Jun 24, 2016 at 23:09 UTC 55c529a7005c653ceb318e1e25b40ff96a41877f
2 files changed +6
cache.h
+1
@@ -1193,6 +1193,7 @@ extern int get_oid_hex(const char *hex, struct object_id *sha1);
1193 * printf("%s -> %s", sha1_to_hex(one), sha1_to_hex(two));
1194 */
1195 extern char *sha1_to_hex_r(char *out, const unsigned char *sha1);
1196 +extern char *oid_to_hex_r(char *out, const struct object_id *oid);
1197 extern char *sha1_to_hex(const unsigned char *sha1); /* static buffer result! */
1198 extern char *oid_to_hex(const struct object_id *oid); /* same static buffer as sha1_to_hex */
1199
hex.c
+5
@@ -77,6 +77,11 @@ char *sha1_to_hex_r(char *buffer, const unsigned char *sha1)
77 return buffer;
78 }
79
80 +char *oid_to_hex_r(char *buffer, const struct object_id *oid)
81 +{
82 + return sha1_to_hex_r(buffer, oid->hash);
83 +}
84 +
85 char *sha1_to_hex(const unsigned char *sha1)
86 {
87 static int bufno;