{"thread":{"id":"63523","subject":"[PATCH 1/2] userdiff: add support for R programming language","startedAt":"2025-05-25T21:03:10Z","lastAt":"2025-06-03T21:16:06Z","messageCount":9,"participants":["Rodrigo Carvalho","Eric Sunshine","Johannes Sixt","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"518894","messageId":"20250525210236.116342-1-rodrigorsdc@gmail.com","threadId":"63523","inReplyTo":null,"subject":"[PATCH 1/2] userdiff: add support for R programming language","fromName":"Rodrigo Carvalho","fromEmail":"rodrigorsdc@gmail.com","sentAt":"2025-05-25T21:02:35Z","receivedAt":"2025-05-25T21:03:10Z","isPatch":true,"sender":{"key":"rodrigorsdc@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701582?v=4"},"body":"The patch appends userdiff.c file in order to support R programming\nlanguage function header. This will be useful for those who use Git\nfor versioning .R files.\n\nSigned-off-by: Rodrigo Carvalho <rodrigorsdc@gmail.com>\n---\n userdiff.c | 4 ++++\n 1 file changed, 4 insertions(+)\n\ndiff --git a/userdiff.c b/userdiff.c\nindex da75625020..d1d31ea67e 100644\n--- a/userdiff.c\n+++ b/userdiff.c\n@@ -317,6 +317,10 @@ PATTERNS(\"python\",\n \t \"|[-+0-9.e]+[jJlL]?|0[xX]?[0-9a-fA-F]+[lL]?\"\n \t \"|[-+*/<>%&^|=!]=|//=?|<<=?|>>=?|\\\\*\\\\*=?\"),\n \t /* -- */\n+PATTERNS(\"r\",\n+\t\"^[ \\t]*([a-zA-z][a-zA-Z0-9_.]*[ \\t]*<-[ \\t]*function.*)$\",\n+\t/* -- */\n+\t\"[a-zA-Z_][a-zA-Z0-9_.]*\"),\n PATTERNS(\"ruby\",\n \t \"^[ \\t]*((class|module|def)[ \\t].*)$\",\n \t /* -- */\n-- \n2.43.0\n\n"},{"id":"518895","messageId":"20250525210236.116342-2-rodrigorsdc@gmail.com","threadId":"63523","inReplyTo":"20250525210236.116342-1-rodrigorsdc@gmail.com","subject":"[PATCH 2/2] t4018: add two userdiff tests for R language","fromName":"Rodrigo Carvalho","fromEmail":"rodrigorsdc@gmail.com","sentAt":"2025-05-25T21:02:36Z","receivedAt":"2025-05-25T21:03:12Z","isPatch":true,"sender":{"key":"rodrigorsdc@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701582?v=4"},"body":"This patch adds two userdiff tests for R programming language\nfiles. These files define a simple function, with and without\nindentation.\n\nSigned-off-by: Rodrigo Carvalho <rodrigorsdc@gmail.com>\n---\n t/t4018/r-indent   | 6 ++++++\n t/t4018/r-noindent | 6 ++++++\n 2 files changed, 12 insertions(+)\n create mode 100644 t/t4018/r-indent\n create mode 100644 t/t4018/r-noindent\n\ndiff --git a/t/t4018/r-indent b/t/t4018/r-indent\nnew file mode 100644\nindex 0000000000..9df440f2a4\n--- /dev/null\n+++ b/t/t4018/r-indent\n@@ -0,0 +1,6 @@\n+RIGHT <- function(a, b) {\n+    c = mean(a, b)\n+    d = c + 2\n+    ChangeMe()\n+    return (d)\n+}\ndiff --git a/t/t4018/r-noindent b/t/t4018/r-noindent\nnew file mode 100644\nindex 0000000000..6d9b01ffe3\n--- /dev/null\n+++ b/t/t4018/r-noindent\n@@ -0,0 +1,6 @@\n+RIGHT <- function(a, b) {\n+c = mean(a, b)\n+d = c + 2\n+ChangeMe()\n+return (c)\n+}\n-- \n2.43.0\n\n"},{"id":"518896","messageId":"CAPig+cQ07SMbfD8Er1Ukdpih_8AL_exbz7U6WzZ3b2js2ge1cg@mail.gmail.com","threadId":"63523","inReplyTo":"20250525210236.116342-2-rodrigorsdc@gmail.com","subject":"Re: [PATCH 2/2] t4018: add two userdiff tests for R language","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2025-05-25T22:42:43Z","receivedAt":"2025-05-25T22:42:54Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sun, May 25, 2025 at 5:03 PM Rodrigo Carvalho <rodrigorsdc@gmail.com> wrote:\n> This patch adds two userdiff tests for R programming language\n> files. These files define a simple function, with and without\n> indentation.\n>\n> Signed-off-by: Rodrigo Carvalho <rodrigorsdc@gmail.com>\n> ---\n> diff --git a/t/t4018/r-indent b/t/t4018/r-indent\n> @@ -0,0 +1,6 @@\n> +RIGHT <- function(a, b) {\n> +    c = mean(a, b)\n> +    d = c + 2\n> +    ChangeMe()\n> +    return (d)\n> +}\n\nAlthough nontraditional, do we care that some people define functions\nusing `=` rather than `<-`?\n\n    foo = function(x) {...}\n"},{"id":"518901","messageId":"385d7189-98fa-4863-8bcf-905c76eccbc8@kdbg.org","threadId":"63523","inReplyTo":"20250525210236.116342-1-rodrigorsdc@gmail.com","subject":"Re: [PATCH 1/2] userdiff: add support for R programming language","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2025-05-26T05:57:33Z","receivedAt":"2025-05-26T06:31:28Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 25.05.25 um 23:02 schrieb Rodrigo Carvalho:\n> The patch appends userdiff.c file in order to support R programming\n> language function header. This will be useful for those who use Git\n> for versioning .R files.\n> \n> Signed-off-by: Rodrigo Carvalho <rodrigorsdc@gmail.com>\n> ---\n>  userdiff.c | 4 ++++\n>  1 file changed, 4 insertions(+)\n> \n> diff --git a/userdiff.c b/userdiff.c\n> index da75625020..d1d31ea67e 100644\n> --- a/userdiff.c\n> +++ b/userdiff.c\n> @@ -317,6 +317,10 @@ PATTERNS(\"python\",\n>  \t \"|[-+0-9.e]+[jJlL]?|0[xX]?[0-9a-fA-F]+[lL]?\"\n>  \t \"|[-+*/<>%&^|=!]=|//=?|<<=?|>>=?|\\\\*\\\\*=?\"),\n>  \t /* -- */\n> +PATTERNS(\"r\",\n\nRant mode: I am not a fan of the name \"R\". It is so un-searchable. It\nhijacks a single character for its own purpose.\n\nI don't see a negative impact in this case, though.\n\n> +\t\"^[ \\t]*([a-zA-z][a-zA-Z0-9_.]*[ \\t]*<-[ \\t]*function.*)$\",\n\nI wonder how useful this is in practice. Unlike C or Java for example,\ncode can live outside of functions in R scripts. If you have a script\nwithout any functions, there would not be any hunk headers. If you have\na script with a mix of functions and code outside of functions, the code\nafter a function would be attributed to the function. I'm not saying\nthat this is bad, but just asking if this is part of the plan.\n\n> +\t/* -- */\n> +\t\"[a-zA-Z_][a-zA-Z0-9_.]*\"),\n\nThis singles out identifiers. Every single other characters would be its\nown word. I'd consider this a disimprovement. If you are not prepared to\nprovide worddiff patterns, I recommend to use \"[^ \\t]+\", which roughly\namounts to the default behavior. It can be improved incrementally in\nlater patches.\n\n>  PATTERNS(\"ruby\",\n>  \t \"^[ \\t]*((class|module|def)[ \\t].*)$\",\n>  \t /* -- */\n\nPlease squash the test cases into this patch. Don't forget to test an\nindented function, and while at it, test a function definition *nested*\nin a function definition: that documents what the expected outcome is.\n\n-- Hannes\n\n"},{"id":"518993","messageId":"xmqq4ix6rt75.fsf@gitster.g","threadId":"63523","inReplyTo":"385d7189-98fa-4863-8bcf-905c76eccbc8@kdbg.org","subject":"Re: [PATCH 1/2] userdiff: add support for R programming language","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-05-27T15:04:14Z","receivedAt":"2025-05-27T15:04:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Sixt <j6t@kdbg.org> writes:\n\n>> +\t\"^[ \\t]*([a-zA-z][a-zA-Z0-9_.]*[ \\t]*<-[ \\t]*function.*)$\",\n>\n> I wonder how useful this is in practice. Unlike C or Java for example,\n> code can live outside of functions in R scripts. If you have a script\n> without any functions, there would not be any hunk headers. If you have\n> a script with a mix of functions and code outside of functions, the code\n> after a function would be attributed to the function. I'm not saying\n> that this is bad, but just asking if this is part of the plan.\n\nIsn't it the same as shell, perl, python, e-lisp and perhaps others?\n\nIf we can reliably detect that we are outside of any function and\nset it to an empty string that would be great ;-).\n\n>> +\t/* -- */\n>> +\t\"[a-zA-Z_][a-zA-Z0-9_.]*\"),\n>\n> This singles out identifiers. Every single other characters would be its\n> own word. I'd consider this a disimprovement. If you are not prepared to\n> provide worddiff patterns, I recommend to use \"[^ \\t]+\", which roughly\n> amounts to the default behavior. It can be improved incrementally in\n> later patches.\n\nGood point.\n\n> Please squash the test cases into this patch. Don't forget to test an\n> indented function, and while at it, test a function definition *nested*\n> in a function definition: that documents what the expected outcome is.\n\nAgain, good point.\n\nThanks.\n"},{"id":"519181","messageId":"CAOeBkLo-Df7p-ndr06vA8MGHd42GEB6X3i66PnBt=MrQk7GJjw@mail.gmail.com","threadId":"63523","inReplyTo":"xmqq4ix6rt75.fsf@gitster.g","subject":"Re: [PATCH 1/2] userdiff: add support for R programming language","fromName":"Rodrigo Carvalho","fromEmail":"rodrigorsdc@gmail.com","sentAt":"2025-05-29T21:36:50Z","receivedAt":"2025-05-29T21:37:03Z","isPatch":true,"sender":{"key":"rodrigorsdc@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701582?v=4"},"body":"> > This singles out identifiers. Every single other characters would be its\n> > own word. I'd consider this a disimprovement. If you are not prepared to\n> > provide worddiff patterns, I recommend to use \"[^ \\t]+\", which roughly\n> > amounts to the default behavior. It can be improved incrementally in\n> > later patches.\n>\n> Good point.\n\nThanks for the remark. I'll change to this approach in v2\n\n\n> > Please squash the test cases into this patch. Don't forget to test an\n> > indented function, and while at it, test a function definition *nested*\n> > in a function definition: that documents what the expected outcome is.\n>\n> Again, good point.\n\nSure, that is an important feature that a userdiff driver should\naddress. Thanks again\n"},{"id":"519185","messageId":"20250529221805.97036-1-rodrigorsdc@gmail.com","threadId":"63523","inReplyTo":"20250525210236.116342-1-rodrigorsdc@gmail.com","subject":"[PATCH v2] userdiff: add support for R programming language","fromName":"Rodrigo Carvalho","fromEmail":"rodrigorsdc@gmail.com","sentAt":"2025-05-29T22:16:41Z","receivedAt":"2025-05-29T22:18:54Z","isPatch":true,"sender":{"key":"rodrigorsdc@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701582?v=4"},"body":"The patch appends userdiff.c file in order to support R programming\nlanguage function header. This will be useful for those who use Git\nfor versioning .R files.\n\nAlso, add three userdiff tests for R programming language\nfiles. These files define simple function and nested function,\nwith and without indentation.\n\nSigned-off-by: Rodrigo Carvalho <rodrigorsdc@gmail.com>\n---\nChanges in v2:\n- Add support for function defined by '='\n- Replace word regex to '[^ \\t']\n- Add new test that handles with nested function\n\n t/t4018/r-indent        |  6 ++++++\n t/t4018/r-indent-nested | 10 ++++++++++\n t/t4018/r-noindent      |  6 ++++++\n userdiff.c              |  4 ++++\n 4 files changed, 26 insertions(+)\n create mode 100644 t/t4018/r-indent\n create mode 100644 t/t4018/r-indent-nested\n create mode 100644 t/t4018/r-noindent\n\ndiff --git a/t/t4018/r-indent b/t/t4018/r-indent\nnew file mode 100644\nindex 0000000000..9df440f2a4\n--- /dev/null\n+++ b/t/t4018/r-indent\n@@ -0,0 +1,6 @@\n+RIGHT <- function(a, b) {\n+    c = mean(a, b)\n+    d = c + 2\n+    ChangeMe()\n+    return (d)\n+}\ndiff --git a/t/t4018/r-indent-nested b/t/t4018/r-indent-nested\nnew file mode 100644\nindex 0000000000..30412e6c79\n--- /dev/null\n+++ b/t/t4018/r-indent-nested\n@@ -0,0 +1,10 @@\n+LEFT = function(a, b) {\n+    c = mean(a, b)\n+    RIGHT = function(d, e) {\n+        f = var(d, e)\n+        g = f + 1\n+        ChangeMe()\n+        return (g)\n+    }\n+    return (RIGHT(2, 3))\n+}\ndiff --git a/t/t4018/r-noindent b/t/t4018/r-noindent\nnew file mode 100644\nindex 0000000000..6d9b01ffe3\n--- /dev/null\n+++ b/t/t4018/r-noindent\n@@ -0,0 +1,6 @@\n+RIGHT <- function(a, b) {\n+c = mean(a, b)\n+d = c + 2\n+ChangeMe()\n+return (c)\n+}\ndiff --git a/userdiff.c b/userdiff.c\nindex da75625020..64e5005682 100644\n--- a/userdiff.c\n+++ b/userdiff.c\n@@ -317,6 +317,10 @@ PATTERNS(\"python\",\n \t \"|[-+0-9.e]+[jJlL]?|0[xX]?[0-9a-fA-F]+[lL]?\"\n \t \"|[-+*/<>%&^|=!]=|//=?|<<=?|>>=?|\\\\*\\\\*=?\"),\n \t /* -- */\n+PATTERNS(\"r\",\n+\t\"^[ \\t]*([a-zA-z][a-zA-Z0-9_.]*[ \\t]*(<-|=)[ \\t]*function.*)$\",\n+\t/* -- */\n+\t\"[^ \\t]+\"),\n PATTERNS(\"ruby\",\n \t \"^[ \\t]*((class|module|def)[ \\t].*)$\",\n \t /* -- */\n-- \n2.43.0\n\n"},{"id":"519583","messageId":"xmqq8qm8k7p8.fsf@gitster.g","threadId":"63523","inReplyTo":"20250529221805.97036-1-rodrigorsdc@gmail.com","subject":"Re: [PATCH v2] userdiff: add support for R programming language","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-06-03T18:20:51Z","receivedAt":"2025-06-03T18:20:54Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Rodrigo Carvalho <rodrigorsdc@gmail.com> writes:\n\n> The patch appends userdiff.c file in order to support R programming\n> language function header. This will be useful for those who use Git\n> for versioning .R files.\n>\n> Also, add three userdiff tests for R programming language\n> files. These files define simple function and nested function,\n> with and without indentation.\n>\n> Signed-off-by: Rodrigo Carvalho <rodrigorsdc@gmail.com>\n> ---\n> Changes in v2:\n> - Add support for function defined by '='\n> - Replace word regex to '[^ \\t']\n> - Add new test that handles with nested function\n\nSorry, but this fell of the radar.\n\nIt seems all the reviewer comments on the previous round have been\naddressed.  If everybody is happy with this version, let's merge it\ndown to 'next', for the next cycle.\n\nThanks.\n"},{"id":"519595","messageId":"61ee9fac-303e-435d-ab0f-8338c23f2d5d@kdbg.org","threadId":"63523","inReplyTo":"xmqq8qm8k7p8.fsf@gitster.g","subject":"Re: [PATCH v2] userdiff: add support for R programming language","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2025-06-03T21:15:54Z","receivedAt":"2025-06-03T21:16:06Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 03.06.25 um 20:20 schrieb Junio C Hamano:\n> Rodrigo Carvalho <rodrigorsdc@gmail.com> writes:\n> \n>> The patch appends userdiff.c file in order to support R programming\n>> language function header. This will be useful for those who use Git\n>> for versioning .R files.\n>>\n>> Also, add three userdiff tests for R programming language\n>> files. These files define simple function and nested function,\n>> with and without indentation.\n>>\n>> Signed-off-by: Rodrigo Carvalho <rodrigorsdc@gmail.com>\n>> ---\n>> Changes in v2:\n>> - Add support for function defined by '='\n>> - Replace word regex to '[^ \\t']\n>> - Add new test that handles with nested function\n> \n> Sorry, but this fell of the radar.\n> \n> It seems all the reviewer comments on the previous round have been\n> addressed.  If everybody is happy with this version, let's merge it\n> down to 'next', for the next cycle.\n> \n> Thanks.\n\nSorry for being slow. This round looks good to me, too.\n\n-- Hannes\n\n"}]}