git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] userdiff: add built-in pattern for CSS

From
Johannes Sixt <j6t@kdbg.org>
Date
May 26, 2016, 21:11 UTC
Message-ID
<5747669C.9020807@kdbg.org>
In-Reply-To
<20160524142537.19324-1-william.duclot@ensimag.grenoble-inp.fr>
Am 24.05.2016 um 16:25 schrieb William Duclot:
> +PATTERNS("css",
> +	 "^([^,{}]+)((,[^}]*\\{)|([ \t]*\\{))$",

This hunk header pattern is a bit too restrictive for my taste. Find below a few more test cases that you should squash in. One case fails because only the first CSS selector is picked up, for which I do not see a reason.

Another case fails because the opening brace is not on the line with the CSS selectors.

I think what the hunk header pattern should do is:
1. reject lines containing a colon (because that are properties)
2. if a line begins with a name in column 1, pick the whole line
See the cpp patterns: a pattern beginning with ! is a "reject" pattern.
diff --git a/t/t4018/css-brace-in-col-1 b/t/t4018/css-brace-in-col-1
new file mode 100644
index 0000000..7831577
--- /dev/null
+++ b/t/t4018/css-brace-in-col-1
@@ -0,0 +1,5 @@
+RIGHT label.control-label
+{
+    margin-top: 10px!important;
+    border : 10px ChangeMe #C6C6C6;
+}
diff --git a/t/t4018/css-rule b/t/t4018/css-common
similarity index 100%
rename from t/t4018/css-rule
rename to t/t4018/css-common
diff --git a/t/t4018/css-long-selector-list b/t/t4018/css-long-selector-list
new file mode 100644
index 0000000..7ccd25d
--- /dev/null
+++ b/t/t4018/css-long-selector-list
@@ -0,0 +1,6 @@
+p.header,
+label.control-label,
+div ul#RIGHT {
+    margin-top: 10px!important;
+    border : 10px ChangeMe #C6C6C6;
+}
diff --git a/t/t4018/css-prop-sans-indent b/t/t4018/css-prop-sans-indent
new file mode 100644
index 0000000..a9e3c86
--- /dev/null
+++ b/t/t4018/css-prop-sans-indent
@@ -0,0 +1,5 @@
+RIGHT, label.control-label {
+margin-top: 10px!important;
+padding: 0;
+border : 10px ChangeMe #C6C6C6;
+}
diff --git a/t/t4018/css-short-selector-list b/t/t4018/css-short-selector-list
new file mode 100644
index 0000000..6a0bdee
--- /dev/null
+++ b/t/t4018/css-short-selector-list
@@ -0,0 +1,4 @@
+label.control, div ul#RIGHT {
+    margin-top: 10px!important;
+    border : 10px ChangeMe #C6C6C6;
+}
-- 
2.9.0.rc0.40.gb3c1388
Previous: Junio C HamanoNext: William Duclot
Message 7 of 21 in “userdiff: add built-in pattern for CSS”
  1. userdiff: add built-in pattern for CSSWilliam Duclot, May 20, 2016
  2. Junio C HamanoMay 20, 2016
  3. userdiff: add built-in pattern for CSSWilliam Duclot, May 24, 2016
  4. Junio C HamanoMay 24, 2016
  5. William DuclotMay 24, 2016
  6. Junio C HamanoMay 24, 2016
  7. Johannes SixtMay 26, 2016
  8. William DuclotMay 27, 2016
  9. userdiff: add built-in pattern for CSSWilliam Duclot, Jun 2, 2016
  10. Junio C HamanoJun 2, 2016
  11. Johannes SixtJun 3, 2016
  12. Matthieu MoyJun 3, 2016
  13. Johannes SixtJun 3, 2016
  14. William DuclotJun 3, 2016
  15. Junio C HamanoJun 3, 2016
  16. William DuclotJun 6, 2016
  17. Junio C HamanoJun 6, 2016
  18. William DuclotJun 6, 2016
  19. Junio C HamanoJun 6, 2016
  20. userdiff: add built-in pattern for CSSWilliam Duclot, Jun 3, 2016
  21. Johannes SixtJun 3, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.