real_path: have callers use real_pathdup and strbuf_realpath
[gitweb.git] / setup.c
diff --git a/setup.c b/setup.c
index fe572b82c355390e6101aea15d2d53ec5b3b1e15..1b534a750810f3773ba9c21a5ec221f54857349b 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -256,8 +256,10 @@ int get_common_dir_noenv(struct strbuf *sb, const char *gitdir)
                strbuf_addbuf(&path, &data);
                strbuf_addstr(sb, real_path(path.buf));
                ret = 1;
-       } else
+       } else {
                strbuf_addstr(sb, gitdir);
+       }
+
        strbuf_release(&data);
        strbuf_release(&path);
        return ret;
@@ -692,7 +694,7 @@ static const char *setup_discovered_git_dir(const char *gitdir,
        /* --work-tree is set without --git-dir; use discovered one */
        if (getenv(GIT_WORK_TREE_ENVIRONMENT) || git_work_tree_cfg) {
                if (offset != cwd->len && !is_absolute_path(gitdir))
-                       gitdir = xstrdup(real_path(gitdir));
+                       gitdir = real_pathdup(gitdir);
                if (chdir(cwd->buf))
                        die_errno("Could not come back to cwd");
                return setup_explicit_git_dir(gitdir, cwd, nongit_ok);
@@ -800,11 +802,12 @@ static int canonicalize_ceiling_entry(struct string_list_item *item,
                /* Keep entry but do not canonicalize it */
                return 1;
        } else {
-               const char *real_path = real_path_if_valid(ceil);
-               if (!real_path)
+               char *real_path = real_pathdup(ceil);
+               if (!real_path) {
                        return 0;
+               }
                free(item->string);
-               item->string = xstrdup(real_path);
+               item->string = real_path;
                return 1;
        }
 }