Skip to content

Commit d49c2c3

Browse files
committed
Merge branch 'sb/userdiff-dts'
Device-tree files learned their own userdiff patterns. * sb/userdiff-dts: userdiff: add a builtin pattern for dts files
2 parents 2743b61 + 3c81760 commit d49c2c3

File tree

14 files changed

+168
-0
lines changed

14 files changed

+168
-0
lines changed

Documentation/gitattributes.txt

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

811811
- `css` suitable for cascading style sheets.
812812

813+
- `dts` suitable for devicetree (DTS) files.
814+
813815
- `fortran` suitable for source code in the Fortran language.
814816

815817
- `fountain` suitable for Fountain documents.

t/t4018-diff-funcname.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ diffpatterns="
3131
cpp
3232
csharp
3333
css
34+
dts
3435
fortran
3536
fountain
3637
golang

t/t4018/dts-labels

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/ {
2+
label_1: node1@ff00 {
3+
label2: RIGHT {
4+
vendor,some-property;
5+
6+
ChangeMe = <0x45-30>;
7+
};
8+
};
9+
};

t/t4018/dts-node-unitless

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/ {
2+
label_1: node1 {
3+
RIGHT {
4+
prop-array = <1>, <4>;
5+
ChangeMe = <0xffeedd00>;
6+
};
7+
};
8+
};

t/t4018/dts-nodes

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/ {
2+
label_1: node1@ff00 {
3+
RIGHT@deadf00,4000 {
4+
#size-cells = <1>;
5+
ChangeMe = <0xffeedd00>;
6+
};
7+
};
8+
};

t/t4018/dts-nodes-comment1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/ {
2+
label_1: node1@ff00 {
3+
RIGHT@deadf00,4000 /* &a comment */ {
4+
#size-cells = <1>;
5+
ChangeMe = <0xffeedd00>;
6+
};
7+
};
8+
};

t/t4018/dts-nodes-comment2

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/ {
2+
label_1: node1@ff00 {
3+
RIGHT@deadf00,4000 { /* a trailing comment */
4+
#size-cells = <1>;
5+
ChangeMe = <0xffeedd00>;
6+
};
7+
};
8+
};

t/t4018/dts-reference

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
&label_1 {
2+
TEST = <455>;
3+
};
4+
5+
&RIGHT {
6+
vendor,some-property;
7+
8+
ChangeMe = <0x45-30>;
9+
};

t/t4018/dts-root

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/RIGHT { /* Technically just supposed to be a slash */
2+
#size-cells = <1>;
3+
4+
ChangeMe = <0xffeedd00>;
5+
};

t/t4034-diff-words.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ test_language_driver bibtex
303303
test_language_driver cpp
304304
test_language_driver csharp
305305
test_language_driver css
306+
test_language_driver dts
306307
test_language_driver fortran
307308
test_language_driver html
308309
test_language_driver java

t/t4034/dts/expect

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<BOLD>diff --git a/pre b/post<RESET>
2+
<BOLD>index b6a9051..7803aee 100644<RESET>
3+
<BOLD>--- a/pre<RESET>
4+
<BOLD>+++ b/post<RESET>
5+
<CYAN>@@ -1,32 +1,32 @@<RESET>
6+
/ {<RESET>
7+
<RED>this_handle<RESET><GREEN>HANDLE_2<RESET>: <RED>node<RESET><GREEN>new-node<RESET>@<RED>f00<RESET><GREEN>eeda<RESET> {
8+
compatible = "<RED>mydev<RESET><GREEN>vendor,compat<RESET>";
9+
string-prop = <RED>start<RESET><GREEN>end<RESET>: "hello <RED>world!<RESET><GREEN>world?<RESET>" <RED>end<RESET><GREEN>start<RESET>: ;
10+
<RED>#size-cells<RESET><GREEN>#address-cells<RESET> = <<RED>0+0<RESET><GREEN>0+40<RESET>>;
11+
reg = <<RED>0xf00<RESET><GREEN>0xeeda<RESET>>;
12+
prop = <<GREEN>(<RESET>1<GREEN>)<RESET>>;
13+
prop = <<GREEN>(<RESET>-1e10<GREEN>)<RESET>>;
14+
prop = <(!<RED>3<RESET><GREEN>1<RESET>)>;
15+
prop = <(~<RED>3<RESET><GREEN>1<RESET>)>;
16+
prop = <(<RED>3<RESET><GREEN>1<RESET>*<RED>4<RESET><GREEN>2<RESET>)>;
17+
prop = <(<RED>3<RESET><GREEN>1<RESET>&<RED>4<RESET><GREEN>2<RESET>)>;
18+
prop = <(<RED>3<RESET><GREEN>1<RESET>*<RED>4<RESET><GREEN>2<RESET>)>;
19+
prop = <(<RED>3<RESET><GREEN>1<RESET>/<RED>4<RESET><GREEN>2<RESET>)>;
20+
prop = <(<RED>3<RESET><GREEN>1<RESET>%<RED>4<RESET><GREEN>2<RESET>)>;
21+
prop = <(<RED>3+4<RESET><GREEN>1+2<RESET>)>;
22+
prop = <(<RED>3-4<RESET><GREEN>1-2<RESET>)>;
23+
prop = /bits/ <RED>64<RESET><GREEN>32<RESET> <(<RED>3<RESET><GREEN>1<RESET><<<RED>4<RESET><GREEN>2<RESET>)>;
24+
prop = <(<RED>3<RESET><GREEN>1<RESET>>><RED>4<RESET><GREEN>2<RESET>)>;
25+
prop = <(<RED>3<RESET><GREEN>1<RESET>&<RED>4<RESET><GREEN>2<RESET>)>;
26+
prop = <(<RED>3<RESET><GREEN>1<RESET>^<RED>4<RESET><GREEN>2<RESET>)>;
27+
prop = <(<RED>3<RESET><GREEN>1<RESET>|<RED>4<RESET><GREEN>2<RESET>)>;
28+
prop = <(<RED>3<RESET><GREEN>1<RESET>&&<RED>4<RESET><GREEN>2<RESET>)>;
29+
prop = <(<RED>3<RESET><GREEN>1<RESET>||<RED>4<RESET><GREEN>2<RESET>)>;
30+
prop = <(<RED>4?5<RESET><GREEN>1?2<RESET>:3)>;
31+
list = <&<RED>this_handle<RESET><GREEN>HANDLE_2<RESET>>, <0 0 0 <RED>0<RESET><GREEN>1<RESET>>;
32+
};<RESET>
33+
34+
&<RED>phandle<RESET><GREEN>phandle2<RESET> {
35+
<RED>pre-phandle<RESET><GREEN>prop_handle<RESET> = <&<RED>this_handle<RESET><GREEN>HANDLE_2<RESET>>;
36+
};<RESET>
37+
};<RESET>

t/t4034/dts/post

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/ {
2+
HANDLE_2: new-node@eeda {
3+
compatible = "vendor,compat";
4+
string-prop = end: "hello world?" start: ;
5+
#address-cells = <0+40>;
6+
reg = <0xeeda>;
7+
prop = <(1)>;
8+
prop = <(-1e10)>;
9+
prop = <(!1)>;
10+
prop = <(~1)>;
11+
prop = <(1*2)>;
12+
prop = <(1&2)>;
13+
prop = <(1*2)>;
14+
prop = <(1/2)>;
15+
prop = <(1%2)>;
16+
prop = <(1+2)>;
17+
prop = <(1-2)>;
18+
prop = /bits/ 32 <(1<<2)>;
19+
prop = <(1>>2)>;
20+
prop = <(1&2)>;
21+
prop = <(1^2)>;
22+
prop = <(1|2)>;
23+
prop = <(1&&2)>;
24+
prop = <(1||2)>;
25+
prop = <(1?2:3)>;
26+
list = <&HANDLE_2>, <0 0 0 1>;
27+
};
28+
29+
&phandle2 {
30+
prop_handle = <&HANDLE_2>;
31+
};
32+
};

t/t4034/dts/pre

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/ {
2+
this_handle: node@f00 {
3+
compatible = "mydev";
4+
string-prop = start: "hello world!" end: ;
5+
#size-cells = <0+0>;
6+
reg = <0xf00>;
7+
prop = <1>;
8+
prop = <-1e10>;
9+
prop = <(!3)>;
10+
prop = <(~3)>;
11+
prop = <(3*4)>;
12+
prop = <(3&4)>;
13+
prop = <(3*4)>;
14+
prop = <(3/4)>;
15+
prop = <(3%4)>;
16+
prop = <(3+4)>;
17+
prop = <(3-4)>;
18+
prop = /bits/ 64 <(3<<4)>;
19+
prop = <(3>>4)>;
20+
prop = <(3&4)>;
21+
prop = <(3^4)>;
22+
prop = <(3|4)>;
23+
prop = <(3&&4)>;
24+
prop = <(3||4)>;
25+
prop = <(4?5:3)>;
26+
list = <&this_handle>, <0 0 0 0>;
27+
};
28+
29+
&phandle {
30+
pre-phandle = <&this_handle>;
31+
};
32+
};

userdiff.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ IPATTERN("ada",
2323
"[a-zA-Z][a-zA-Z0-9_]*"
2424
"|[-+]?[0-9][0-9#_.aAbBcCdDeEfF]*([eE][+-]?[0-9_]+)?"
2525
"|=>|\\.\\.|\\*\\*|:=|/=|>=|<=|<<|>>|<>"),
26+
PATTERNS("dts",
27+
"!;\n"
28+
/* lines beginning with a word optionally preceded by '&' or the root */
29+
"^[ \t]*((/|&?[a-zA-Z_]).*)",
30+
/* -- */
31+
/* Property names and math operators */
32+
"[a-zA-Z0-9,._+?#-]+"
33+
"|[-+*/%&^|!~]|>>|<<|&&|\\|\\|"),
2634
IPATTERN("fortran",
2735
"!^([C*]|[ \t]*!)\n"
2836
"!^[ \t]*MODULE[ \t]+PROCEDURE[ \t]\n"

0 commit comments

Comments
 (0)