Code

submodule add: fix breakage when re-adding a deep submodule
[git.git] / tree-walk.c
index a8d8a66d597f54e3a99a4c3e9615330eb7a7fe1a..418107ec83728473093b43dfe74ab709f312e8a8 100644 (file)
@@ -549,7 +549,7 @@ static int match_entry(const struct name_entry *entry, int pathlen,
        return 0;
 }
 
-static int match_dir_prefix(const char *base, int baselen,
+static int match_dir_prefix(const char *base,
                            const char *match, int matchlen)
 {
        if (strncmp(base, match, matchlen))
@@ -606,7 +606,7 @@ int tree_entry_interesting(const struct name_entry *entry,
 
                if (baselen >= matchlen) {
                        /* If it doesn't match, move along... */
-                       if (!match_dir_prefix(base_str, baselen, match, matchlen))
+                       if (!match_dir_prefix(base_str, match, matchlen))
                                goto match_wildcards;
 
                        if (!ps->recursive || ps->max_depth == -1)
@@ -618,8 +618,8 @@ int tree_entry_interesting(const struct name_entry *entry,
                                              ps->max_depth);
                }
 
-               /* Does the base match? */
-               if (!strncmp(base_str, match, baselen)) {
+               /* Either there must be no base, or the base must match. */
+               if (baselen == 0 || !strncmp(base_str, match, baselen)) {
                        if (match_entry(entry, pathlen,
                                        match + baselen, matchlen - baselen,
                                        &never_interesting))