git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Björn Steinbrink" <B.Steinbrink@gmx.de>
Cc: Eric Wong <normalperson@yhbt.net>,
	Anton Gyllenberg <anton@iki.fi>,
	git@vger.kernel.org
Subject: Re: [PATCH] tree_entry_interesting: Only recurse when the pathspec is a leading path component
Date: Wed, 01 Apr 2009 21:32:05 -0700	[thread overview]
Message-ID: <7vbprfn0ai.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <20090331150501.GA11446@atjola.homenet> (Björn Steinbrink's message of "Tue, 31 Mar 2009 17:05:01 +0200")

Björn Steinbrink <B.Steinbrink@gmx.de> writes:

> Previously the code did a simple prefix match, which means that it
> treated for example "foo/" as a subdirectory of "f".
>
> Signed-off-by: Björn Steinbrink <B.Steinbrink@gmx.de>
> ---
> I'm not exactly happy with the commit message, but that's the best I
> could come up with. Probably shows how little I know about that code :-/
> The test suite still passes and I'll try to provide a new testcase
> tonight or tommorow.

I'm planning to queue this.

From: Björn Steinbrink <B.Steinbrink@gmx.de>
Date: Tue, 31 Mar 2009 17:05:01 +0200
Subject: [PATCH] tree_entry_interesting: a pathspec only matches at directory boundary

Previously the code did a simple prefix match, which means that a
path in a directory "frotz/" would have matched with pathspec "f".

Signed-off-by: Björn Steinbrink <B.Steinbrink@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 t/t4010-diff-pathspec.sh |    8 ++++++++
 tree-diff.c              |   12 +++++++++---
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/t/t4010-diff-pathspec.sh b/t/t4010-diff-pathspec.sh
index ad3d9e4..4c4c8b1 100755
--- a/t/t4010-diff-pathspec.sh
+++ b/t/t4010-diff-pathspec.sh
@@ -62,4 +62,12 @@ test_expect_success \
     'git diff-index --cached $tree -- file0/ >current &&
      compare_diff_raw current expected'
 
+test_expect_success 'diff-tree pathspec' '
+	tree2=$(git write-tree) &&
+	echo "$tree2" &&
+	git diff-tree -r --name-only $tree $tree2 -- pa path1/a >current &&
+	>expected &&
+	test_cmp expected current
+'
+
 test_done
diff --git a/tree-diff.c b/tree-diff.c
index 9f67af6..b05d0f4 100644
--- a/tree-diff.c
+++ b/tree-diff.c
@@ -118,10 +118,16 @@ static int tree_entry_interesting(struct tree_desc *desc, const char *base, int
 				continue;
 
 			/*
-			 * The base is a subdirectory of a path which
-			 * was specified, so all of them are interesting.
+			 * If the base is a subdirectory of a path which
+			 * was specified, all of them are interesting.
 			 */
-			return 2;
+			if (!matchlen ||
+			    base[matchlen] == '/' ||
+			    match[matchlen - 1] == '/')
+				return 2;
+
+			/* Just a random prefix match */
+			continue;
 		}
 
 		/* Does the base match? */

  reply	other threads:[~2009-04-02  4:33 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-26 10:31 svn clone Checksum mismatch question Gilbert Liddell
2009-03-26 13:02 ` Björn Steinbrink
2009-03-26 13:28   ` Gilbert Liddell
2009-03-26 13:54     ` Sverre Rabbelier
2009-03-26 14:18       ` Gilbert Liddell
2009-03-26 14:34       ` Johannes Schindelin
2009-03-26 14:35   ` Anton Gyllenberg
2009-03-27 11:18     ` Anton Gyllenberg
2009-03-29  6:08       ` Eric Wong
2009-03-29  6:10         ` [PATCH] git-svn: fix ls-tree usage with dash-prefixed paths Eric Wong
2009-03-29 20:33           ` Junio C Hamano
2009-03-29 21:56             ` Eric Wong
2009-03-30  6:44               ` Junio C Hamano
2009-03-30 17:41                 ` Eric Wong
2009-03-30 18:05                   ` Junio C Hamano
2009-03-30 22:58                     ` Eric Wong
2009-03-31  7:11                       ` Björn Steinbrink
2009-03-31  7:31                         ` Björn Steinbrink
2009-03-31  9:41                           ` Björn Steinbrink
2009-03-31 15:05                             ` [PATCH] tree_entry_interesting: Only recurse when the pathspec is a leading path component Björn Steinbrink
2009-04-02  4:32                               ` Junio C Hamano [this message]
2009-04-02  4:41                                 ` [PATCH] match_tree_entry(): a pathspec only matches at directory boundaries Junio C Hamano
2009-04-02 16:36                                   ` Linus Torvalds
2009-04-02 11:38                                 ` [PATCH] tree_entry_interesting: Only recurse when the pathspec is a leading path component Björn Steinbrink
2009-04-03 16:25                                   ` Junio C Hamano
2009-03-30  5:28             ` [PATCH] git-svn: fix ls-tree usage with dash-prefixed paths Björn Steinbrink
2009-03-30  7:26         ` svn clone Checksum mismatch question Anton Gyllenberg
2009-03-26 14:34 ` Peter Harris

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=7vbprfn0ai.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=B.Steinbrink@gmx.de \
    --cc=anton@iki.fi \
    --cc=git@vger.kernel.org \
    --cc=normalperson@yhbt.net \
    /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).