show-branch: use strbuf instead of static buffer
commitaaa07e3eee6f42d0adeac826dfb52d5ade26defc
authorJeff King <peff@peff.net>
Fri, 5 Apr 2013 21:15:50 +0000 (5 17:15 -0400)
committerJunio C Hamano <gitster@pobox.com>
Sun, 7 Apr 2013 01:57:15 +0000 (6 18:57 -0700)
tree0a188f1f8321dce9fe433eba70b8598669a4f77d
parent15999998fbda60552742275570947431b57108ae
show-branch: use strbuf instead of static buffer

When we generate relative names (e.g., "master~20^2"), we
format the name into a static buffer, then xstrdup the
result to attach it to the commit. Since the first thing we
add into the static buffer is the already-computed name of
the child commit, the names may get longer and longer as
the traversal gets deeper, and we may eventually overflow
the fixed-size buffer.

Fix this by converting the fixed-size buffer into a dynamic
strbuf.  The performance implications should be minimal, as
we end up allocating a heap copy of the name anyway (and now
we can just detach the heap copy from the strbuf).

Reported-by: Eric Roman <eroman@chromium.org>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/show-branch.c