* Parse the pathspec element looking for short magic * * saves all magic in 'magic' * returns the position in 'elem' after all magic has been parsed */
| 393 | * returns the position in 'elem' after all magic has been parsed |
| 394 | */ |
| 395 | static const char *parse_short_magic(unsigned *magic, const char *elem) |
| 396 | { |
| 397 | const char *pos; |
| 398 | |
| 399 | for (pos = elem + 1; *pos && *pos != ':'; pos++) { |
| 400 | char ch = *pos; |
| 401 | unsigned int i; |
| 402 | |
| 403 | /* Special case alias for '!' */ |
| 404 | if (ch == '^') { |
| 405 | *magic |= PATHSPEC_EXCLUDE; |
| 406 | continue; |
| 407 | } |
| 408 | |
| 409 | if (!is_pathspec_magic(ch)) |
| 410 | break; |
| 411 | |
| 412 | for (i = 0; i < ARRAY_SIZE(pathspec_magic); i++) { |
| 413 | if (pathspec_magic[i].mnemonic == ch) { |
| 414 | *magic |= pathspec_magic[i].bit; |
| 415 | break; |
| 416 | } |
| 417 | } |
| 418 | |
| 419 | if (ARRAY_SIZE(pathspec_magic) <= i) |
| 420 | die(_("Unimplemented pathspec magic '%c' in '%s'"), |
| 421 | ch, elem); |
| 422 | } |
| 423 | |
| 424 | if (*pos == ':') |
| 425 | pos++; |
| 426 | |
| 427 | return pos; |
| 428 | } |
| 429 | |
| 430 | static const char *parse_element_magic(unsigned *magic, int *prefix_len, |
| 431 | struct pathspec_item *item, |
no test coverage detected