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

Re: [PATCH] get_cwd_relative(): do not misinterpret root path

From
Clemens Buchacher <drizzd@aon.at>
Date
Nov 19, 2010, 20:41 UTC
Message-ID
<20101119204159.GA28622@localhost>
In-Reply-To
<1290158239-12138-1-git-send-email-pclouds@gmail.com>
Hi Duy,
Thanks for looking into this.
On Fri, Nov 19, 2010 at 04:17:19PM +0700, Nguyễn Thái Ngọc Duy wrote:
Show 14 quoted lines
> 
> @@ -965,6 +965,12 @@ char *get_relative_cwd(char *buffer, int size, const char *dir)
>  	case '/':
>  		return cwd + 1;
>  	default:
> +		/*
> +		 * dir can end with a path separator when it's root
> +		 * directory. Return proper prefix in that case.
> +		 */
> +		if (is_dir_sep(dir[-1]))
> +			return cwd;
>  		return NULL;
>  	}
>  }

make_absolute_path() already rewrites dir to contain slashes only. I think it is confusing to use is_dir_sep() here, when we only check for / above.

Otherwise, the patch looks good to me.
Clemens
Next: Nguyễn Thái Ngọc Duy
Message 1 of 2 in “Re: [PATCH] get_cwd_relative(): do not misinterpret root path”
  1. Clemens BuchacherNov 19, 2010
  2. get_cwd_relative(): do not misinterpret root pathNguyễn Thái Ngọc Duy, Nov 20, 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.