Teach git diff about Objective-C syntax
Add support for recognition of Objective-C class & instance methods, C functions, and class implementation/interfaces. Signed-off-by: Jonathan del Strother <jon.delStrother@bestbefore.tv> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Jonathan del Strother committed
Oct 1, 2008 at 00:46 UTC
5d1e958e2467ef295637844fd85be7a8ab187ef1
2 files changed
+12
Documentation/gitattributes.txt
+2
@@ -315,6 +315,8 @@ patterns are available:
315
316
- `java` suitable for source code in the Java language.
317
318
+- `objc` suitable for source code in the Objective-C language.
319
+
320
- `pascal` suitable for source code in the Pascal/Delphi language.
321
322
- `php` suitable for source code in the PHP language.
diff.c
+10
@@ -1429,6 +1429,16 @@ static const struct funcname_pattern_entry builtin_funcname_pattern[] = {
1429
"!^[ \t]*(catch|do|for|if|instanceof|new|return|switch|throw|while)\n"
1430
"^[ \t]*(([ \t]*[A-Za-z_][A-Za-z_0-9]*){2,}[ \t]*\\([^;]*)$",
1431
REG_EXTENDED },
1432
+ { "objc",
1433
+ /* Negate C statements that can look like functions */
1434
+ "!^[ \t]*(do|for|if|else|return|switch|while)\n"
1435
+ /* Objective-C methods */
1436
+ "^[ \t]*([-+][ \t]*\\([ \t]*[A-Za-z_][A-Za-z_0-9* \t]*\\)[ \t]*[A-Za-z_].*)$\n"
1437
+ /* C functions */
1438
+ "^[ \t]*(([ \t]*[A-Za-z_][A-Za-z_0-9]*){2,}[ \t]*\\([^;]*)$\n"
1439
+ /* Objective-C class/protocol definitions */
1440
+ "^(@(implementation|interface|protocol)[ \t].*)$",
1441
+ REG_EXTENDED },
1442
{ "pascal",
1443
"^((procedure|function|constructor|destructor|interface|"
1444
"implementation|initialization|finalization)[ \t]*.*)$"