Convert this function to use struct object_id.  Use parse_oid_hex to
avoid having to hard-code the number of bytes to be parsed.

Signed-off-by: brian m. carlson <sand...@crustytoothpaste.net>
---
 builtin/fetch-pack.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
index 19215b3..f3b89a9 100644
--- a/builtin/fetch-pack.c
+++ b/builtin/fetch-pack.c
@@ -14,12 +14,14 @@ static void add_sought_entry_mem(struct ref ***sought, int 
*nr, int *alloc,
                                 const char *name, int namelen)
 {
        struct ref *ref = xcalloc(1, sizeof(*ref) + namelen + 1);
-       unsigned char sha1[20];
+       struct object_id oid;
+       int hexlen;
 
-       if (namelen > 41 && name[40] == ' ' && !get_sha1_hex(name, sha1)) {
-               hashcpy(ref->old_oid.hash, sha1);
-               name += 41;
-               namelen -= 41;
+       if ((hexlen = parse_oid_hex(name, namelen, &oid)) && namelen > hexlen + 
1 &&
+               name[hexlen] == ' ') {
+               oidcpy(&ref->old_oid, &oid);
+               name += hexlen + 1;
+               namelen -= hexlen + 1;
        }
 
        memcpy(ref->name, name, namelen);
-- 
2.4.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to