real_path_if_valid(): remove unsafe API

This commit continues the work started with previous commit.

Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Alexandr Miloslavskiy
2020-03-10 13:11:23 +00:00
committed by Junio C Hamano
parent 3d7747e318
commit 4530a85b4c
6 changed files with 14 additions and 26 deletions

View File

@ -676,20 +676,15 @@ void add_to_alternates_memory(const char *reference)
char *compute_alternate_path(const char *path, struct strbuf *err)
{
char *ref_git = NULL;
const char *repo, *ref_git_s;
const char *repo;
int seen_error = 0;
ref_git_s = real_path_if_valid(path);
if (!ref_git_s) {
ref_git = real_pathdup(path, 0);
if (!ref_git) {
seen_error = 1;
strbuf_addf(err, _("path '%s' does not exist"), path);
goto out;
} else
/*
* Beware: read_gitfile(), real_path() and mkpath()
* return static buffer
*/
ref_git = xstrdup(ref_git_s);
}
repo = read_gitfile(ref_git);
if (!repo)