Subject: [PATCH 2/5] pathspec: add tree_recursive_diff parameter

From: Nguyễn Thái Ngọc Duy <[email-masked]>
Date: Mon, 20 Sep 2010 09:29:57 +1000

When wildcard match is implemented, a full path is needed to do final
match. What type of diff_tree is performed determines how to treat
directories:

 - If it's recursive diff, directories are just an intermediate step.
   All path must end with a file name. Thus, directories will be
   unconditionally matched.

 - If it's non-recursive, directories are treated like files and is
   matched against pathspect as full path.

Strictly speaking, this should be a new parameter to
tree_entry_interesting(). But I don't feel like chaning
tree_entry_interesting() too often.

Signed-off-by: Nguyễn Thái Ngọc Duy <[email-masked]>
---
 cache.h     |    1 +
 tree-diff.c |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/cache.h b/cache.h
index 7a3e0a0..dc54d16 100644
--- a/cache.h
+++ b/cache.h
@@ -496,6 +496,7 @@ struct pathspec {
 	const char **raw;
 	int nr;
 	int has_wildcard:1;
+	int tree_recursive_diff:1;
 	struct pathspec_item {
 		int len;
 		int has_wildcard:1;
diff --git a/tree-diff.c b/tree-diff.c
index 50d7e6d..7e58f54 100644
--- a/tree-diff.c
+++ b/tree-diff.c
@@ -170,6 +170,7 @@ int diff_tree(struct tree_desc *t1, struct tree_desc *t2, const char *base, stru
 {
 	int baselen = strlen(base);
 
+	opt->pathspec.tree_recursive_diff = DIFF_OPT_TST(opt, RECURSIVE);
 	for (;;) {
 		if (DIFF_OPT_TST(opt, QUICK) &&
 		    DIFF_OPT_TST(opt, HAS_CHANGES))
-- 
1.7.1.rc1.70.g788ca