diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2013-12-06 14:30:48 +0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-12-06 13:00:39 -0800 |
commit | ef79b1f8704668a6cdf4278f9255e03ca785bfb4 (patch) | |
tree | f74ee3986aee50992cab9fcf16fcac3e55abe551 /pathspec.c | |
parent | 8b7cb51a9dda0debf48c62ae79b9d60a23507097 (diff) | |
download | git-ef79b1f8704668a6cdf4278f9255e03ca785bfb4.tar.gz |
Support pathspec magic :(exclude) and its short form :!
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 'pathspec.c')
-rw-r--r-- | pathspec.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/pathspec.c b/pathspec.c index 87b3b82f1f..4e6a727570 100644 --- a/pathspec.c +++ b/pathspec.c @@ -71,6 +71,7 @@ static struct pathspec_magic { { PATHSPEC_LITERAL, 0, "literal" }, { PATHSPEC_GLOB, '\0', "glob" }, { PATHSPEC_ICASE, '\0', "icase" }, + { PATHSPEC_EXCLUDE, '!', "exclude" }, }; /* @@ -355,7 +356,7 @@ void parse_pathspec(struct pathspec *pathspec, { struct pathspec_item *item; const char *entry = argv ? *argv : NULL; - int i, n, prefixlen; + int i, n, prefixlen, nr_exclude = 0; memset(pathspec, 0, sizeof(*pathspec)); @@ -412,6 +413,8 @@ void parse_pathspec(struct pathspec *pathspec, if ((flags & PATHSPEC_LITERAL_PATH) && !(magic_mask & PATHSPEC_LITERAL)) item[i].magic |= PATHSPEC_LITERAL; + if (item[i].magic & PATHSPEC_EXCLUDE) + nr_exclude++; if (item[i].magic & magic_mask) unsupported_magic(entry, item[i].magic & magic_mask, @@ -427,6 +430,10 @@ void parse_pathspec(struct pathspec *pathspec, pathspec->magic |= item[i].magic; } + if (nr_exclude == n) + die(_("There is nothing to exclude from by :(exclude) patterns.\n" + "Perhaps you forgot to add either ':/' or '.' ?")); + if (pathspec->magic & PATHSPEC_MAXDEPTH) { if (flags & PATHSPEC_KEEP_ORDER) |