diff options
author | Junio C Hamano <gitster@pobox.com> | 2010-03-20 11:29:36 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-03-20 11:29:36 -0700 |
commit | 4e7d08a229a531f8d7841a8a1a892d5989130d67 (patch) | |
tree | a87269ea1d14f85508f2548d0cc7f75c338da566 /dir.c | |
parent | f1aa782a3b72a2c4de46dc93b484eb99dc01d4d0 (diff) | |
parent | b75aea8f5bea614f802256c436b06733486a2088 (diff) | |
download | git-4e7d08a229a531f8d7841a8a1a892d5989130d67.tar.gz |
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.c | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -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); /* |