userdiff style: re-order drivers in alphabetical order
Address some old code smell and move around the built-in userdiff drivers so they're both in alphabetical order, and now in the same order they appear in the gitattributes(5) documentation. The two started drifting in be58e70dba (diff: unify external diff and funcname parsing code, 2008-10-05), and then even further in 80c49c3de2 (color-words: make regex configurable via attributes, 2009-01-17) when the "cpp" pattern was added. There are no functional changes here, and as --color-moved will show only moved existing lines. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ævar Arnfjörð Bjarmason committed
Apr 8, 2021 at 17:04 UTC
ddd164d026d24fd5a2ca3e3d0be06bbcaebb2476
1 file changed
+38
-38
userdiff.c
+38
-38
@@ -44,6 +44,44 @@ PATTERNS("bash",
44
/* -- */
45
/* Characters not in the default $IFS value */
46
"[^ \t]+"),
47
+PATTERNS("bibtex", "(@[a-zA-Z]{1,}[ \t]*\\{{0,1}[ \t]*[^ \t\"@',\\#}{~%]*).*$",
48
+ "[={}\"]|[^={}\" \t]+"),
49
+PATTERNS("cpp",
50
+ /* Jump targets or access declarations */
51
+ "!^[ \t]*[A-Za-z_][A-Za-z_0-9]*:[[:space:]]*($|/[/*])\n"
52
+ /* functions/methods, variables, and compounds at top level */
53
+ "^((::[[:space:]]*)?[A-Za-z_].*)$",
54
+ /* -- */
55
+ "[a-zA-Z_][a-zA-Z0-9_]*"
56
+ "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lLuU]*"
57
+ "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->\\*?|\\.\\*"),
58
+PATTERNS("csharp",
59
+ /* Keywords */
60
+ "!^[ \t]*(do|while|for|if|else|instanceof|new|return|switch|case|throw|catch|using)\n"
61
+ /* Methods and constructors */
62
+ "^[ \t]*(((static|public|internal|private|protected|new|virtual|sealed|override|unsafe|async)[ \t]+)*[][<>@.~_[:alnum:]]+[ \t]+[<>@._[:alnum:]]+[ \t]*\\(.*\\))[ \t]*$\n"
63
+ /* Properties */
64
+ "^[ \t]*(((static|public|internal|private|protected|new|virtual|sealed|override|unsafe)[ \t]+)*[][<>@.~_[:alnum:]]+[ \t]+[@._[:alnum:]]+)[ \t]*$\n"
65
+ /* Type definitions */
66
+ "^[ \t]*(((static|public|internal|private|protected|new|unsafe|sealed|abstract|partial)[ \t]+)*(class|enum|interface|struct)[ \t]+.*)$\n"
67
+ /* Namespace */
68
+ "^[ \t]*(namespace[ \t]+.*)$",
69
+ /* -- */
70
+ "[a-zA-Z_][a-zA-Z0-9_]*"
71
+ "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?"
72
+ "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->"),
73
+IPATTERN("css",
74
+ "![:;][[:space:]]*$\n"
75
+ "^[:[@.#]?[_a-z0-9].*$",
76
+ /* -- */
77
+ /*
78
+ * This regex comes from W3C CSS specs. Should theoretically also
79
+ * allow ISO 10646 characters U+00A0 and higher,
80
+ * but they are not handled in this regex.
81
+ */
82
+ "-?[_a-zA-Z][-_a-zA-Z0-9]*" /* identifiers */
83
+ "|-?[0-9]+|\\#[0-9a-fA-F]+" /* numbers */
84
+),
85
PATTERNS("dts",
86
"!;\n"
87
"!=\n"
@@ -191,46 +229,8 @@ PATTERNS("rust",
229
"[a-zA-Z_][a-zA-Z0-9_]*"
230
"|[0-9][0-9_a-fA-Fiosuxz]*(\\.([0-9]*[eE][+-]?)?[0-9_fF]*)?"
231
"|[-+*\\/<>%&^|=!:]=|<<=?|>>=?|&&|\\|\\||->|=>|\\.{2}=|\\.{3}|::"),
194
-PATTERNS("bibtex", "(@[a-zA-Z]{1,}[ \t]*\\{{0,1}[ \t]*[^ \t\"@',\\#}{~%]*).*$",
195
- "[={}\"]|[^={}\" \t]+"),
232
PATTERNS("tex", "^(\\\\((sub)*section|chapter|part)\\*{0,1}\\{.*)$",
233
"\\\\[a-zA-Z@]+|\\\\.|[a-zA-Z0-9\x80-\xff]+"),
198
-PATTERNS("cpp",
199
- /* Jump targets or access declarations */
200
- "!^[ \t]*[A-Za-z_][A-Za-z_0-9]*:[[:space:]]*($|/[/*])\n"
201
- /* functions/methods, variables, and compounds at top level */
202
- "^((::[[:space:]]*)?[A-Za-z_].*)$",
203
- /* -- */
204
- "[a-zA-Z_][a-zA-Z0-9_]*"
205
- "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lLuU]*"
206
- "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->\\*?|\\.\\*"),
207
-PATTERNS("csharp",
208
- /* Keywords */
209
- "!^[ \t]*(do|while|for|if|else|instanceof|new|return|switch|case|throw|catch|using)\n"
210
- /* Methods and constructors */
211
- "^[ \t]*(((static|public|internal|private|protected|new|virtual|sealed|override|unsafe|async)[ \t]+)*[][<>@.~_[:alnum:]]+[ \t]+[<>@._[:alnum:]]+[ \t]*\\(.*\\))[ \t]*$\n"
212
- /* Properties */
213
- "^[ \t]*(((static|public|internal|private|protected|new|virtual|sealed|override|unsafe)[ \t]+)*[][<>@.~_[:alnum:]]+[ \t]+[@._[:alnum:]]+)[ \t]*$\n"
214
- /* Type definitions */
215
- "^[ \t]*(((static|public|internal|private|protected|new|unsafe|sealed|abstract|partial)[ \t]+)*(class|enum|interface|struct)[ \t]+.*)$\n"
216
- /* Namespace */
217
- "^[ \t]*(namespace[ \t]+.*)$",
218
- /* -- */
219
- "[a-zA-Z_][a-zA-Z0-9_]*"
220
- "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?"
221
- "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->"),
222
-IPATTERN("css",
223
- "![:;][[:space:]]*$\n"
224
- "^[:[@.#]?[_a-z0-9].*$",
225
- /* -- */
226
- /*
227
- * This regex comes from W3C CSS specs. Should theoretically also
228
- * allow ISO 10646 characters U+00A0 and higher,
229
- * but they are not handled in this regex.
230
- */
231
- "-?[_a-zA-Z][-_a-zA-Z0-9]*" /* identifiers */
232
- "|-?[0-9]+|\\#[0-9a-fA-F]+" /* numbers */
233
-),
234
{ "default", NULL, -1, { NULL, 0 } },
235
};
236
#undef PATTERNS