git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alex Riesen <raa.lkml@gmail.com>
To: David Reiss <dreiss@facebook.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 1/4] Implement normalize_absolute_path
Date: Wed, 21 May 2008 00:24:47 +0200	[thread overview]
Message-ID: <20080520222447.GA13123@steel.home> (raw)
In-Reply-To: <48327456.1060202@facebook.com>

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);
}

  parent reply	other threads:[~2008-05-20 22:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-20  6:48 [PATCH 1/4] Implement normalize_absolute_path David Reiss
2008-05-20 12:22 ` Johannes Schindelin
2008-05-20 16:44   ` David Reiss
2008-05-20 22:24 ` Alex Riesen [this message]
2008-05-21  8:34   ` David Reiss
2008-05-22 12:48     ` Alex Riesen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080520222447.GA13123@steel.home \
    --to=raa.lkml@gmail.com \
    --cc=dreiss@facebook.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).