]> git.ipfire.org Git - thirdparty/git.git/commit - refs.c
resolve_ref: use strbufs for internal buffers
authorJeff King <peff@peff.net>
Thu, 24 Sep 2015 21:07:22 +0000 (17:07 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 25 Sep 2015 17:18:18 +0000 (10:18 -0700)
commit495127dbcbd53e89d7edee8db42bfa7e57c8a120
treea72a2916db245c5862ee09843059886b9f673b8c
parent0e265a92a1d2b9275d638f696c65c9bbe747e78c
resolve_ref: use strbufs for internal buffers

resolve_ref already uses a strbuf internally when generating
pathnames, but it uses fixed-size buffers for storing the
refname and symbolic refs. This means that you cannot
actually point HEAD to a ref that is larger than 256 bytes.

We can lift this limit by using strbufs here, too. Like
sb_path, we pass the the buffers into our helper function,
so that we can easily clean up all output paths. We can also
drop the "unsafe" name from our helper function, as it no
longer uses a single static buffer (but of course
resolve_ref_unsafe is still unsafe, because the static
buffers moved there).

As a bonus, we also get to drop some strcpy calls between
the two fixed buffers (that cannot currently overflow
because the two buffers are sized identically).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs.c
t/t1401-symbolic-ref.sh