diff options
author | Carlo Marcelo Arenas Belon <carenas@sajinet.com.pe> | 2010-12-27 02:54:37 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-01-04 13:44:41 -0800 |
commit | 18e051a3981f38db08521bb61ccf7e4571335353 (patch) | |
tree | feb3a76f9899832572c5fdeb021b99b04445df81 | |
parent | setup_work_tree: adjust relative $GIT_WORK_TREE after moving cwd (diff) | |
download | tgif-18e051a3981f38db08521bb61ccf7e4571335353.tar.xz |
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>
-rw-r--r-- | setup.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -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); |