Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
add_sought_entry_mem: convert to struct object_id
author
brian m. carlson
<sandals@crustytoothpaste.net>
Tue, 10 Nov 2015 02:22:21 +0000
(
02:22
+0000)
committer
Jeff King
<peff@peff.net>
Fri, 20 Nov 2015 13:02:05 +0000
(08:02 -0500)
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>
builtin/fetch-pack.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
f4e54d0
)
diff --git
a/builtin/fetch-pack.c
b/builtin/fetch-pack.c
index 19215b3303d90fe953a59741f1841873d1c8f08c..cf3019e05bdf45e1fa16a483621a6773976f98c5 100644
(file)
--- 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);
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);
}
memcpy(ref->name, name, namelen);