From: Jeff King Date: Tue, 28 Mar 2017 19:46:33 +0000 (-0400) Subject: avoid using mksnpath for refs X-Git-Tag: v2.13.0-rc0~28^2~10 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/6cd4a8982dbde0b6fee26faba2873c475af50a28?ds=inline;hp=6cd4a8982dbde0b6fee26faba2873c475af50a28 avoid using mksnpath for refs Like the previous commit, we'd like to avoid the assumption that refs fit into PATH_MAX-sized buffers. These callsites have an extra twist, though: they write the refnames using mksnpath. This does two things beyond a regular snprintf: 1. It quietly writes "/bad-path/" when truncation occurs. This saves the caller having to check the error code, but if you aren't actually feeding the result to a system call (and we aren't here), it's questionable. 2. It calls cleanup_path(), which removes leading instances of "./". That's questionable when dealing with refnames, as we could silently canonicalize a syntactically bogus refname into a valid one. Let's convert each case to use a strbuf. This is preferable to xstrfmt() because we can reuse the same buffer as we loop. Signed-off-by: Jeff King ---