read_packed_refs: use a strbuf for reading lines
commit10c497aa0cc7ccb5bd213f53fc0cd803bd73a508
authorJeff King <peff@peff.net>
Wed, 10 Dec 2014 10:40:07 +0000 (10 05:40 -0500)
committerJunio C Hamano <gitster@pobox.com>
Wed, 10 Dec 2014 17:27:24 +0000 (10 09:27 -0800)
treed6820a550c72b2d52432df90b47808f1ca3c9a6f
parent7fa1365c54c28b3cd9375539f381b54061a1880d
read_packed_refs: use a strbuf for reading lines

Current code uses a fixed PATH_MAX-sized buffer for reading
packed-refs lines. This is a reasonable guess, in the sense
that git generally cannot work with refs larger than
PATH_MAX.  However, there are a few cases where it is not
great:

  1. Some systems may have a low value of PATH_MAX, but can
     actually handle larger paths in practice. Fixing this
     code path probably isn't enough to make them work
     completely with long refs, but it is a step in the
     right direction.

  2. We use fgets, which will happily give us half a line on
     the first read, and then the rest of the line on the
     second. This is probably OK in practice, because our
     refline parser is careful enough to look for the
     trailing newline on the first line. The second line may
     look like a peeled line to us, but since "^" is illegal
     in refnames, it is not likely to come up.

     Still, it does not hurt to be more careful.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs.c