@matheusbsbs / matheus-bagliano / commits / 18e051a398
Fork 0

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 <carenas@sajinet.com.pe> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Carlo Marcelo Arenas Belon committed Dec 27, 2010 at 02:54 UTC 18e051a3981f38db08521bb61ccf7e4571335353
1 file changed +7 -4
setup.c
+7 -4
@@ -7,10 +7,13 @@ static int inside_work_tree = -1;
7 const char *prefix_path(const char *prefix, int len, const char *path)
8 {
9 const char *orig = path;
10 - char *sanitized = xmalloc(len + strlen(path) + 1);
11 - if (is_absolute_path(orig))
12 - strcpy(sanitized, path);
13 - else {
10 + char *sanitized;
11 + if (is_absolute_path(orig)) {
12 + const char *temp = make_absolute_path(path);
13 + sanitized = xmalloc(len + strlen(temp) + 1);
14 + strcpy(sanitized, temp);
15 + } else {
16 + sanitized = xmalloc(len + strlen(path) + 1);
17 if (len)
18 memcpy(sanitized, prefix, len);
19 strcpy(sanitized + len, path);