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

Re: [PATCH 1/4] Implement normalize_absolute_path

From
DRDavid Reiss <dreiss@facebook.com>
Date
May 21, 2008, 08:34 UTC
Message-ID
<4833DE89.4000106@facebook.com>
In-Reply-To
<20080520222447.GA13123@steel.home>

This is close enough to what I want that I could definitely use it if it were in the main tree. I read through most of that thread, but I couldn't figure out what ever happened to your patch. (I couldn't find a clear rejection, but I also don't see it in master.)

--David
Alex Riesen wrote:
Show 45 quoted lines
> David Reiss, Tue, May 20, 2008 08:48:54 +0200:
>> normalize_absolute_path removes several oddities form absolute paths,
>> giving nice clean paths like "/dir/sub1/sub2".  Also add a test case
>> for this utility, based on a new test program (in the style of test-sha1).
> 
> Heh...
> http://thread.gmane.org/gmane.comp.version-control.git/68786/focus=68812
> 
> The test of the function has these cases:
> 
> static void check(const char *cwd, const char *path, const char *good);
> 
> int main(int argc, char **argv)
> {
>         /* 1 */ check("/onelevel", "aa", "onelevel/aa");
>         /* 2 */ check("/", "..", "");
>         /* 3 */ check("/", "../..", "");
>         /* 4 */ check("/one", "aa/../bb", "one/bb");
>         /* 5 */ check("/one/two", "aa//bb", "one/two/aa/bb");
>         /* 6 */ check("", "/aa//bb", "aa/bb");
>         /* 7 */ check("/one/two", "", "one/two");
>         /* 8 */ check("/one/two", "aa/..bb/x/../cc/", "one/two/aa/..bb/cc");
>         /* 9 */ check("/one/two", "aa/x/././cc////", "one/two/aa/x/cc");
>         /* 10 */ check("/one/two", "../../../../aa", "aa");
>         /* 11 */ check("one/", "../one/two", "one/two");
>         /* 12 */ check("", "../../two", "two");
>         /* 13 */ check("a/b/c", "../../two", "a/two");
>         /* 14 */ check("a/b/", "../two", "a/two");
>         /* 15 */ check("///", "../two", "two");
>         return 0;
> }
> 
> static void check(const char *cwd, const char *path, const char *good)
> {
>         static int n = 0;
>         printf("%-2d: %10s$ cd %s", ++n, cwd, path);
>         char *t = pathexpand(cwd, path);
>         if ( strcmp(t, good) )
>                 printf(" ____________________failed(%s)\n", t);
>         else
>                 printf(" \033[32m%s\033[0m\n", t);
>         free(t);
> }
> 
> 
Previous: Alex RiesenNext: Alex Riesen
Message 5 of 6 in “Implement normalize_absolute_path”
  1. 1/4 Implement normalize_absolute_pathDavid Reiss, May 20, 2008
  2. Johannes SchindelinMay 20, 2008
  3. David ReissMay 20, 2008
  4. Alex RiesenMay 20, 2008
  5. David ReissMay 21, 2008
  6. Alex RiesenMay 22, 2008

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.