summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2014-12-10 05:40:36 -0500
committerJunio C Hamano <gitster@pobox.com>2014-12-10 09:40:33 -0800
commitea417833ea9a07d7b8d568358ff20f57851cb26e (patch)
treec3bdd5a211743f6cf8ab88bbdbeff669a3bd9c83 /refs.c
parent6a49870a7245934eac671e3dcd7186a90dac255d (diff)
downloadgit-ea417833ea9a07d7b8d568358ff20f57851cb26e.tar.gz
read_packed_refs: use skip_prefix instead of static arrayjk/read-packed-refs-without-path-max
We want to recognize the packed-refs header and skip to the "traits" part of the line. We currently do it by feeding sizeof() a static const array to strncmp. However, it's a bit simpler to just skip_prefix, which expresses the intention more directly, and without remembering to account for the NUL-terminator in each sizeof() call. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs.c')
-rw-r--r--refs.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/refs.c b/refs.c
index 047353ea1f..ba3003ffd2 100644
--- a/refs.c
+++ b/refs.c
@@ -1040,10 +1040,9 @@ static void read_packed_refs(FILE *f, struct ref_dir *dir)
while (strbuf_getwholeline(&line, f, '\n') != EOF) {
unsigned char sha1[20];
const char *refname;
- static const char header[] = "# pack-refs with:";
+ const char *traits;
- if (!strncmp(line.buf, header, sizeof(header)-1)) {
- const char *traits = line.buf + sizeof(header) - 1;
+ if (skip_prefix(line.buf, "# pack-refs with:", &traits)) {
if (strstr(traits, " fully-peeled "))
peeled = PEELED_FULLY;
else if (strstr(traits, " peeled "))