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>
This commit is contained in:
parent
f4e54d02b8
commit
854ecb9cad
@ -14,12 +14,14 @@ static void add_sought_entry_mem(struct ref ***sought, int *nr, int *alloc,
|
|||||||
const char *name, int namelen)
|
const char *name, int namelen)
|
||||||
{
|
{
|
||||||
struct ref *ref = xcalloc(1, sizeof(*ref) + namelen + 1);
|
struct ref *ref = xcalloc(1, sizeof(*ref) + namelen + 1);
|
||||||
unsigned char sha1[20];
|
struct object_id oid;
|
||||||
|
const int chunksz = GIT_SHA1_HEXSZ + 1;
|
||||||
|
|
||||||
if (namelen > 41 && name[40] == ' ' && !get_sha1_hex(name, sha1)) {
|
if (namelen > chunksz && name[chunksz - 1] == ' ' &&
|
||||||
hashcpy(ref->old_oid.hash, sha1);
|
!get_oid_hex(name, &oid)) {
|
||||||
name += 41;
|
oidcpy(&ref->old_oid, &oid);
|
||||||
namelen -= 41;
|
name += chunksz;
|
||||||
|
namelen -= chunksz;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(ref->name, name, namelen);
|
memcpy(ref->name, name, namelen);
|
||||||
|
Loading…
Reference in New Issue
Block a user