{"thread":{"id":"51656","subject":"[PATCH v2] userdiff: Add a builtin pattern for dts files","startedAt":"2019-08-16T23:06:36Z","lastAt":"2019-08-19T21:35:43Z","messageCount":6,"participants":["Stephen Boyd","Frank Rowand","Alban Gruin","Johannes Sixt"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"380567","messageId":"20190816225658.8946-1-sboyd@kernel.org","threadId":"51656","inReplyTo":null,"subject":"[PATCH v2] userdiff: Add a builtin pattern for dts files","fromName":"Stephen Boyd","fromEmail":"sboyd@kernel.org","sentAt":"2019-08-16T22:56:58Z","receivedAt":"2019-08-16T23:06:36Z","isPatch":true,"sender":{"key":"sboyd@kernel.org","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"The Linux kernel receives many patches to the devicetree files each\nrelease. The hunk header for those patches typically show nothing,\nmaking it difficult to figure out what node is being modified without\napplying the patch or opening the file and seeking to the context. Let's\nadd a builtin 'dts' pattern to git so that users can get better diff\noutput on dts files when they use the diff=dts driver.\n\nThe regex has been constructed based on the spec at devicetree.org[1]\n\n[1] https://github.com/devicetree-org/devicetree-specification/releases/latest\n\nCc: Rob Herring <robh+dt@kernel.org>\nSigned-off-by: Stephen Boyd <sboyd@kernel.org>\n---\n\nSending this again after getting feedback and it getting stuck in\nreview[1]. I'm not sure what happened with the meta question from Junio\nto add a way for various projects to introduce their own patterns, but\nI'd still prefer to have this in git proper because the kernel uses git\nextensively and we rely on git formatted patches in our workflow. I\nrecently reviewed a dts change and remembered this never got accepted.\n\nChanges from v1:\n * Updated regex to handle anything after node names instead of\n   requiring a '{'\n * Updated test for boolean relation operators\n * Sent out a patch to devicetree spec to document % operator\n\n[1] Feedback was in 16335abe-5e7e-fd7a-25f4-373f94e176e1@gmail.com\n\n Documentation/gitattributes.txt |  2 ++\n t/t4018-diff-funcname.sh        |  1 +\n t/t4018/dts-labels              |  8 +++++++\n t/t4018/dts-node-unitless       |  8 +++++++\n t/t4018/dts-nodes               |  8 +++++++\n t/t4018/dts-reference           |  8 +++++++\n t/t4034-diff-words.sh           |  1 +\n t/t4034/dts/expect              | 37 +++++++++++++++++++++++++++++++++\n t/t4034/dts/post                | 32 ++++++++++++++++++++++++++++\n t/t4034/dts/pre                 | 32 ++++++++++++++++++++++++++++\n userdiff.c                      |  9 ++++++++\n 11 files changed, 146 insertions(+)\n create mode 100644 t/t4018/dts-labels\n create mode 100644 t/t4018/dts-node-unitless\n create mode 100644 t/t4018/dts-nodes\n create mode 100644 t/t4018/dts-reference\n create mode 100644 t/t4034/dts/expect\n create mode 100644 t/t4034/dts/post\n create mode 100644 t/t4034/dts/pre\n\ndiff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt\nindex fb1d188d440c..c5a528c667b6 100644\n--- a/Documentation/gitattributes.txt\n+++ b/Documentation/gitattributes.txt\n@@ -810,6 +810,8 @@ patterns are available:\n \n - `css` suitable for cascading style sheets.\n \n+- `dts` suitable for devicetree (DTS) files.\n+\n - `fortran` suitable for source code in the Fortran language.\n \n - `fountain` suitable for Fountain documents.\ndiff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh\nindex 9261d6d3a000..6f5ef0035e92 100755\n--- a/t/t4018-diff-funcname.sh\n+++ b/t/t4018-diff-funcname.sh\n@@ -31,6 +31,7 @@ diffpatterns=\"\n \tcpp\n \tcsharp\n \tcss\n+\tdts\n \tfortran\n \tfountain\n \tgolang\ndiff --git a/t/t4018/dts-labels b/t/t4018/dts-labels\nnew file mode 100644\nindex 000000000000..27cd4921cfb6\n--- /dev/null\n+++ b/t/t4018/dts-labels\n@@ -0,0 +1,8 @@\n+/ {\n+\tlabel_1: node1@ff00 {\n+\t\tlabel2: RIGHT {\n+\t\t\tvendor,some-property;\n+\t\t\tChangeMe = <0x45-30>;\n+\t\t};\n+\t};\n+};\ndiff --git a/t/t4018/dts-node-unitless b/t/t4018/dts-node-unitless\nnew file mode 100644\nindex 000000000000..c5287d91416e\n--- /dev/null\n+++ b/t/t4018/dts-node-unitless\n@@ -0,0 +1,8 @@\n+/ {\n+\tlabel_1: node1 {\n+\t\tRIGHT {\n+\t\t\tprop-array = <1>, <4>;\n+\t\t\tChangeMe = <0xffeedd00>;\n+\t\t};\n+\t};\n+};\ndiff --git a/t/t4018/dts-nodes b/t/t4018/dts-nodes\nnew file mode 100644\nindex 000000000000..5a4334bb1645\n--- /dev/null\n+++ b/t/t4018/dts-nodes\n@@ -0,0 +1,8 @@\n+/ {\n+\tlabel_1: node1@ff00 {\n+\t\tRIGHT@deadf00,4000 {\n+\t\t\t#size-cells = <1>;\n+\t\t\tChangeMe = <0xffeedd00>;\n+\t\t};\n+\t};\n+};\ndiff --git a/t/t4018/dts-reference b/t/t4018/dts-reference\nnew file mode 100644\nindex 000000000000..f115d4291d25\n--- /dev/null\n+++ b/t/t4018/dts-reference\n@@ -0,0 +1,8 @@\n+&label_1 {\n+\tTEST = <455>;\n+};\n+\n+&RIGHT {\n+\tvendor,some-property;\n+\tChangeMe = <0x45-30>;\n+};\ndiff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh\nindex 912df91226f2..9a93c2a3e0dd 100755\n--- a/t/t4034-diff-words.sh\n+++ b/t/t4034-diff-words.sh\n@@ -303,6 +303,7 @@ test_language_driver bibtex\n test_language_driver cpp\n test_language_driver csharp\n test_language_driver css\n+test_language_driver dts\n test_language_driver fortran\n test_language_driver html\n test_language_driver java\ndiff --git a/t/t4034/dts/expect b/t/t4034/dts/expect\nnew file mode 100644\nindex 000000000000..560fc9918476\n--- /dev/null\n+++ b/t/t4034/dts/expect\n@@ -0,0 +1,37 @@\n+<BOLD>diff --git a/pre b/post<RESET>\n+<BOLD>index b6a9051..7803aee 100644<RESET>\n+<BOLD>--- a/pre<RESET>\n+<BOLD>+++ b/post<RESET>\n+<CYAN>@@ -1,32 +1,32 @@<RESET>\n+/ {<RESET>\n+\t<RED>this_handle<RESET><GREEN>HANDLE_2<RESET>: <RED>node<RESET><GREEN>new-node<RESET>@<RED>f00<RESET><GREEN>eeda<RESET> {\n+\t\tcompatible = \"<RED>mydev<RESET><GREEN>vendor,compat<RESET>\";\n+\t\tstring-prop = <RED>start<RESET><GREEN>end<RESET>: \"hello <RED>world!<RESET><GREEN>world?<RESET>\" <RED>end<RESET><GREEN>start<RESET>: ;\n+\t\t<RED>#size-cells<RESET><GREEN>#address-cells<RESET> = <<RED>0+0<RESET><GREEN>0+40<RESET>>;\n+\t\treg = <<RED>0xf00<RESET><GREEN>0xeeda<RESET>>;\n+\t\tprop = <<GREEN>(<RESET>1<GREEN>)<RESET>>;\n+\t\tprop = <<GREEN>(<RESET>-1e10<GREEN>)<RESET>>;\n+\t\tprop = <(!<RED>3<RESET><GREEN>1<RESET>)>;\n+\t\tprop = <(~<RED>3<RESET><GREEN>1<RESET>)>;\n+\t\tprop = <(<RED>3<RESET><GREEN>1<RESET>*<RED>4<RESET><GREEN>2<RESET>)>;\n+\t\tprop = <(<RED>3<RESET><GREEN>1<RESET>&<RED>4<RESET><GREEN>2<RESET>)>;\n+\t\tprop = <(<RED>3<RESET><GREEN>1<RESET>*<RED>4<RESET><GREEN>2<RESET>)>;\n+\t\tprop = <(<RED>3<RESET><GREEN>1<RESET>/<RED>4<RESET><GREEN>2<RESET>)>;\n+\t\tprop = <(<RED>3<RESET><GREEN>1<RESET>%<RED>4<RESET><GREEN>2<RESET>)>;\n+\t\tprop = <(<RED>3+4<RESET><GREEN>1+2<RESET>)>;\n+\t\tprop = <(<RED>3-4<RESET><GREEN>1-2<RESET>)>;\n+\t\tprop = /bits/ <RED>64<RESET><GREEN>32<RESET> <(<RED>3<RESET><GREEN>1<RESET><<<RED>4<RESET><GREEN>2<RESET>)>;\n+\t\tprop = <(<RED>3<RESET><GREEN>1<RESET>>><RED>4<RESET><GREEN>2<RESET>)>;\n+\t\tprop = <(<RED>3<RESET><GREEN>1<RESET>&<RED>4<RESET><GREEN>2<RESET>)>;\n+\t\tprop = <(<RED>3<RESET><GREEN>1<RESET>^<RED>4<RESET><GREEN>2<RESET>)>;\n+\t\tprop = <(<RED>3<RESET><GREEN>1<RESET>|<RED>4<RESET><GREEN>2<RESET>)>;\n+\t\tprop = <(<RED>3<RESET><GREEN>1<RESET>&&<RED>4<RESET><GREEN>2<RESET>)>;\n+\t\tprop = <(<RED>3<RESET><GREEN>1<RESET>||<RED>4<RESET><GREEN>2<RESET>)>;\n+\t\tprop = <(<RED>4?5<RESET><GREEN>1?2<RESET>:3)>;\n+\t\tlist = <&<RED>this_handle<RESET><GREEN>HANDLE_2<RESET>>, <0 0 0 <RED>0<RESET><GREEN>1<RESET>>;\n+\t};<RESET>\n+\n+\t&<RED>phandle<RESET><GREEN>phandle2<RESET> {\n+\t\t<RED>pre-phandle<RESET><GREEN>prop_handle<RESET> = <&<RED>this_handle<RESET><GREEN>HANDLE_2<RESET>>;\n+\t};<RESET>\n+};<RESET>\ndiff --git a/t/t4034/dts/post b/t/t4034/dts/post\nnew file mode 100644\nindex 000000000000..7803aee28093\n--- /dev/null\n+++ b/t/t4034/dts/post\n@@ -0,0 +1,32 @@\n+/ {\n+\tHANDLE_2: new-node@eeda {\n+\t\tcompatible = \"vendor,compat\";\n+\t\tstring-prop = end: \"hello world?\" start: ;\n+\t\t#address-cells = <0+40>;\n+\t\treg = <0xeeda>;\n+\t\tprop = <(1)>;\n+\t\tprop = <(-1e10)>;\n+\t\tprop = <(!1)>;\n+\t\tprop = <(~1)>;\n+\t\tprop = <(1*2)>;\n+\t\tprop = <(1&2)>;\n+\t\tprop = <(1*2)>;\n+\t\tprop = <(1/2)>;\n+\t\tprop = <(1%2)>;\n+\t\tprop = <(1+2)>;\n+\t\tprop = <(1-2)>;\n+\t\tprop = /bits/ 32 <(1<<2)>;\n+\t\tprop = <(1>>2)>;\n+\t\tprop = <(1&2)>;\n+\t\tprop = <(1^2)>;\n+\t\tprop = <(1|2)>;\n+\t\tprop = <(1&&2)>;\n+\t\tprop = <(1||2)>;\n+\t\tprop = <(1?2:3)>;\n+\t\tlist = <&HANDLE_2>, <0 0 0 1>;\n+\t};\n+\n+\t&phandle2 {\n+\t\tprop_handle = <&HANDLE_2>;\n+\t};\n+};\ndiff --git a/t/t4034/dts/pre b/t/t4034/dts/pre\nnew file mode 100644\nindex 000000000000..b6a905113c22\n--- /dev/null\n+++ b/t/t4034/dts/pre\n@@ -0,0 +1,32 @@\n+/ {\n+\tthis_handle: node@f00 {\n+\t\tcompatible = \"mydev\";\n+\t\tstring-prop = start: \"hello world!\" end: ;\n+\t\t#size-cells = <0+0>;\n+\t\treg = <0xf00>;\n+\t\tprop = <1>;\n+\t\tprop = <-1e10>;\n+\t\tprop = <(!3)>;\n+\t\tprop = <(~3)>;\n+\t\tprop = <(3*4)>;\n+\t\tprop = <(3&4)>;\n+\t\tprop = <(3*4)>;\n+\t\tprop = <(3/4)>;\n+\t\tprop = <(3%4)>;\n+\t\tprop = <(3+4)>;\n+\t\tprop = <(3-4)>;\n+\t\tprop = /bits/ 64 <(3<<4)>;\n+\t\tprop = <(3>>4)>;\n+\t\tprop = <(3&4)>;\n+\t\tprop = <(3^4)>;\n+\t\tprop = <(3|4)>;\n+\t\tprop = <(3&&4)>;\n+\t\tprop = <(3||4)>;\n+\t\tprop = <(4?5:3)>;\n+\t\tlist = <&this_handle>, <0 0 0 0>;\n+\t};\n+\n+\t&phandle {\n+\t\tpre-phandle = <&this_handle>;\n+\t};\n+};\ndiff --git a/userdiff.c b/userdiff.c\nindex e74a6d402255..1db5d30aaebe 100644\n--- a/userdiff.c\n+++ b/userdiff.c\n@@ -23,6 +23,15 @@ IPATTERN(\"ada\",\n \t \"[a-zA-Z][a-zA-Z0-9_]*\"\n \t \"|[-+]?[0-9][0-9#_.aAbBcCdDeEfF]*([eE][+-]?[0-9_]+)?\"\n \t \"|=>|\\\\.\\\\.|\\\\*\\\\*|:=|/=|>=|<=|<<|>>|<>\"),\n+PATTERNS(\"dts\",\n+\t /* Node name with optional label and unit address */\n+\t \"^[ \\t]*((([a-zA-Z_][a-zA-Z0-9_]*:[ \\t]*)?[a-zA-Z][a-zA-Z0-9,._+-]*(@[a-zA-Z0-9,._+-]+)?\"\n+\t /* Reference */\n+\t \"|&[a-zA-Z_][a-zA-Z0-9_]*)[ \\t]*[^;]*)$\",\n+\t /* -- */\n+\t /* Property names and math operators */\n+\t \"[a-zA-Z0-9,._+?#-]+\"\n+\t \"|[-+*/%&^|!~]|>>|<<|&&|\\\\|\\\\|\"),\n IPATTERN(\"fortran\",\n \t \"!^([C*]|[ \\t]*!)\\n\"\n \t \"!^[ \\t]*MODULE[ \\t]+PROCEDURE[ \\t]\\n\"\n-- \nSent by a computer through tubes\n\n"},{"id":"380573","messageId":"4dc7fb1a-b2ba-a938-5299-20330e0241c3@gmail.com","threadId":"51656","inReplyTo":"20190816225658.8946-1-sboyd@kernel.org","subject":"Re: [PATCH v2] userdiff: Add a builtin pattern for dts files","fromName":"Frank Rowand","fromEmail":"frowand.list@gmail.com","sentAt":"2019-08-17T01:48:32Z","receivedAt":"2019-08-17T01:48:37Z","isPatch":true,"sender":{"key":"frowand.list@gmail.com","avatar":null},"body":"+Frank (me)\n\nOn 8/16/19 3:56 PM, Stephen Boyd wrote:\n> The Linux kernel receives many patches to the devicetree files each\n> release. The hunk header for those patches typically show nothing,\n> making it difficult to figure out what node is being modified without\n> applying the patch or opening the file and seeking to the context. Let's\n> add a builtin 'dts' pattern to git so that users can get better diff\n> output on dts files when they use the diff=dts driver.\n> \n> The regex has been constructed based on the spec at devicetree.org[1]\n> \n> [1] https://github.com/devicetree-org/devicetree-specification/releases/latest\n> \n> Cc: Rob Herring <robh+dt@kernel.org>\n> Signed-off-by: Stephen Boyd <sboyd@kernel.org>\n> ---\n> \n> Sending this again after getting feedback and it getting stuck in\n> review[1]. I'm not sure what happened with the meta question from Junio\n> to add a way for various projects to introduce their own patterns, but\n> I'd still prefer to have this in git proper because the kernel uses git\n> extensively and we rely on git formatted patches in our workflow. I\n> recently reviewed a dts change and remembered this never got accepted.\n> \n> Changes from v1:\n>  * Updated regex to handle anything after node names instead of\n>    requiring a '{'\n>  * Updated test for boolean relation operators\n>  * Sent out a patch to devicetree spec to document % operator\n> \n> [1] Feedback was in 16335abe-5e7e-fd7a-25f4-373f94e176e1@gmail.com\n> \n>  Documentation/gitattributes.txt |  2 ++\n>  t/t4018-diff-funcname.sh        |  1 +\n>  t/t4018/dts-labels              |  8 +++++++\n>  t/t4018/dts-node-unitless       |  8 +++++++\n>  t/t4018/dts-nodes               |  8 +++++++\n>  t/t4018/dts-reference           |  8 +++++++\n>  t/t4034-diff-words.sh           |  1 +\n>  t/t4034/dts/expect              | 37 +++++++++++++++++++++++++++++++++\n>  t/t4034/dts/post                | 32 ++++++++++++++++++++++++++++\n>  t/t4034/dts/pre                 | 32 ++++++++++++++++++++++++++++\n>  userdiff.c                      |  9 ++++++++\n>  11 files changed, 146 insertions(+)\n>  create mode 100644 t/t4018/dts-labels\n>  create mode 100644 t/t4018/dts-node-unitless\n>  create mode 100644 t/t4018/dts-nodes\n>  create mode 100644 t/t4018/dts-reference\n>  create mode 100644 t/t4034/dts/expect\n>  create mode 100644 t/t4034/dts/post\n>  create mode 100644 t/t4034/dts/pre\n> \n> diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt\n> index fb1d188d440c..c5a528c667b6 100644\n> --- a/Documentation/gitattributes.txt\n> +++ b/Documentation/gitattributes.txt\n> @@ -810,6 +810,8 @@ patterns are available:\n>  \n>  - `css` suitable for cascading style sheets.\n>  \n> +- `dts` suitable for devicetree (DTS) files.\n> +\n>  - `fortran` suitable for source code in the Fortran language.\n>  \n>  - `fountain` suitable for Fountain documents.\n> diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh\n> index 9261d6d3a000..6f5ef0035e92 100755\n> --- a/t/t4018-diff-funcname.sh\n> +++ b/t/t4018-diff-funcname.sh\n> @@ -31,6 +31,7 @@ diffpatterns=\"\n>  \tcpp\n>  \tcsharp\n>  \tcss\n> +\tdts\n>  \tfortran\n>  \tfountain\n>  \tgolang\n> diff --git a/t/t4018/dts-labels b/t/t4018/dts-labels\n> new file mode 100644\n> index 000000000000..27cd4921cfb6\n> --- /dev/null\n> +++ b/t/t4018/dts-labels\n> @@ -0,0 +1,8 @@\n> +/ {\n> +\tlabel_1: node1@ff00 {\n> +\t\tlabel2: RIGHT {\n> +\t\t\tvendor,some-property;\n> +\t\t\tChangeMe = <0x45-30>;\n> +\t\t};\n> +\t};\n> +};\n> diff --git a/t/t4018/dts-node-unitless b/t/t4018/dts-node-unitless\n> new file mode 100644\n> index 000000000000..c5287d91416e\n> --- /dev/null\n> +++ b/t/t4018/dts-node-unitless\n> @@ -0,0 +1,8 @@\n> +/ {\n> +\tlabel_1: node1 {\n> +\t\tRIGHT {\n> +\t\t\tprop-array = <1>, <4>;\n> +\t\t\tChangeMe = <0xffeedd00>;\n> +\t\t};\n> +\t};\n> +};\n> diff --git a/t/t4018/dts-nodes b/t/t4018/dts-nodes\n> new file mode 100644\n> index 000000000000..5a4334bb1645\n> --- /dev/null\n> +++ b/t/t4018/dts-nodes\n> @@ -0,0 +1,8 @@\n> +/ {\n> +\tlabel_1: node1@ff00 {\n> +\t\tRIGHT@deadf00,4000 {\n> +\t\t\t#size-cells = <1>;\n> +\t\t\tChangeMe = <0xffeedd00>;\n> +\t\t};\n> +\t};\n> +};\n> diff --git a/t/t4018/dts-reference b/t/t4018/dts-reference\n> new file mode 100644\n> index 000000000000..f115d4291d25\n> --- /dev/null\n> +++ b/t/t4018/dts-reference\n> @@ -0,0 +1,8 @@\n> +&label_1 {\n> +\tTEST = <455>;\n> +};\n> +\n> +&RIGHT {\n> +\tvendor,some-property;\n> +\tChangeMe = <0x45-30>;\n> +};\n> diff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh\n> index 912df91226f2..9a93c2a3e0dd 100755\n> --- a/t/t4034-diff-words.sh\n> +++ b/t/t4034-diff-words.sh\n> @@ -303,6 +303,7 @@ test_language_driver bibtex\n>  test_language_driver cpp\n>  test_language_driver csharp\n>  test_language_driver css\n> +test_language_driver dts\n>  test_language_driver fortran\n>  test_language_driver html\n>  test_language_driver java\n> diff --git a/t/t4034/dts/expect b/t/t4034/dts/expect\n> new file mode 100644\n> index 000000000000..560fc9918476\n> --- /dev/null\n> +++ b/t/t4034/dts/expect\n> @@ -0,0 +1,37 @@\n> +<BOLD>diff --git a/pre b/post<RESET>\n> +<BOLD>index b6a9051..7803aee 100644<RESET>\n> +<BOLD>--- a/pre<RESET>\n> +<BOLD>+++ b/post<RESET>\n> +<CYAN>@@ -1,32 +1,32 @@<RESET>\n> +/ {<RESET>\n> +\t<RED>this_handle<RESET><GREEN>HANDLE_2<RESET>: <RED>node<RESET><GREEN>new-node<RESET>@<RED>f00<RESET><GREEN>eeda<RESET> {\n> +\t\tcompatible = \"<RED>mydev<RESET><GREEN>vendor,compat<RESET>\";\n> +\t\tstring-prop = <RED>start<RESET><GREEN>end<RESET>: \"hello <RED>world!<RESET><GREEN>world?<RESET>\" <RED>end<RESET><GREEN>start<RESET>: ;\n> +\t\t<RED>#size-cells<RESET><GREEN>#address-cells<RESET> = <<RED>0+0<RESET><GREEN>0+40<RESET>>;\n> +\t\treg = <<RED>0xf00<RESET><GREEN>0xeeda<RESET>>;\n> +\t\tprop = <<GREEN>(<RESET>1<GREEN>)<RESET>>;\n> +\t\tprop = <<GREEN>(<RESET>-1e10<GREEN>)<RESET>>;\n> +\t\tprop = <(!<RED>3<RESET><GREEN>1<RESET>)>;\n> +\t\tprop = <(~<RED>3<RESET><GREEN>1<RESET>)>;\n> +\t\tprop = <(<RED>3<RESET><GREEN>1<RESET>*<RED>4<RESET><GREEN>2<RESET>)>;\n> +\t\tprop = <(<RED>3<RESET><GREEN>1<RESET>&<RED>4<RESET><GREEN>2<RESET>)>;\n> +\t\tprop = <(<RED>3<RESET><GREEN>1<RESET>*<RED>4<RESET><GREEN>2<RESET>)>;\n> +\t\tprop = <(<RED>3<RESET><GREEN>1<RESET>/<RED>4<RESET><GREEN>2<RESET>)>;\n> +\t\tprop = <(<RED>3<RESET><GREEN>1<RESET>%<RED>4<RESET><GREEN>2<RESET>)>;\n> +\t\tprop = <(<RED>3+4<RESET><GREEN>1+2<RESET>)>;\n> +\t\tprop = <(<RED>3-4<RESET><GREEN>1-2<RESET>)>;\n> +\t\tprop = /bits/ <RED>64<RESET><GREEN>32<RESET> <(<RED>3<RESET><GREEN>1<RESET><<<RED>4<RESET><GREEN>2<RESET>)>;\n> +\t\tprop = <(<RED>3<RESET><GREEN>1<RESET>>><RED>4<RESET><GREEN>2<RESET>)>;\n> +\t\tprop = <(<RED>3<RESET><GREEN>1<RESET>&<RED>4<RESET><GREEN>2<RESET>)>;\n> +\t\tprop = <(<RED>3<RESET><GREEN>1<RESET>^<RED>4<RESET><GREEN>2<RESET>)>;\n> +\t\tprop = <(<RED>3<RESET><GREEN>1<RESET>|<RED>4<RESET><GREEN>2<RESET>)>;\n> +\t\tprop = <(<RED>3<RESET><GREEN>1<RESET>&&<RED>4<RESET><GREEN>2<RESET>)>;\n> +\t\tprop = <(<RED>3<RESET><GREEN>1<RESET>||<RED>4<RESET><GREEN>2<RESET>)>;\n> +\t\tprop = <(<RED>4?5<RESET><GREEN>1?2<RESET>:3)>;\n> +\t\tlist = <&<RED>this_handle<RESET><GREEN>HANDLE_2<RESET>>, <0 0 0 <RED>0<RESET><GREEN>1<RESET>>;\n> +\t};<RESET>\n> +\n> +\t&<RED>phandle<RESET><GREEN>phandle2<RESET> {\n> +\t\t<RED>pre-phandle<RESET><GREEN>prop_handle<RESET> = <&<RED>this_handle<RESET><GREEN>HANDLE_2<RESET>>;\n> +\t};<RESET>\n> +};<RESET>\n> diff --git a/t/t4034/dts/post b/t/t4034/dts/post\n> new file mode 100644\n> index 000000000000..7803aee28093\n> --- /dev/null\n> +++ b/t/t4034/dts/post\n> @@ -0,0 +1,32 @@\n> +/ {\n> +\tHANDLE_2: new-node@eeda {\n> +\t\tcompatible = \"vendor,compat\";\n> +\t\tstring-prop = end: \"hello world?\" start: ;\n> +\t\t#address-cells = <0+40>;\n> +\t\treg = <0xeeda>;\n> +\t\tprop = <(1)>;\n> +\t\tprop = <(-1e10)>;\n> +\t\tprop = <(!1)>;\n> +\t\tprop = <(~1)>;\n> +\t\tprop = <(1*2)>;\n> +\t\tprop = <(1&2)>;\n> +\t\tprop = <(1*2)>;\n> +\t\tprop = <(1/2)>;\n> +\t\tprop = <(1%2)>;\n> +\t\tprop = <(1+2)>;\n> +\t\tprop = <(1-2)>;\n> +\t\tprop = /bits/ 32 <(1<<2)>;\n> +\t\tprop = <(1>>2)>;\n> +\t\tprop = <(1&2)>;\n> +\t\tprop = <(1^2)>;\n> +\t\tprop = <(1|2)>;\n> +\t\tprop = <(1&&2)>;\n> +\t\tprop = <(1||2)>;\n> +\t\tprop = <(1?2:3)>;\n> +\t\tlist = <&HANDLE_2>, <0 0 0 1>;\n> +\t};\n> +\n> +\t&phandle2 {\n> +\t\tprop_handle = <&HANDLE_2>;\n> +\t};\n> +};\n> diff --git a/t/t4034/dts/pre b/t/t4034/dts/pre\n> new file mode 100644\n> index 000000000000..b6a905113c22\n> --- /dev/null\n> +++ b/t/t4034/dts/pre\n> @@ -0,0 +1,32 @@\n> +/ {\n> +\tthis_handle: node@f00 {\n> +\t\tcompatible = \"mydev\";\n> +\t\tstring-prop = start: \"hello world!\" end: ;\n> +\t\t#size-cells = <0+0>;\n> +\t\treg = <0xf00>;\n> +\t\tprop = <1>;\n> +\t\tprop = <-1e10>;\n> +\t\tprop = <(!3)>;\n> +\t\tprop = <(~3)>;\n> +\t\tprop = <(3*4)>;\n> +\t\tprop = <(3&4)>;\n> +\t\tprop = <(3*4)>;\n> +\t\tprop = <(3/4)>;\n> +\t\tprop = <(3%4)>;\n> +\t\tprop = <(3+4)>;\n> +\t\tprop = <(3-4)>;\n> +\t\tprop = /bits/ 64 <(3<<4)>;\n> +\t\tprop = <(3>>4)>;\n> +\t\tprop = <(3&4)>;\n> +\t\tprop = <(3^4)>;\n> +\t\tprop = <(3|4)>;\n> +\t\tprop = <(3&&4)>;\n> +\t\tprop = <(3||4)>;\n> +\t\tprop = <(4?5:3)>;\n> +\t\tlist = <&this_handle>, <0 0 0 0>;\n> +\t};\n> +\n> +\t&phandle {\n> +\t\tpre-phandle = <&this_handle>;\n> +\t};\n> +};\n> diff --git a/userdiff.c b/userdiff.c\n> index e74a6d402255..1db5d30aaebe 100644\n> --- a/userdiff.c\n> +++ b/userdiff.c\n> @@ -23,6 +23,15 @@ IPATTERN(\"ada\",\n>  \t \"[a-zA-Z][a-zA-Z0-9_]*\"\n>  \t \"|[-+]?[0-9][0-9#_.aAbBcCdDeEfF]*([eE][+-]?[0-9_]+)?\"\n>  \t \"|=>|\\\\.\\\\.|\\\\*\\\\*|:=|/=|>=|<=|<<|>>|<>\"),\n> +PATTERNS(\"dts\",\n> +\t /* Node name with optional label and unit address */\n> +\t \"^[ \\t]*((([a-zA-Z_][a-zA-Z0-9_]*:[ \\t]*)?[a-zA-Z][a-zA-Z0-9,._+-]*(@[a-zA-Z0-9,._+-]+)?\"\n> +\t /* Reference */\n> +\t \"|&[a-zA-Z_][a-zA-Z0-9_]*)[ \\t]*[^;]*)$\",\n> +\t /* -- */\n> +\t /* Property names and math operators */\n> +\t \"[a-zA-Z0-9,._+?#-]+\"\n> +\t \"|[-+*/%&^|!~]|>>|<<|&&|\\\\|\\\\|\"),\n>  IPATTERN(\"fortran\",\n>  \t \"!^([C*]|[ \\t]*!)\\n\"\n>  \t \"!^[ \\t]*MODULE[ \\t]+PROCEDURE[ \\t]\\n\"\n> \n\n"},{"id":"380578","messageId":"40ec31c4-6f13-a513-6514-93b6c8e84a7f@gmail.com","threadId":"51656","inReplyTo":"20190816225658.8946-1-sboyd@kernel.org","subject":"Re: [PATCH v2] userdiff: Add a builtin pattern for dts files","fromName":"Alban Gruin","fromEmail":"alban.gruin@gmail.com","sentAt":"2019-08-17T15:18:19Z","receivedAt":"2019-08-17T15:18:37Z","isPatch":true,"sender":{"key":"alban.gruin@gmail.com","avatar":"https://avatars.githubusercontent.com/u/6310153?v=4"},"body":"Hi Stephen,\n\nLe 17/08/2019 à 00:56, Stephen Boyd a écrit :\n> The Linux kernel receives many patches to the devicetree files each\n> release. The hunk header for those patches typically show nothing,\n> making it difficult to figure out what node is being modified without\n> applying the patch or opening the file and seeking to the context. Let's\n> add a builtin 'dts' pattern to git so that users can get better diff\n> output on dts files when they use the diff=dts driver.\n> \n> The regex has been constructed based on the spec at devicetree.org[1]\n> \n> [1] https://github.com/devicetree-org/devicetree-specification/releases/latest\n> \n> Cc: Rob Herring <robh+dt@kernel.org>\n> Signed-off-by: Stephen Boyd <sboyd@kernel.org>\n> ---\n> \n> Sending this again after getting feedback and it getting stuck in\n> review[1]. I'm not sure what happened with the meta question from Junio\n> to add a way for various projects to introduce their own patterns,\n\nNothing happened, AFAIK.\n\n> but\n> I'd still prefer to have this in git proper because the kernel uses git\n> extensively and we rely on git formatted patches in our workflow. I\n> recently reviewed a dts change and remembered this never got accepted.\n> \n> Changes from v1:\n>  * Updated regex to handle anything after node names instead of\n>    requiring a '{'\n>  * Updated test for boolean relation operators\n>  * Sent out a patch to devicetree spec to document % operator\n> \n> [1] Feedback was in 16335abe-5e7e-fd7a-25f4-373f94e176e1@gmail.com\n> \n>  -%<-\nThis looks good to me.\n\nCheers,\nAlban\n\n"},{"id":"380723","messageId":"98f9cdc2-fa9b-b639-b906-44b17f0efd76@kdbg.org","threadId":"51656","inReplyTo":"20190816225658.8946-1-sboyd@kernel.org","subject":"Re: [PATCH v2] userdiff: Add a builtin pattern for dts files","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2019-08-19T18:40:47Z","receivedAt":"2019-08-19T18:40:53Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 17.08.19 um 00:56 schrieb Stephen Boyd:\n> The Linux kernel receives many patches to the devicetree files each\n> release. The hunk header for those patches typically show nothing,\n> making it difficult to figure out what node is being modified without\n> applying the patch or opening the file and seeking to the context. Let's\n> add a builtin 'dts' pattern to git so that users can get better diff\n> output on dts files when they use the diff=dts driver.\n> \n> The regex has been constructed based on the spec at devicetree.org[1]\n> \n> [1] https://github.com/devicetree-org/devicetree-specification/releases/latest\n> \n> Cc: Rob Herring <robh+dt@kernel.org>\n> Signed-off-by: Stephen Boyd <sboyd@kernel.org>\n> ---\n> \n> Sending this again after getting feedback and it getting stuck in\n> review[1]. I'm not sure what happened with the meta question from Junio\n> to add a way for various projects to introduce their own patterns, but\n> I'd still prefer to have this in git proper because the kernel uses git\n> extensively and we rely on git formatted patches in our workflow. I\n> recently reviewed a dts change and remembered this never got accepted.\n> \n> Changes from v1:\n>  * Updated regex to handle anything after node names instead of\n>    requiring a '{'\n>  * Updated test for boolean relation operators\n>  * Sent out a patch to devicetree spec to document % operator\n> \n> [1] Feedback was in 16335abe-5e7e-fd7a-25f4-373f94e176e1@gmail.com\n\nThanks. I've a few suggestions below.\n\n> diff --git a/t/t4018/dts-labels b/t/t4018/dts-labels\n> new file mode 100644\n> index 000000000000..27cd4921cfb6\n> --- /dev/null\n> +++ b/t/t4018/dts-labels\n> @@ -0,0 +1,8 @@\n> +/ {\n> +\tlabel_1: node1@ff00 {\n> +\t\tlabel2: RIGHT {\n> +\t\t\tvendor,some-property;\n> +\t\t\tChangeMe = <0x45-30>;\n\nIn these tests, it would be worthwhile to leave another (possibly blank)\nline before the ChangeMe line in order to demonstrate that lines\nbeginning with a word, such as the 'vendor,some-property;' line, are\n_not_ picked up when they are not in the hunk context.\n\n> +\t\t};\n> +\t};\n> +};\n> diff --git a/t/t4018/dts-node-unitless b/t/t4018/dts-node-unitless\n> new file mode 100644\n> index 000000000000..c5287d91416e\n> --- /dev/null\n> +++ b/t/t4018/dts-node-unitless\n> @@ -0,0 +1,8 @@\n> +/ {\n> +\tlabel_1: node1 {\n> +\t\tRIGHT {\n> +\t\t\tprop-array = <1>, <4>;\n> +\t\t\tChangeMe = <0xffeedd00>;\n> +\t\t};\n> +\t};\n> +};\n> diff --git a/t/t4018/dts-nodes b/t/t4018/dts-nodes\n> new file mode 100644\n> index 000000000000..5a4334bb1645\n> --- /dev/null\n> +++ b/t/t4018/dts-nodes\n> @@ -0,0 +1,8 @@\n> +/ {\n> +\tlabel_1: node1@ff00 {\n> +\t\tRIGHT@deadf00,4000 {\n> +\t\t\t#size-cells = <1>;\n> +\t\t\tChangeMe = <0xffeedd00>;\n> +\t\t};\n> +\t};\n> +};\n> diff --git a/t/t4018/dts-reference b/t/t4018/dts-reference\n> new file mode 100644\n> index 000000000000..f115d4291d25\n> --- /dev/null\n> +++ b/t/t4018/dts-reference\n> @@ -0,0 +1,8 @@\n> +&label_1 {\n> +\tTEST = <455>;\n> +};\n> +\n> +&RIGHT {\n> +\tvendor,some-property;\n> +\tChangeMe = <0x45-30>;\n> +};\n> diff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh\n> index 912df91226f2..9a93c2a3e0dd 100755\n> --- a/t/t4034-diff-words.sh\n> +++ b/t/t4034-diff-words.sh\n> @@ -303,6 +303,7 @@ test_language_driver bibtex\n>  test_language_driver cpp\n>  test_language_driver csharp\n>  test_language_driver css\n> +test_language_driver dts\n>  test_language_driver fortran\n>  test_language_driver html\n>  test_language_driver java\n> diff --git a/t/t4034/dts/expect b/t/t4034/dts/expect\n> new file mode 100644\n> index 000000000000..560fc9918476\n> --- /dev/null\n> +++ b/t/t4034/dts/expect\n> @@ -0,0 +1,37 @@\n> +<BOLD>diff --git a/pre b/post<RESET>\n> +<BOLD>index b6a9051..7803aee 100644<RESET>\n> +<BOLD>--- a/pre<RESET>\n> +<BOLD>+++ b/post<RESET>\n> +<CYAN>@@ -1,32 +1,32 @@<RESET>\n> +/ {<RESET>\n> +\t<RED>this_handle<RESET><GREEN>HANDLE_2<RESET>: <RED>node<RESET><GREEN>new-node<RESET>@<RED>f00<RESET><GREEN>eeda<RESET> {\n> +\t\tcompatible = \"<RED>mydev<RESET><GREEN>vendor,compat<RESET>\";\n> +\t\tstring-prop = <RED>start<RESET><GREEN>end<RESET>: \"hello <RED>world!<RESET><GREEN>world?<RESET>\" <RED>end<RESET><GREEN>start<RESET>: ;\n> +\t\t<RED>#size-cells<RESET><GREEN>#address-cells<RESET> = <<RED>0+0<RESET><GREEN>0+40<RESET>>;\n> +\t\treg = <<RED>0xf00<RESET><GREEN>0xeeda<RESET>>;\n> +\t\tprop = <<GREEN>(<RESET>1<GREEN>)<RESET>>;\n> +\t\tprop = <<GREEN>(<RESET>-1e10<GREEN>)<RESET>>;\n> +\t\tprop = <(!<RED>3<RESET><GREEN>1<RESET>)>;\n> +\t\tprop = <(~<RED>3<RESET><GREEN>1<RESET>)>;\n> +\t\tprop = <(<RED>3<RESET><GREEN>1<RESET>*<RED>4<RESET><GREEN>2<RESET>)>;\n> +\t\tprop = <(<RED>3<RESET><GREEN>1<RESET>&<RED>4<RESET><GREEN>2<RESET>)>;\n> +\t\tprop = <(<RED>3<RESET><GREEN>1<RESET>*<RED>4<RESET><GREEN>2<RESET>)>;\n> +\t\tprop = <(<RED>3<RESET><GREEN>1<RESET>/<RED>4<RESET><GREEN>2<RESET>)>;\n> +\t\tprop = <(<RED>3<RESET><GREEN>1<RESET>%<RED>4<RESET><GREEN>2<RESET>)>;\n> +\t\tprop = <(<RED>3+4<RESET><GREEN>1+2<RESET>)>;\n> +\t\tprop = <(<RED>3-4<RESET><GREEN>1-2<RESET>)>;\n> +\t\tprop = /bits/ <RED>64<RESET><GREEN>32<RESET> <(<RED>3<RESET><GREEN>1<RESET><<<RED>4<RESET><GREEN>2<RESET>)>;\n> +\t\tprop = <(<RED>3<RESET><GREEN>1<RESET>>><RED>4<RESET><GREEN>2<RESET>)>;\n> +\t\tprop = <(<RED>3<RESET><GREEN>1<RESET>&<RED>4<RESET><GREEN>2<RESET>)>;\n> +\t\tprop = <(<RED>3<RESET><GREEN>1<RESET>^<RED>4<RESET><GREEN>2<RESET>)>;\n> +\t\tprop = <(<RED>3<RESET><GREEN>1<RESET>|<RED>4<RESET><GREEN>2<RESET>)>;\n> +\t\tprop = <(<RED>3<RESET><GREEN>1<RESET>&&<RED>4<RESET><GREEN>2<RESET>)>;\n> +\t\tprop = <(<RED>3<RESET><GREEN>1<RESET>||<RED>4<RESET><GREEN>2<RESET>)>;\n> +\t\tprop = <(<RED>4?5<RESET><GREEN>1?2<RESET>:3)>;\n> +\t\tlist = <&<RED>this_handle<RESET><GREEN>HANDLE_2<RESET>>, <0 0 0 <RED>0<RESET><GREEN>1<RESET>>;\n> +\t};<RESET>\n> +\n> +\t&<RED>phandle<RESET><GREEN>phandle2<RESET> {\n> +\t\t<RED>pre-phandle<RESET><GREEN>prop_handle<RESET> = <&<RED>this_handle<RESET><GREEN>HANDLE_2<RESET>>;\n> +\t};<RESET>\n> +};<RESET>\n> diff --git a/t/t4034/dts/post b/t/t4034/dts/post\n> new file mode 100644\n> index 000000000000..7803aee28093\n> --- /dev/null\n> +++ b/t/t4034/dts/post\n> @@ -0,0 +1,32 @@\n> +/ {\n> +\tHANDLE_2: new-node@eeda {\n> +\t\tcompatible = \"vendor,compat\";\n> +\t\tstring-prop = end: \"hello world?\" start: ;\n> +\t\t#address-cells = <0+40>;\n> +\t\treg = <0xeeda>;\n> +\t\tprop = <(1)>;\n> +\t\tprop = <(-1e10)>;\n> +\t\tprop = <(!1)>;\n> +\t\tprop = <(~1)>;\n> +\t\tprop = <(1*2)>;\n> +\t\tprop = <(1&2)>;\n> +\t\tprop = <(1*2)>;\n> +\t\tprop = <(1/2)>;\n> +\t\tprop = <(1%2)>;\n> +\t\tprop = <(1+2)>;\n> +\t\tprop = <(1-2)>;\n> +\t\tprop = /bits/ 32 <(1<<2)>;\n> +\t\tprop = <(1>>2)>;\n> +\t\tprop = <(1&2)>;\n> +\t\tprop = <(1^2)>;\n> +\t\tprop = <(1|2)>;\n> +\t\tprop = <(1&&2)>;\n> +\t\tprop = <(1||2)>;\n> +\t\tprop = <(1?2:3)>;\n> +\t\tlist = <&HANDLE_2>, <0 0 0 1>;\n> +\t};\n> +\n> +\t&phandle2 {\n> +\t\tprop_handle = <&HANDLE_2>;\n> +\t};\n> +};\n> diff --git a/t/t4034/dts/pre b/t/t4034/dts/pre\n> new file mode 100644\n> index 000000000000..b6a905113c22\n> --- /dev/null\n> +++ b/t/t4034/dts/pre\n> @@ -0,0 +1,32 @@\n> +/ {\n> +\tthis_handle: node@f00 {\n> +\t\tcompatible = \"mydev\";\n> +\t\tstring-prop = start: \"hello world!\" end: ;\n> +\t\t#size-cells = <0+0>;\n> +\t\treg = <0xf00>;\n> +\t\tprop = <1>;\n> +\t\tprop = <-1e10>;\n> +\t\tprop = <(!3)>;\n> +\t\tprop = <(~3)>;\n> +\t\tprop = <(3*4)>;\n> +\t\tprop = <(3&4)>;\n> +\t\tprop = <(3*4)>;\n> +\t\tprop = <(3/4)>;\n> +\t\tprop = <(3%4)>;\n> +\t\tprop = <(3+4)>;\n> +\t\tprop = <(3-4)>;\n> +\t\tprop = /bits/ 64 <(3<<4)>;\n> +\t\tprop = <(3>>4)>;\n> +\t\tprop = <(3&4)>;\n> +\t\tprop = <(3^4)>;\n> +\t\tprop = <(3|4)>;\n> +\t\tprop = <(3&&4)>;\n> +\t\tprop = <(3||4)>;\n> +\t\tprop = <(4?5:3)>;\n> +\t\tlist = <&this_handle>, <0 0 0 0>;\n> +\t};\n> +\n> +\t&phandle {\n> +\t\tpre-phandle = <&this_handle>;\n> +\t};\n> +};\n> diff --git a/userdiff.c b/userdiff.c\n> index e74a6d402255..1db5d30aaebe 100644\n> --- a/userdiff.c\n> +++ b/userdiff.c\n> @@ -23,6 +23,15 @@ IPATTERN(\"ada\",\n>  \t \"[a-zA-Z][a-zA-Z0-9_]*\"\n>  \t \"|[-+]?[0-9][0-9#_.aAbBcCdDeEfF]*([eE][+-]?[0-9_]+)?\"\n>  \t \"|=>|\\\\.\\\\.|\\\\*\\\\*|:=|/=|>=|<=|<<|>>|<>\"),\n> +PATTERNS(\"dts\",\n> +\t /* Node name with optional label and unit address */\n> +\t \"^[ \\t]*((([a-zA-Z_][a-zA-Z0-9_]*:[ \\t]*)?[a-zA-Z][a-zA-Z0-9,._+-]*(@[a-zA-Z0-9,._+-]+)?\"\n\nFrom the examples I see in this patch, it looks like lines ending in a\n';' are not candidates, everything that begins with 'word' or '&word'\nis. Wouldn't that greatly simplify these patterns?\n\n\t\"!;\\n\"\n\t/* lines beginning with a word optionally preceded by '&' */\n\t\"^[ \\t]*(&?([a-zA-Z_].*)\"\n\n> +\t /* Reference */\n> +\t \"|&[a-zA-Z_][a-zA-Z0-9_]*)[ \\t]*[^;]*)$\",\n\nNote that you don't have to replicate the syntax faithfully in the\npatterns because you can assume that files adhere to the correct syntax.\nYou could merge this into the former pattern by just matching \"&?\" after\nthe initial whitespace.\n\n> +\t /* -- */\n> +\t /* Property names and math operators */\n> +\t \"[a-zA-Z0-9,._+?#-]+\"\n> +\t \"|[-+*/%&^|!~]|>>|<<|&&|\\\\|\\\\|\"),\n>  IPATTERN(\"fortran\",\n>  \t \"!^([C*]|[ \\t]*!)\\n\"\n>  \t \"!^[ \\t]*MODULE[ \\t]+PROCEDURE[ \\t]\\n\"\n> \n\n-- Hannes\n"},{"id":"380729","messageId":"20190819204451.522D422CEB@mail.kernel.org","threadId":"51656","inReplyTo":"98f9cdc2-fa9b-b639-b906-44b17f0efd76@kdbg.org","subject":"Re: [PATCH v2] userdiff: Add a builtin pattern for dts files","fromName":"Stephen Boyd","fromEmail":"sboyd@kernel.org","sentAt":"2019-08-19T20:44:50Z","receivedAt":"2019-08-19T20:44:53Z","isPatch":true,"sender":{"key":"sboyd@kernel.org","avatar":"https://avatars.githubusercontent.com/u/38832?v=4"},"body":"Quoting Johannes Sixt (2019-08-19 11:40:47)\n> Am 17.08.19 um 00:56 schrieb Stephen Boyd:\n> > The Linux kernel receives many patches to the devicetree files each\n> > release. The hunk header for those patches typically show nothing,\n> > making it difficult to figure out what node is being modified without\n> > applying the patch or opening the file and seeking to the context. Let's\n> > add a builtin 'dts' pattern to git so that users can get better diff\n> > output on dts files when they use the diff=dts driver.\n> > \n> > The regex has been constructed based on the spec at devicetree.org[1]\n> > \n> > [1] https://github.com/devicetree-org/devicetree-specification/releases/latest\n> > \n> > Cc: Rob Herring <robh+dt@kernel.org>\n> > Signed-off-by: Stephen Boyd <sboyd@kernel.org>\n> > ---\n> > \n> > Sending this again after getting feedback and it getting stuck in\n> > review[1]. I'm not sure what happened with the meta question from Junio\n> > to add a way for various projects to introduce their own patterns, but\n> > I'd still prefer to have this in git proper because the kernel uses git\n> > extensively and we rely on git formatted patches in our workflow. I\n> > recently reviewed a dts change and remembered this never got accepted.\n> > \n> > Changes from v1:\n> >  * Updated regex to handle anything after node names instead of\n> >    requiring a '{'\n> >  * Updated test for boolean relation operators\n> >  * Sent out a patch to devicetree spec to document % operator\n> > \n> > [1] Feedback was in 16335abe-5e7e-fd7a-25f4-373f94e176e1@gmail.com\n> \n> Thanks. I've a few suggestions below.\n> \n> > diff --git a/t/t4018/dts-labels b/t/t4018/dts-labels\n> > new file mode 100644\n> > index 000000000000..27cd4921cfb6\n> > --- /dev/null\n> > +++ b/t/t4018/dts-labels\n> > @@ -0,0 +1,8 @@\n> > +/ {\n> > +     label_1: node1@ff00 {\n> > +             label2: RIGHT {\n> > +                     vendor,some-property;\n> > +                     ChangeMe = <0x45-30>;\n> \n> In these tests, it would be worthwhile to leave another (possibly blank)\n> line before the ChangeMe line in order to demonstrate that lines\n> beginning with a word, such as the 'vendor,some-property;' line, are\n> _not_ picked up when they are not in the hunk context.\n\nSure. I can add a blank line. Did you want it on all the tests or just\nsome of them?\n\n> > diff --git a/userdiff.c b/userdiff.c\n> > index e74a6d402255..1db5d30aaebe 100644\n> > --- a/userdiff.c\n> > +++ b/userdiff.c\n> > @@ -23,6 +23,15 @@ IPATTERN(\"ada\",\n> >        \"[a-zA-Z][a-zA-Z0-9_]*\"\n> >        \"|[-+]?[0-9][0-9#_.aAbBcCdDeEfF]*([eE][+-]?[0-9_]+)?\"\n> >        \"|=>|\\\\.\\\\.|\\\\*\\\\*|:=|/=|>=|<=|<<|>>|<>\"),\n> > +PATTERNS(\"dts\",\n> > +      /* Node name with optional label and unit address */\n> > +      \"^[ \\t]*((([a-zA-Z_][a-zA-Z0-9_]*:[ \\t]*)?[a-zA-Z][a-zA-Z0-9,._+-]*(@[a-zA-Z0-9,._+-]+)?\"\n> \n> From the examples I see in this patch, it looks like lines ending in a\n> ';' are not candidates, everything that begins with 'word' or '&word'\n> is. Wouldn't that greatly simplify these patterns?\n> \n>         \"!;\\n\"\n>         /* lines beginning with a word optionally preceded by '&' */\n>         \"^[ \\t]*(&?([a-zA-Z_].*)\"\n\nRight. I was stuck with my old regex ways where it wasn't considering\nlines that didn't end in a semicolon. This looks like it will work.\n\n> \n> > +      /* Reference */\n> > +      \"|&[a-zA-Z_][a-zA-Z0-9_]*)[ \\t]*[^;]*)$\",\n> \n> Note that you don't have to replicate the syntax faithfully in the\n> patterns because you can assume that files adhere to the correct syntax.\n> You could merge this into the former pattern by just matching \"&?\" after\n> the initial whitespace.\n\nOk. Thanks for simplifying by providing the regex above. I'll rework and\nresend.\n\n"},{"id":"380737","messageId":"806dbf7a-0488-6dde-70b9-a62cc5dca23e@kdbg.org","threadId":"51656","inReplyTo":"20190819204451.522D422CEB@mail.kernel.org","subject":"Re: [PATCH v2] userdiff: Add a builtin pattern for dts files","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2019-08-19T21:35:39Z","receivedAt":"2019-08-19T21:35:43Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 19.08.19 um 22:44 schrieb Stephen Boyd:\n> Quoting Johannes Sixt (2019-08-19 11:40:47)\n>> Am 17.08.19 um 00:56 schrieb Stephen Boyd:\n>>> diff --git a/t/t4018/dts-labels b/t/t4018/dts-labels\n>>> new file mode 100644\n>>> index 000000000000..27cd4921cfb6\n>>> --- /dev/null\n>>> +++ b/t/t4018/dts-labels\n>>> @@ -0,0 +1,8 @@\n>>> +/ {\n>>> +     label_1: node1@ff00 {\n>>> +             label2: RIGHT {\n>>> +                     vendor,some-property;\n>>> +                     ChangeMe = <0x45-30>;\n>>\n>> In these tests, it would be worthwhile to leave another (possibly blank)\n>> line before the ChangeMe line in order to demonstrate that lines\n>> beginning with a word, such as the 'vendor,some-property;' line, are\n>> _not_ picked up when they are not in the hunk context.\n> \n> Sure. I can add a blank line. Did you want it on all the tests or just\n> some of them?\n\nSome of them. We should have cases that show that\n\"vendor,some-property;\" and \"prop-erty = value;\" are not picked up.\n\n-- Hannes\n"}]}