X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=tree-walk.c;h=418107ec83728473093b43dfe74ab709f312e8a8;hb=13d24b018f348401cceca45da5c0dd6d17411268;hp=808bb55ba3f21d113e6358f6874e2e20cb33bbea;hpb=b5b6521645ed41353e88c443ebaf124b214f25b1;p=git.git diff --git a/tree-walk.c b/tree-walk.c index 808bb55ba..418107ec8 100644 --- a/tree-walk.c +++ b/tree-walk.c @@ -344,7 +344,7 @@ int traverse_trees(int n, struct tree_desc *t, struct traverse_info *info) unsigned long mask, dirmask; const char *first = NULL; int first_len = 0; - struct name_entry *e; + struct name_entry *e = NULL; int len; for (i = 0; i < n; i++) { @@ -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))