path: use strbuf_add_real_path()
authorRené Scharfe <l.s.r@web.de>
Sun, 1 Oct 2017 14:44:06 +0000 (16:44 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 2 Oct 2017 04:13:41 +0000 (13:13 +0900)
Avoid a string copy to a static buffer by using strbuf_add_real_path()
instead of combining strbuf_addstr() and real_path().

Patch generated by Coccinelle and contrib/coccinelle/strbuf.cocci.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
path.c
diff --git a/path.c b/path.c
index b533ec938dd18320beb533969b0763992d4d3a85..bf096c411c300273f3490949179c893b993c67da 100644 (file)
--- a/path.c
+++ b/path.c
@@ -717,7 +717,7 @@ char *expand_user_path(const char *path, int real_home)
                        if (!home)
                                goto return_null;
                        if (real_home)
-                               strbuf_addstr(&user_path, real_path(home));
+                               strbuf_add_real_path(&user_path, home);
                        else
                                strbuf_addstr(&user_path, home);
 #ifdef GIT_WINDOWS_NATIVE