git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] setup: translate symlinks in filename when using absolute paths

From
Carlo Marcelo Arenas Belon <carenas@sajinet.com.pe>
Date
Dec 27, 2010, 10:54 UTC
Message-ID
<1293447277-30598-1-git-send-email-carenas@sajinet.com.pe>

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
Next: Junio C Hamano
Message 1 of 4 in “setup: translate symlinks in filename when using absolute paths”
  1. setup: translate symlinks in filename when using absolute pathsCarlo Marcelo Arenas Belon, Dec 27, 2010
  2. Junio C HamanoDec 28, 2010
  3. Carlo Marcelo Arenas BelonDec 29, 2010
  4. Nguyen Thai Ngoc DuyDec 29, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.