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

Re: Unix root dir as a work tree

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
Feb 8, 2010, 02:18 UTC
Message-ID
<fcaeb9bf1002071818j29fe919bve0ef2d1c4cac8a79@mail.gmail.com>
In-Reply-To
<4B6F6971.6000106@jonny.eng.br>
2010/2/8 João Carlos Mendes Luís <jonny@jonny.eng.br>:
Show 5 quoted lines
>  Now, I have a patch that appears to work, but since I am a beginner to git,
> I don't know if this is the best way to implement it, if it has any side
> effects, or even if it works for other operating systems (probably they
> don't even have the bug).  Would any git wizard care to look at it, check if
> it is ok, and maybe commit in HEAD or give me any advice against my patch?

Hmm.. I guess you put .git at root directory so you needed your patch. I haven't tried it yet because I don't have root access here.

Anyway you may also need the below patch. Please report back if any Git operation that does not work under your setup.

diff --git a/setup.c b/setup.c
index 710e2f3..d31dcb8 100644
--- a/setup.c
+++ b/setup.c
@@ -25,7 +25,7 @@ const char *prefix_path(const char *prefix, int len,
const char *path)
 		len = strlen(work_tree);
 		total = strlen(sanitized) + 1;
 		if (strncmp(sanitized, work_tree, len) ||
-		    (sanitized[len] != '\0' && sanitized[len] != '/')) {
+		    (len > 1 && sanitized[len] != '\0' && sanitized[len] != '/')) {
 		error_out:
 			die("'%s' is outside repository", orig);
 		}
-- 
Duy
Previous: João Carlos Mendes Luís
Message 4 of 4 in “Unix root dir as a work tree”
  1. João Carlos Mendes LuísFeb 8, 2010
  2. Nguyen Thai Ngoc DuyFeb 8, 2010
  3. João Carlos Mendes LuísFeb 8, 2010
  4. Nguyen Thai Ngoc DuyFeb 8, 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.