Merge branch 'jk/read-packed-refs-without-path-max'
authorJunio C Hamano <gitster@pobox.com>
Mon, 22 Dec 2014 20:28:04 +0000 (12:28 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 22 Dec 2014 20:28:04 +0000 (12:28 -0800)
Git did not correctly read an overlong refname from a packed refs
file.

* jk/read-packed-refs-without-path-max:
read_packed_refs: use skip_prefix instead of static array
read_packed_refs: pass strbuf to parse_ref_line
read_packed_refs: use a strbuf for reading lines

1  2 
refs.c
diff --cc refs.c
index bfe4ba4213d445189b564726a9acbaa0924e1370,ba3003ffd2bd63a1741771e63ed296de69f4e607..5fcacc6c41e6c7033367cc9c4cf7c18b33eea286
--- 1/refs.c
--- 2/refs.c
+++ b/refs.c
@@@ -1144,15 -1051,9 +1146,15 @@@ static void read_packed_refs(FILE *f, s
                        continue;
                }
  
-               refname = parse_ref_line(refline, sha1);
+               refname = parse_ref_line(&line, sha1);
                if (refname) {
 -                      last = create_ref_entry(refname, sha1, REF_ISPACKED, 1);
 +                      int flag = REF_ISPACKED;
 +
 +                      if (check_refname_format(refname, REFNAME_ALLOW_ONELEVEL)) {
 +                              hashclr(sha1);
 +                              flag |= REF_BAD_NAME | REF_ISBROKEN;
 +                      }
 +                      last = create_ref_entry(refname, sha1, flag, 0);
                        if (peeled == PEELED_FULLY ||
                            (peeled == PEELED_TAGS && starts_with(refname, "refs/tags/")))
                                last->flag |= REF_KNOWS_PEELED;