57
*
58
* Possible future magic semantics include stuff like:
59
*
60
- * { PATHSPEC_NOGLOB, '!', "noglob" },
60
* { PATHSPEC_ICASE, '\0', "icase" },
61
* { PATHSPEC_RECURSIVE, '*', "recursive" },
62
* { PATHSPEC_REGEXP, '\0', "regexp" },
70
} pathspec_magic[] = {
71
{ PATHSPEC_FROMTOP, '/', "top" },
72
{ PATHSPEC_LITERAL, 0, "literal" },
73
+ { PATHSPEC_GLOB, '\0', "glob" },
74
};
75
76
/*
93
const char *elt)
94
{
95
static int literal_global = -1;
96
+ static int glob_global = -1;
97
+ static int noglob_global = -1;
98
unsigned magic = 0, short_magic = 0, global_magic = 0;
99
const char *copyfrom = elt, *long_magic_end = NULL;
100
char *match;
105
if (literal_global)
106
global_magic |= PATHSPEC_LITERAL;
107
108
+ if (glob_global < 0)
109
+ glob_global = git_env_bool(GIT_GLOB_PATHSPECS_ENVIRONMENT, 0);
110
+ if (glob_global)
111
+ global_magic |= PATHSPEC_GLOB;
112
+
113
+ if (noglob_global < 0)
114
+ noglob_global = git_env_bool(GIT_NOGLOB_PATHSPECS_ENVIRONMENT, 0);
115
+
116
+ if (glob_global && noglob_global)
117
+ die(_("global 'glob' and 'noglob' pathspec settings are incompatible"));
118
+
119
+ if ((global_magic & PATHSPEC_LITERAL) &&
120
+ (global_magic & ~PATHSPEC_LITERAL))
121
+ die(_("global 'literal' pathspec setting is incompatible "
122
+ "with all other global pathspec settings"));
123
+
124
if (elt[0] != ':' || literal_global) {
125
; /* nothing to do */
126
} else if (elt[1] == '(') {
185
186
magic |= short_magic;
187
*p_short_magic = short_magic;
188
+
189
+ /* --noglob-pathspec adds :(literal) _unless_ :(glob) is specifed */
190
+ if (noglob_global && !(magic & PATHSPEC_GLOB))
191
+ global_magic |= PATHSPEC_LITERAL;
192
+
193
+ /* --glob-pathspec is overriden by :(literal) */
194
+ if ((global_magic & PATHSPEC_GLOB) && (magic & PATHSPEC_LITERAL))
195
+ global_magic &= ~PATHSPEC_GLOB;
196
+
197
magic |= global_magic;
198
199
if (pathspec_prefix >= 0 &&
200
(prefixlen || (prefix && *prefix)))
201
die("BUG: 'prefix' magic is supposed to be used at worktree's root");
202
203
+ if ((magic & PATHSPEC_LITERAL) && (magic & PATHSPEC_GLOB))
204
+ die(_("%s: 'literal' and 'glob' are incompatible"), elt);
205
+
206
if (pathspec_prefix >= 0) {
207
match = xstrdup(copyfrom);
208
prefixlen = pathspec_prefix;
278
item->nowildcard_len = prefixlen;
279
}
280
item->flags = 0;
251
- if (item->nowildcard_len < item->len &&
252
- item->match[item->nowildcard_len] == '*' &&
253
- no_wildcard(item->match + item->nowildcard_len + 1))
254
- item->flags |= PATHSPEC_ONESTAR;
281
+ if (magic & PATHSPEC_GLOB) {
282
+ /*
283
+ * FIXME: should we enable ONESTAR in _GLOB for
284
+ * pattern "* * / * . c"?
285
+ */
286
+ } else {
287
+ if (item->nowildcard_len < item->len &&
288
+ item->match[item->nowildcard_len] == '*' &&
289
+ no_wildcard(item->match + item->nowildcard_len + 1))
290
+ item->flags |= PATHSPEC_ONESTAR;
291
+ }
292
293
/* sanity checks, pathspec matchers assume these are sane */
294
assert(item->nowildcard_len <= item->len &&