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

[PATCH] worktree: use strbuf_add_absolute_path() directly

From
René Scharfe <l.s.r@web.de>
Date
Jul 9, 2016, 15:43 UTC
Message-ID
<57811BBF.3020101@web.de>

absolute_path() is a wrapper for strbuf_add_absolute_path(). Call the latter directly for adding absolute paths to a strbuf. That's shorter and avoids an extra string copy.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
 worktree.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/worktree.c b/worktree.c
index e2a94e0..b819baf 100644
--- a/worktree.c
+++ b/worktree.c
@@ -80,7 +80,7 @@ static struct worktree *get_main_worktree(void)
 	int is_bare = 0;
 	int is_detached = 0;
 
-	strbuf_addstr(&worktree_path, absolute_path(get_git_common_dir()));
+	strbuf_add_absolute_path(&worktree_path, get_git_common_dir());
 	is_bare = !strbuf_strip_suffix(&worktree_path, "/.git");
 	if (is_bare)
 		strbuf_strip_suffix(&worktree_path, "/.");
@@ -125,7 +125,7 @@ static struct worktree *get_linked_worktree(const char *id)
 	strbuf_rtrim(&worktree_path);
 	if (!strbuf_strip_suffix(&worktree_path, "/.git")) {
 		strbuf_reset(&worktree_path);
-		strbuf_addstr(&worktree_path, absolute_path("."));
+		strbuf_add_absolute_path(&worktree_path, ".");
 		strbuf_strip_suffix(&worktree_path, "/.");
 	}
 
-- 
2.9.0
Message 1 of 1 in “worktree: use strbuf_add_absolute_path() directly”
  1. worktree: use strbuf_add_absolute_path() directlyRené Scharfe, Jul 9, 2016

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.