aboutsummaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2013-04-22 21:52:13 +0200
committerJunio C Hamano <gitster@pobox.com>2013-05-01 15:33:09 -0700
commit3feb4f0cfb7597a98d6e650abc8e9a1a9a0d65b5 (patch)
treeb21d3a1d18295984c662499d5778ae143b8b5aa6 /refs.c
parent7d76fdc8299639096ace153aef0f0b96dcc5b308 (diff)
downloadgit-3feb4f0cfb7597a98d6e650abc8e9a1a9a0d65b5.tar.gz
git-3feb4f0cfb7597a98d6e650abc8e9a1a9a0d65b5.tar.xz
refs: define constant PEELED_LINE_LENGTH
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/refs.c b/refs.c
index ccbd04a03..390251476 100644
--- a/refs.c
+++ b/refs.c
@@ -806,6 +806,9 @@ void invalidate_ref_cache(const char *submodule)
clear_loose_ref_cache(refs);
}
+/* The length of a peeled reference line in packed-refs, including EOL: */
+#define PEELED_LINE_LENGTH 42
+
/*
* Parse one line from a packed-refs file. Write the SHA1 to sha1.
* 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)
}
if (last &&
refline[0] == '^' &&
- strlen(refline) == 42 &&
- refline[41] == '\n' &&
+ strlen(refline) == PEELED_LINE_LENGTH &&
+ refline[PEELED_LINE_LENGTH - 1] == '\n' &&
!get_sha1_hex(refline + 1, sha1)) {
hashcpy(last->u.value.peeled, sha1);
/*