]> git.ipfire.org Git - thirdparty/git.git/commitdiff
hex: add oid_to_hex_r()
authorbrian m. carlson <sandals@crustytoothpaste.net>
Fri, 24 Jun 2016 23:09:19 +0000 (23:09 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 28 Jun 2016 18:39:02 +0000 (11:39 -0700)
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>
cache.h
hex.c

diff --git a/cache.h b/cache.h
index 6049f867113896def34306f22ac6927b8f0e8e1e..7bd7c472f8232693afe0d59e562e1016a5a63cb5 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -1193,6 +1193,7 @@ extern int get_oid_hex(const char *hex, struct object_id *sha1);
  *   printf("%s -> %s", sha1_to_hex(one), sha1_to_hex(two));
  */
 extern char *sha1_to_hex_r(char *out, const unsigned char *sha1);
+extern char *oid_to_hex_r(char *out, const struct object_id *oid);
 extern char *sha1_to_hex(const unsigned char *sha1);   /* static buffer result! */
 extern char *oid_to_hex(const struct object_id *oid);  /* same static buffer as sha1_to_hex */
 
diff --git a/hex.c b/hex.c
index 0519f853b26e527aa529c75da6c302663881102e..9619b67af0b79c4ebae4c5e6a5f5748405bd4dea 100644 (file)
--- a/hex.c
+++ b/hex.c
@@ -77,6 +77,11 @@ char *sha1_to_hex_r(char *buffer, const unsigned char *sha1)
        return buffer;
 }
 
+char *oid_to_hex_r(char *buffer, const struct object_id *oid)
+{
+       return sha1_to_hex_r(buffer, oid->hash);
+}
+
 char *sha1_to_hex(const unsigned char *sha1)
 {
        static int bufno;