{"thread":{"id":"54355","subject":"[PATCH] userdiff: support Rust macros","startedAt":"2020-10-06T12:13:58Z","lastAt":"2020-10-07T13:26:18Z","messageCount":6,"participants":["Konrad Borowski via GitGitGadget","Phillip Wood","Johannes Sixt","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"406990","messageId":"pull.865.git.git.1601986430388.gitgitgadget@gmail.com","threadId":"54355","inReplyTo":null,"subject":"[PATCH] userdiff: support Rust macros","fromName":"Konrad Borowski via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-10-06T12:13:50Z","receivedAt":"2020-10-06T12:13:58Z","isPatch":true,"sender":{"key":"name:Konrad Borowski","avatar":null},"body":"From: Konrad Borowski <konrad@borowski.pw>\n\nThis adds a support for macro_rules! keyword which declares\na macro. It also includes a test case.\n\nSigned-off-by: Konrad Borowski <konrad@borowski.pw>\n---\n    userdiff: support Rust macros\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-865%2Fxfix%2Fuserdiff-macro-rules-rust-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-865/xfix/userdiff-macro-rules-rust-v1\nPull-Request: https://github.com/git/git/pull/865\n\n t/t4018/rust-macro-rules | 6 ++++++\n userdiff.c               | 2 +-\n 2 files changed, 7 insertions(+), 1 deletion(-)\n create mode 100644 t/t4018/rust-macro-rules\n\ndiff --git a/t/t4018/rust-macro-rules b/t/t4018/rust-macro-rules\nnew file mode 100644\nindex 0000000000..ec610c5b62\n--- /dev/null\n+++ b/t/t4018/rust-macro-rules\n@@ -0,0 +1,6 @@\n+macro_rules! RIGHT {\n+    () => {\n+        // a comment\n+        let x = ChangeMe;\n+    };\n+}\ndiff --git a/userdiff.c b/userdiff.c\nindex fde02f225b..f13a913697 100644\n--- a/userdiff.c\n+++ b/userdiff.c\n@@ -165,7 +165,7 @@ PATTERNS(\"ruby\", \"^[ \\t]*((class|module|def)[ \\t].*)$\",\n \t \"|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+|\\\\?(\\\\\\\\C-)?(\\\\\\\\M-)?.\"\n \t \"|//=?|[-+*/<>%&^|=!]=|<<=?|>>=?|===|\\\\.{1,3}|::|[!=]~\"),\n PATTERNS(\"rust\",\n-\t \"^[\\t ]*((pub(\\\\([^\\\\)]+\\\\))?[\\t ]+)?((async|const|unsafe|extern([\\t ]+\\\"[^\\\"]+\\\"))[\\t ]+)?(struct|enum|union|mod|trait|fn|impl)[< \\t]+[^;]*)$\",\n+\t \"^[\\t ]*(((pub(\\\\([^\\\\)]+\\\\))?[\\t ]+)?((async|const|unsafe|extern([\\t ]+\\\"[^\\\"]+\\\"))[\\t ]+)?(struct|enum|union|mod|trait|fn|impl)[< \\t]+|macro_rules[\\t ]*!)[^;]*)$\",\n \t /* -- */\n \t \"[a-zA-Z_][a-zA-Z0-9_]*\"\n \t \"|[0-9][0-9_a-fA-Fiosuxz]*(\\\\.([0-9]*[eE][+-]?)?[0-9_fF]*)?\"\n\nbase-commit: d98273ba77e1ab9ec755576bc86c716a97bf59d7\n-- \ngitgitgadget\n"},{"id":"406993","messageId":"18297f15-3b67-73a6-9ad4-cf477622fe62@gmail.com","threadId":"54355","inReplyTo":"pull.865.git.git.1601986430388.gitgitgadget@gmail.com","subject":"Re: [PATCH] userdiff: support Rust macros","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2020-10-06T16:44:54Z","receivedAt":"2020-10-06T16:44:59Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"Hi Konrad\n\nThanks for the patch, this would be a useful addition\n\nOn 06/10/2020 13:13, Konrad Borowski via GitGitGadget wrote:\n> From: Konrad Borowski <konrad@borowski.pw>\n> \n> This adds a support for macro_rules! keyword which declares\n> a macro. It also includes a test case.\n> \n> Signed-off-by: Konrad Borowski <konrad@borowski.pw>\n> ---\n>      userdiff: support Rust macros\n> \n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-865%2Fxfix%2Fuserdiff-macro-rules-rust-v1\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-865/xfix/userdiff-macro-rules-rust-v1\n> Pull-Request: https://github.com/git/git/pull/865\n> \n>   t/t4018/rust-macro-rules | 6 ++++++\n>   userdiff.c               | 2 +-\n>   2 files changed, 7 insertions(+), 1 deletion(-)\n>   create mode 100644 t/t4018/rust-macro-rules\n> \n> diff --git a/t/t4018/rust-macro-rules b/t/t4018/rust-macro-rules\n> new file mode 100644\n> index 0000000000..ec610c5b62\n> --- /dev/null\n> +++ b/t/t4018/rust-macro-rules\n> @@ -0,0 +1,6 @@\n> +macro_rules! RIGHT {\n> +    () => {\n> +        // a comment\n> +        let x = ChangeMe;\n> +    };\n> +}\n> diff --git a/userdiff.c b/userdiff.c\n> index fde02f225b..f13a913697 100644\n> --- a/userdiff.c\n> +++ b/userdiff.c\n> @@ -165,7 +165,7 @@ PATTERNS(\"ruby\", \"^[ \\t]*((class|module|def)[ \\t].*)$\",\n>   \t \"|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+|\\\\?(\\\\\\\\C-)?(\\\\\\\\M-)?.\"\n>   \t \"|//=?|[-+*/<>%&^|=!]=|<<=?|>>=?|===|\\\\.{1,3}|::|[!=]~\"),\n>   PATTERNS(\"rust\",\n> -\t \"^[\\t ]*((pub(\\\\([^\\\\)]+\\\\))?[\\t ]+)?((async|const|unsafe|extern([\\t ]+\\\"[^\\\"]+\\\"))[\\t ]+)?(struct|enum|union|mod|trait|fn|impl)[< \\t]+[^;]*)$\",\n> +\t \"^[\\t ]*(((pub(\\\\([^\\\\)]+\\\\))?[\\t ]+)?((async|const|unsafe|extern([\\t ]+\\\"[^\\\"]+\\\"))[\\t ]+)?(struct|enum|union|mod|trait|fn|impl)[< \\t]+|macro_rules[\\t ]*!)\n\nI think you want the `!` before the `[\\t ]`. We could probably get away \nwith just adding `macro-rules!` as another alternative in the group \nstarting with `struct`\n\nBest Wishes\n\nPhillip\n\n[^;]*)$\",\n>   \t /* -- */\n>   \t \"[a-zA-Z_][a-zA-Z0-9_]*\"\n>   \t \"|[0-9][0-9_a-fA-Fiosuxz]*(\\\\.([0-9]*[eE][+-]?)?[0-9_fF]*)?\"\n> \n> base-commit: d98273ba77e1ab9ec755576bc86c716a97bf59d7\n> \n"},{"id":"406996","messageId":"42808d58-6472-5959-a471-3d09d06d8fd3@kdbg.org","threadId":"54355","inReplyTo":"pull.865.git.git.1601986430388.gitgitgadget@gmail.com","subject":"Re: [PATCH] userdiff: support Rust macros","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2020-10-06T18:44:10Z","receivedAt":"2020-10-06T18:44:15Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 06.10.20 um 14:13 schrieb Konrad Borowski via GitGitGadget:\n> From: Konrad Borowski <konrad@borowski.pw>\n> \n> This adds a support for macro_rules! keyword which declares\n> a macro. It also includes a test case.\n\nWe would write this sentence in imperative mood, i.e., give the codebase\nthe order to become so. That a test case is included can be seen from\nthe patch text and need not be mentioned.\n\nIn this case, if I were the only one to judge, I would accept this\ncommit without a message if the commit summary were:\n\n  userdiff: permit Rust's macro_rules! keyword in hunk headers\n\n> \n> Signed-off-by: Konrad Borowski <konrad@borowski.pw>\n> ---\n>     userdiff: support Rust macros\n> \n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-865%2Fxfix%2Fuserdiff-macro-rules-rust-v1\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-865/xfix/userdiff-macro-rules-rust-v1\n> Pull-Request: https://github.com/git/git/pull/865\n> \n>  t/t4018/rust-macro-rules | 6 ++++++\n>  userdiff.c               | 2 +-\n>  2 files changed, 7 insertions(+), 1 deletion(-)\n>  create mode 100644 t/t4018/rust-macro-rules\n> \n> diff --git a/t/t4018/rust-macro-rules b/t/t4018/rust-macro-rules\n> new file mode 100644\n> index 0000000000..ec610c5b62\n> --- /dev/null\n> +++ b/t/t4018/rust-macro-rules\n> @@ -0,0 +1,6 @@\n> +macro_rules! RIGHT {\n> +    () => {\n> +        // a comment\n> +        let x = ChangeMe;\n> +    };\n> +}\n> diff --git a/userdiff.c b/userdiff.c\n> index fde02f225b..f13a913697 100644\n> --- a/userdiff.c\n> +++ b/userdiff.c\n> @@ -165,7 +165,7 @@ PATTERNS(\"ruby\", \"^[ \\t]*((class|module|def)[ \\t].*)$\",\n>  \t \"|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+|\\\\?(\\\\\\\\C-)?(\\\\\\\\M-)?.\"\n>  \t \"|//=?|[-+*/<>%&^|=!]=|<<=?|>>=?|===|\\\\.{1,3}|::|[!=]~\"),\n>  PATTERNS(\"rust\",\n> -\t \"^[\\t ]*((pub(\\\\([^\\\\)]+\\\\))?[\\t ]+)?((async|const|unsafe|extern([\\t ]+\\\"[^\\\"]+\\\"))[\\t ]+)?(struct|enum|union|mod|trait|fn|impl)[< \\t]+[^;]*)$\",\n> +\t \"^[\\t ]*(((pub(\\\\([^\\\\)]+\\\\))?[\\t ]+)?((async|const|unsafe|extern([\\t ]+\\\"[^\\\"]+\\\"))[\\t ]+)?(struct|enum|union|mod|trait|fn|impl)[< \\t]+|macro_rules[\\t ]*!)[^;]*)$\",\n>  \t /* -- */\n>  \t \"[a-zA-Z_][a-zA-Z0-9_]*\"\n>  \t \"|[0-9][0-9_a-fA-Fiosuxz]*(\\\\.([0-9]*[eE][+-]?)?[0-9_fF]*)?\"\n\nTechnically, this looks fine. Originally I thought that the new keyword\ncould just be thrown into the mix of struct|enum etc, but judging from\nthe (existing) test cases, this new case looks fairly different (I am\nnot a Rust expert, so I cannot really tell). Therefore, it is OK to put\nit in an alternative branch in the regexp.\n\nReviewed-by: Johannes Sixt <j6t@kdbg.org>\n\n-- Hannes\n"},{"id":"407026","messageId":"pull.865.v2.git.git.1602048429067.gitgitgadget@gmail.com","threadId":"54355","inReplyTo":"pull.865.git.git.1601986430388.gitgitgadget@gmail.com","subject":"[PATCH v2] userdiff: permit Rust's macro_rules! keyword in hunk headers","fromName":"Konrad Borowski via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-10-07T05:27:08Z","receivedAt":"2020-10-07T05:27:17Z","isPatch":true,"sender":{"key":"name:Konrad Borowski","avatar":null},"body":"From: Konrad Borowski <konrad@borowski.pw>\n\nChanges since v1:\n- Changed macro_rules! to be considered to use the same\n  rule as rest of keywords to reduce the size of a change\n  as suggested by Phillip Wood. This means that\n  'pub macro_rules!` (a syntax error) is considered to be\n  a hunk header.\n\n- Written commit message in imperative mood as suggested by\n  Johannes Sixt.\n\nSigned-off-by: Konrad Borowski <konrad@borowski.pw>\n---\n    userdiff: support Rust macros\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-865%2Fxfix%2Fuserdiff-macro-rules-rust-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-865/xfix/userdiff-macro-rules-rust-v2\nPull-Request: https://github.com/git/git/pull/865\n\nRange-diff vs v1:\n\n 1:  9e071ddf63 ! 1:  a3fd67d84f userdiff: support Rust macros\n     @@ Metadata\n      Author: Konrad Borowski <konrad@borowski.pw>\n      \n       ## Commit message ##\n     -    userdiff: support Rust macros\n     +    userdiff: permit Rust's macro_rules! keyword in hunk headers\n      \n     -    This adds a support for macro_rules! keyword which declares\n     -    a macro. It also includes a test case.\n     +    Changes since v1:\n     +    - Changed macro_rules! to be considered to use the same\n     +      rule as rest of keywords to reduce the size of a change\n     +      as suggested by Phillip Wood. This means that\n     +      'pub macro_rules!` (a syntax error) is considered to be\n     +      a hunk header.\n     +\n     +    - Written commit message in imperative mood as suggested by\n     +      Johannes Sixt.\n      \n          Signed-off-by: Konrad Borowski <konrad@borowski.pw>\n      \n     @@ userdiff.c: PATTERNS(\"ruby\", \"^[ \\t]*((class|module|def)[ \\t].*)$\",\n       \t \"|//=?|[-+*/<>%&^|=!]=|<<=?|>>=?|===|\\\\.{1,3}|::|[!=]~\"),\n       PATTERNS(\"rust\",\n      -\t \"^[\\t ]*((pub(\\\\([^\\\\)]+\\\\))?[\\t ]+)?((async|const|unsafe|extern([\\t ]+\\\"[^\\\"]+\\\"))[\\t ]+)?(struct|enum|union|mod|trait|fn|impl)[< \\t]+[^;]*)$\",\n     -+\t \"^[\\t ]*(((pub(\\\\([^\\\\)]+\\\\))?[\\t ]+)?((async|const|unsafe|extern([\\t ]+\\\"[^\\\"]+\\\"))[\\t ]+)?(struct|enum|union|mod|trait|fn|impl)[< \\t]+|macro_rules[\\t ]*!)[^;]*)$\",\n     ++\t \"^[\\t ]*((pub(\\\\([^\\\\)]+\\\\))?[\\t ]+)?((async|const|unsafe|extern([\\t ]+\\\"[^\\\"]+\\\"))[\\t ]+)?(struct|enum|union|mod|trait|fn|impl|macro_rules[\\t ]*!)[< \\t]+[^;]*)$\",\n       \t /* -- */\n       \t \"[a-zA-Z_][a-zA-Z0-9_]*\"\n       \t \"|[0-9][0-9_a-fA-Fiosuxz]*(\\\\.([0-9]*[eE][+-]?)?[0-9_fF]*)?\"\n\n\n t/t4018/rust-macro-rules | 6 ++++++\n userdiff.c               | 2 +-\n 2 files changed, 7 insertions(+), 1 deletion(-)\n create mode 100644 t/t4018/rust-macro-rules\n\ndiff --git a/t/t4018/rust-macro-rules b/t/t4018/rust-macro-rules\nnew file mode 100644\nindex 0000000000..ec610c5b62\n--- /dev/null\n+++ b/t/t4018/rust-macro-rules\n@@ -0,0 +1,6 @@\n+macro_rules! RIGHT {\n+    () => {\n+        // a comment\n+        let x = ChangeMe;\n+    };\n+}\ndiff --git a/userdiff.c b/userdiff.c\nindex fde02f225b..c0f63c57b2 100644\n--- a/userdiff.c\n+++ b/userdiff.c\n@@ -165,7 +165,7 @@ PATTERNS(\"ruby\", \"^[ \\t]*((class|module|def)[ \\t].*)$\",\n \t \"|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+|\\\\?(\\\\\\\\C-)?(\\\\\\\\M-)?.\"\n \t \"|//=?|[-+*/<>%&^|=!]=|<<=?|>>=?|===|\\\\.{1,3}|::|[!=]~\"),\n PATTERNS(\"rust\",\n-\t \"^[\\t ]*((pub(\\\\([^\\\\)]+\\\\))?[\\t ]+)?((async|const|unsafe|extern([\\t ]+\\\"[^\\\"]+\\\"))[\\t ]+)?(struct|enum|union|mod|trait|fn|impl)[< \\t]+[^;]*)$\",\n+\t \"^[\\t ]*((pub(\\\\([^\\\\)]+\\\\))?[\\t ]+)?((async|const|unsafe|extern([\\t ]+\\\"[^\\\"]+\\\"))[\\t ]+)?(struct|enum|union|mod|trait|fn|impl|macro_rules[\\t ]*!)[< \\t]+[^;]*)$\",\n \t /* -- */\n \t \"[a-zA-Z_][a-zA-Z0-9_]*\"\n \t \"|[0-9][0-9_a-fA-Fiosuxz]*(\\\\.([0-9]*[eE][+-]?)?[0-9_fF]*)?\"\n\nbase-commit: d98273ba77e1ab9ec755576bc86c716a97bf59d7\n-- \ngitgitgadget\n"},{"id":"407027","messageId":"xmqqimbm4ldb.fsf@gitster.c.googlers.com","threadId":"54355","inReplyTo":"pull.865.v2.git.git.1602048429067.gitgitgadget@gmail.com","subject":"Re: [PATCH v2] userdiff: permit Rust's macro_rules! keyword in hunk headers","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-10-07T06:10:24Z","receivedAt":"2020-10-07T06:10:29Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Konrad Borowski via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Konrad Borowski <konrad@borowski.pw>\n>\n> Changes since v1:\n> - Changed macro_rules! to be considered to use the same\n>   rule as rest of keywords to reduce the size of a change\n>   as suggested by Phillip Wood. This means that\n>   'pub macro_rules!` (a syntax error) is considered to be\n>   a hunk header.\n>\n> - Written commit message in imperative mood as suggested by\n>   Johannes Sixt.\n\nThe above is where you write the proposed log message, not where you\nwrite the differences between v1 and v2 (which, if exists, would be\nbelow the three-dash line after your sign off).  After all, people\nwho are reading the final history of the project in \"git log\" will\nnot even know or care that what they are reading is the second\niteration and/or there was a first iteration that was different from\nthe final version.\n\n> Subject: [PATCH v2] userdiff: permit Rust's macro_rules! keyword in hunk headers\n\nSomehow I find the \"permit\" a bit odd---it is not like we are\ndisallowing Rust programs written in certain way.\n\n     userdiff: recognize 'macro_rules!' as starting a Rust function block\n\nor something?\n\n> Signed-off-by: Konrad Borowski <konrad@borowski.pw>\n> ---\n> ...\n\nAs to the simplified rule that matches 'pub macro_rules!'.\n\nWe assume what is written by the end-user, in which these patterns\nare used to find function headers, is a syntactically correct\nprogram.  This allows us to write a pattern that may match with a\nsyntactic nonsense (i.e. false positive is perfectly fine).  What\nwe care about is to avoid false negatives---if our pattern does not\nrecognize what users would consider a valid and common function\nheader line, that is a problem.\n\nSo, from that point of view, you do not have to worry too much about\n'pub macro_rules!'  matching your pattern.\n\n> diff --git a/t/t4018/rust-macro-rules b/t/t4018/rust-macro-rules\n> new file mode 100644\n> index 0000000000..ec610c5b62\n> --- /dev/null\n> +++ b/t/t4018/rust-macro-rules\n> @@ -0,0 +1,6 @@\n> +macro_rules! RIGHT {\n> +    () => {\n> +        // a comment\n> +        let x = ChangeMe;\n> +    };\n> +}\n> diff --git a/userdiff.c b/userdiff.c\n> index fde02f225b..c0f63c57b2 100644\n> --- a/userdiff.c\n> +++ b/userdiff.c\n> @@ -165,7 +165,7 @@ PATTERNS(\"ruby\", \"^[ \\t]*((class|module|def)[ \\t].*)$\",\n>  \t \"|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+|\\\\?(\\\\\\\\C-)?(\\\\\\\\M-)?.\"\n>  \t \"|//=?|[-+*/<>%&^|=!]=|<<=?|>>=?|===|\\\\.{1,3}|::|[!=]~\"),\n>  PATTERNS(\"rust\",\n> -\t \"^[\\t ]*((pub(\\\\([^\\\\)]+\\\\))?[\\t ]+)?((async|const|unsafe|extern([\\t ]+\\\"[^\\\"]+\\\"))[\\t ]+)?(struct|enum|union|mod|trait|fn|impl)[< \\t]+[^;]*)$\",\n> +\t \"^[\\t ]*((pub(\\\\([^\\\\)]+\\\\))?[\\t ]+)?((async|const|unsafe|extern([\\t ]+\\\"[^\\\"]+\\\"))[\\t ]+)?(struct|enum|union|mod|trait|fn|impl|macro_rules[\\t ]*!)[< \\t]+[^;]*)$\",\n\nI notice that you still allow \"macro_rules    !\" as Phillip pointed\nout.  Is that intended?\n\nThanks.\n"},{"id":"407052","messageId":"pull.865.v3.git.git.1602077171751.gitgitgadget@gmail.com","threadId":"54355","inReplyTo":"pull.865.v2.git.git.1602048429067.gitgitgadget@gmail.com","subject":"[PATCH v3] userdiff: recognize 'macro_rules!' as starting a Rust function block","fromName":"Konrad Borowski via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2020-10-07T13:26:11Z","receivedAt":"2020-10-07T13:26:18Z","isPatch":true,"sender":{"key":"name:Konrad Borowski","avatar":null},"body":"From: Konrad Borowski <konrad@borowski.pw>\n\nSigned-off-by: Konrad Borowski <konrad@borowski.pw>\n---\n    userdiff: support Rust macros\n    \n    Changes since v1:\n    \n     * Changed macro_rules! to be considered to use the same rule as rest of\n       keywords to reduce the size of a change as suggested by Phillip Wood.\n       This means that 'pub macro_rules!` (a syntax error) is considered to\n       be a hunk header.\n     * Written commit message in imperative mood as suggested by Johannes\n       Sixt.\n    \n    Changes since v2:\n    \n     * Updated the commit message as suggested by Junio C Hamano.\n     * Removed handling for 'macro_rules !' with a space in-between tokens.\n       While it is allowed by the compiler to have a space between\n       'macro_rules' and '!' it's pretty much never done.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-865%2Fxfix%2Fuserdiff-macro-rules-rust-v3\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-865/xfix/userdiff-macro-rules-rust-v3\nPull-Request: https://github.com/git/git/pull/865\n\nRange-diff vs v2:\n\n 1:  a3fd67d84f ! 1:  0d8e6e06d4 userdiff: permit Rust's macro_rules! keyword in hunk headers\n     @@ Metadata\n      Author: Konrad Borowski <konrad@borowski.pw>\n      \n       ## Commit message ##\n     -    userdiff: permit Rust's macro_rules! keyword in hunk headers\n     -\n     -    Changes since v1:\n     -    - Changed macro_rules! to be considered to use the same\n     -      rule as rest of keywords to reduce the size of a change\n     -      as suggested by Phillip Wood. This means that\n     -      'pub macro_rules!` (a syntax error) is considered to be\n     -      a hunk header.\n     -\n     -    - Written commit message in imperative mood as suggested by\n     -      Johannes Sixt.\n     +    userdiff: recognize 'macro_rules!' as starting a Rust function block\n      \n          Signed-off-by: Konrad Borowski <konrad@borowski.pw>\n      \n     @@ userdiff.c: PATTERNS(\"ruby\", \"^[ \\t]*((class|module|def)[ \\t].*)$\",\n       \t \"|//=?|[-+*/<>%&^|=!]=|<<=?|>>=?|===|\\\\.{1,3}|::|[!=]~\"),\n       PATTERNS(\"rust\",\n      -\t \"^[\\t ]*((pub(\\\\([^\\\\)]+\\\\))?[\\t ]+)?((async|const|unsafe|extern([\\t ]+\\\"[^\\\"]+\\\"))[\\t ]+)?(struct|enum|union|mod|trait|fn|impl)[< \\t]+[^;]*)$\",\n     -+\t \"^[\\t ]*((pub(\\\\([^\\\\)]+\\\\))?[\\t ]+)?((async|const|unsafe|extern([\\t ]+\\\"[^\\\"]+\\\"))[\\t ]+)?(struct|enum|union|mod|trait|fn|impl|macro_rules[\\t ]*!)[< \\t]+[^;]*)$\",\n     ++\t \"^[\\t ]*((pub(\\\\([^\\\\)]+\\\\))?[\\t ]+)?((async|const|unsafe|extern([\\t ]+\\\"[^\\\"]+\\\"))[\\t ]+)?(struct|enum|union|mod|trait|fn|impl|macro_rules!)[< \\t]+[^;]*)$\",\n       \t /* -- */\n       \t \"[a-zA-Z_][a-zA-Z0-9_]*\"\n       \t \"|[0-9][0-9_a-fA-Fiosuxz]*(\\\\.([0-9]*[eE][+-]?)?[0-9_fF]*)?\"\n\n\n t/t4018/rust-macro-rules | 6 ++++++\n userdiff.c               | 2 +-\n 2 files changed, 7 insertions(+), 1 deletion(-)\n create mode 100644 t/t4018/rust-macro-rules\n\ndiff --git a/t/t4018/rust-macro-rules b/t/t4018/rust-macro-rules\nnew file mode 100644\nindex 0000000000..ec610c5b62\n--- /dev/null\n+++ b/t/t4018/rust-macro-rules\n@@ -0,0 +1,6 @@\n+macro_rules! RIGHT {\n+    () => {\n+        // a comment\n+        let x = ChangeMe;\n+    };\n+}\ndiff --git a/userdiff.c b/userdiff.c\nindex fde02f225b..2903037724 100644\n--- a/userdiff.c\n+++ b/userdiff.c\n@@ -165,7 +165,7 @@ PATTERNS(\"ruby\", \"^[ \\t]*((class|module|def)[ \\t].*)$\",\n \t \"|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+|\\\\?(\\\\\\\\C-)?(\\\\\\\\M-)?.\"\n \t \"|//=?|[-+*/<>%&^|=!]=|<<=?|>>=?|===|\\\\.{1,3}|::|[!=]~\"),\n PATTERNS(\"rust\",\n-\t \"^[\\t ]*((pub(\\\\([^\\\\)]+\\\\))?[\\t ]+)?((async|const|unsafe|extern([\\t ]+\\\"[^\\\"]+\\\"))[\\t ]+)?(struct|enum|union|mod|trait|fn|impl)[< \\t]+[^;]*)$\",\n+\t \"^[\\t ]*((pub(\\\\([^\\\\)]+\\\\))?[\\t ]+)?((async|const|unsafe|extern([\\t ]+\\\"[^\\\"]+\\\"))[\\t ]+)?(struct|enum|union|mod|trait|fn|impl|macro_rules!)[< \\t]+[^;]*)$\",\n \t /* -- */\n \t \"[a-zA-Z_][a-zA-Z0-9_]*\"\n \t \"|[0-9][0-9_a-fA-Fiosuxz]*(\\\\.([0-9]*[eE][+-]?)?[0-9_fF]*)?\"\n\nbase-commit: d98273ba77e1ab9ec755576bc86c716a97bf59d7\n-- \ngitgitgadget\n"}]}