refs: define constant PEELED_LINE_LENGTH
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty committed
Apr 22, 2013 at 21:52 UTC
3feb4f0cfb7597a98d6e650abc8e9a1a9a0d65b5
1 file changed
+5
-2
refs.c
+5
-2
@@ -806,6 +806,9 @@ void invalidate_ref_cache(const char *submodule)
806
clear_loose_ref_cache(refs);
807
}
808
809
+/* The length of a peeled reference line in packed-refs, including EOL: */
810
+#define PEELED_LINE_LENGTH 42
811
+
812
/*
813
* Parse one line from a packed-refs file. Write the SHA1 to sha1.
814
* Return a pointer to the refname within the line (null-terminated),
@@ -898,8 +901,8 @@ static void read_packed_refs(FILE *f, struct ref_dir *dir)
901
}
902
if (last &&
903
refline[0] == '^' &&
901
- strlen(refline) == 42 &&
902
- refline[41] == '\n' &&
904
+ strlen(refline) == PEELED_LINE_LENGTH &&
905
+ refline[PEELED_LINE_LENGTH - 1] == '\n' &&
906
!get_sha1_hex(refline + 1, sha1)) {
907
hashcpy(last->u.value.peeled, sha1);
908
/*