]> git.ipfire.org Git - thirdparty/git.git/commit - strbuf.h
strbuf: add strbuf_add_real_path()
authorRené Scharfe <l.s.r@web.de>
Sat, 25 Feb 2017 16:00:33 +0000 (17:00 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 Feb 2017 19:02:06 +0000 (11:02 -0800)
commit33ad9ddd0b5398063f0aabea639b5fe569f458ea
tree9dcbafba9ded540f034e2697bf47198f4f217036
parent3f64699ffde6cd2152db2106505a2310601a207f
strbuf: add strbuf_add_real_path()

Add a function for appending the canonized absolute pathname of a given
path to a strbuf.  It keeps the existing contents intact, as expected of
a function of the strbuf_add() family, while avoiding copying the result
if the given strbuf is empty.  It's more consistent with the rest of the
strbuf API than strbuf_realpath(), which it's wrapping.

Also add a semantic patch demonstrating its intended usage and apply it
to the current tree.  Using strbuf_add_real_path() instead of calling
strbuf_addstr() and real_path() avoids an extra copy to a static buffer.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/coccinelle/strbuf.cocci
setup.c
strbuf.c
strbuf.h