aboutsummaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-03-24 16:24:03 -0700
committerJunio C Hamano <gitster@pobox.com>2010-03-24 16:24:03 -0700
commitbcbbe4f9d9afa025024f18a474d11bfec32e3207 (patch)
tree10c711f417d3b1ccb77946d0eb134e9debb9946d /dir.c
parent7b676b1bb53c936770a07354ec6c6550fb31b421 (diff)
parentb75aea8f5bea614f802256c436b06733486a2088 (diff)
downloadgit-bcbbe4f9d9afa025024f18a474d11bfec32e3207.tar.gz
git-bcbbe4f9d9afa025024f18a474d11bfec32e3207.tar.xz
Merge branch 'jk/maint-add-ignored-dir' into maint
* 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 133c333df..cb83332a2 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);
/*