real_path: have callers use real_pathdup and strbuf_realpath
Migrate callers of real_path() who duplicate the retern value to use real_pathdup or strbuf_realpath. Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
7241764076
commit
4ac9006f83
13
setup.c
13
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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user