diff options
author | René Scharfe <l.s.r@web.de> | 2017-02-25 17:00:33 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-02-27 20:02:06 +0100 |
commit | 33ad9ddd0b5398063f0aabea639b5fe569f458ea (patch) | |
tree | 9dcbafba9ded540f034e2697bf47198f4f217036 /setup.c | |
parent | cocci: use ALLOC_ARRAY (diff) | |
download | git-33ad9ddd0b5398063f0aabea639b5fe569f458ea.tar.xz git-33ad9ddd0b5398063f0aabea639b5fe569f458ea.zip |
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>
Diffstat (limited to 'setup.c')
-rw-r--r-- | setup.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -254,7 +254,7 @@ int get_common_dir_noenv(struct strbuf *sb, const char *gitdir) if (!is_absolute_path(data.buf)) strbuf_addf(&path, "%s/", gitdir); strbuf_addbuf(&path, &data); - strbuf_addstr(sb, real_path(path.buf)); + strbuf_add_real_path(sb, path.buf); ret = 1; } else strbuf_addstr(sb, gitdir); |