Skip to contentSkip to conversation

worktree: use strbuf_add_absolute_path() directly

PATCH New René Scharfe 1 participant 1 message Jul 9, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 worktree: use strbuf_add_absolute_path() directly

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.

---
 worktree.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
worktree.c +2 -2
index e2a94e0..b819baf 100644
@@ -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, "/.");
 	}
 
Signature · 1 line
2.9.0