{"thread":{"id":"54363","subject":"[PATCH] userdiff: expand detected chunk headers for css","startedAt":"2020-10-07T09:25:31Z","lastAt":"2020-10-08T17:23:47Z","messageCount":5,"participants":["Sohom Datta via GitGitGadget","Johannes Sixt","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"407042","messageId":"pull.866.git.git.1602062726316.gitgitgadget@gmail.com","threadId":"54363","inReplyTo":null,"subject":"[PATCH] userdiff: expand detected chunk headers for css","fromName":"Sohom Datta via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-10-07T09:25:26Z","receivedAt":"2020-10-07T09:25:31Z","isPatch":true,"sender":{"key":"name:Sohom Datta","avatar":null},"body":"From: Sohom <sohom.datta@learner.manipal.edu>\n\nAdded support for classes, ids, :root selectors\nas well as @-based statements (ex: @page, @media\nand @keyframes ).\n\nAlso added tests for the same.\n\nSigned-off-by: Sohom Datta <sohom.datta@learner.manipal.edu>\n---\n    userdiff: Expand detected chunk headers for css\n    \n    Currently, the regex used for the CSS builtin diff driver in git is only\n    able to show chunk headers for lines that start with a number, a letter\n    or an underscore.\n    \n    However, the regex fails to detect classes (starts with a .), ids\n    (starts with a #), :root and attribute-value based selectors (for\n    example [class*=\"col-\"]), as well as @based block-level statements like \n    @page,@keyframes and @media since all of them, start with a special\n    character.\n    \n    I've modified the chunk header CSS regex so that it is able to detect\n    the statements above and add them to the chunk header.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-866%2Fsohomdatta1%2Fcss-userdiff-fix-test-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-866/sohomdatta1/css-userdiff-fix-test-v1\nPull-Request: https://github.com/git/git/pull/866\n\n t/t4018/css-attribute-value-selector |  4 ++++\n t/t4018/css-block-level-@-statements | 10 ++++++++++\n t/t4018/css-class-selector           |  4 ++++\n t/t4018/css-id-selector              |  4 ++++\n t/t4018/css-root-selector            |  4 ++++\n userdiff.c                           |  2 +-\n 6 files changed, 27 insertions(+), 1 deletion(-)\n create mode 100644 t/t4018/css-attribute-value-selector\n create mode 100644 t/t4018/css-block-level-@-statements\n create mode 100644 t/t4018/css-class-selector\n create mode 100644 t/t4018/css-id-selector\n create mode 100644 t/t4018/css-root-selector\n\ndiff --git a/t/t4018/css-attribute-value-selector b/t/t4018/css-attribute-value-selector\nnew file mode 100644\nindex 0000000000..918256b20c\n--- /dev/null\n+++ b/t/t4018/css-attribute-value-selector\n@@ -0,0 +1,4 @@\n+[class*=\"RIGHT\"] {\n+    background : #000;\n+    border : 10px ChangeMe #C6C6C6;\n+}\ndiff --git a/t/t4018/css-block-level-@-statements b/t/t4018/css-block-level-@-statements\nnew file mode 100644\nindex 0000000000..d6755f2f3d\n--- /dev/null\n+++ b/t/t4018/css-block-level-@-statements\n@@ -0,0 +1,10 @@\n+@keyframes RIGHT {\n+    from {\n+        background : #000;\n+        border : 10px ChangeMe #C6C6C6;\n+    }\n+    to {\n+        background : #fff;\n+        border : 10px solid #C6C6C6;\n+    }\n+}\ndiff --git a/t/t4018/css-class-selector b/t/t4018/css-class-selector\nnew file mode 100644\nindex 0000000000..f790a0062f\n--- /dev/null\n+++ b/t/t4018/css-class-selector\n@@ -0,0 +1,4 @@\n+.RIGHT {\n+    background : #000;\n+    border : 10px ChangeMe #C6C6C6;\n+}\ndiff --git a/t/t4018/css-id-selector b/t/t4018/css-id-selector\nnew file mode 100644\nindex 0000000000..17c5111052\n--- /dev/null\n+++ b/t/t4018/css-id-selector\n@@ -0,0 +1,4 @@\n+#RIGHT {\n+    background : #000;\n+    border : 10px ChangeMe #C6C6C6;\n+}\ndiff --git a/t/t4018/css-root-selector b/t/t4018/css-root-selector\nnew file mode 100644\nindex 0000000000..22b958e369\n--- /dev/null\n+++ b/t/t4018/css-root-selector\n@@ -0,0 +1,4 @@\n+:RIGHT {\n+    background : #000;\n+    border : 10px ChangeMe #C6C6C6;\n+}\ndiff --git a/userdiff.c b/userdiff.c\nindex fde02f225b..49c9771891 100644\n--- a/userdiff.c\n+++ b/userdiff.c\n@@ -200,7 +200,7 @@ PATTERNS(\"csharp\",\n \t \"|[-+*/<>%&^|=!]=|--|\\\\+\\\\+|<<=?|>>=?|&&|\\\\|\\\\||::|->\"),\n IPATTERN(\"css\",\n \t \"![:;][[:space:]]*$\\n\"\n-\t \"^[_a-z0-9].*$\",\n+\t \"^(([_a-z0-9]|[:[@.#][_a-z0-9]).*)$\",\n \t /* -- */\n \t /*\n \t  * This regex comes from W3C CSS specs. Should theoretically also\n\nbase-commit: d98273ba77e1ab9ec755576bc86c716a97bf59d7\n-- \ngitgitgadget\n"},{"id":"407073","messageId":"98994014-c049-f13f-bf5c-20ca9059707d@kdbg.org","threadId":"54363","inReplyTo":"pull.866.git.git.1602062726316.gitgitgadget@gmail.com","subject":"Re: [PATCH] userdiff: expand detected chunk headers for css","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2020-10-07T16:51:04Z","receivedAt":"2020-10-07T16:51:09Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 07.10.20 um 11:25 schrieb Sohom Datta via GitGitGadget:\n> From: Sohom <sohom.datta@learner.manipal.edu>\n> \n> Added support for classes, ids, :root selectors\n\ns/Added/Add/ since we prefer this sentence in imperative mood.\n\n> as well as @-based statements (ex: @page, @media\n> and @keyframes ).\n> \n> Also added tests for the same.\n\nDitto, or just drop this sentence.\n\n> \n> Signed-off-by: Sohom Datta <sohom.datta@learner.manipal.edu>\n> ---\n>     userdiff: Expand detected chunk headers for css\n>     \n>     Currently, the regex used for the CSS builtin diff driver in git is only\n>     able to show chunk headers for lines that start with a number, a letter\n>     or an underscore.\n>     \n>     However, the regex fails to detect classes (starts with a .), ids\n>     (starts with a #), :root and attribute-value based selectors (for\n>     example [class*=\"col-\"]), as well as @based block-level statements like \n>     @page,@keyframes and @media since all of them, start with a special\n>     character.\n\nThis text would have made a very good introductory part of the commit\nmessage, but since it is after the three-dash separator, it is ignored.\n\nThe patch text looks good.\n\n>     \n>     I've modified the chunk header CSS regex so that it is able to detect\n>     the statements above and add them to the chunk header.\n> \n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-866%2Fsohomdatta1%2Fcss-userdiff-fix-test-v1\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-866/sohomdatta1/css-userdiff-fix-test-v1\n> Pull-Request: https://github.com/git/git/pull/866\n> \n>  t/t4018/css-attribute-value-selector |  4 ++++\n>  t/t4018/css-block-level-@-statements | 10 ++++++++++\n>  t/t4018/css-class-selector           |  4 ++++\n>  t/t4018/css-id-selector              |  4 ++++\n>  t/t4018/css-root-selector            |  4 ++++\n>  userdiff.c                           |  2 +-\n>  6 files changed, 27 insertions(+), 1 deletion(-)\n>  create mode 100644 t/t4018/css-attribute-value-selector\n>  create mode 100644 t/t4018/css-block-level-@-statements\n>  create mode 100644 t/t4018/css-class-selector\n>  create mode 100644 t/t4018/css-id-selector\n>  create mode 100644 t/t4018/css-root-selector\n> \n> diff --git a/t/t4018/css-attribute-value-selector b/t/t4018/css-attribute-value-selector\n> new file mode 100644\n> index 0000000000..918256b20c\n> --- /dev/null\n> +++ b/t/t4018/css-attribute-value-selector\n> @@ -0,0 +1,4 @@\n> +[class*=\"RIGHT\"] {\n> +    background : #000;\n> +    border : 10px ChangeMe #C6C6C6;\n> +}\n> diff --git a/t/t4018/css-block-level-@-statements b/t/t4018/css-block-level-@-statements\n> new file mode 100644\n> index 0000000000..d6755f2f3d\n> --- /dev/null\n> +++ b/t/t4018/css-block-level-@-statements\n> @@ -0,0 +1,10 @@\n> +@keyframes RIGHT {\n> +    from {\n> +        background : #000;\n> +        border : 10px ChangeMe #C6C6C6;\n> +    }\n> +    to {\n> +        background : #fff;\n> +        border : 10px solid #C6C6C6;\n> +    }\n> +}\n> diff --git a/t/t4018/css-class-selector b/t/t4018/css-class-selector\n> new file mode 100644\n> index 0000000000..f790a0062f\n> --- /dev/null\n> +++ b/t/t4018/css-class-selector\n> @@ -0,0 +1,4 @@\n> +.RIGHT {\n> +    background : #000;\n> +    border : 10px ChangeMe #C6C6C6;\n> +}\n> diff --git a/t/t4018/css-id-selector b/t/t4018/css-id-selector\n> new file mode 100644\n> index 0000000000..17c5111052\n> --- /dev/null\n> +++ b/t/t4018/css-id-selector\n> @@ -0,0 +1,4 @@\n> +#RIGHT {\n> +    background : #000;\n> +    border : 10px ChangeMe #C6C6C6;\n> +}\n> diff --git a/t/t4018/css-root-selector b/t/t4018/css-root-selector\n> new file mode 100644\n> index 0000000000..22b958e369\n> --- /dev/null\n> +++ b/t/t4018/css-root-selector\n> @@ -0,0 +1,4 @@\n> +:RIGHT {\n> +    background : #000;\n> +    border : 10px ChangeMe #C6C6C6;\n> +}\n> diff --git a/userdiff.c b/userdiff.c\n> index fde02f225b..49c9771891 100644\n> --- a/userdiff.c\n> +++ b/userdiff.c\n> @@ -200,7 +200,7 @@ PATTERNS(\"csharp\",\n>  \t \"|[-+*/<>%&^|=!]=|--|\\\\+\\\\+|<<=?|>>=?|&&|\\\\|\\\\||::|->\"),\n>  IPATTERN(\"css\",\n>  \t \"![:;][[:space:]]*$\\n\"\n> -\t \"^[_a-z0-9].*$\",\n> +\t \"^(([_a-z0-9]|[:[@.#][_a-z0-9]).*)$\",\n>  \t /* -- */\n>  \t /*\n>  \t  * This regex comes from W3C CSS specs. Should theoretically also\n> \n> base-commit: d98273ba77e1ab9ec755576bc86c716a97bf59d7\n> \n\n"},{"id":"407074","messageId":"xmqqtuv62ca6.fsf@gitster.c.googlers.com","threadId":"54363","inReplyTo":"pull.866.git.git.1602062726316.gitgitgadget@gmail.com","subject":"Re: [PATCH] userdiff: expand detected chunk headers for css","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-10-07T17:09:37Z","receivedAt":"2020-10-07T17:09:45Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Sohom Datta via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Sohom <sohom.datta@learner.manipal.edu>\n>\n> Added support for classes, ids, :root selectors\n> as well as @-based statements (ex: @page, @media\n> and @keyframes ).\n>\n> Also added tests for the same.\n>\n> Signed-off-by: Sohom Datta <sohom.datta@learner.manipal.edu>\n> ---\n>     userdiff: Expand detected chunk headers for css\n>     \n>     Currently, the regex used for the CSS builtin diff driver in git is only\n>     able to show chunk headers for lines that start with a number, a letter\n>     or an underscore.\n>     \n>     However, the regex fails to detect classes (starts with a .), ids\n>     (starts with a #), :root and attribute-value based selectors (for\n>     example [class*=\"col-\"]), as well as @based block-level statements like \n>     @page,@keyframes and @media since all of them, start with a special\n>     character.\n\nThe above two would be much better beginning of the log message for\nthis change modulo a few nits.\n\n - We first explain what the current system does in the present\n   tense.  \"Currently, \" at the beginning is a pure noise.\n\n - And we point out what may be lacking (which you did a very good\n   job in the second paragraph).\n\n - And finally, we write in imperative mood to give an order to the\n   codebase to \"become like so.\" or an order to the patch monkey to\n   \"make the codebase like so.\"\n\nAs the last paragraph to follow the two paragraphs, something like\n\n    Allow the selectors to begin with these special characters.\n\nwould be sufficient.\n\n> -\t \"^[_a-z0-9].*$\",\n> +\t \"^(([_a-z0-9]|[:[@.#][_a-z0-9]).*)$\",\n\nAs we seem to allow ? (i.e. zero or one) in the patterns, it probably\nmakes it easier to read to spell the above like this instead?\n\n-\t\"^[_a-z0-9].*$\",\n+\t\"^[:[@.#]?[_a-z0-9].*$\"\n\n"},{"id":"407132","messageId":"pull.866.v2.git.git.1602146164799.gitgitgadget@gmail.com","threadId":"54363","inReplyTo":"pull.866.git.git.1602062726316.gitgitgadget@gmail.com","subject":"[PATCH v2] userdiff: expand detected chunk headers for css","fromName":"Sohom Datta via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-10-08T08:36:04Z","receivedAt":"2020-10-08T08:36:09Z","isPatch":true,"sender":{"key":"name:Sohom Datta","avatar":null},"body":"From: Sohom <sohom.datta@learner.manipal.edu>\n\nThe regex used for the CSS builtin diff driver in git is only\nable to show chunk headers for lines that start with a number,\na letter or an underscore.\n\nHowever, the regex fails to detect classes (starts with a .), ids\n(starts with a #), :root and attribute-value based selectors (for\nexample [class*=\"col-\"]), as well as @based block-level statements\nlike @page,@keyframes and @media since all of them, start with a\nspecial character.\n\nAllow the selectors and block level statements to begin with these\nspecial characters.\n\nSigned-off-by: Sohom Datta <sohom.datta@learner.manipal.edu>\n---\n    userdiff: Expand detected chunk headers for css\n    \n    Changes since v1\n    \n     * Updated commit message as suggested by Johannes Sixt and Junio C\n       Hamano\n     * Simplified the regex as suggested by Junio C Hamano\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-866%2Fsohomdatta1%2Fcss-userdiff-fix-test-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-866/sohomdatta1/css-userdiff-fix-test-v2\nPull-Request: https://github.com/git/git/pull/866\n\nRange-diff vs v1:\n\n 1:  ca178c0cda ! 1:  a76703d4ac userdiff: expand detected chunk headers for css\n     @@ Metadata\n       ## Commit message ##\n          userdiff: expand detected chunk headers for css\n      \n     -    Added support for classes, ids, :root selectors\n     -    as well as @-based statements (ex: @page, @media\n     -    and @keyframes ).\n     +    The regex used for the CSS builtin diff driver in git is only\n     +    able to show chunk headers for lines that start with a number,\n     +    a letter or an underscore.\n      \n     -    Also added tests for the same.\n     +    However, the regex fails to detect classes (starts with a .), ids\n     +    (starts with a #), :root and attribute-value based selectors (for\n     +    example [class*=\"col-\"]), as well as @based block-level statements\n     +    like @page,@keyframes and @media since all of them, start with a\n     +    special character.\n     +\n     +    Allow the selectors and block level statements to begin with these\n     +    special characters.\n      \n          Signed-off-by: Sohom Datta <sohom.datta@learner.manipal.edu>\n      \n     @@ userdiff.c: PATTERNS(\"csharp\",\n       IPATTERN(\"css\",\n       \t \"![:;][[:space:]]*$\\n\"\n      -\t \"^[_a-z0-9].*$\",\n     -+\t \"^(([_a-z0-9]|[:[@.#][_a-z0-9]).*)$\",\n     ++\t \"^[:[@.#]?[_a-z0-9].*$\",\n       \t /* -- */\n       \t /*\n       \t  * This regex comes from W3C CSS specs. Should theoretically also\n\n\n t/t4018/css-attribute-value-selector |  4 ++++\n t/t4018/css-block-level-@-statements | 10 ++++++++++\n t/t4018/css-class-selector           |  4 ++++\n t/t4018/css-id-selector              |  4 ++++\n t/t4018/css-root-selector            |  4 ++++\n userdiff.c                           |  2 +-\n 6 files changed, 27 insertions(+), 1 deletion(-)\n create mode 100644 t/t4018/css-attribute-value-selector\n create mode 100644 t/t4018/css-block-level-@-statements\n create mode 100644 t/t4018/css-class-selector\n create mode 100644 t/t4018/css-id-selector\n create mode 100644 t/t4018/css-root-selector\n\ndiff --git a/t/t4018/css-attribute-value-selector b/t/t4018/css-attribute-value-selector\nnew file mode 100644\nindex 0000000000..918256b20c\n--- /dev/null\n+++ b/t/t4018/css-attribute-value-selector\n@@ -0,0 +1,4 @@\n+[class*=\"RIGHT\"] {\n+    background : #000;\n+    border : 10px ChangeMe #C6C6C6;\n+}\ndiff --git a/t/t4018/css-block-level-@-statements b/t/t4018/css-block-level-@-statements\nnew file mode 100644\nindex 0000000000..d6755f2f3d\n--- /dev/null\n+++ b/t/t4018/css-block-level-@-statements\n@@ -0,0 +1,10 @@\n+@keyframes RIGHT {\n+    from {\n+        background : #000;\n+        border : 10px ChangeMe #C6C6C6;\n+    }\n+    to {\n+        background : #fff;\n+        border : 10px solid #C6C6C6;\n+    }\n+}\ndiff --git a/t/t4018/css-class-selector b/t/t4018/css-class-selector\nnew file mode 100644\nindex 0000000000..f790a0062f\n--- /dev/null\n+++ b/t/t4018/css-class-selector\n@@ -0,0 +1,4 @@\n+.RIGHT {\n+    background : #000;\n+    border : 10px ChangeMe #C6C6C6;\n+}\ndiff --git a/t/t4018/css-id-selector b/t/t4018/css-id-selector\nnew file mode 100644\nindex 0000000000..17c5111052\n--- /dev/null\n+++ b/t/t4018/css-id-selector\n@@ -0,0 +1,4 @@\n+#RIGHT {\n+    background : #000;\n+    border : 10px ChangeMe #C6C6C6;\n+}\ndiff --git a/t/t4018/css-root-selector b/t/t4018/css-root-selector\nnew file mode 100644\nindex 0000000000..22b958e369\n--- /dev/null\n+++ b/t/t4018/css-root-selector\n@@ -0,0 +1,4 @@\n+:RIGHT {\n+    background : #000;\n+    border : 10px ChangeMe #C6C6C6;\n+}\ndiff --git a/userdiff.c b/userdiff.c\nindex fde02f225b..f6a4b0fb2e 100644\n--- a/userdiff.c\n+++ b/userdiff.c\n@@ -200,7 +200,7 @@ PATTERNS(\"csharp\",\n \t \"|[-+*/<>%&^|=!]=|--|\\\\+\\\\+|<<=?|>>=?|&&|\\\\|\\\\||::|->\"),\n IPATTERN(\"css\",\n \t \"![:;][[:space:]]*$\\n\"\n-\t \"^[_a-z0-9].*$\",\n+\t \"^[:[@.#]?[_a-z0-9].*$\",\n \t /* -- */\n \t /*\n \t  * This regex comes from W3C CSS specs. Should theoretically also\n\nbase-commit: d98273ba77e1ab9ec755576bc86c716a97bf59d7\n-- \ngitgitgadget\n"},{"id":"407169","messageId":"xmqqeem8y6ld.fsf@gitster.c.googlers.com","threadId":"54363","inReplyTo":"pull.866.v2.git.git.1602146164799.gitgitgadget@gmail.com","subject":"Re: [PATCH v2] userdiff: expand detected chunk headers for css","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-10-08T17:23:42Z","receivedAt":"2020-10-08T17:23:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Sohom Datta via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Sohom <sohom.datta@learner.manipal.edu>\n\nI'd call this line *1* for later reference...\n\n> The regex used for the CSS builtin diff driver in git is only\n> able to show chunk headers for lines that start with a number,\n> a letter or an underscore.\n>\n> However, the regex fails to detect classes (starts with a .), ids\n> (starts with a #), :root and attribute-value based selectors (for\n> example [class*=\"col-\"]), as well as @based block-level statements\n> like @page,@keyframes and @media since all of them, start with a\n> special character.\n>\n> Allow the selectors and block level statements to begin with these\n> special characters.\n>\n> Signed-off-by: Sohom Datta <sohom.datta@learner.manipal.edu>\n> ---\n\nLooking good.\n\nThe \"Name <email>\" on line *1* must match that on the last\n\"signed-off-by\" line, so I'll locally tweak the authorship information\nbefore applying the patch.\n\nThanks.\n\n"}]}