Commit Diff


commit - ab62f2123a6a5e453ab9645daf04cd1f2bd8442d
commit + 35a11c8a7a3ae3f902bdddd1eb91c23982c612b0
blob - 070b80df0cce4e90b81489df1c9f71ce5c1c3cc7
blob + 8310d258ed0862c91aa319a890177e42fbb539df
--- lib/reference.c
+++ lib/reference.c
@@ -298,8 +298,10 @@ parse_packed_ref_line(struct got_reference **ref, cons
 {
 	struct got_object_id id;
 	const char *name;
+	size_t idlen;
 
 	*ref = NULL;
+	idlen = got_hash_digest_string_length(algo);
 
 	if (line[0] == '#' || line[0] == '^')
 		return NULL;
@@ -308,11 +310,11 @@ parse_packed_ref_line(struct got_reference **ref, cons
 		return got_error(GOT_ERR_BAD_REF_DATA);
 
 	if (abs_refname) {
-		if (strcmp(line + SHA1_DIGEST_STRING_LENGTH, abs_refname) != 0)
+		if (strcmp(line + idlen, abs_refname) != 0)
 			return NULL;
 		name = abs_refname;
 	} else
-		name = line + SHA1_DIGEST_STRING_LENGTH;
+		name = line + idlen;
 
 	return alloc_ref(ref, name, &id, GOT_REF_IS_PACKED, mtime);
 }