Skip to content

Commit fd2e7da

Browse files
rscharfegitster
authored andcommitted
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. Signed-off-by: Rene Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5c9159d commit fd2e7da

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

worktree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static struct worktree *get_main_worktree(void)
8080
int is_bare = 0;
8181
int is_detached = 0;
8282

83-
strbuf_addstr(&worktree_path, absolute_path(get_git_common_dir()));
83+
strbuf_add_absolute_path(&worktree_path, get_git_common_dir());
8484
is_bare = !strbuf_strip_suffix(&worktree_path, "/.git");
8585
if (is_bare)
8686
strbuf_strip_suffix(&worktree_path, "/.");
@@ -125,7 +125,7 @@ static struct worktree *get_linked_worktree(const char *id)
125125
strbuf_rtrim(&worktree_path);
126126
if (!strbuf_strip_suffix(&worktree_path, "/.git")) {
127127
strbuf_reset(&worktree_path);
128-
strbuf_addstr(&worktree_path, absolute_path("."));
128+
strbuf_add_absolute_path(&worktree_path, ".");
129129
strbuf_strip_suffix(&worktree_path, "/.");
130130
}
131131

0 commit comments

Comments
 (0)