Add built-in diff patterns for MATLAB code
MATLAB is often used in industry and academia for scientific computations motivating it being included as a built-in pattern. Signed-off-by: Gustaf Hendeby <hendeby@isy.liu.se> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Gustaf Hendeby committed
Nov 15, 2011 at 21:15 UTC
53b10a140527253f61cfc209a4e85e132c0bc4ee
7 files changed
+39
-1
Documentation/gitattributes.txt
+2
@@ -500,6 +500,8 @@ patterns are available:
500
501
- `java` suitable for source code in the Java language.
502
503
+- `matlab` suitable for source code in the MATLAB language.
504
+
505
- `objc` suitable for source code in the Objective-C language.
506
507
- `pascal` suitable for source code in the Pascal/Delphi language.
t/t4018-diff-funcname.sh
+1
-1
@@ -105,7 +105,7 @@ test_expect_funcname () {
105
grep "^@@.*@@ $1" diff
106
}
107
108
-for p in bibtex cpp csharp fortran html java objc pascal perl php python ruby tex
108
+for p in bibtex cpp csharp fortran html java matlab objc pascal perl php python ruby tex
109
do
110
test_expect_success "builtin $p pattern compiles" '
111
echo "*.java diff=$p" >.gitattributes &&
t/t4034-diff-words.sh
+1
@@ -299,6 +299,7 @@ test_language_driver csharp
299
test_language_driver fortran
300
test_language_driver html
301
test_language_driver java
302
+test_language_driver matlab
303
test_language_driver objc
304
test_language_driver pascal
305
test_language_driver perl
t/t4034/matlab/expect
new
+14
@@ -0,0 +1,14 @@
1
+<BOLD>diff --git a/pre b/post<RESET>
2
+<BOLD>index dc204db..70e05f0 100644<RESET>
3
+<BOLD>--- a/pre<RESET>
4
+<BOLD>+++ b/post<RESET>
5
+<CYAN>@@ -1,9 +1,9 @@<RESET>
6
+(<RED>1<RESET><GREEN>0<RESET>) (<RED>-1e10<RESET><GREEN>-0e10<RESET>) '<RED>b<RESET><GREEN>y<RESET>';
7
+[<RED>a<RESET><GREEN>x<RESET>] {<RED>a<RESET><GREEN>x<RESET>} <RED>a<RESET><GREEN>x<RESET>.<RED>b<RESET><GREEN>y<RESET>;
8
+~<RED>a<RESET><GREEN>x<RESET>;
9
+<RED>a<RESET><GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>.*<RED>b a<RESET><GREEN>y x<RESET>/<RED>b a<RESET><GREEN>y x<RESET>./<RED>b a<RESET><GREEN>y x<RESET>^<RED>b a<RESET><GREEN>y x<RESET>.^<RED>b a<RESET><GREEN>y x<RESET>.\<RED>b a<RESET><GREEN>y x<RESET>.';
10
+<RED>a<RESET><GREEN>x<RESET>+<RED>b a<RESET><GREEN>y x<RESET>-<RED>b<RESET><GREEN>y<RESET>;
11
+<RED>a<RESET><GREEN>x<RESET>&<RED>b a<RESET><GREEN>y x<RESET>&&<RED>b a<RESET><GREEN>y x<RESET>|<RED>b a<RESET><GREEN>y x<RESET>||<RED>b<RESET><GREEN>y<RESET>;
12
+<RED>a<RESET><GREEN>x<RESET><<RED>b a<RESET><GREEN>y x<RESET><=<RED>b a<RESET><GREEN>y x<RESET>><RED>b a<RESET><GREEN>y x<RESET>>=<RED>b<RESET><GREEN>y<RESET>;
13
+<RED>a<RESET><GREEN>x<RESET>==<RED>b a<RESET><GREEN>y x<RESET>~=<RED>b<RESET><GREEN>y<RESET>;
14
+<RED>a<RESET><GREEN>x<RESET>,<RED>b<RESET><GREEN>y<RESET>;
t/t4034/matlab/post
new
+9
@@ -0,0 +1,9 @@
1
+(0) (-0e10) 'y';
2
+[x] {x} x.y;
3
+~x;
4
+x*y x.*y x/y x./y x^y x.^y x.\y x.';
5
+x+y x-y;
6
+x&y x&&y x|y x||y;
7
+x<y x<=y x>y x>=y;
8
+x==y x~=y;
9
+x,y;
t/t4034/matlab/pre
new
+9
@@ -0,0 +1,9 @@
1
+(1) (-1e10) 'b';
2
+[a] {a} a.b;
3
+~a;
4
+a*b a.*b a/b a./b a^b a.^b a.\b a.';
5
+a+b a-b;
6
+a&b a&&b a|b a||b;
7
+a<b a<=b a>b a>=b;
8
+a==b a~=b;
9
+a,b;
userdiff.c
+3
@@ -37,6 +37,9 @@ PATTERNS("java",
37
"|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?"
38
"|[-+*/<>%&^|=!]="
39
"|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"),
40
+PATTERNS("matlab",
41
+ "^[[:space:]]*((classdef|function)[[:space:]].*)$|^%%[[:space:]].*$",
42
+ "[a-zA-Z_][a-zA-Z0-9_]*|[-+0-9.e]+|[=~<>]=|\\.[*/\\^']|\\|\\||&&"),
43
PATTERNS("objc",
44
/* Negate C statements that can look like functions */
45
"!^[ \t]*(do|for|if|else|return|switch|while)\n"