git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] setup: translate symlinks in filename when using absolute paths
@ 2010-12-27 10:54 Carlo Marcelo Arenas Belon
  2010-12-28 19:47 ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Carlo Marcelo Arenas Belon @ 2010-12-27 10:54 UTC (permalink / raw)
  To: git

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>
---
 setup.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/setup.c b/setup.c
index 91887a4..e7c0d4d 100644
--- a/setup.c
+++ b/setup.c
@@ -7,10 +7,13 @@ static int inside_work_tree = -1;
 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);
-- 
1.7.3.4.626.g73e7b.dirty

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-12-29 13:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-27 10:54 [PATCH] setup: translate symlinks in filename when using absolute paths Carlo Marcelo Arenas Belon
2010-12-28 19:47 ` Junio C Hamano
2010-12-29  9:35   ` Carlo Marcelo Arenas Belon
2010-12-29 13:44   ` Nguyen Thai Ngoc Duy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).