Code

Fix off-by-one in read_tree_recursive
[git.git] / tree-diff.c
index 9f67af6c1fbb9130962cd373d8e2ebecf543c640..b05d0f43555d28f872fd5225e6773eeb636ef302 100644 (file)
@@ -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? */