aboutsummaryrefslogtreecommitdiff
path: root/strbuf.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-03-28 13:52:19 -0700
committerJunio C Hamano <gitster@pobox.com>2017-03-28 13:52:19 -0700
commitcd27bc7a0bdb7e62090c503b9e8ab4b4a6bb3d06 (patch)
treed056097ed72d93eedc487640b463bde3650cd9a3 /strbuf.c
parentc772d1bcdc058d655e6cd3518440a721433cb511 (diff)
parent33ad9ddd0b5398063f0aabea639b5fe569f458ea (diff)
downloadgit-cd27bc7a0bdb7e62090c503b9e8ab4b4a6bb3d06.tar.xz
Merge branch 'rs/strbuf-add-real-path' into maint
An helper function to make it easier to append the result from real_path() to a strbuf has been added. * rs/strbuf-add-real-path: strbuf: add strbuf_add_real_path() cocci: use ALLOC_ARRAY
Diffstat (limited to 'strbuf.c')
-rw-r--r--strbuf.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/strbuf.c b/strbuf.c
index 8fec6579f7..ace58e7367 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -707,6 +707,17 @@ void strbuf_add_absolute_path(struct strbuf *sb, const char *path)
strbuf_addstr(sb, path);
}
+void strbuf_add_real_path(struct strbuf *sb, const char *path)
+{
+ if (sb->len) {
+ struct strbuf resolved = STRBUF_INIT;
+ strbuf_realpath(&resolved, path, 1);
+ strbuf_addbuf(sb, &resolved);
+ strbuf_release(&resolved);
+ } else
+ strbuf_realpath(sb, path, 1);
+}
+
int printf_ln(const char *fmt, ...)
{
int ret;