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

@ -2173,7 +2173,7 @@ const char *get_superproject_working_tree(void)
static struct strbuf realpath = STRBUF_INIT;
struct child_process cp = CHILD_PROCESS_INIT;
struct strbuf sb = STRBUF_INIT;
const char *one_up = real_path_if_valid("../");
struct strbuf one_up = STRBUF_INIT;
const char *cwd = xgetcwd();
const char *ret = NULL;
const char *subpath;
@ -2188,10 +2188,11 @@ const char *get_superproject_working_tree(void)
*/
return NULL;
if (!one_up)
if (!strbuf_realpath(&one_up, "../", 0))
return NULL;
subpath = relative_path(cwd, one_up, &sb);
subpath = relative_path(cwd, one_up.buf, &sb);
strbuf_release(&one_up);
prepare_submodule_repo_env(&cp.env_array);
argv_array_pop(&cp.env_array);