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

Re: [PATCH] Support working directory located at root

From
Johannes Sixt <j6t@kdbg.org>
Date
Feb 8, 2010, 21:29 UTC
Message-ID
<201002082229.43024.j6t@kdbg.org>
In-Reply-To
<1265640810-6361-1-git-send-email-pclouds@gmail.com>
On Montag, 8. Februar 2010, Nguyễn Thái Ngọc Duy wrote:
Show 27 quoted lines
> @@ -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);
>  		}
> @@ -403,7 +403,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
>  			if (!work_tree_env)
>  				inside_work_tree = 0;
>  			if (offset != len) {
> -				cwd[offset] = '\0';
> +				cwd[offset ? offset : 1] = '\0';
>  				set_git_dir(cwd);
>  			} else
>  				set_git_dir(".");
> @@ -427,6 +427,8 @@ const char *setup_git_directory_gently(int *nongit_ok)
>  	inside_git_dir = 0;
>  	if (!work_tree_env)
>  		inside_work_tree = 1;
> +	if (offset == 0) /* reached root, set worktree to '/' */
> +		offset = 1;
>  	git_work_tree_cfg = xstrndup(cwd, offset);
>  	if (check_repository_format_gently(nongit_ok))
>  		return NULL;
Does not work:

etc@master:1028> ~/Src/git/git/git add resolv.conf fatal: pathspec 'tc/resolv.conf' did not match any files

I wonder how this works on Windows where we do not want to strip the slash from C:/ either.

-- Hannes
Previous: Nguyen Thai Ngoc Duy
Message 5 of 5 in “Support working directory located at root”
  1. Support working directory located at rootNguyễn Thái Ngọc Duy, Feb 8, 2010
  2. Junio C HamanoFeb 8, 2010
  3. Nguyen Thai Ngoc DuyFeb 9, 2010
  4. Nguyen Thai Ngoc DuyFeb 9, 2010
  5. Johannes SixtFeb 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.