mirror of
https://github.com/git/git.git
synced 2024-12-15 12:53:36 +08:00
2f6c9760de
The earlier design was to take whatever non-alnum that the short format parser happens to support, leaving the rest as part of the pattern, so a version of git that knows '*' magic and a version that does not would have behaved differently when given ":*Makefile". The former would have applied the '*' magic to the pattern "Makefile", while the latter would used no magic to the pattern "*Makefile". Instead, just reserve all non-alnum ASCII letters that are neither glob nor regexp special as potential magic signature, and when we see a magic that is not supported, die with an error message, just like the longhand codepath does. With this, ":%#!*Makefile" will always mean "%#!" magic applied to the pattern "*Makefile", no matter what version of git is used (it is a different matter if the version of git supports all of these three magic matching rules). Also make ':' without anything else to mean "there is no pathspec". This would allow differences between "git log" and "git log ." run from the top level of the working tree (the latter simplifies no-op commits away from the history) to be expressed from a subdirectory by saying "git log :". Helped-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
28 lines
941 B
C
28 lines
941 B
C
/*
|
|
* Sane locale-independent, ASCII ctype.
|
|
*
|
|
* No surprises, and works with signed and unsigned chars.
|
|
*/
|
|
#include "cache.h"
|
|
|
|
enum {
|
|
S = GIT_SPACE,
|
|
A = GIT_ALPHA,
|
|
D = GIT_DIGIT,
|
|
G = GIT_GLOB_SPECIAL, /* *, ?, [, \\ */
|
|
R = GIT_REGEX_SPECIAL, /* $, (, ), +, ., ^, {, | */
|
|
P = GIT_PATHSPEC_MAGIC /* other non-alnum, except for ] and } */
|
|
};
|
|
|
|
unsigned char sane_ctype[256] = {
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, S, S, 0, 0, S, 0, 0, /* 0.. 15 */
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 16.. 31 */
|
|
S, P, P, P, R, P, P, P, R, R, G, R, P, P, R, P, /* 32.. 47 */
|
|
D, D, D, D, D, D, D, D, D, D, P, P, P, P, P, G, /* 48.. 63 */
|
|
P, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, /* 64.. 79 */
|
|
A, A, A, A, A, A, A, A, A, A, A, G, G, 0, R, P, /* 80.. 95 */
|
|
P, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, /* 96..111 */
|
|
A, A, A, A, A, A, A, A, A, A, A, R, R, 0, P, 0, /* 112..127 */
|
|
/* Nothing in the 128.. range */
|
|
};
|