use absolute_pathdup()
Apply the semantic patch for converting callers that duplicate the result of absolute_path() to call absolute_pathdup() instead, which avoids an extra string copy to a static buffer. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe committed
Jan 26, 2017 at 18:54 UTC
0aaad415bcbdd7ccdfbb27eafb2f5926540455fa
3 files changed
+4
-4
builtin/clone.c
+2
-2
@@ -161,7 +161,7 @@ static char *get_repo_path(const char *repo, int *is_bundle)
161
162
strbuf_addstr(&path, repo);
163
raw = get_repo_path_1(&path, is_bundle);
164
- canon = raw ? xstrdup(absolute_path(raw)) : NULL;
164
+ canon = raw ? absolute_pathdup(raw) : NULL;
165
strbuf_release(&path);
166
return canon;
167
}
@@ -892,7 +892,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
892
893
path = get_repo_path(repo_name, &is_bundle);
894
if (path)
895
- repo = xstrdup(absolute_path(repo_name));
895
+ repo = absolute_pathdup(repo_name);
896
else if (!strchr(repo_name, ':'))
897
die(_("repository '%s' does not exist"), repo_name);
898
else
builtin/submodule--helper.c
+1
-1
@@ -515,7 +515,7 @@ static int module_clone(int argc, const char **argv, const char *prefix)
515
module_clone_options);
516
517
strbuf_addf(&sb, "%s/modules/%s", get_git_dir(), name);
518
- sm_gitdir = xstrdup(absolute_path(sb.buf));
518
+ sm_gitdir = absolute_pathdup(sb.buf);
519
strbuf_reset(&sb);
520
521
if (!is_absolute_path(path)) {
worktree.c
+1
-1
@@ -158,7 +158,7 @@ done:
158
159
static void mark_current_worktree(struct worktree **worktrees)
160
{
161
- char *git_dir = xstrdup(absolute_path(get_git_dir()));
161
+ char *git_dir = absolute_pathdup(get_git_dir());
162
int i;
163
164
for (i = 0; worktrees[i]; i++) {