summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-03-20 18:29:36 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-03-20 18:29:36 (GMT)
commit4e7d08a229a531f8d7841a8a1a892d5989130d67 (patch)
treea87269ea1d14f85508f2548d0cc7f75c338da566 /dir.c
parentf1aa782a3b72a2c4de46dc93b484eb99dc01d4d0 (diff)
parentb75aea8f5bea614f802256c436b06733486a2088 (diff)
downloadgit-4e7d08a229a531f8d7841a8a1a892d5989130d67.zip
git-4e7d08a229a531f8d7841a8a1a892d5989130d67.tar.gz
git-4e7d08a229a531f8d7841a8a1a892d5989130d67.tar.bz2
Merge branch 'jk/maint-add-ignored-dir'
* jk/maint-add-ignored-dir: tests for "git add ignored-dir/file" without -f dir: fix COLLECT_IGNORED on excluded prefixes t0050: mark non-working test as such
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/dir.c b/dir.c
index 133c333..cb83332 100644
--- a/dir.c
+++ b/dir.c
@@ -594,13 +594,29 @@ static int simplify_away(const char *path, int pathlen, const struct path_simpli
return 0;
}
-static int in_pathspec(const char *path, int len, const struct path_simplify *simplify)
+/*
+ * This function tells us whether an excluded path matches a
+ * list of "interesting" pathspecs. That is, whether a path matched
+ * by any of the pathspecs could possibly be ignored by excluding
+ * the specified path. This can happen if:
+ *
+ * 1. the path is mentioned explicitly in the pathspec
+ *
+ * 2. the path is a directory prefix of some element in the
+ * pathspec
+ */
+static int exclude_matches_pathspec(const char *path, int len,
+ const struct path_simplify *simplify)
{
if (simplify) {
for (; simplify->path; simplify++) {
if (len == simplify->len
&& !memcmp(path, simplify->path, len))
return 1;
+ if (len < simplify->len
+ && simplify->path[len] == '/'
+ && !memcmp(path, simplify->path, len))
+ return 1;
}
}
return 0;
@@ -678,7 +694,7 @@ static enum path_treatment treat_one_path(struct dir_struct *dir,
{
int exclude = excluded(dir, path, &dtype);
if (exclude && (dir->flags & DIR_COLLECT_IGNORED)
- && in_pathspec(path, *len, simplify))
+ && exclude_matches_pathspec(path, *len, simplify))
dir_add_ignored(dir, path, *len);
/*