@@ -1378,6 +1378,17 @@ enum pattern_match_result path_matches_pattern_list(
strbuf_addch(&parent_pathname, '/');
strbuf_add(&parent_pathname, pathname, pathlen);
+ /*
+ * Directory entries are matched if and only if a file
+ * contained immediately within them is matched. For the
+ * case of a directory entry, modify the path to create
+ * a fake filename within this directory, allowing us to
+ * use the file-base matching logic in an equivalent way.
+ */
+ if (parent_pathname.len > 0 &&
+ parent_pathname.buf[parent_pathname.len - 1] == '/')
+ strbuf_add(&parent_pathname, "-", 1);
+
if (hashmap_contains_path(&pl->recursive_hashmap,
&parent_pathname)) {
result = MATCHED_RECURSIVE;