userdiff: Add a builtin pattern for dts files
PATCH v2 1/1 userdiff: Add a builtin pattern for dts files
The Linux kernel receives many patches to the devicetree files each release. The hunk header for those patches typically show nothing, making it difficult to figure out what node is being modified without applying the patch or opening the file and seeking to the context. Let's add a builtin 'dts' pattern to git so that users can get better diff output on dts files when they use the diff=dts driver.
The regex has been constructed based on the spec at devicetree.org[1]
[1] https://github.com/devicetree-org/devicetree-specification/releases/latest
---
Sending this again after getting feedback and it getting stuck in review[1]. I'm not sure what happened with the meta question from Junio to add a way for various projects to introduce their own patterns, but I'd still prefer to have this in git proper because the kernel uses git extensively and we rely on git formatted patches in our workflow. I recently reviewed a dts change and remembered this never got accepted.
Changes from v1:
* Updated regex to handle anything after node names instead of requiring a '{'
* Updated test for boolean relation operators
* Sent out a patch to devicetree spec to document % operator
[1] Feedback was in [email protected]
Documentation/gitattributes.txt | 2 ++ t/t4018-diff-funcname.sh | 1 + t/t4018/dts-labels | 8 +++++++ t/t4018/dts-node-unitless | 8 +++++++ t/t4018/dts-nodes | 8 +++++++ t/t4018/dts-reference | 8 +++++++ t/t4034-diff-words.sh | 1 + t/t4034/dts/expect | 37 +++++++++++++++++++++++++++++++++ t/t4034/dts/post | 32 ++++++++++++++++++++++++++++ t/t4034/dts/pre | 32 ++++++++++++++++++++++++++++ userdiff.c | 9 ++++++++ 11 files changed, 146 insertions(+) create mode 100644 t/t4018/dts-labels create mode 100644 t/t4018/dts-node-unitless create mode 100644 t/t4018/dts-nodes create mode 100644 t/t4018/dts-reference create mode 100644 t/t4034/dts/expect create mode 100644 t/t4034/dts/post create mode 100644 t/t4034/dts/pre
Documentation/gitattributes.txt +2 -0
@@ -810,6 +810,8 @@ patterns are available: - `css` suitable for cascading style sheets. +- `dts` suitable for devicetree (DTS) files. + - `fortran` suitable for source code in the Fortran language. - `fountain` suitable for Fountain documents.
t/t4018-diff-funcname.sh +1 -0
@@ -31,6 +31,7 @@ diffpatterns=" cpp csharp css + dts fortran fountain golang
t/t4018/dts-labels new file +8 -0
@@ -0,0 +1,8 @@ +/ { + label_1: node1@ff00 { + label2: RIGHT { + vendor,some-property; + ChangeMe = <0x45-30>; + }; + }; +};
t/t4018/dts-node-unitless new file +8 -0
@@ -0,0 +1,8 @@ +/ { + label_1: node1 { + RIGHT { + prop-array = <1>, <4>; + ChangeMe = <0xffeedd00>; + }; + }; +};
t/t4018/dts-nodes new file +8 -0
@@ -0,0 +1,8 @@ +/ { + label_1: node1@ff00 { + RIGHT@deadf00,4000 { + #size-cells = <1>; + ChangeMe = <0xffeedd00>; + }; + }; +};
t/t4018/dts-reference new file +8 -0
@@ -0,0 +1,8 @@ +&label_1 { + TEST = <455>; +}; + +&RIGHT { + vendor,some-property; + ChangeMe = <0x45-30>; +};
t/t4034-diff-words.sh +1 -0
@@ -303,6 +303,7 @@ test_language_driver bibtex test_language_driver cpp test_language_driver csharp test_language_driver css +test_language_driver dts test_language_driver fortran test_language_driver html test_language_driver java
t/t4034/dts/expect new file +37 -0
@@ -0,0 +1,37 @@ +<BOLD>diff --git a/pre b/post<RESET> +<BOLD>index b6a9051..7803aee 100644<RESET> +<BOLD>--- a/pre<RESET> +<BOLD>+++ b/post<RESET> +<CYAN>@@ -1,32 +1,32 @@<RESET> +/ {<RESET> + <RED>this_handle<RESET><GREEN>HANDLE_2<RESET>: <RED>node<RESET><GREEN>new-node<RESET>@<RED>f00<RESET><GREEN>eeda<RESET> { + compatible = "<RED>mydev<RESET><GREEN>vendor,compat<RESET>"; + string-prop = <RED>start<RESET><GREEN>end<RESET>: "hello <RED>world!<RESET><GREEN>world?<RESET>" <RED>end<RESET><GREEN>start<RESET>: ; + <RED>#size-cells<RESET><GREEN>#address-cells<RESET> = <<RED>0+0<RESET><GREEN>0+40<RESET>>; + reg = <<RED>0xf00<RESET><GREEN>0xeeda<RESET>>; + prop = <<GREEN>(<RESET>1<GREEN>)<RESET>>; + prop = <<GREEN>(<RESET>-1e10<GREEN>)<RESET>>; + prop = <(!<RED>3<RESET><GREEN>1<RESET>)>; + prop = <(~<RED>3<RESET><GREEN>1<RESET>)>; + prop = <(<RED>3<RESET><GREEN>1<RESET>*<RED>4<RESET><GREEN>2<RESET>)>; + prop = <(<RED>3<RESET><GREEN>1<RESET>&<RED>4<RESET><GREEN>2<RESET>)>; + prop = <(<RED>3<RESET><GREEN>1<RESET>*<RED>4<RESET><GREEN>2<RESET>)>; + prop = <(<RED>3<RESET><GREEN>1<RESET>/<RED>4<RESET><GREEN>2<RESET>)>; + prop = <(<RED>3<RESET><GREEN>1<RESET>%<RED>4<RESET><GREEN>2<RESET>)>; + prop = <(<RED>3+4<RESET><GREEN>1+2<RESET>)>; + prop = <(<RED>3-4<RESET><GREEN>1-2<RESET>)>; + prop = /bits/ <RED>64<RESET><GREEN>32<RESET> <(<RED>3<RESET><GREEN>1<RESET><<<RED>4<RESET><GREEN>2<RESET>)>; + prop = <(<RED>3<RESET><GREEN>1<RESET>>><RED>4<RESET><GREEN>2<RESET>)>; + prop = <(<RED>3<RESET><GREEN>1<RESET>&<RED>4<RESET><GREEN>2<RESET>)>; + prop = <(<RED>3<RESET><GREEN>1<RESET>^<RED>4<RESET><GREEN>2<RESET>)>; + prop = <(<RED>3<RESET><GREEN>1<RESET>|<RED>4<RESET><GREEN>2<RESET>)>; + prop = <(<RED>3<RESET><GREEN>1<RESET>&&<RED>4<RESET><GREEN>2<RESET>)>; + prop = <(<RED>3<RESET><GREEN>1<RESET>||<RED>4<RESET><GREEN>2<RESET>)>; + prop = <(<RED>4?5<RESET><GREEN>1?2<RESET>:3)>; + list = <&<RED>this_handle<RESET><GREEN>HANDLE_2<RESET>>, <0 0 0 <RED>0<RESET><GREEN>1<RESET>>; + };<RESET> + + &<RED>phandle<RESET><GREEN>phandle2<RESET> { + <RED>pre-phandle<RESET><GREEN>prop_handle<RESET> = <&<RED>this_handle<RESET><GREEN>HANDLE_2<RESET>>; + };<RESET> +};<RESET>
t/t4034/dts/post new file +32 -0
@@ -0,0 +1,32 @@ +/ { + HANDLE_2: new-node@eeda { + compatible = "vendor,compat"; + string-prop = end: "hello world?" start: ; + #address-cells = <0+40>; + reg = <0xeeda>; + prop = <(1)>; + prop = <(-1e10)>; + prop = <(!1)>; + prop = <(~1)>; + prop = <(1*2)>; + prop = <(1&2)>; + prop = <(1*2)>; + prop = <(1/2)>; + prop = <(1%2)>; + prop = <(1+2)>; + prop = <(1-2)>; + prop = /bits/ 32 <(1<<2)>; + prop = <(1>>2)>; + prop = <(1&2)>; + prop = <(1^2)>; + prop = <(1|2)>; + prop = <(1&&2)>; + prop = <(1||2)>; + prop = <(1?2:3)>; + list = <&HANDLE_2>, <0 0 0 1>; + }; + + &phandle2 { + prop_handle = <&HANDLE_2>; + }; +};
t/t4034/dts/pre new file +32 -0
@@ -0,0 +1,32 @@ +/ { + this_handle: node@f00 { + compatible = "mydev"; + string-prop = start: "hello world!" end: ; + #size-cells = <0+0>; + reg = <0xf00>; + prop = <1>; + prop = <-1e10>; + prop = <(!3)>; + prop = <(~3)>; + prop = <(3*4)>; + prop = <(3&4)>; + prop = <(3*4)>; + prop = <(3/4)>; + prop = <(3%4)>; + prop = <(3+4)>; + prop = <(3-4)>; + prop = /bits/ 64 <(3<<4)>; + prop = <(3>>4)>; + prop = <(3&4)>; + prop = <(3^4)>; + prop = <(3|4)>; + prop = <(3&&4)>; + prop = <(3||4)>; + prop = <(4?5:3)>; + list = <&this_handle>, <0 0 0 0>; + }; + + &phandle { + pre-phandle = <&this_handle>; + }; +};
userdiff.c +9 -0
@@ -23,6 +23,15 @@ IPATTERN("ada","[a-zA-Z][a-zA-Z0-9_]*" "|[-+]?[0-9][0-9#_.aAbBcCdDeEfF]*([eE][+-]?[0-9_]+)?" "|=>|\\.\\.|\\*\\*|:=|/=|>=|<=|<<|>>|<>"), +PATTERNS ("dts" , +/* Node name with optional label and unit address */ +"^[ \t]*((([a-zA-Z_][a-zA-Z0-9_]*:[ \t]*)?[a-zA-Z][a-zA-Z0-9,._+-]*(@[a-zA-Z0-9,._+-]+)?" +/* Reference */ +"|&[a-zA-Z_][a-zA-Z0-9_]*)[ \t]*[^;]*)$" , +/* -- */ +/* Property names and math operators */ +"[a-zA-Z0-9,._+?#-]+" +"|[-+*/%&^|!~]|>>|<<|&&|\\|\\|" ),IPATTERN ("fortran" ,"!^([C*]|[ \t]*!)\n" "!^[ \t]*MODULE[ \t]+PROCEDURE[ \t]\n"
Signature · 1 line
Sent by a computer through tubes
+Frank (me)
Quoted 283 lines · Stephen Boyd
The Linux kernel receives many patches to the devicetree files each release. The hunk header for those patches typically show nothing, making it difficult to figure out what node is being modified without applying the patch or opening the file and seeking to the context. Let's add a builtin 'dts' pattern to git so that users can get better diff output on dts files when they use the diff=dts driver.
The regex has been constructed based on the spec at devicetree.org[1]
[1] https://github.com/devicetree-org/devicetree-specification/releases/latest
Cc Rob Herring <[email protected]>Signed-off-by Stephen Boyd <[email protected]>---
Sending this again after getting feedback and it getting stuck in review[1]. I'm not sure what happened with the meta question from Junio to add a way for various projects to introduce their own patterns, but I'd still prefer to have this in git proper because the kernel uses git extensively and we rely on git formatted patches in our workflow. I recently reviewed a dts change and remembered this never got accepted.
Changes from v1:
* Updated regex to handle anything after node names instead of requiring a '{'
* Updated test for boolean relation operators
* Sent out a patch to devicetree spec to document % operator[1] Feedback was in [email protected]
Documentation/gitattributes.txt | 2 ++ t/t4018-diff-funcname.sh | 1 + t/t4018/dts-labels | 8 +++++++ t/t4018/dts-node-unitless | 8 +++++++ t/t4018/dts-nodes | 8 +++++++ t/t4018/dts-reference | 8 +++++++ t/t4034-diff-words.sh | 1 + t/t4034/dts/expect | 37 +++++++++++++++++++++++++++++++++ t/t4034/dts/post | 32 ++++++++++++++++++++++++++++ t/t4034/dts/pre | 32 ++++++++++++++++++++++++++++ userdiff.c | 9 ++++++++ 11 files changed, 146 insertions(+) create mode 100644 t/t4018/dts-labels create mode 100644 t/t4018/dts-node-unitless create mode 100644 t/t4018/dts-nodes create mode 100644 t/t4018/dts-reference create mode 100644 t/t4034/dts/expect create mode 100644 t/t4034/dts/post create mode 100644 t/t4034/dts/preDocumentation/gitattributes.txt +2
-0@@ -810,6 +810,8 @@ patterns are available: - `css` suitable for cascading style sheets. +- `dts` suitable for devicetree (DTS) files. + - `fortran` suitable for source code in the Fortran language. - `fountain` suitable for Fountain documents.t/t4018-diff-funcname.sh +1
-0@@ -31,6 +31,7 @@ diffpatterns=" cpp csharp css + dts fortran fountain golangt/t4018/dts-labels new file +8
-0@@ -0,0 +1,8 @@ +/ { + label_1: node1@ff00 { + label2: RIGHT { + vendor,some-property; + ChangeMe = <0x45-30>; + }; + }; +};t/t4018/dts-node-unitless new file +8
-0@@ -0,0 +1,8 @@ +/ { + label_1: node1 { + RIGHT { + prop-array = <1>, <4>; + ChangeMe = <0xffeedd00>; + }; + }; +};t/t4018/dts-nodes new file +8
-0@@ -0,0 +1,8 @@ +/ { + label_1: node1@ff00 { + RIGHT@deadf00,4000 { + #size-cells = <1>; + ChangeMe = <0xffeedd00>; + }; + }; +};t/t4018/dts-reference new file +8
-0@@ -0,0 +1,8 @@ +&label_1 { + TEST = <455>; +}; + +&RIGHT { + vendor,some-property; + ChangeMe = <0x45-30>; +};t/t4034-diff-words.sh +1
-0@@ -303,6 +303,7 @@ test_language_driver bibtex test_language_driver cpp test_language_driver csharp test_language_driver css +test_language_driver dts test_language_driver fortran test_language_driver html test_language_driver javat/t4034/dts/expect new file +37
-0@@ -0,0 +1,37 @@ +<BOLD>diff --git a/pre b/post<RESET> +<BOLD>index b6a9051..7803aee 100644<RESET> +<BOLD>--- a/pre<RESET> +<BOLD>+++ b/post<RESET> +<CYAN>@@ -1,32 +1,32 @@<RESET> +/ {<RESET> + <RED>this_handle<RESET><GREEN>HANDLE_2<RESET>: <RED>node<RESET><GREEN>new-node<RESET>@<RED>f00<RESET><GREEN>eeda<RESET> { + compatible = "<RED>mydev<RESET><GREEN>vendor,compat<RESET>"; + string-prop = <RED>start<RESET><GREEN>end<RESET>: "hello <RED>world!<RESET><GREEN>world?<RESET>" <RED>end<RESET><GREEN>start<RESET>: ; + <RED>#size-cells<RESET><GREEN>#address-cells<RESET> = <<RED>0+0<RESET><GREEN>0+40<RESET>>; + reg = <<RED>0xf00<RESET><GREEN>0xeeda<RESET>>; + prop = <<GREEN>(<RESET>1<GREEN>)<RESET>>; + prop = <<GREEN>(<RESET>-1e10<GREEN>)<RESET>>; + prop = <(!<RED>3<RESET><GREEN>1<RESET>)>; + prop = <(~<RED>3<RESET><GREEN>1<RESET>)>; + prop = <(<RED>3<RESET><GREEN>1<RESET>*<RED>4<RESET><GREEN>2<RESET>)>; + prop = <(<RED>3<RESET><GREEN>1<RESET>&<RED>4<RESET><GREEN>2<RESET>)>; + prop = <(<RED>3<RESET><GREEN>1<RESET>*<RED>4<RESET><GREEN>2<RESET>)>; + prop = <(<RED>3<RESET><GREEN>1<RESET>/<RED>4<RESET><GREEN>2<RESET>)>; + prop = <(<RED>3<RESET><GREEN>1<RESET>%<RED>4<RESET><GREEN>2<RESET>)>; + prop = <(<RED>3+4<RESET><GREEN>1+2<RESET>)>; + prop = <(<RED>3-4<RESET><GREEN>1-2<RESET>)>; + prop = /bits/ <RED>64<RESET><GREEN>32<RESET> <(<RED>3<RESET><GREEN>1<RESET><<<RED>4<RESET><GREEN>2<RESET>)>; + prop = <(<RED>3<RESET><GREEN>1<RESET>>><RED>4<RESET><GREEN>2<RESET>)>; + prop = <(<RED>3<RESET><GREEN>1<RESET>&<RED>4<RESET><GREEN>2<RESET>)>; + prop = <(<RED>3<RESET><GREEN>1<RESET>^<RED>4<RESET><GREEN>2<RESET>)>; + prop = <(<RED>3<RESET><GREEN>1<RESET>|<RED>4<RESET><GREEN>2<RESET>)>; + prop = <(<RED>3<RESET><GREEN>1<RESET>&&<RED>4<RESET><GREEN>2<RESET>)>; + prop = <(<RED>3<RESET><GREEN>1<RESET>||<RED>4<RESET><GREEN>2<RESET>)>; + prop = <(<RED>4?5<RESET><GREEN>1?2<RESET>:3)>; + list = <&<RED>this_handle<RESET><GREEN>HANDLE_2<RESET>>, <0 0 0 <RED>0<RESET><GREEN>1<RESET>>; + };<RESET> + + &<RED>phandle<RESET><GREEN>phandle2<RESET> { + <RED>pre-phandle<RESET><GREEN>prop_handle<RESET> = <&<RED>this_handle<RESET><GREEN>HANDLE_2<RESET>>; + };<RESET> +};<RESET>t/t4034/dts/post new file +32
-0@@ -0,0 +1,32 @@ +/ { + HANDLE_2: new-node@eeda { + compatible = "vendor,compat"; + string-prop = end: "hello world?" start: ; + #address-cells = <0+40>; + reg = <0xeeda>; + prop = <(1)>; + prop = <(-1e10)>; + prop = <(!1)>; + prop = <(~1)>; + prop = <(1*2)>; + prop = <(1&2)>; + prop = <(1*2)>; + prop = <(1/2)>; + prop = <(1%2)>; + prop = <(1+2)>; + prop = <(1-2)>; + prop = /bits/ 32 <(1<<2)>; + prop = <(1>>2)>; + prop = <(1&2)>; + prop = <(1^2)>; + prop = <(1|2)>; + prop = <(1&&2)>; + prop = <(1||2)>; + prop = <(1?2:3)>; + list = <&HANDLE_2>, <0 0 0 1>; + }; + + &phandle2 { + prop_handle = <&HANDLE_2>; + }; +};t/t4034/dts/pre new file +32
-0@@ -0,0 +1,32 @@ +/ { + this_handle: node@f00 { + compatible = "mydev"; + string-prop = start: "hello world!" end: ; + #size-cells = <0+0>; + reg = <0xf00>; + prop = <1>; + prop = <-1e10>; + prop = <(!3)>; + prop = <(~3)>; + prop = <(3*4)>; + prop = <(3&4)>; + prop = <(3*4)>; + prop = <(3/4)>; + prop = <(3%4)>; + prop = <(3+4)>; + prop = <(3-4)>; + prop = /bits/ 64 <(3<<4)>; + prop = <(3>>4)>; + prop = <(3&4)>; + prop = <(3^4)>; + prop = <(3|4)>; + prop = <(3&&4)>; + prop = <(3||4)>; + prop = <(4?5:3)>; + list = <&this_handle>, <0 0 0 0>; + }; + + &phandle { + pre-phandle = <&this_handle>; + }; +};userdiff.c +9
-0@@ -23,6 +23,15 @@ IPATTERN("ada","[a-zA-Z][a-zA-Z0-9_]*" "|[-+]?[0-9][0-9#_.aAbBcCdDeEfF]*([eE][+-]?[0-9_]+)?" "|=>|\\.\\.|\\*\\*|:=|/=|>=|<=|<<|>>|<>"), +PATTERNS ("dts" , +/* Node name with optional label and unit address */ +"^[ \t]*((([a-zA-Z_][a-zA-Z0-9_]*:[ \t]*)?[a-zA-Z][a-zA-Z0-9,._+-]*(@[a-zA-Z0-9,._+-]+)?" +/* Reference */ +"|&[a-zA-Z_][a-zA-Z0-9_]*)[ \t]*[^;]*)$" , +/* -- */ +/* Property names and math operators */ +"[a-zA-Z0-9,._+?#-]+" +"|[-+*/%&^|!~]|>>|<<|&&|\\|\\|" ),IPATTERN ("fortran" ,"!^([C*]|[ \t]*!)\n" "!^[ \t]*MODULE[ \t]+PROCEDURE[ \t]\n"
Hi Stephen,
Le 17/08/2019 à 00:56, Stephen Boyd a écrit :
Quoted 11 lines
The Linux kernel receives many patches to the devicetree files each release. The hunk header for those patches typically show nothing, making it difficult to figure out what node is being modified without applying the patch or opening the file and seeking to the context. Let's add a builtin 'dts' pattern to git so that users can get better diff output on dts files when they use the diff=dts driver.
The regex has been constructed based on the spec at devicetree.org[1]
[1] https://github.com/devicetree-org/devicetree-specification/releases/latest
Quoted 7 lines
Cc Rob Herring <[email protected]>Signed-off-by Stephen Boyd <[email protected]>---
Sending this again after getting feedback and it getting stuck in review[1]. I'm not sure what happened with the meta question from Junio to add a way for various projects to introduce their own patterns,
Nothing happened, AFAIK.
Quoted 11 lines
but
I'd still prefer to have this in git proper because the kernel uses git extensively and we rely on git formatted patches in our workflow. I recently reviewed a dts change and remembered this never got accepted.Changes from v1:
* Updated regex to handle anything after node names instead of requiring a '{'
* Updated test for boolean relation operators
* Sent out a patch to devicetree spec to document % operator
Quoted 3 lines
[1] Feedback was in [email protected]
-%<-
This looks good to me.
Cheers,
Alban
Am 17.08.19 um 00:56 schrieb Stephen Boyd:
Quoted 22 lines
The Linux kernel receives many patches to the devicetree files each release. The hunk header for those patches typically show nothing, making it difficult to figure out what node is being modified without applying the patch or opening the file and seeking to the context. Let's add a builtin 'dts' pattern to git so that users can get better diff output on dts files when they use the diff=dts driver.
The regex has been constructed based on the spec at devicetree.org[1]
[1] https://github.com/devicetree-org/devicetree-specification/releases/latest
Cc Rob Herring <[email protected]>Signed-off-by Stephen Boyd <[email protected]>---
Sending this again after getting feedback and it getting stuck in review[1]. I'm not sure what happened with the meta question from Junio to add a way for various projects to introduce their own patterns, but I'd still prefer to have this in git proper because the kernel uses git extensively and we rely on git formatted patches in our workflow. I recently reviewed a dts change and remembered this never got accepted.
Quoted 7 lines
Changes from v1:
* Updated regex to handle anything after node names instead of requiring a '{'
* Updated test for boolean relation operators
* Sent out a patch to devicetree spec to document % operator[1] Feedback was in [email protected]
Thanks. I've a few suggestions below.
t/t4018/dts-labels line 5
Quoted 11 lines
t/t4018/dts-labels new file +5
-0@@ -0,0 +1,8 @@ +/ { + label_1: node1@ff00 { + label2: RIGHT { + vendor,some-property; + ChangeMe = <0x45-30>;
In these tests, it would be worthwhile to leave another (possibly blank) line before the ChangeMe line in order to demonstrate that lines beginning with a word, such as the 'vendor,some-property;' line, are _not_ picked up when they are not in the hunk context.
Quoted 188 lines
t/t4018/dts-labels new file +3
-0+ }; + }; +};t/t4018/dts-node-unitless new file +8
-0@@ -0,0 +1,8 @@ +/ { + label_1: node1 { + RIGHT { + prop-array = <1>, <4>; + ChangeMe = <0xffeedd00>; + }; + }; +};t/t4018/dts-nodes new file +8
-0@@ -0,0 +1,8 @@ +/ { + label_1: node1@ff00 { + RIGHT@deadf00,4000 { + #size-cells = <1>; + ChangeMe = <0xffeedd00>; + }; + }; +};t/t4018/dts-reference new file +8
-0@@ -0,0 +1,8 @@ +&label_1 { + TEST = <455>; +}; + +&RIGHT { + vendor,some-property; + ChangeMe = <0x45-30>; +};t/t4034-diff-words.sh +1
-0@@ -303,6 +303,7 @@ test_language_driver bibtex test_language_driver cpp test_language_driver csharp test_language_driver css +test_language_driver dts test_language_driver fortran test_language_driver html test_language_driver javat/t4034/dts/expect new file +37
-0@@ -0,0 +1,37 @@ +<BOLD>diff --git a/pre b/post<RESET> +<BOLD>index b6a9051..7803aee 100644<RESET> +<BOLD>--- a/pre<RESET> +<BOLD>+++ b/post<RESET> +<CYAN>@@ -1,32 +1,32 @@<RESET> +/ {<RESET> + <RED>this_handle<RESET><GREEN>HANDLE_2<RESET>: <RED>node<RESET><GREEN>new-node<RESET>@<RED>f00<RESET><GREEN>eeda<RESET> { + compatible = "<RED>mydev<RESET><GREEN>vendor,compat<RESET>"; + string-prop = <RED>start<RESET><GREEN>end<RESET>: "hello <RED>world!<RESET><GREEN>world?<RESET>" <RED>end<RESET><GREEN>start<RESET>: ; + <RED>#size-cells<RESET><GREEN>#address-cells<RESET> = <<RED>0+0<RESET><GREEN>0+40<RESET>>; + reg = <<RED>0xf00<RESET><GREEN>0xeeda<RESET>>; + prop = <<GREEN>(<RESET>1<GREEN>)<RESET>>; + prop = <<GREEN>(<RESET>-1e10<GREEN>)<RESET>>; + prop = <(!<RED>3<RESET><GREEN>1<RESET>)>; + prop = <(~<RED>3<RESET><GREEN>1<RESET>)>; + prop = <(<RED>3<RESET><GREEN>1<RESET>*<RED>4<RESET><GREEN>2<RESET>)>; + prop = <(<RED>3<RESET><GREEN>1<RESET>&<RED>4<RESET><GREEN>2<RESET>)>; + prop = <(<RED>3<RESET><GREEN>1<RESET>*<RED>4<RESET><GREEN>2<RESET>)>; + prop = <(<RED>3<RESET><GREEN>1<RESET>/<RED>4<RESET><GREEN>2<RESET>)>; + prop = <(<RED>3<RESET><GREEN>1<RESET>%<RED>4<RESET><GREEN>2<RESET>)>; + prop = <(<RED>3+4<RESET><GREEN>1+2<RESET>)>; + prop = <(<RED>3-4<RESET><GREEN>1-2<RESET>)>; + prop = /bits/ <RED>64<RESET><GREEN>32<RESET> <(<RED>3<RESET><GREEN>1<RESET><<<RED>4<RESET><GREEN>2<RESET>)>; + prop = <(<RED>3<RESET><GREEN>1<RESET>>><RED>4<RESET><GREEN>2<RESET>)>; + prop = <(<RED>3<RESET><GREEN>1<RESET>&<RED>4<RESET><GREEN>2<RESET>)>; + prop = <(<RED>3<RESET><GREEN>1<RESET>^<RED>4<RESET><GREEN>2<RESET>)>; + prop = <(<RED>3<RESET><GREEN>1<RESET>|<RED>4<RESET><GREEN>2<RESET>)>; + prop = <(<RED>3<RESET><GREEN>1<RESET>&&<RED>4<RESET><GREEN>2<RESET>)>; + prop = <(<RED>3<RESET><GREEN>1<RESET>||<RED>4<RESET><GREEN>2<RESET>)>; + prop = <(<RED>4?5<RESET><GREEN>1?2<RESET>:3)>; + list = <&<RED>this_handle<RESET><GREEN>HANDLE_2<RESET>>, <0 0 0 <RED>0<RESET><GREEN>1<RESET>>; + };<RESET> + + &<RED>phandle<RESET><GREEN>phandle2<RESET> { + <RED>pre-phandle<RESET><GREEN>prop_handle<RESET> = <&<RED>this_handle<RESET><GREEN>HANDLE_2<RESET>>; + };<RESET> +};<RESET>t/t4034/dts/post new file +32
-0@@ -0,0 +1,32 @@ +/ { + HANDLE_2: new-node@eeda { + compatible = "vendor,compat"; + string-prop = end: "hello world?" start: ; + #address-cells = <0+40>; + reg = <0xeeda>; + prop = <(1)>; + prop = <(-1e10)>; + prop = <(!1)>; + prop = <(~1)>; + prop = <(1*2)>; + prop = <(1&2)>; + prop = <(1*2)>; + prop = <(1/2)>; + prop = <(1%2)>; + prop = <(1+2)>; + prop = <(1-2)>; + prop = /bits/ 32 <(1<<2)>; + prop = <(1>>2)>; + prop = <(1&2)>; + prop = <(1^2)>; + prop = <(1|2)>; + prop = <(1&&2)>; + prop = <(1||2)>; + prop = <(1?2:3)>; + list = <&HANDLE_2>, <0 0 0 1>; + }; + + &phandle2 { + prop_handle = <&HANDLE_2>; + }; +};t/t4034/dts/pre new file +32
-0@@ -0,0 +1,32 @@ +/ { + this_handle: node@f00 { + compatible = "mydev"; + string-prop = start: "hello world!" end: ; + #size-cells = <0+0>; + reg = <0xf00>; + prop = <1>; + prop = <-1e10>; + prop = <(!3)>; + prop = <(~3)>; + prop = <(3*4)>; + prop = <(3&4)>; + prop = <(3*4)>; + prop = <(3/4)>; + prop = <(3%4)>; + prop = <(3+4)>; + prop = <(3-4)>; + prop = /bits/ 64 <(3<<4)>; + prop = <(3>>4)>; + prop = <(3&4)>; + prop = <(3^4)>; + prop = <(3|4)>; + prop = <(3&&4)>; + prop = <(3||4)>; + prop = <(4?5:3)>; + list = <&this_handle>, <0 0 0 0>; + }; + + &phandle { + pre-phandle = <&this_handle>; + }; +};userdiff.c +3
-0@@ -23,6 +23,15 @@ IPATTERN("ada","[a-zA-Z][a-zA-Z0-9_]*" "|[-+]?[0-9][0-9#_.aAbBcCdDeEfF]*([eE][+-]?[0-9_]+)?" "|=>|\\.\\.|\\*\\*|:=|/=|>=|<=|<<|>>|<>"), +PATTERNS ("dts" , +/* Node name with optional label and unit address */ + "^[ \t]*((([a-zA-Z_][a-zA-Z0-9_]*:[ \t]*)?[a-zA-Z][a-zA-Z0-9,._+-]*(@[a-zA-Z0-9,._+-]+)?"
Quoted 1 line
From the examples I see in this patch, it looks like lines ending in a
';' are not candidates, everything that begins with 'word' or '&word' is. Wouldn't that greatly simplify these patterns?
"!;\n" /* lines beginning with a word optionally preceded by '&' */ "^[ \t]*(&?([a-zA-Z_].*)"
userdiff.c IPATTERN("ada", · line 30
Quoted 2 lines
userdiff.c +2
-0+/* Reference */ + "|&[a-zA-Z_][a-zA-Z0-9_]*)[ \t]*[^;]*)$",
Note that you don't have to replicate the syntax faithfully in the patterns because you can assume that files adhere to the correct syntax. You could merge this into the former pattern by just matching "&?" after the initial whitespace.
userdiff.c IPATTERN("ada", · line 37
Quoted 8 lines
userdiff.c +4
-0+/* -- */ +/* Property names and math operators */ +"[a-zA-Z0-9,._+?#-]+" + "|[-+*/%&^|!~]|>>|<<|&&|\\|\\|"),IPATTERN ("fortran" ,"!^([C*]|[ \t]*!)\n" "!^[ \t]*MODULE[ \t]+PROCEDURE[ \t]\n"
-- Hannes
Quoting Johannes Sixt (2019-08-19 11:40:47)
Quoted 33 lines
Am 17.08.19 um 00:56 schrieb Stephen Boyd:
Quoted 22 lines
The Linux kernel receives many patches to the devicetree files each release. The hunk header for those patches typically show nothing, making it difficult to figure out what node is being modified without applying the patch or opening the file and seeking to the context. Let's add a builtin 'dts' pattern to git so that users can get better diff output on dts files when they use the diff=dts driver.
The regex has been constructed based on the spec at devicetree.org[1]
[1] https://github.com/devicetree-org/devicetree-specification/releases/latest
Cc Rob Herring <[email protected]>Signed-off-by Stephen Boyd <[email protected]>---
Sending this again after getting feedback and it getting stuck in review[1]. I'm not sure what happened with the meta question from Junio to add a way for various projects to introduce their own patterns, but I'd still prefer to have this in git proper because the kernel uses git extensively and we rely on git formatted patches in our workflow. I recently reviewed a dts change and remembered this never got accepted.
Quoted 7 lines
Changes from v1:
* Updated regex to handle anything after node names instead of requiring a '{'
* Updated test for boolean relation operators
* Sent out a patch to devicetree spec to document % operator[1] Feedback was in [email protected]
Thanks. I've a few suggestions below.
Quoted 16 lines
t/t4018/dts-labels line 5
Quoted 11 lines
t/t4018/dts-labels new file +5
-0@@ -0,0 +1,8 @@ +/ { + label_1: node1@ff00 { + label2: RIGHT { + vendor,some-property; + ChangeMe = <0x45-30>;In these tests, it would be worthwhile to leave another (possibly blank) line before the ChangeMe line in order to demonstrate that lines beginning with a word, such as the 'vendor,some-property;' line, are _not_ picked up when they are not in the hunk context.
Sure. I can add a blank line. Did you want it on all the tests or just some of them?
Quoted 16 lines
userdiff.c IPATTERN("ada", · line 28
Quoted 11 lines
userdiff.c +3
-0@@ -23,6 +23,15 @@ IPATTERN("ada","[a-zA-Z][a-zA-Z0-9_]*" "|[-+]?[0-9][0-9#_.aAbBcCdDeEfF]*([eE][+-]?[0-9_]+)?" "|=>|\\.\\.|\\*\\*|:=|/=|>=|<=|<<|>>|<>"), +PATTERNS ("dts" , +/* Node name with optional label and unit address */ + "^[ \t]*((([a-zA-Z_][a-zA-Z0-9_]*:[ \t]*)?[a-zA-Z][a-zA-Z0-9,._+-]*(@[a-zA-Z0-9,._+-]+)?"From the examples I see in this patch, it looks like lines ending in a ';' are not candidates, everything that begins with 'word' or '&word' is. Wouldn't that greatly simplify these patterns?
Quoted 3 lines
"!;\n"
/* lines beginning with a word optionally preceded by '&' */
"^[ \t]*(&?([a-zA-Z_].*)"Right. I was stuck with my old regex ways where it wasn't considering lines that didn't end in a semicolon. This looks like it will work.
Quoted 8 lines
userdiff.c IPATTERN("ada", · line 30
Quoted 3 lines
userdiff.c +2
-0+/* Reference */ + "|&[a-zA-Z_][a-zA-Z0-9_]*)[ \t]*[^;]*)$",Note that you don't have to replicate the syntax faithfully in the patterns because you can assume that files adhere to the correct syntax. You could merge this into the former pattern by just matching "&?" after the initial whitespace.
Ok. Thanks for simplifying by providing the regex above. I'll rework and resend.
Am 19.08.19 um 22:44 schrieb Stephen Boyd:
Quoted 19 lines
Quoting Johannes Sixt (2019-08-19 11:40:47)
Quoted 17 lines
Am 17.08.19 um 00:56 schrieb Stephen Boyd:
t/t4018/dts-labels line 5
Quoted 11 lines
t/t4018/dts-labels new file +5
-0@@ -0,0 +1,8 @@ +/ { + label_1: node1@ff00 { + label2: RIGHT { + vendor,some-property; + ChangeMe = <0x45-30>;In these tests, it would be worthwhile to leave another (possibly blank) line before the ChangeMe line in order to demonstrate that lines beginning with a word, such as the 'vendor,some-property;' line, are _not_ picked up when they are not in the hunk context.
Quoted 2 lines
Sure. I can add a blank line. Did you want it on all the tests or just some of them?
Some of them. We should have cases that show that "vendor,some-property;" and "prop-erty = value;" are not picked up.
-- Hannes