summaryrefslogtreecommitdiff
path: root/builtin/fetch-pack.c
diff options
context:
space:
mode:
authorbrian m. carlson <sandals@crustytoothpaste.net>2015-11-10 02:22:21 (GMT)
committerJeff King <peff@peff.net>2015-11-20 13:02:05 (GMT)
commit854ecb9cadde1063883e2a74ae6b8ea46c0a451a (patch)
tree0a9eed5de7b6d112d621d171538cc68e38fbf820 /builtin/fetch-pack.c
parentf4e54d02b894064d370e461385b48701485672bd (diff)
downloadgit-854ecb9cadde1063883e2a74ae6b8ea46c0a451a.zip
git-854ecb9cadde1063883e2a74ae6b8ea46c0a451a.tar.gz
git-854ecb9cadde1063883e2a74ae6b8ea46c0a451a.tar.bz2
add_sought_entry_mem: convert to struct object_id
Convert this function to use struct object_id. Express several hardcoded constants in terms of GIT_SHA1_HEXSZ. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Jeff King <peff@peff.net>
Diffstat (limited to 'builtin/fetch-pack.c')
-rw-r--r--builtin/fetch-pack.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
index 19215b3..cf3019e 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];
-
- if (namelen > 41 && name[40] == ' ' && !get_sha1_hex(name, sha1)) {
- hashcpy(ref->old_oid.hash, sha1);
- name += 41;
- namelen -= 41;
+ struct object_id oid;
+ const int chunksz = GIT_SHA1_HEXSZ + 1;
+
+ if (namelen > chunksz && name[chunksz - 1] == ' ' &&
+ !get_oid_hex(name, &oid)) {
+ oidcpy(&ref->old_oid, &oid);
+ name += chunksz;
+ namelen -= chunksz;
}
memcpy(ref->name, name, namelen);