[PATCH] tree_entry_interesting: Only recurse when the pathspec is a leading path component
- From
Björn Steinbrink <b.steinbrink@gmx.de>
- Date
- Mar 31, 2009, 15:05 UTC
- Message-ID
- <20090331150501.GA11446@atjola.homenet>
- In-Reply-To
- <20090331094107.GC3307@atjola.homenet>
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.
tree-diff.c | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-)
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? */
-- 1.6.2.1.426.gf94cd