worktree: use strbuf_add_absolute_path() directly
authorRené Scharfe <l.s.r@web.de>
Sat, 9 Jul 2016 15:43:59 +0000 (17:43 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 12 Jul 2016 22:11:01 +0000 (15:11 -0700)
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
worktree.c
index 199b1ef94ba84aad094a5a0fe95360c2df631003..6b4f5f3e6dc99379311622f7f7900f56cc706e78 100644 (file)
@@ -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, "/.");
        }