git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] path: use strbuf_add_real_path()

From
René Scharfe <l.s.r@web.de>
Date
Oct 1, 2017, 14:44 UTC
Message-ID
<7f710738-98e1-f075-9369-113296e077bb@web.de>

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>
---
 path.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/path.c b/path.c
index b533ec938d..bf096c411c 100644
--- 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
-- 
2.14.2
Message 1 of 1 in “path: use strbuf_add_real_path()”
  1. path: use strbuf_add_real_path()René Scharfe, Oct 1, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.