read_packed_refs: use skip_prefix instead of static array

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>

Jeff King committed Dec 10, 2014 at 05:40 UTC ea417833ea9a07d7b8d568358ff20f57851cb26e
1 file changed +2 -3
refs.c
+2 -3
@@ -1040,10 +1040,9 @@ static void read_packed_refs(FILE *f, struct ref_dir *dir)
1040 while (strbuf_getwholeline(&line, f, '\n') != EOF) {
1041 unsigned char sha1[20];
1042 const char *refname;
1043 - static const char header[] = "# pack-refs with:";
1043 + const char *traits;
1044
1045 - if (!strncmp(line.buf, header, sizeof(header)-1)) {
1046 - const char *traits = line.buf + sizeof(header) - 1;
1045 + if (skip_prefix(line.buf, "# pack-refs with:", &traits)) {
1046 if (strstr(traits, " fully-peeled "))
1047 peeled = PEELED_FULLY;
1048 else if (strstr(traits, " peeled "))