From: Carlo Marcelo Arenas Belon Date: Mon, 27 Dec 2010 10:54:37 +0000 (-0800) Subject: setup: translate symlinks in filename when using absolute paths X-Git-Tag: ko-next~29^2 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=18e051a3981f38db08521bb61ccf7e4571335353;p=git.git setup: translate symlinks in filename when using absolute paths otherwise, comparison to validate against work tree will fail when the path includes a symlink and the name passed is not canonical. Signed-off-by: Carlo Marcelo Arenas Belon Signed-off-by: Junio C Hamano --- diff --git a/setup.c b/setup.c index be550af42..8031f99e9 100644 --- a/setup.c +++ b/setup.c @@ -7,10 +7,13 @@ static int inside_work_tree = -1; const char *prefix_path(const char *prefix, int len, const char *path) { const char *orig = path; - char *sanitized = xmalloc(len + strlen(path) + 1); - if (is_absolute_path(orig)) - strcpy(sanitized, path); - else { + char *sanitized; + if (is_absolute_path(orig)) { + const char *temp = make_absolute_path(path); + sanitized = xmalloc(len + strlen(temp) + 1); + strcpy(sanitized, temp); + } else { + sanitized = xmalloc(len + strlen(path) + 1); if (len) memcpy(sanitized, prefix, len); strcpy(sanitized + len, path);