summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2016-01-08 19:05:25 +0700
committerJunio C Hamano <gitster@pobox.com>2016-01-08 11:24:14 -0800
commit8c722360d1277259d4baec951e1488086f775214 (patch)
tree4539c7a62a9f42aa6e5d51189789039e0c39e001 /dir.c
parent57534ee77d22e725d971ee89c77dc6aad61c573f (diff)
downloadgit-8c722360d1277259d4baec951e1488086f775214.tar.gz
Revert "dir.c: don't exclude whole dir prematurely if neg pattern may match"
This reverts commit 57534ee77d22e725d971ee89c77dc6aad61c573f. The feature added in that commit requires that patterns behave the same way from anywhere. But some patterns can behave differently depending on current "working" directory. The conditions to catch and avoid these patterns are too loose. The untracked listing[1] and sparse-checkout selection[2] can become incorrect as a result. [1] http://article.gmane.org/gmane.comp.version-control.git/283520 [2] http://article.gmane.org/gmane.comp.version-control.git/283532 Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c74
1 files changed, 1 insertions, 73 deletions
diff --git a/dir.c b/dir.c
index 894027c0cd..4893181a0c 100644
--- a/dir.c
+++ b/dir.c
@@ -733,25 +733,6 @@ int match_pathname(const char *pathname, int pathlen,
*/
if (!patternlen && !namelen)
return 1;
- /*
- * This can happen when we ignore some exclude rules
- * on directories in other to see if negative rules
- * may match. E.g.
- *
- * /abc
- * !/abc/def/ghi
- *
- * The pattern of interest is "/abc". On the first
- * try, we should match path "abc" with this pattern
- * in the "if" statement right above, but the caller
- * ignores it.
- *
- * On the second try with paths within "abc",
- * e.g. "abc/xyz", we come here and try to match it
- * with "/abc".
- */
- if (!patternlen && namelen && *name == '/')
- return 1;
}
return fnmatch_icase_mem(pattern, patternlen,
@@ -760,48 +741,6 @@ int match_pathname(const char *pathname, int pathlen,
}
/*
- * Return non-zero if pathname is a directory and an ancestor of the
- * literal path in a (negative) pattern. This is used to keep
- * descending in "foo" and "foo/bar" when the pattern is
- * "!foo/bar/.gitignore". "foo/notbar" will not be descended however.
- */
-static int match_neg_path(const char *pathname, int pathlen, int *dtype,
- const char *base, int baselen,
- const char *pattern, int prefix, int patternlen,
- int flags)
-{
- assert((flags & EXC_FLAG_NEGATIVE) && !(flags & EXC_FLAG_NODIR));
-
- if (*dtype == DT_UNKNOWN)
- *dtype = get_dtype(NULL, pathname, pathlen);
- if (*dtype != DT_DIR)
- return 0;
-
- if (*pattern == '/') {
- pattern++;
- patternlen--;
- prefix--;
- }
-
- if (baselen) {
- if (((pathlen < baselen && base[pathlen] == '/') ||
- pathlen == baselen) &&
- !strncmp_icase(pathname, base, pathlen))
- return 1;
- pathname += baselen + 1;
- pathlen -= baselen + 1;
- }
-
-
- if (prefix &&
- ((pathlen < prefix && pattern[pathlen] == '/') &&
- !strncmp_icase(pathname, pattern, pathlen)))
- return 1;
-
- return 0;
-}
-
-/*
* Scan the given exclude list in reverse to see whether pathname
* should be ignored. The first match (i.e. the last on the list), if
* any, determines the fate. Returns the exclude_list element which
@@ -814,7 +753,7 @@ static struct exclude *last_exclude_matching_from_list(const char *pathname,
struct exclude_list *el)
{
struct exclude *exc = NULL; /* undecided */
- int i, matched_negative_path = 0;
+ int i;
if (!el->nr)
return NULL; /* undefined */
@@ -849,18 +788,7 @@ static struct exclude *last_exclude_matching_from_list(const char *pathname,
exc = x;
break;
}
-
- if ((x->flags & EXC_FLAG_NEGATIVE) && !matched_negative_path &&
- match_neg_path(pathname, pathlen, dtype, x->base,
- x->baselen ? x->baselen - 1 : 0,
- exclude, prefix, x->patternlen, x->flags))
- matched_negative_path = 1;
}
- if (exc &&
- !(exc->flags & EXC_FLAG_NEGATIVE) &&
- !(exc->flags & EXC_FLAG_NODIR) &&
- matched_negative_path)
- exc = NULL;
return exc;
}