From: Junio C Hamano <gitster@pobox.com>
To: David Reiss <dreiss@facebook.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v3] Add support for GIT_CEILING_DIRS
Date: Thu, 15 May 2008 12:46:53 -0700 [thread overview]
Message-ID: <7vej83gxjm.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <482C85C8.90804@facebook.com> (David Reiss's message of "Thu, 15 May 2008 11:49:44 -0700")
David Reiss <dreiss@facebook.com> writes:
> + * .... Paths must
> + * be in a canonical form: empty components, or "." or ".." components
> + * are not allowed. prefix_list may be null, which is like "".
The caller starts from cwd[] and chomps, so you can safely assume that it
would not feed anything problematic. But prefix_list comes from user's
environment, and it is easy to make mistakes like doubled slashes (which
you seem to take care) and also is tempting to use ".." when specifying
the ceiling (e.g. "CEIL=$HOME/.."). Perhaps canonicalizing the ceiling
would make this easier to use for end users?
> +#if 0
> +static void test_longest_ancestor_length()
> +{
> ...
> + assert(longest_ancestor_length("/foo/bar", "/:/bar/" ) == 0);
No test for nonsense/invalid input, like "::/foo" for prefix_list?
> diff --git a/t/t1504-ceiling-dirs.sh b/t/t1504-ceiling-dirs.sh
> new file mode 100755
> index 0000000..091baad
> --- /dev/null
> +++ b/t/t1504-ceiling-dirs.sh
> @@ -0,0 +1,156 @@
> +#!/bin/sh
> +
> +test_description='test GIT_CEILING_DIRS'
> +. ./test-lib.sh
> +
> +test_prefix() {
> + test_expect_success "$1" \
> + "test '$2' = \"\$(git rev-parse --show-prefix)\""
> +}
> +
> +test_fail() {
> + test_expect_code 128 "$1: prefix" \
> + "git rev-parse --show-prefix"
> +}
> +
> +TRASH_ROOT="$(pwd)"
> +ROOT_PARENT=$(dirname "$TRASH_ROOT")
> +
> +
> +unset GIT_CEILING_DIRS
> +test_prefix no_ceil ""
> +
> +export GIT_CEILING_DIRS=""
Portability. Instead write this as two separate statements, please.
VAR=val
export VAR
> +test_prefix ceil_empty ""
> +
> +export GIT_CEILING_DIRS="$ROOT_PARENT"
> +test_prefix ceil_at_parent ""
> +
> +export GIT_CEILING_DIRS="$ROOT_PARENT/"
> +test_prefix ceil_at_parent_slash ""
> +
> +export GIT_CEILING_DIRS="$TRASH_ROOT"
> +test_prefix ceil_at_trash ""
> +
> ...
> +
> +export GIT_CEILING_DIRS="$TRASH_ROOT/subdi"
> +test_prefix subdir_ceil_at_subdi_slash "sub/dir/"
> +
> +
> +export GIT_CEILING_DIRS="foo:$TRASH_ROOT/sub"
> +test_fail second_of_two
> +
> +export GIT_CEILING_DIRS="$TRASH_ROOT/sub:bar"
> +test_fail first_of_two
You may also check stuff like "sub//dir" and "::sub/dir/".
How well would this colon separated list work with msys folks?
next prev parent reply other threads:[~2008-05-15 19:48 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-15 18:49 [PATCH v3] Add support for GIT_CEILING_DIRS David Reiss
2008-05-15 19:03 ` Johannes Schindelin
2008-05-15 19:40 ` David Reiss
2008-05-15 20:27 ` [PATCH] Add support for GIT_CEILING_DIRECTORIES Johannes Schindelin
2008-05-15 21:09 ` David Reiss
2008-05-15 22:29 ` Johannes Schindelin
2008-05-15 22:45 ` David Reiss
2008-05-15 23:27 ` [SQUASHED PATCH] " Johannes Schindelin
2008-05-16 6:54 ` Johannes Sixt
2008-05-16 10:20 ` Johannes Schindelin
2008-05-16 10:50 ` Johannes Sixt
2008-05-16 17:43 ` David Reiss
2008-05-17 0:19 ` Johannes Schindelin
2008-05-17 0:20 ` [2nd SQUASHED " Johannes Schindelin
2008-05-19 7:55 ` [SQUASHED " Johannes Sixt
2008-05-19 10:49 ` Johannes Schindelin
2008-05-15 19:46 ` Junio C Hamano [this message]
2008-05-15 20:34 ` [PATCH v3] Add support for GIT_CEILING_DIRS Johannes Schindelin
2008-05-16 7:03 ` Johannes Sixt
2008-05-16 10:21 ` Johannes Schindelin
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=7vej83gxjm.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.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).