git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Reiss <dreiss@facebook.com>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Add support for GIT_CEILING_DIRECTORIES
Date: Thu, 15 May 2008 15:45:06 -0700	[thread overview]
Message-ID: <482CBCF2.6030202@facebook.com> (raw)
In-Reply-To: <alpine.DEB.1.00.0805152327440.30431@racer>

This meets my needs.

Junio, if you'd like, I can incorporate your suggestions of normalizing paths
internally and testing more corner cases.  But if you just want to take this
version, I'll be fine.

--David

Johannes Schindelin wrote:
> Hi,
> 
> On Thu, 15 May 2008, David Reiss wrote:
> 
>> longest_prefix is just a textual check.  It doesn't verify that the prefix
>> is actually a full directory component of the cwd.
> 
> Okay.
> 
>> Also, I think it is better to move the 'chdir("..")' after the do loop,
>> so that git won't even chdir up into the ceiling directory.  This
>> actually doesn't matter to me, but I figured that it might be nice for
>> someone.
> 
> I'd rather go with the minimal diff, unless there is a good reason to
> change it.
> 
>> Finally, just a small thing.  The documentation still says
>> "GIT_CEILING_DIRS".
> 
> Okay.
> 
> How about this on top (still pretty simple):
> 
> ---
> 
>  Documentation/git.txt          |    2 +-
>  path.c                         |   10 ++++++++--
>  t/t1504-ceiling-directories.sh |    8 ++++++++
>  3 files changed, 17 insertions(+), 3 deletions(-)
> 
> diff --git a/Documentation/git.txt b/Documentation/git.txt
> index a12d1f8..e4413bf 100644
> --- a/Documentation/git.txt
> +++ b/Documentation/git.txt
> @@ -415,7 +415,7 @@ git so take care if using Cogito etc.
>         This can also be controlled by the '--work-tree' command line
>         option and the core.worktree configuration variable.
> 
> -'GIT_CEILING_DIRS'::
> +'GIT_CEILING_DIRECTORIES'::
>         If set (to a colon delimited list of absolute directories), Git
>         will refuse to look for the .git/ directory further when hitting
>         one of those directories (otherwise it would traverse the parent
> diff --git a/path.c b/path.c
> index c0d7364..a097ecc 100644
> --- a/path.c
> +++ b/path.c
> @@ -358,13 +358,18 @@ const char *make_absolute_path(const char *path)
>         return buf;
>  }
> 
> +static int is_separator(char c)
> +{
> +       return !c || c == '/';
> +}
> +
>  int longest_prefix(const char *path, const char *prefix_list)
>  {
>         int max_length = 0, length = 0, i;
> 
>         for (i = 0; prefix_list[i]; i++)
>                 if (prefix_list[i] == ':') {
> -                       if (length > max_length)
> +                       if (length > max_length &&
> is_separator(path[length]))
>                                 max_length = length;
>                         length = 0;
>                 }
> @@ -374,5 +379,6 @@ int longest_prefix(const char *path, const char
> *prefix_list)
>                         else
>                                 length = -1;
>                 }
> -       return max_length > length ? max_length : length;
> +       return max_length > length || !is_separator(path[length]) ?
> +               max_length : length;
>  }
> diff --git a/t/t1504-ceiling-directories.sh b/t/t1504-ceiling-directories.sh
> index 1d8ef0b..6c8757d 100644
> --- a/t/t1504-ceiling-directories.sh
> +++ b/t/t1504-ceiling-directories.sh
> @@ -43,4 +43,12 @@ test_expect_success 'with matching ceiling directories' '
> 
>  '
> 
> +test_expect_success 'with non-directory prefix' '
> +
> +       GIT_CEILING_DIRECTORIES="$CWD/sub" &&
> +       export GIT_CEILING_DIRECTORIES &&
> +       (cd subdir && git rev-parse --git-dir)
> +
> +'
> +
>  test_done
> 

  reply	other threads:[~2008-05-15 22:46 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 [this message]
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 ` [PATCH v3] Add support for GIT_CEILING_DIRS Junio C Hamano
2008-05-15 20:34   ` 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=482CBCF2.6030202@facebook.com \
    --to=dreiss@facebook.com \
    --cc=Johannes.Schindelin@gmx.de \
    --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).