fixup! Refuse to follow invalid paths in .git files

TortoiseGit actually compiles kind of a "libified" version of this,
where the `die()` calls are substituted with C++ `throw` constructs.
Therefore the (`static`, stays allocated even after returning from the
function) `realpath` actually _can_ be reused.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin
2026-06-29 19:03:20 +02:00
parent c373206b40
commit 7bfd7c63b6

View File

@@ -1047,6 +1047,7 @@ const char *read_gitfile_gently(const char *path, int *return_error_code)
}
#if (defined _WIN32 || defined __WIN32__)
if (is_dir_sep(dir[0]) && is_invalid_dotgit_path(path, dir)) {
strbuf_reset(&realpath);
strbuf_add(&realpath, dir, strlen(dir));
path = realpath.buf;
goto cleanup_return;
@@ -1057,6 +1058,7 @@ const char *read_gitfile_gently(const char *path, int *return_error_code)
goto cleanup_return;
}
strbuf_reset(&realpath);
strbuf_realpath(&realpath, dir, 1);
path = realpath.buf;