Skip to content

Commit 7723023

Browse files
committed
Merge branch 'gh/userdiff-matlab'
* gh/userdiff-matlab: Add built-in diff patterns for MATLAB code
2 parents 9ef5697 + 53b10a1 commit 7723023

File tree

7 files changed

+39
-1
lines changed

7 files changed

+39
-1
lines changed

Documentation/gitattributes.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,8 @@ patterns are available:
500500

501501
- `java` suitable for source code in the Java language.
502502

503+
- `matlab` suitable for source code in the MATLAB language.
504+
503505
- `objc` suitable for source code in the Objective-C language.
504506

505507
- `pascal` suitable for source code in the Pascal/Delphi language.

t/t4018-diff-funcname.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ test_expect_funcname () {
105105
grep "^@@.*@@ $1" diff
106106
}
107107

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
109109
do
110110
test_expect_success "builtin $p pattern compiles" '
111111
echo "*.java diff=$p" >.gitattributes &&

t/t4034-diff-words.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ test_language_driver csharp
299299
test_language_driver fortran
300300
test_language_driver html
301301
test_language_driver java
302+
test_language_driver matlab
302303
test_language_driver objc
303304
test_language_driver pascal
304305
test_language_driver perl

t/t4034/matlab/expect

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ PATTERNS("java",
3737
"|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?"
3838
"|[-+*/<>%&^|=!]="
3939
"|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"),
40+
PATTERNS("matlab",
41+
"^[[:space:]]*((classdef|function)[[:space:]].*)$|^%%[[:space:]].*$",
42+
"[a-zA-Z_][a-zA-Z0-9_]*|[-+0-9.e]+|[=~<>]=|\\.[*/\\^']|\\|\\||&&"),
4043
PATTERNS("objc",
4144
/* Negate C statements that can look like functions */
4245
"!^[ \t]*(do|for|if|else|return|switch|while)\n"

0 commit comments

Comments
 (0)