{"thread":{"id":"60710","subject":"[GSOC][RFC] Add more builtin patterns for userdiff, as Mircroproject.","startedAt":"2024-01-09T19:55:56Z","lastAt":"2024-03-19T21:02:21Z","messageCount":33,"participants":["Sergius Nyah","Christian Couder","Ghanshyam Thakkar","Junio C Hamano","Patrick Steinhardt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"486468","messageId":"CANAnif95ux=vCNCKbVw0q_vYamQRkbFqSa9_-u6xRvK6r+2a+Q@mail.gmail.com","threadId":"60710","inReplyTo":null,"subject":"[GSOC][RFC] Add more builtin patterns for userdiff, as Mircroproject.","fromName":"Sergius Nyah","fromEmail":"sergiusnyah@gmail.com","sentAt":"2024-01-09T19:55:44Z","receivedAt":"2024-01-09T19:55:56Z","isPatch":false,"sender":{"key":"sergiusnyah@gmail.com","avatar":null},"body":"Hello everyone,\nI'm Sergius, a Computer Science undergraduate student, and I want to\nbegin Contributing to the Git project. So far, I've gone through\nMatheus' tutorial on First steps Contributing to Git, and I found it\nvery helpful. I've also read the Contribution guidelines keenly and\nbuilt Git from source.\n\nIn accordance to the contributor guidelines, I came across this\nMircoproject idea from: https://git.github.io/SoC-2022-Microprojects/\nwhich I'm willing to work on. It talked about enhancing Git's\n\"userdiff\" feature in \"userdiff.c\" which is crucial for identifying\nfunction names in various programming languages, thereby improving the\nreadability of \"git diff\" outputs.\n\nFrom my understanding, the project involves extending the `userdiff`\nfeature to support additional programming languages that are currently\nnot covered such as Shell, Swift, Go and the others.\n\nHere is a sample of how a language is defined in `userdiff.c`:\n\n> #define PATTERNS(lang, rx, wrx) { \\\n> .name = lang, \\\n> .binary = -1, \\\n> .funcname = { \\\n> .pattern = rx, \\\n> .cflags = REG_EXTENDED, \\\n> }, \\\n> .word_regex = wrx \"|[^[:space:]]|[\\xc0-\\xff][\\x80-\\xbf]+\", \\\n> .word_regex_multi_byte = wrx \"|[^[:space:]]\", \\\n> }\n\nIn this code, `lang` is the name of the language, `rx` is the regular\nexpression for identifying function names, and `wrx` is the word\nregex.\n\nApproach: I Identified the Programming Languages that are not\ncurrently supported by the userdiff feature by reviewing the existing\npatterns in userdiff.c and comparing them with some popular\nprogramming languages.\nFor each supported language, I would define a regular expression that\ncould help identify function names in that language. This could\ninclude researching each language's syntax and testing their\nexpressions to ensure that they work well.\nAlso, I'd add a new IPATTERN definition for each language to the\n\"userdiff.c\" file, then rebuild Git and test the changes by creating a\nrepo with files in the newly supported languages then run \"git diff\"\nto ensure the line @@ ... @@ produces their correct function names.\nThen submit a patch.\n\nBest Regards!\nSergius.\n"},{"id":"486518","messageId":"CAP8UFD30h7D7D42Eiq3sk97v_ef8hi=K1qdy2wRczQ18JM++LA@mail.gmail.com","threadId":"60710","inReplyTo":"CANAnif95ux=vCNCKbVw0q_vYamQRkbFqSa9_-u6xRvK6r+2a+Q@mail.gmail.com","subject":"Re: [GSOC][RFC] Add more builtin patterns for userdiff, as Mircroproject.","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2024-01-10T11:33:32Z","receivedAt":"2024-01-10T11:33:46Z","isPatch":false,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Hi Sergius,\n\nOn Tue, Jan 9, 2024 at 8:59 PM Sergius Nyah <sergiusnyah@gmail.com> wrote:\n>\n> Hello everyone,\n> I'm Sergius, a Computer Science undergraduate student, and I want to\n> begin Contributing to the Git project. So far, I've gone through\n> Matheus' tutorial on First steps Contributing to Git, and I found it\n> very helpful. I've also read the Contribution guidelines keenly and\n> built Git from source.\n\nThanks for your interest in contributing to Git!\n\n> In accordance to the contributor guidelines, I came across this\n> Mircoproject idea from: https://git.github.io/SoC-2022-Microprojects/\n\ns/Mircoproject/microproject/\n\nThere is a similar typo in the subject of your email too.\n\n> which I'm willing to work on. It talked about enhancing Git's\n> \"userdiff\" feature in \"userdiff.c\" which is crucial for identifying\n> function names in various programming languages, thereby improving the\n> readability of \"git diff\" outputs.\n>\n> From my understanding, the project involves extending the `userdiff`\n> feature to support additional programming languages that are currently\n> not covered such as Shell, Swift, Go and the others.\n\nAs far as I can see in userdiff.c, Golang and Bash seem to be supported.\n\n> Here is a sample of how a language is defined in `userdiff.c`:\n>\n> > #define PATTERNS(lang, rx, wrx) { \\\n> > .name = lang, \\\n> > .binary = -1, \\\n> > .funcname = { \\\n> > .pattern = rx, \\\n> > .cflags = REG_EXTENDED, \\\n> > }, \\\n> > .word_regex = wrx \"|[^[:space:]]|[\\xc0-\\xff][\\x80-\\xbf]+\", \\\n> > .word_regex_multi_byte = wrx \"|[^[:space:]]\", \\\n> > }\n>\n> In this code, `lang` is the name of the language, `rx` is the regular\n> expression for identifying function names, and `wrx` is the word\n> regex.\n>\n> Approach: I Identified the Programming Languages that are not\n> currently supported by the userdiff feature by reviewing the existing\n> patterns in userdiff.c and comparing them with some popular\n> programming languages.\n> For each supported language, I would define a regular expression that\n> could help identify function names in that language. This could\n> include researching each language's syntax and testing their\n> expressions to ensure that they work well.\n\nIn your microproject, you only need to add support for ONE language\nthat is not supported yet. Please don't try to do more than that.\n\n> Also, I'd add a new IPATTERN definition for each language to the\n> \"userdiff.c\" file, then rebuild Git and test the changes by creating a\n> repo with files in the newly supported languages then run \"git diff\"\n> to ensure the line @@ ... @@ produces their correct function names.\n> Then submit a patch.\n\nExcept for my comments above, this looks like a good plan. Thanks.\n"},{"id":"486630","messageId":"CANAnif-hWovPnRmSy0pnEJnA274vwiSAkRexstGQdQJ4u-5+pw@mail.gmail.com","threadId":"60710","inReplyTo":"CAP8UFD3e=Zv2wkx5tswCz05Vwn3vD68Vw-TD6SoENWK+norYsw@mail.gmail.com","subject":"Fwd: [GSOC][RFC] Add more builtin patterns for userdiff, as Mircroproject.","fromName":"Sergius Nyah","fromEmail":"sergiusnyah@gmail.com","sentAt":"2024-01-11T14:23:22Z","receivedAt":"2024-01-11T14:23:35Z","isPatch":false,"sender":{"key":"sergiusnyah@gmail.com","avatar":null},"body":"---------- Forwarded message ---------\nFrom: Christian Couder <christian.couder@gmail.com>\nDate: Thu, Jan 11, 2024 at 11:51 AM\nSubject: Re: [GSOC][RFC] Add more builtin patterns for userdiff, as\nMircroproject.\nTo: Sergius Nyah <sergiusnyah@gmail.com>\n\n\nOn Thu, Jan 11, 2024 at 11:48 AM Christian Couder\n<christian.couder@gmail.com> wrote:\n>\n> On Wed, Jan 10, 2024 at 9:10 PM Sergius Nyah <sergiusnyah@gmail.com> wrote:\n\n> > > Okay then. I will add support for shell, as it was primarily suggested\n> > > in the idea itself.\n>\n> As Bash is a shell and is already supported, I am not sure which kind\n> of shell you want to support. There are other shells or kinds of shell\n> with different syntax that might be worth supporting, but then you\n> might want to tell us which shell or which new kind of shell.\n>\n> Thanks!\n\nI've definitely learned one more thing. Thank you!\nAlso, after taking another keen look at the Patterns defined in userdiff.c,\nIn accordance with what you've said, I realized that Kotlin isn't\nsupported yet.\nSo, I'd begin working on it.\nThanks!\n\nBy the way I realized that you replied privately to me instead of\nkeeping the mailing list in Cc: This made me reply privately to you.\n\nThank you for the correction Christian. Noted!\n\nI think it would be better if the discussions were all public as this\nway others could give you their opinion on this.\n\nDefinitely True.\n"},{"id":"486631","messageId":"CAP8UFD0YicYXrYgHdvcrWps+cMa=Dp9Ob7SfYLMXQKLp7-B+7w@mail.gmail.com","threadId":"60710","inReplyTo":"CANAnif-hWovPnRmSy0pnEJnA274vwiSAkRexstGQdQJ4u-5+pw@mail.gmail.com","subject":"Re: [GSOC][RFC] Add more builtin patterns for userdiff, as Mircroproject.","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2024-01-11T15:11:39Z","receivedAt":"2024-01-11T15:11:53Z","isPatch":false,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Thu, Jan 11, 2024 at 3:23 PM Sergius Nyah <sergiusnyah@gmail.com> wrote:\n>\n> ---------- Forwarded message ---------\n> From: Christian Couder <christian.couder@gmail.com>\n> Date: Thu, Jan 11, 2024 at 11:51 AM\n> Subject: Re: [GSOC][RFC] Add more builtin patterns for userdiff, as\n> Mircroproject.\n> To: Sergius Nyah <sergiusnyah@gmail.com>\n>\n>\n> On Thu, Jan 11, 2024 at 11:48 AM Christian Couder\n> <christian.couder@gmail.com> wrote:\n> >\n> > On Wed, Jan 10, 2024 at 9:10 PM Sergius Nyah <sergiusnyah@gmail.com> wrote:\n>\n> > > > Okay then. I will add support for shell, as it was primarily suggested\n> > > > in the idea itself.\n> >\n> > As Bash is a shell and is already supported, I am not sure which kind\n> > of shell you want to support. There are other shells or kinds of shell\n> > with different syntax that might be worth supporting, but then you\n> > might want to tell us which shell or which new kind of shell.\n> >\n> > Thanks!\n>\n> I've definitely learned one more thing. Thank you!\n> Also, after taking another keen look at the Patterns defined in userdiff.c,\n> In accordance with what you've said, I realized that Kotlin isn't\n> supported yet.\n\nIt is actually already supported too:\n\n$ grep -i -n kotlin userdiff.c\n186:PATTERNS(\"kotlin\",\n\nTo help you a bit, you can get the list of already supported languages using:\n\n$ perl -ne 'print \"$1\\n\" if m/PATTERNS\\(\\\"(\\w+)\\\"/ or\nm/IPATTERN\\(\\\"(\\w+)\\\"/' <userdiff.c\nada\nbash\nbibtex\ncpp\ncsharp\ncss\ndts\nelixir\nfortran\nfountain\ngolang\nhtml\njava\nkotlin\nmarkdown\nmatlab\nobjc\npascal\nperl\nphp\npython\nruby\nrust\nscheme\ntex\n"},{"id":"486632","messageId":"CANAnif-OganZLi0Cu_uq=nveC+u5n14c=o_DQHT-wFOqQ9Vs0Q@mail.gmail.com","threadId":"60710","inReplyTo":"CAP8UFD0YicYXrYgHdvcrWps+cMa=Dp9Ob7SfYLMXQKLp7-B+7w@mail.gmail.com","subject":"Re: [GSOC][RFC] Add more builtin patterns for userdiff, as Mircroproject.","fromName":"Sergius Nyah","fromEmail":"sergiusnyah@gmail.com","sentAt":"2024-01-11T15:42:08Z","receivedAt":"2024-01-11T15:42:20Z","isPatch":false,"sender":{"key":"sergiusnyah@gmail.com","avatar":null},"body":"On Thu, Jan 11, 2024 at 4:11 PM Christian Couder\n<christian.couder@gmail.com> wrote:\n>\n> On Thu, Jan 11, 2024 at 3:23 PM Sergius Nyah <sergiusnyah@gmail.com> wrote:\n> >\n> > ---------- Forwarded message ---------\n> > From: Christian Couder <christian.couder@gmail.com>\n> > Date: Thu, Jan 11, 2024 at 11:51 AM\n> > Subject: Re: [GSOC][RFC] Add more builtin patterns for userdiff, as\n> > Mircroproject.\n> > To: Sergius Nyah <sergiusnyah@gmail.com>\n> >\n> >\n> > On Thu, Jan 11, 2024 at 11:48 AM Christian Couder\n> > <christian.couder@gmail.com> wrote:\n> > >\n> > > On Wed, Jan 10, 2024 at 9:10 PM Sergius Nyah <sergiusnyah@gmail.com> wrote:\n> >\n> > > > > Okay then. I will add support for shell, as it was primarily suggested\n> > > > > in the idea itself.\n> > >\n> > > As Bash is a shell and is already supported, I am not sure which kind\n> > > of shell you want to support. There are other shells or kinds of shell\n> > > with different syntax that might be worth supporting, but then you\n> > > might want to tell us which shell or which new kind of shell.\n> > >\n> > > Thanks!\n> >\n> > I've definitely learned one more thing. Thank you!\n> > Also, after taking another keen look at the Patterns defined in userdiff.c,\n> > In accordance with what you've said, I realized that Kotlin isn't\n> > supported yet.\n>\n> It is actually already supported too:\n>\n> $ grep -i -n kotlin userdiff.c\n> 186:PATTERNS(\"kotlin\",\n>\n> To help you a bit, you can get the list of already supported languages using:\n>\n> $ perl -ne 'print \"$1\\n\" if m/PATTERNS\\(\\\"(\\w+)\\\"/ or\n> m/IPATTERN\\(\\\"(\\w+)\\\"/' <userdiff.c\n\nThank you for these. $ perl -ne 'print \"$1\\n\" if\nm/IPATTERN\\(\\\"(\\w+)\\\"/' userdiff.c works too.\n\n> ada\n> bash\n> bibtex\n> cpp\n> csharp\n> css\n> dts\n> elixir\n> fortran\n> fountain\n> golang\n> html\n> java\n> kotlin\n> markdown\n> matlab\n> objc\n> pascal\n> perl\n> php\n> python\n> ruby\n> rust\n> scheme\n> tex\n\nGreat! JavaScript, despite its widespread use, isn't implemented, so I\nwill take it.\nThank you!\n"},{"id":"489500","messageId":"20240227141947.71447-1-74214119+Sergius-Nyah@users.noreply.github.com","threadId":"60710","inReplyTo":"CANAnif-OganZLi0Cu_uq=nveC+u5n14c=o_DQHT-wFOqQ9Vs0Q@mail.gmail.com","subject":"[GSOC][PATCH 0/2] Add builtin patterns for userdiff in JavaScript, as Microproject.","fromName":"Sergius Nyah","fromEmail":"sergiusnyah@gmail.com","sentAt":"2024-02-27T14:19:45Z","receivedAt":"2024-02-27T14:19:56Z","isPatch":true,"sender":{"key":"sergiusnyah@gmail.com","avatar":null},"body":"Firstly, I'm so sorry for the delay between selecting the Microproject and sending the patch series.\nLearning about regular expressions took me a bit longer than I expected, but it was all worth it.\nI'm very grateful for the opportunity to work on this project and I'm looking forward to contributing more to Git.\n\nThis patch series adds builtin patterns for JavaScript function detection in userdiff, as \nmy Microproject for GSOC. The first patch adds a regular expression for detecting JavaScript\nfunctions in Git diffs while the second adds a test for JavaScript function detection in Git diffs.\nThis new pattern looks for lines that start with optional whitespace, followed by 'function' and any \ncharacters (for function declarations), or valid JavaScript identifiers, equals sign '=', 'function'\nkeyword and any characters (for function expressions). It also considers functions defined inside blocks with '{...}'.\n\n\n t/t4018-diff-funcname.sh | 25 +++++++++++++++++++++++--\n userdiff.c               | 17 +++++++++++++++--\n 2 files changed, 38 insertions(+), 4 deletions(-)\n \n\nbase-commit: c5b454771e6b086f60c7f1f139025f174bcedac9\n-- \n2.43.2\n\nI would greatly appreciate any feedback on the patch series.\nBest, \nSergius.\n\n"},{"id":"489501","messageId":"20240227141947.71447-2-74214119+Sergius-Nyah@users.noreply.github.com","threadId":"60710","inReplyTo":"20240227141947.71447-1-74214119+Sergius-Nyah@users.noreply.github.com","subject":"[PATCH 1/2] Subject: [GSOC][RFC PATCH 1/2] Add builtin patterns for JavaScript function detection in userdiff.","fromName":"Sergius Nyah","fromEmail":"sergiusnyah@gmail.com","sentAt":"2024-02-27T14:19:46Z","receivedAt":"2024-02-27T14:20:00Z","isPatch":true,"sender":{"key":"sergiusnyah@gmail.com","avatar":null},"body":"From: Sergius Justus Chesami Nyah <74214119+Sergius-Nyah@users.noreply.github.com>\n\nThis patch adds the regular expression for detecting JavaScript functions and expressions in Git diffs. The pattern accurately identifies function declerations, expressions, and definitions inside blocks.\n---\n userdiff.c | 17 +++++++++++++++--\n 1 file changed, 15 insertions(+), 2 deletions(-)\n\ndiff --git a/userdiff.c b/userdiff.c\nindex e399543823..12e31ff14d 100644\n--- a/userdiff.c\n+++ b/userdiff.c\n@@ -1,7 +1,7 @@\n #include \"git-compat-util.h\"\n #include \"config.h\"\n #include \"userdiff.h\"\n-#include \"attr.h\"\n+#include \"attr.h\" \n #include \"strbuf.h\"\n \n static struct userdiff_driver *drivers;\n@@ -183,6 +183,19 @@ PATTERNS(\"java\",\n \t \"|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?\"\n \t \"|[-+*/<>%&^|=!]=\"\n \t \"|--|\\\\+\\\\+|<<=?|>>>?=?|&&|\\\\|\\\\|\"),\n+PATTERNS(\"javascript\",\n+     /* \n+\t  * Looks for lines that start with optional whitespace, followed \n+\t  * by 'function'* and any characters (for function declarations), \n+      * or valid JavaScript identifiers, equals sign '=', 'function' keyword\n+\t  * and any characters (for function expressions).\n+      * Also considers functions defined inside blocks with '{...}'.\n+\t  */ \n+\t \"^[ \\t]*(function[ \\t]*.*|[a-zA-Z_$][0-9a-zA-Z_$]*[ \\t]*=[ \\t]*function[ \\t]*.*|(\\\\{[ \\t]*)?)\\n\",\n+     /* This pattern matches JavaScript identifiers */\n+     \"[a-zA-Z_$][0-9a-zA-Z_$]*\"\n+     \"|[-+0-9.eE]+|0[xX][0-9a-fA-F]+\" \n+     \"|[-+*/<>%&^|=!:]=|--|\\\\+\\\\+|<<=?|>>=?|&&|\\\\|\\\\|\"), \n PATTERNS(\"kotlin\",\n \t \"^[ \\t]*(([a-z]+[ \\t]+)*(fun|class|interface)[ \\t]+.*)$\",\n \t /* -- */\n@@ -192,7 +205,7 @@ PATTERNS(\"kotlin\",\n \t /* integers and floats */\n \t \"|[0-9][0-9_]*([.][0-9_]*)?([Ee][-+]?[0-9]+)?[fFlLuU]*\"\n \t /* floating point numbers beginning with decimal point */\n-\t \"|[.][0-9][0-9_]*([Ee][-+]?[0-9]+)?[fFlLuU]?\"\n+\t \"|[.][0-9][0-9_]*([Ee][-+]?[0-9]+ )?[fFlLuU]?\"\n \t /* unary and binary operators */\n \t \"|[-+*/<>%&^|=!]==?|--|\\\\+\\\\+|<<=|>>=|&&|\\\\|\\\\||->|\\\\.\\\\*|!!|[?:.][.:]\"),\n PATTERNS(\"markdown\",\n-- \n2.43.2\n\n"},{"id":"489502","messageId":"20240227141947.71447-3-74214119+Sergius-Nyah@users.noreply.github.com","threadId":"60710","inReplyTo":"20240227141947.71447-1-74214119+Sergius-Nyah@users.noreply.github.com","subject":"[PATCH 2/2] Subject:[GSOC] [RFC PATCH 2/2] Add test for JavaScript function detection in Git diffs","fromName":"Sergius Nyah","fromEmail":"sergiusnyah@gmail.com","sentAt":"2024-02-27T14:19:47Z","receivedAt":"2024-02-27T14:20:04Z","isPatch":true,"sender":{"key":"sergiusnyah@gmail.com","avatar":null},"body":"From: Sergius Justus Chesami Nyah <74214119+Sergius-Nyah@users.noreply.github.com>\n\nThis commit introduces a new test case in t4018-diff-funcname.sh to verify the enhanced JavaScript function detection in Git diffs. The test creates a JavaScript file with function declarations and expressions, modifies them, and then checks the output of git diff to ensure that the changes are correctly identified. This test validates the changes made to userdiff.c for improved JavaScript function detection.\n---\n t/t4018-diff-funcname.sh | 25 +++++++++++++++++++++++--\n 1 file changed, 23 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh\nindex e026fac1f4..e88e63bd1f 100755\n--- a/t/t4018-diff-funcname.sh\n+++ b/t/t4018-diff-funcname.sh\n@@ -11,7 +11,7 @@ test_expect_success 'setup' '\n \t# a non-trivial custom pattern\n \tgit config diff.custom1.funcname \"!static\n !String\n-[^ \t].*s.*\" &&\n+[^ \t].*s.*\" && \n \n \t# a custom pattern which matches to end of line\n \tgit config diff.custom2.funcname \"......Beer\\$\" &&\n@@ -119,4 +119,25 @@ do\n \t\"\n done\n \n-test_done\n+test_expect_success 'identify builtin patterns in Javascript' '\n+    # setup\n+    echo \"function myFunction() { return true; }\" > test.js &&\n+    echo \"var myVar = function() { return false; }\" >> test.js &&\n+    git add test.js &&\n+    git commit -m \"add test.js\" &&\n+\n+    # modify the file\n+    echo \"function myFunction() { return false; }\" > test.js &&\n+    echo \"var myVar = function() { return true; }\" >> test.js &&\n+\n+    # command under test\n+    git diff >output &&\n+\n+    # check results\n+    test_i18ngrep \"function myFunction() { return true; }\" output &&\n+    test_i18ngrep \"function myFunction() { return false; }\" output &&\n+    test_i18ngrep \"var myVar = function() { return false; }\" output &&\n+    test_i18ngrep \"var myVar = function() { return true; }\" output\n+'\n+\n+test_done \n\\ No newline at end of file\n-- \n2.43.2\n\n"},{"id":"489503","messageId":"20240227142121.72518-1-74214119+Sergius-Nyah@users.noreply.github.com","threadId":"60710","inReplyTo":"CANAnif-OganZLi0Cu_uq=nveC+u5n14c=o_DQHT-wFOqQ9Vs0Q@mail.gmail.com","subject":"[GSOC][PATCH 0/2] Add builtin patterns for userdiff in JavaScript, as Microproject.","fromName":"Sergius Nyah","fromEmail":"sergiusnyah@gmail.com","sentAt":"2024-02-27T14:21:19Z","receivedAt":"2024-02-27T14:21:30Z","isPatch":true,"sender":{"key":"sergiusnyah@gmail.com","avatar":null},"body":"Firstly, I'm so sorry for the delay between selecting the Microproject and sending the patch series.\nLearning about regular expressions took me a bit longer than I expected, but it was all worth it.\nI'm very grateful for the opportunity to work on this project and I'm looking forward to contributing more to Git.\n\nThis patch series adds builtin patterns for JavaScript function detection in userdiff, as \nmy Microproject for GSOC. The first patch adds a regular expression for detecting JavaScript\nfunctions in Git diffs while the second adds a test for JavaScript function detection in Git diffs.\nThis new pattern looks for lines that start with optional whitespace, followed by 'function' and any \ncharacters (for function declarations), or valid JavaScript identifiers, equals sign '=', 'function'\nkeyword and any characters (for function expressions). It also considers functions defined inside blocks with '{...}'.\n\n\n t/t4018-diff-funcname.sh | 25 +++++++++++++++++++++++--\n userdiff.c               | 17 +++++++++++++++--\n 2 files changed, 38 insertions(+), 4 deletions(-)\n \n\nbase-commit: c5b454771e6b086f60c7f1f139025f174bcedac9\n-- \n2.43.2\n\nI would greatly appreciate any feedback on the patch series.\nBest, \nSergius.\n\n"},{"id":"489504","messageId":"20240227142121.72518-2-74214119+Sergius-Nyah@users.noreply.github.com","threadId":"60710","inReplyTo":"20240227142121.72518-1-74214119+Sergius-Nyah@users.noreply.github.com","subject":"[PATCH 1/2] Subject: [GSOC][RFC PATCH 1/2] Add builtin patterns for JavaScript function detection in userdiff.","fromName":"Sergius Nyah","fromEmail":"sergiusnyah@gmail.com","sentAt":"2024-02-27T14:21:20Z","receivedAt":"2024-02-27T14:21:35Z","isPatch":true,"sender":{"key":"sergiusnyah@gmail.com","avatar":null},"body":"From: Sergius Justus Chesami Nyah <74214119+Sergius-Nyah@users.noreply.github.com>\n\nThis patch adds the regular expression for detecting JavaScript functions and expressions in Git diffs. The pattern accurately identifies function declerations, expressions, and definitions inside blocks.\n---\n userdiff.c | 17 +++++++++++++++--\n 1 file changed, 15 insertions(+), 2 deletions(-)\n\ndiff --git a/userdiff.c b/userdiff.c\nindex e399543823..12e31ff14d 100644\n--- a/userdiff.c\n+++ b/userdiff.c\n@@ -1,7 +1,7 @@\n #include \"git-compat-util.h\"\n #include \"config.h\"\n #include \"userdiff.h\"\n-#include \"attr.h\"\n+#include \"attr.h\" \n #include \"strbuf.h\"\n \n static struct userdiff_driver *drivers;\n@@ -183,6 +183,19 @@ PATTERNS(\"java\",\n \t \"|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?\"\n \t \"|[-+*/<>%&^|=!]=\"\n \t \"|--|\\\\+\\\\+|<<=?|>>>?=?|&&|\\\\|\\\\|\"),\n+PATTERNS(\"javascript\",\n+     /* \n+\t  * Looks for lines that start with optional whitespace, followed \n+\t  * by 'function'* and any characters (for function declarations), \n+      * or valid JavaScript identifiers, equals sign '=', 'function' keyword\n+\t  * and any characters (for function expressions).\n+      * Also considers functions defined inside blocks with '{...}'.\n+\t  */ \n+\t \"^[ \\t]*(function[ \\t]*.*|[a-zA-Z_$][0-9a-zA-Z_$]*[ \\t]*=[ \\t]*function[ \\t]*.*|(\\\\{[ \\t]*)?)\\n\",\n+     /* This pattern matches JavaScript identifiers */\n+     \"[a-zA-Z_$][0-9a-zA-Z_$]*\"\n+     \"|[-+0-9.eE]+|0[xX][0-9a-fA-F]+\" \n+     \"|[-+*/<>%&^|=!:]=|--|\\\\+\\\\+|<<=?|>>=?|&&|\\\\|\\\\|\"), \n PATTERNS(\"kotlin\",\n \t \"^[ \\t]*(([a-z]+[ \\t]+)*(fun|class|interface)[ \\t]+.*)$\",\n \t /* -- */\n@@ -192,7 +205,7 @@ PATTERNS(\"kotlin\",\n \t /* integers and floats */\n \t \"|[0-9][0-9_]*([.][0-9_]*)?([Ee][-+]?[0-9]+)?[fFlLuU]*\"\n \t /* floating point numbers beginning with decimal point */\n-\t \"|[.][0-9][0-9_]*([Ee][-+]?[0-9]+)?[fFlLuU]?\"\n+\t \"|[.][0-9][0-9_]*([Ee][-+]?[0-9]+ )?[fFlLuU]?\"\n \t /* unary and binary operators */\n \t \"|[-+*/<>%&^|=!]==?|--|\\\\+\\\\+|<<=|>>=|&&|\\\\|\\\\||->|\\\\.\\\\*|!!|[?:.][.:]\"),\n PATTERNS(\"markdown\",\n-- \n2.43.2\n\n"},{"id":"489505","messageId":"20240227142121.72518-3-74214119+Sergius-Nyah@users.noreply.github.com","threadId":"60710","inReplyTo":"20240227142121.72518-1-74214119+Sergius-Nyah@users.noreply.github.com","subject":"[PATCH 2/2] Subject:[GSOC] [RFC PATCH 2/2] Add test for JavaScript function detection in Git diffs","fromName":"Sergius Nyah","fromEmail":"sergiusnyah@gmail.com","sentAt":"2024-02-27T14:21:21Z","receivedAt":"2024-02-27T14:21:39Z","isPatch":true,"sender":{"key":"sergiusnyah@gmail.com","avatar":null},"body":"From: Sergius Justus Chesami Nyah <74214119+Sergius-Nyah@users.noreply.github.com>\n\nThis commit introduces a new test case in t4018-diff-funcname.sh to verify the enhanced JavaScript function detection in Git diffs. The test creates a JavaScript file with function declarations and expressions, modifies them, and then checks the output of git diff to ensure that the changes are correctly identified. This test validates the changes made to userdiff.c for improved JavaScript function detection.\n---\n t/t4018-diff-funcname.sh | 25 +++++++++++++++++++++++--\n 1 file changed, 23 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh\nindex e026fac1f4..e88e63bd1f 100755\n--- a/t/t4018-diff-funcname.sh\n+++ b/t/t4018-diff-funcname.sh\n@@ -11,7 +11,7 @@ test_expect_success 'setup' '\n \t# a non-trivial custom pattern\n \tgit config diff.custom1.funcname \"!static\n !String\n-[^ \t].*s.*\" &&\n+[^ \t].*s.*\" && \n \n \t# a custom pattern which matches to end of line\n \tgit config diff.custom2.funcname \"......Beer\\$\" &&\n@@ -119,4 +119,25 @@ do\n \t\"\n done\n \n-test_done\n+test_expect_success 'identify builtin patterns in Javascript' '\n+    # setup\n+    echo \"function myFunction() { return true; }\" > test.js &&\n+    echo \"var myVar = function() { return false; }\" >> test.js &&\n+    git add test.js &&\n+    git commit -m \"add test.js\" &&\n+\n+    # modify the file\n+    echo \"function myFunction() { return false; }\" > test.js &&\n+    echo \"var myVar = function() { return true; }\" >> test.js &&\n+\n+    # command under test\n+    git diff >output &&\n+\n+    # check results\n+    test_i18ngrep \"function myFunction() { return true; }\" output &&\n+    test_i18ngrep \"function myFunction() { return false; }\" output &&\n+    test_i18ngrep \"var myVar = function() { return false; }\" output &&\n+    test_i18ngrep \"var myVar = function() { return true; }\" output\n+'\n+\n+test_done \n\\ No newline at end of file\n-- \n2.43.2\n\n"},{"id":"489507","messageId":"20240227142540.73972-1-74214119+Sergius-Nyah@users.noreply.github.com","threadId":"60710","inReplyTo":"CANAnif-OganZLi0Cu_uq=nveC+u5n14c=o_DQHT-wFOqQ9Vs0Q@mail.gmail.com","subject":"[GSOC][PATCH 0/2] Add builtin patterns for userdiff in JavaScript, as Microproject.","fromName":"Sergius Nyah","fromEmail":"sergiusnyah@gmail.com","sentAt":"2024-02-27T14:25:37Z","receivedAt":"2024-02-27T14:25:48Z","isPatch":true,"sender":{"key":"sergiusnyah@gmail.com","avatar":null},"body":"From: Sergius Nyah <sergiusnyah@gmail.com>\n\nFirstly, I'm so sorry for the delay between selecting the Microproject and sending the patch series.\nLearning about regular expressions took me a bit longer than I expected, but it was all worth it.\nI'm very grateful for the opportunity to work on this project and I'm looking forward to contributing more to Git.\n\nThis patch series adds builtin patterns for JavaScript function detection in userdiff, as \nmy Microproject for GSOC. The first patch adds a regular expression for detecting JavaScript\nfunctions in Git diffs while the second adds a test for JavaScript function detection in Git diffs.\nThis new pattern looks for lines that start with optional whitespace, followed by 'function' and any \ncharacters (for function declarations), or valid JavaScript identifiers, equals sign '=', 'function'\nkeyword and any characters (for function expressions). It also considers functions defined inside blocks with '{...}'.\n\n\n t/t4018-diff-funcname.sh | 25 +++++++++++++++++++++++--\n userdiff.c               | 17 +++++++++++++++--\n 2 files changed, 38 insertions(+), 4 deletions(-)\n \n\nbase-commit: c5b454771e6b086f60c7f1f139025f174bcedac9\n-- \n2.43.2\n\nI would greatly appreciate any feedback on the patch series.\nBest, \nSergius.\n\n"},{"id":"489508","messageId":"20240227142540.73972-2-74214119+Sergius-Nyah@users.noreply.github.com","threadId":"60710","inReplyTo":"20240227142540.73972-1-74214119+Sergius-Nyah@users.noreply.github.com","subject":"[PATCH 1/2] Subject: [GSOC][RFC PATCH 1/2] Add builtin patterns for JavaScript function detection in userdiff.","fromName":"Sergius Nyah","fromEmail":"sergiusnyah@gmail.com","sentAt":"2024-02-27T14:25:38Z","receivedAt":"2024-02-27T14:25:55Z","isPatch":true,"sender":{"key":"sergiusnyah@gmail.com","avatar":null},"body":"From: Sergius Justus Chesami Nyah <74214119+Sergius-Nyah@users.noreply.github.com>\n\nThis patch adds the regular expression for detecting JavaScript functions and expressions in Git diffs. The pattern accurately identifies function declerations, expressions, and definitions inside blocks.\n---\n userdiff.c | 17 +++++++++++++++--\n 1 file changed, 15 insertions(+), 2 deletions(-)\n\ndiff --git a/userdiff.c b/userdiff.c\nindex e399543823..12e31ff14d 100644\n--- a/userdiff.c\n+++ b/userdiff.c\n@@ -1,7 +1,7 @@\n #include \"git-compat-util.h\"\n #include \"config.h\"\n #include \"userdiff.h\"\n-#include \"attr.h\"\n+#include \"attr.h\" \n #include \"strbuf.h\"\n \n static struct userdiff_driver *drivers;\n@@ -183,6 +183,19 @@ PATTERNS(\"java\",\n \t \"|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?\"\n \t \"|[-+*/<>%&^|=!]=\"\n \t \"|--|\\\\+\\\\+|<<=?|>>>?=?|&&|\\\\|\\\\|\"),\n+PATTERNS(\"javascript\",\n+     /* \n+\t  * Looks for lines that start with optional whitespace, followed \n+\t  * by 'function'* and any characters (for function declarations), \n+      * or valid JavaScript identifiers, equals sign '=', 'function' keyword\n+\t  * and any characters (for function expressions).\n+      * Also considers functions defined inside blocks with '{...}'.\n+\t  */ \n+\t \"^[ \\t]*(function[ \\t]*.*|[a-zA-Z_$][0-9a-zA-Z_$]*[ \\t]*=[ \\t]*function[ \\t]*.*|(\\\\{[ \\t]*)?)\\n\",\n+     /* This pattern matches JavaScript identifiers */\n+     \"[a-zA-Z_$][0-9a-zA-Z_$]*\"\n+     \"|[-+0-9.eE]+|0[xX][0-9a-fA-F]+\" \n+     \"|[-+*/<>%&^|=!:]=|--|\\\\+\\\\+|<<=?|>>=?|&&|\\\\|\\\\|\"), \n PATTERNS(\"kotlin\",\n \t \"^[ \\t]*(([a-z]+[ \\t]+)*(fun|class|interface)[ \\t]+.*)$\",\n \t /* -- */\n@@ -192,7 +205,7 @@ PATTERNS(\"kotlin\",\n \t /* integers and floats */\n \t \"|[0-9][0-9_]*([.][0-9_]*)?([Ee][-+]?[0-9]+)?[fFlLuU]*\"\n \t /* floating point numbers beginning with decimal point */\n-\t \"|[.][0-9][0-9_]*([Ee][-+]?[0-9]+)?[fFlLuU]?\"\n+\t \"|[.][0-9][0-9_]*([Ee][-+]?[0-9]+ )?[fFlLuU]?\"\n \t /* unary and binary operators */\n \t \"|[-+*/<>%&^|=!]==?|--|\\\\+\\\\+|<<=|>>=|&&|\\\\|\\\\||->|\\\\.\\\\*|!!|[?:.][.:]\"),\n PATTERNS(\"markdown\",\n-- \n2.43.2\n\n"},{"id":"489509","messageId":"20240227142540.73972-3-74214119+Sergius-Nyah@users.noreply.github.com","threadId":"60710","inReplyTo":"20240227142540.73972-1-74214119+Sergius-Nyah@users.noreply.github.com","subject":"[PATCH 2/2] Subject:[GSOC] [RFC PATCH 2/2] Add test for JavaScript function detection in Git diffs","fromName":"Sergius Nyah","fromEmail":"sergiusnyah@gmail.com","sentAt":"2024-02-27T14:25:39Z","receivedAt":"2024-02-27T14:25:59Z","isPatch":true,"sender":{"key":"sergiusnyah@gmail.com","avatar":null},"body":"From: Sergius Justus Chesami Nyah <74214119+Sergius-Nyah@users.noreply.github.com>\n\nThis commit introduces a new test case in t4018-diff-funcname.sh to verify the enhanced JavaScript function detection in Git diffs. The test creates a JavaScript file with function declarations and expressions, modifies them, and then checks the output of git diff to ensure that the changes are correctly identified. This test validates the changes made to userdiff.c for improved JavaScript function detection.\n---\n t/t4018-diff-funcname.sh | 25 +++++++++++++++++++++++--\n 1 file changed, 23 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh\nindex e026fac1f4..e88e63bd1f 100755\n--- a/t/t4018-diff-funcname.sh\n+++ b/t/t4018-diff-funcname.sh\n@@ -11,7 +11,7 @@ test_expect_success 'setup' '\n \t# a non-trivial custom pattern\n \tgit config diff.custom1.funcname \"!static\n !String\n-[^ \t].*s.*\" &&\n+[^ \t].*s.*\" && \n \n \t# a custom pattern which matches to end of line\n \tgit config diff.custom2.funcname \"......Beer\\$\" &&\n@@ -119,4 +119,25 @@ do\n \t\"\n done\n \n-test_done\n+test_expect_success 'identify builtin patterns in Javascript' '\n+    # setup\n+    echo \"function myFunction() { return true; }\" > test.js &&\n+    echo \"var myVar = function() { return false; }\" >> test.js &&\n+    git add test.js &&\n+    git commit -m \"add test.js\" &&\n+\n+    # modify the file\n+    echo \"function myFunction() { return false; }\" > test.js &&\n+    echo \"var myVar = function() { return true; }\" >> test.js &&\n+\n+    # command under test\n+    git diff >output &&\n+\n+    # check results\n+    test_i18ngrep \"function myFunction() { return true; }\" output &&\n+    test_i18ngrep \"function myFunction() { return false; }\" output &&\n+    test_i18ngrep \"var myVar = function() { return false; }\" output &&\n+    test_i18ngrep \"var myVar = function() { return true; }\" output\n+'\n+\n+test_done \n\\ No newline at end of file\n-- \n2.43.2\n\n"},{"id":"489538","messageId":"20240227160253.104011-1-sergiusnyah@gmail.com","threadId":"60710","inReplyTo":"CANAnif-OganZLi0Cu_uq=nveC+u5n14c=o_DQHT-wFOqQ9Vs0Q@mail.gmail.com","subject":"[GSOC][PATCH 0/2] Add builtin patterns for userdiff in JavaScript, as Microproject.","fromName":"Sergius Nyah","fromEmail":"sergiusnyah@gmail.com","sentAt":"2024-02-27T16:02:51Z","receivedAt":"2024-02-27T16:03:02Z","isPatch":true,"sender":{"key":"sergiusnyah@gmail.com","avatar":null},"body":"I would like to apologize for the numerous irrelevant emails that have been sent to this mailing list recently. \nThey were the result of a configuration issue with my setup, which caused my patches to be sent from a `noreply` GitHub address. \nThis led to a series of failed delivery attempts and unnecessary emails.\n\nFirstly, I'm so sorry for the delay between selecting the Microproject and sending the patch series.\nLearning about regular expressions took me a bit longer than I expected, but it was all worth it.\nI'm very grateful for the opportunity to work on this project and I'm looking forward to contributing more to Git.\n\nThis patch series adds builtin patterns for JavaScript function detection in userdiff, as \nmy Microproject for GSOC. The first patch adds a regular expression for detecting JavaScript\nfunctions in Git diffs while the second adds a test for JavaScript function detection in Git diffs.\nThis new pattern looks for lines that start with optional whitespace, followed by 'function' and any \ncharacters (for function declarations), or valid JavaScript identifiers, equals sign '=', 'function'\nkeyword and any characters (for function expressions). It also considers functions defined inside blocks with '{...}'.\n\n\n t/t4018-diff-funcname.sh | 25 +++++++++++++++++++++++--\n userdiff.c               | 17 +++++++++++++++--\n 2 files changed, 38 insertions(+), 4 deletions(-)\n \n\nbase-commit: c5b454771e6b086f60c7f1f139025f174bcedac9\n-- \n2.43.2\n\nI would greatly appreciate any feedback on the patch series.\nBest, \nSergius.\n\n"},{"id":"489539","messageId":"20240227160253.104011-2-sergiusnyah@gmail.com","threadId":"60710","inReplyTo":"20240227160253.104011-1-sergiusnyah@gmail.com","subject":"[PATCH 1/2] Subject: [GSOC][RFC PATCH 1/2] Add builtin patterns for JavaScript function detection in userdiff.","fromName":"Sergius Nyah","fromEmail":"sergiusnyah@gmail.com","sentAt":"2024-02-27T16:02:52Z","receivedAt":"2024-02-27T16:03:06Z","isPatch":true,"sender":{"key":"sergiusnyah@gmail.com","avatar":null},"body":"This patch adds the regular expression for detecting JavaScript functions and expressions in Git diffs. The pattern accurately identifies function declerations, expressions, and definitions inside blocks.\n---\n userdiff.c | 17 +++++++++++++++--\n 1 file changed, 15 insertions(+), 2 deletions(-)\n\ndiff --git a/userdiff.c b/userdiff.c\nindex e399543823..12e31ff14d 100644\n--- a/userdiff.c\n+++ b/userdiff.c\n@@ -1,7 +1,7 @@\n #include \"git-compat-util.h\"\n #include \"config.h\"\n #include \"userdiff.h\"\n-#include \"attr.h\"\n+#include \"attr.h\" \n #include \"strbuf.h\"\n \n static struct userdiff_driver *drivers;\n@@ -183,6 +183,19 @@ PATTERNS(\"java\",\n \t \"|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?\"\n \t \"|[-+*/<>%&^|=!]=\"\n \t \"|--|\\\\+\\\\+|<<=?|>>>?=?|&&|\\\\|\\\\|\"),\n+PATTERNS(\"javascript\",\n+     /* \n+\t  * Looks for lines that start with optional whitespace, followed \n+\t  * by 'function'* and any characters (for function declarations), \n+      * or valid JavaScript identifiers, equals sign '=', 'function' keyword\n+\t  * and any characters (for function expressions).\n+      * Also considers functions defined inside blocks with '{...}'.\n+\t  */ \n+\t \"^[ \\t]*(function[ \\t]*.*|[a-zA-Z_$][0-9a-zA-Z_$]*[ \\t]*=[ \\t]*function[ \\t]*.*|(\\\\{[ \\t]*)?)\\n\",\n+     /* This pattern matches JavaScript identifiers */\n+     \"[a-zA-Z_$][0-9a-zA-Z_$]*\"\n+     \"|[-+0-9.eE]+|0[xX][0-9a-fA-F]+\" \n+     \"|[-+*/<>%&^|=!:]=|--|\\\\+\\\\+|<<=?|>>=?|&&|\\\\|\\\\|\"), \n PATTERNS(\"kotlin\",\n \t \"^[ \\t]*(([a-z]+[ \\t]+)*(fun|class|interface)[ \\t]+.*)$\",\n \t /* -- */\n@@ -192,7 +205,7 @@ PATTERNS(\"kotlin\",\n \t /* integers and floats */\n \t \"|[0-9][0-9_]*([.][0-9_]*)?([Ee][-+]?[0-9]+)?[fFlLuU]*\"\n \t /* floating point numbers beginning with decimal point */\n-\t \"|[.][0-9][0-9_]*([Ee][-+]?[0-9]+)?[fFlLuU]?\"\n+\t \"|[.][0-9][0-9_]*([Ee][-+]?[0-9]+ )?[fFlLuU]?\"\n \t /* unary and binary operators */\n \t \"|[-+*/<>%&^|=!]==?|--|\\\\+\\\\+|<<=|>>=|&&|\\\\|\\\\||->|\\\\.\\\\*|!!|[?:.][.:]\"),\n PATTERNS(\"markdown\",\n-- \n2.43.2\n:wq\n\n\n"},{"id":"489540","messageId":"20240227160253.104011-3-sergiusnyah@gmail.com","threadId":"60710","inReplyTo":"20240227160253.104011-1-sergiusnyah@gmail.com","subject":"[PATCH 2/2] Subject:[GSOC] [RFC PATCH 2/2] Add test for JavaScript function detection in Git diffs","fromName":"Sergius Nyah","fromEmail":"sergiusnyah@gmail.com","sentAt":"2024-02-27T16:02:53Z","receivedAt":"2024-02-27T16:03:16Z","isPatch":true,"sender":{"key":"sergiusnyah@gmail.com","avatar":null},"body":"From: Sergius Justus Chesami Nyah <sergiusnyah@gmail.com>\n\nThis commit introduces a new test case in t4018-diff-funcname.sh to verify the enhanced JavaScript function detection in Git diffs. The test creates a JavaScript file with function declarations and expressions, modifies them, and then checks the output of git diff to ensure that the changes are correctly identified. This test validates the changes made to userdiff.c for improved JavaScript function detection.\n---\n t/t4018-diff-funcname.sh | 25 +++++++++++++++++++++++--\n 1 file changed, 23 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh\nindex e026fac1f4..e88e63bd1f 100755\n--- a/t/t4018-diff-funcname.sh\n+++ b/t/t4018-diff-funcname.sh\n@@ -11,7 +11,7 @@ test_expect_success 'setup' '\n \t# a non-trivial custom pattern\n \tgit config diff.custom1.funcname \"!static\n !String\n-[^ \t].*s.*\" &&\n+[^ \t].*s.*\" && \n \n \t# a custom pattern which matches to end of line\n \tgit config diff.custom2.funcname \"......Beer\\$\" &&\n@@ -119,4 +119,25 @@ do\n \t\"\n done\n \n-test_done\n+test_expect_success 'identify builtin patterns in Javascript' '\n+    # setup\n+    echo \"function myFunction() { return true; }\" > test.js &&\n+    echo \"var myVar = function() { return false; }\" >> test.js &&\n+    git add test.js &&\n+    git commit -m \"add test.js\" &&\n+\n+    # modify the file\n+    echo \"function myFunction() { return false; }\" > test.js &&\n+    echo \"var myVar = function() { return true; }\" >> test.js &&\n+\n+    # command under test\n+    git diff >output &&\n+\n+    # check results\n+    test_i18ngrep \"function myFunction() { return true; }\" output &&\n+    test_i18ngrep \"function myFunction() { return false; }\" output &&\n+    test_i18ngrep \"var myVar = function() { return false; }\" output &&\n+    test_i18ngrep \"var myVar = function() { return true; }\" output\n+'\n+\n+test_done \n\\ No newline at end of file\n-- \n2.43.2\n\n\n"},{"id":"489566","messageId":"CZG3HO25QLAG.3Q9V03SCO99HL@gmail.com","threadId":"60710","inReplyTo":"20240227160253.104011-2-sergiusnyah@gmail.com","subject":"Re: [PATCH 1/2] Subject: [GSOC][RFC PATCH 1/2] Add builtin patterns for JavaScript function detection in userdiff.","fromName":"Ghanshyam Thakkar","fromEmail":"shyamthakkar001@gmail.com","sentAt":"2024-02-27T19:06:38Z","receivedAt":"2024-02-27T19:06:43Z","isPatch":true,"sender":{"key":"shyamthakkar001@gmail.com","avatar":"https://avatars.githubusercontent.com/u/72698233?v=4"},"body":"On Tue Feb 27, 2024 at 9:32 PM IST, Sergius Nyah wrote:\n> [PATCH 1/2] Subject: [GSOC][RFC PATCH 1/2] Add builtin patterns for JavaScript function detection in userdiff.\n\nI think these prefixes somehow got added twice. In any case, this makes\nit so that \"Subject: [GSOC][RFC PATCH 1/2]\" is part of the commit log,\nwhich shoud not be. And the subject can be better written as:\n\n    userdiff: add builtin patterns for Javascript\n\n> This patch adds the regular expression for detecting JavaScript functions and expressions in Git diffs. The pattern accurately identifies function declerations, expressions, and definitions inside blocks.\n\ncommit message should be wrapped at 72 characters.\n> ---\n>  userdiff.c | 17 +++++++++++++++--\n>  1 file changed, 15 insertions(+), 2 deletions(-)\n>\n> diff --git a/userdiff.c b/userdiff.c\n> index e399543823..12e31ff14d 100644\n> --- a/userdiff.c\n> +++ b/userdiff.c\n> @@ -1,7 +1,7 @@\n>  #include \"git-compat-util.h\"\n>  #include \"config.h\"\n>  #include \"userdiff.h\"\n> -#include \"attr.h\"\n> +#include \"attr.h\" \n\nThis change adds trailing whitespace which is not desired.\n\n>  #include \"strbuf.h\"\n>  \n>  static struct userdiff_driver *drivers;\n> @@ -183,6 +183,19 @@ PATTERNS(\"java\",\n>  \t \"|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?\"\n>  \t \"|[-+*/<>%&^|=!]=\"\n>  \t \"|--|\\\\+\\\\+|<<=?|>>>?=?|&&|\\\\|\\\\|\"),\n> +PATTERNS(\"javascript\",\n> +     /* \n> +\t  * Looks for lines that start with optional whitespace, followed \n> +\t  * by 'function'* and any characters (for function declarations), \n> +      * or valid JavaScript identifiers, equals sign '=', 'function' keyword\n> +\t  * and any characters (for function expressions).\n> +      * Also considers functions defined inside blocks with '{...}'.\n> +\t  */ \n> +\t \"^[ \\t]*(function[ \\t]*.*|[a-zA-Z_$][0-9a-zA-Z_$]*[ \\t]*=[ \\t]*function[ \\t]*.*|(\\\\{[ \\t]*)?)\\n\",\n> +     /* This pattern matches JavaScript identifiers */\n> +     \"[a-zA-Z_$][0-9a-zA-Z_$]*\"\n> +     \"|[-+0-9.eE]+|0[xX][0-9a-fA-F]+\" \n> +     \"|[-+*/<>%&^|=!:]=|--|\\\\+\\\\+|<<=?|>>=?|&&|\\\\|\\\\|\"), \n\nMajority of the lines above (including comment) have trailing whitespace.\nConsider removing them. Also, tabs should be used for indentation instead\nof spaces. (cf. Documentation/CodingGuidelines)\n\n>  PATTERNS(\"kotlin\",\n>  \t \"^[ \\t]*(([a-z]+[ \\t]+)*(fun|class|interface)[ \\t]+.*)$\",\n>  \t /* -- */\n> @@ -192,7 +205,7 @@ PATTERNS(\"kotlin\",\n>  \t /* integers and floats */\n>  \t \"|[0-9][0-9_]*([.][0-9_]*)?([Ee][-+]?[0-9]+)?[fFlLuU]*\"\n>  \t /* floating point numbers beginning with decimal point */\n> -\t \"|[.][0-9][0-9_]*([Ee][-+]?[0-9]+)?[fFlLuU]?\"\n> +\t \"|[.][0-9][0-9_]*([Ee][-+]?[0-9]+ )?[fFlLuU]?\"\n\nThis adds extra whitespace in the middle. Changes not related to the patch\ntopic should be avoided.\n\nAlso this was attempted before, see [1]. I think you can take some\ninspiration and inputs from that also. Aside from that I think the\nseparate patch which adds tests for this can be squashed into this\none.\n\n[1]:\nhttps://lore.kernel.org/git/20220403132508.28196-1-a97410985new@gmail.com/\n\nThanks.\n"},{"id":"489574","messageId":"CANAnif8w-MFcp04s1dDffmGsLGYhsKYkXGTLEQqVrt8zm=UpEQ@mail.gmail.com","threadId":"60710","inReplyTo":"CZG3HO25QLAG.3Q9V03SCO99HL@gmail.com","subject":"Re: [PATCH 1/2] Subject: [GSOC][RFC PATCH 1/2] Add builtin patterns for JavaScript function detection in userdiff.","fromName":"Sergius Nyah","fromEmail":"sergiusnyah@gmail.com","sentAt":"2024-02-27T21:05:12Z","receivedAt":"2024-02-27T21:05:24Z","isPatch":true,"sender":{"key":"sergiusnyah@gmail.com","avatar":null},"body":"On Tue, Feb 27, 2024 at 8:06 PM Ghanshyam Thakkar\n<shyamthakkar001@gmail.com> wrote:\n>\n> On Tue Feb 27, 2024 at 9:32 PM IST, Sergius Nyah wrote:\n> > [PATCH 1/2] Subject: [GSOC][RFC PATCH 1/2] Add builtin patterns for JavaScript function detection in userdiff.\n>\n> I think these prefixes somehow got added twice. In any case, this makes\n> it so that \"Subject: [GSOC][RFC PATCH 1/2]\" is part of the commit log,\n> which shoud not be. And the subject can be better written as:\n>\n>     userdiff: add builtin patterns for Javascript\n>\nNoted, thanks!\n\n> > This patch adds the regular expression for detecting JavaScript functions and expressions in Git diffs. The pattern accurately identifies function declerations, expressions, and definitions inside blocks.\n>\n> commit message should be wrapped at 72 characters.\n> > ---\nThank you for the correction.\n\n> >  userdiff.c | 17 +++++++++++++++--\n> >  1 file changed, 15 insertions(+), 2 deletions(-)\n> >\n> > diff --git a/userdiff.c b/userdiff.c\n> > index e399543823..12e31ff14d 100644\n> > --- a/userdiff.c\n> > +++ b/userdiff.c\n> > @@ -1,7 +1,7 @@\n> >  #include \"git-compat-util.h\"\n> >  #include \"config.h\"\n> >  #include \"userdiff.h\"\n> > -#include \"attr.h\"\n> > +#include \"attr.h\"\n>\n> This change adds trailing whitespace which is not desired.\n>\nOkay. Would avoid them in subsequent commits.\n> >  #include \"strbuf.h\"\n> >\n> >  static struct userdiff_driver *drivers;\n> > @@ -183,6 +183,19 @@ PATTERNS(\"java\",\n> >        \"|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?\"\n> >        \"|[-+*/<>%&^|=!]=\"\n> >        \"|--|\\\\+\\\\+|<<=?|>>>?=?|&&|\\\\|\\\\|\"),\n> > +PATTERNS(\"javascript\",\n> > +     /*\n> > +       * Looks for lines that start with optional whitespace, followed\n> > +       * by 'function'* and any characters (for function declarations),\n> > +      * or valid JavaScript identifiers, equals sign '=', 'function' keyword\n> > +       * and any characters (for function expressions).\n> > +      * Also considers functions defined inside blocks with '{...}'.\n> > +       */\n> > +      \"^[ \\t]*(function[ \\t]*.*|[a-zA-Z_$][0-9a-zA-Z_$]*[ \\t]*=[ \\t]*function[ \\t]*.*|(\\\\{[ \\t]*)?)\\n\",\n> > +     /* This pattern matches JavaScript identifiers */\n> > +     \"[a-zA-Z_$][0-9a-zA-Z_$]*\"\n> > +     \"|[-+0-9.eE]+|0[xX][0-9a-fA-F]+\"\n> > +     \"|[-+*/<>%&^|=!:]=|--|\\\\+\\\\+|<<=?|>>=?|&&|\\\\|\\\\|\"),\n>\n> Majority of the lines above (including comment) have trailing whitespace.\n> Consider removing them. Also, tabs should be used for indentation instead\n> of spaces. (cf. Documentation/CodingGuidelines)\n\nWell received. Thanks!\n>\n> >  PATTERNS(\"kotlin\",\n> >        \"^[ \\t]*(([a-z]+[ \\t]+)*(fun|class|interface)[ \\t]+.*)$\",\n> >        /* -- */\n> > @@ -192,7 +205,7 @@ PATTERNS(\"kotlin\",\n> >        /* integers and floats */\n> >        \"|[0-9][0-9_]*([.][0-9_]*)?([Ee][-+]?[0-9]+)?[fFlLuU]*\"\n> >        /* floating point numbers beginning with decimal point */\n> > -      \"|[.][0-9][0-9_]*([Ee][-+]?[0-9]+)?[fFlLuU]?\"\n> > +      \"|[.][0-9][0-9_]*([Ee][-+]?[0-9]+ )?[fFlLuU]?\"\n>\n> This adds extra whitespace in the middle. Changes not related to the patch\n> topic should be avoided.\n\nSorry about that, I just touched what I shouldn't have.\n>\n> Also this was attempted before, see [1]. I think you can take some\n> inspiration and inputs from that also. Aside from that I think the\n> separate patch which adds tests for this can be squashed into this\n> one.\n>\n> [1]:\n> https://lore.kernel.org/git/20220403132508.28196-1-a97410985new@gmail.com/\n>\n> Thanks.\n\nThank you for all the corrections. I'd submit a patch series with the\ncorrect practices.\n"},{"id":"489616","messageId":"20240228150034.313196-1-sergiusnyah@gmail.com","threadId":"60710","inReplyTo":"CANAnif-OganZLi0Cu_uq=nveC+u5n14c=o_DQHT-wFOqQ9Vs0Q@mail.gmail.com","subject":"[GSOC][PATCH] Userdiff: add builtin patterns for JavaScript.","fromName":"Sergius Nyah","fromEmail":"sergiusnyah@gmail.com","sentAt":"2024-02-28T15:00:34Z","receivedAt":"2024-02-28T15:00:46Z","isPatch":true,"sender":{"key":"sergiusnyah@gmail.com","avatar":null},"body":"This commit introduces builtin patterns for JavaScript in userdiff and adds a new test\ncase in t4018-diff-funcname.sh to verify the enhanced JavaScript function detection in Git diffs.\nSigned-off-by: Sergius Justus Chesami Nyah <sergiusnyah@gmail.com>\n---\n...-PATCH-1-2-Add-builtin-patterns-for-.patch | 53 ++++++-------------\nt/t4018-diff-funcname.sh                      | 25 ++++++++-\n2 files changed, 38 insertions(+), 40 deletions(-)\n\ndiff --git a/Pattern/0001-Subject-GSOC-RFC-PATCH-1-2-Add-builtin-patterns-for-.patch b/Pattern/0001-Subject-GSOC-RFC-PATCH-1-2-Add-builtin-patterns-for-.patch\nindex 43593866bc..9c3b80665e 100644\n--- a/Pattern/0001-Subject-GSOC-RFC-PATCH-1-2-Add-builtin-patterns-for-.patch\n+++ b/Pattern/0001-Subject-GSOC-RFC-PATCH-1-2-Add-builtin-patterns-for-.patch\n-This patch adds the regular expression for detecting JavaScript functions and expressions in Git diffs. The pattern accurately identifies function declerations, expressions, and definitions inside blocks.\n----\n+This patch adds the regular expression for detecting JavaScript functions and expressions in Git diffs.\nuserdiff.c | 17 +++++++++++++++--\n1 file changed, 15 insertions(+), 2 deletions(-)\n\n@@ -18,40 +16,19 @@ index e399543823..12e31ff14d 100644\n#include \"git-compat-util.h\"\n#include \"config.h\"\n#include \"userdiff.h\"\n#include \"strbuf.h\"\n\n+PATTERNS(\"javascript\",\n-+     /*\n++      * Looks for lines that start with optional whitespace, followed\n++      * by 'function'* and any characters (for function declarations),\n++      * or valid JavaScript identifiers, equals sign '=', 'function' keyword\n+       * and any characters (for function expressions).\n++      * Also considers functions defined inside blocks with '{...}'.\n++      */\n+      \"^[ \\t]*(function[ \\t]*.*|[a-zA-Z_$][0-9a-zA-Z_$]*[ \\t]*=[ \\t]*function[ \\t]*.*|(\\\\{[ \\t]*)?)\\n\",\n-+     /* This pattern matches JavaScript identifiers */\n-+     \"[a-zA-Z_$][0-9a-zA-Z_$]*\"\n-+     \"|[-+0-9.eE]+|0[xX][0-9a-fA-F]+\"\n-+     \"|[-+*/<>%&^|=!:]=|--|\\\\+\\\\+|<<=?|>>=?|&&|\\\\|\\\\|\"),\n\nHere is the test file.\n\n-test_done\n+test_expect_success 'identify builtin patterns in Javascript' '\n+    # setup\n+    echo \"function myFunction() { return true; }\" > test.js &&\n+    echo \"var myVar = function() { return false; }\" >> test.js &&\n+    git add test.js &&\n+    git commit -m \"add test.js\" &&\n+\n+    # modify the file\n+    echo \"function myFunction() { return false; }\" > test.js &&\n+    echo \"var myVar = function() { return true; }\" >> test.js &&\n+\n+    # command under test\n+    git diff >output &&\n+\n+    # check results\n+    test_i18ngrep \"function myFunction() { return true; }\" output &&\n+    test_i18ngrep \"function myFunction() { return false; }\" output &&\n+    test_i18ngrep \"var myVar = function() { return false; }\" output &&\n+    test_i18ngrep \"var myVar = function() { return true; }\" output\n+'\n+\n+test_done\n--\n2.43.2\n"},{"id":"489622","messageId":"xmqqttlsjvsi.fsf@gitster.g","threadId":"60710","inReplyTo":"20240228150034.313196-1-sergiusnyah@gmail.com","subject":"Re: [GSOC][PATCH] Userdiff: add builtin patterns for JavaScript.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-02-28T18:19:57Z","receivedAt":"2024-02-28T18:20:05Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sergius Nyah <sergiusnyah@gmail.com> writes:\n\n> This commit introduces builtin patterns for JavaScript in userdiff and adds a new test\n> case in t4018-diff-funcname.sh to verify the enhanced JavaScript function detection in Git diffs.\n> Signed-off-by: Sergius Justus Chesami Nyah <sergiusnyah@gmail.com>\n> ---\n> ...-PATCH-1-2-Add-builtin-patterns-for-.patch | 53 ++++++-------------\n> t/t4018-diff-funcname.sh                      | 25 ++++++++-\n> 2 files changed, 38 insertions(+), 40 deletions(-)\n\nYou apparently have done \"git add\" of a file that is a format-patch\noutput, which led to ...\n\n> diff --git a/Pattern/0001-Subject-GSOC-RFC-PATCH-1-2-Add-builtin-patterns-for-.patch b/Pattern/0001-Subject-GSOC-RFC-PATCH-1-2-Add-builtin-patterns-for-.patch\n> index 43593866bc..9c3b80665e 100644\n> --- a/Pattern/0001-Subject-GSOC-RFC-PATCH-1-2-Add-builtin-patterns-for-.patch\n> +++ b/Pattern/0001-Subject-GSOC-RFC-PATCH-1-2-Add-builtin-patterns-for-.patch\n\n... this thing.\n\nWrap the proposed commit log message to a reasonable length and have\na blank line before your sign-off.  Other pieces of advice about\nformatting and contents found in Documentation/SubmittingPatches are\nalso helpful.\n\nThanks.\n"},{"id":"489656","messageId":"20240229101131.445405-1-sergiusnyah@gmail.com","threadId":"60710","inReplyTo":"xmqqttlsjvsi.fsf@gitster.g","subject":"[GSOC][PATCH] userdiff: add builtin patterns for JavaScript.","fromName":"Sergius Nyah","fromEmail":"sergiusnyah@gmail.com","sentAt":"2024-02-29T10:11:31Z","receivedAt":"2024-02-29T10:11:44Z","isPatch":true,"sender":{"key":"sergiusnyah@gmail.com","avatar":null},"body":"This commit introduces builtin patterns for JavaScript in userdiff.\n\nIt adds a new test case in t4018-diff-funcname.sh to verify the enhanced\nJavaScript function detection in Git diffs.\n\nSigned-off-by: Sergius Justus Chesami Nyah <sergiusnyah@gmail.com>\n---\nuserdiff.c | 17 +++++++++++++++--\nt/t4018-diff-funcname.sh | 25 ++++++++-\n2 files changed, 38 insertions(+), 4 deletions(-)\n\ndiff --git a/userdiff.c b/userdiff.c\nindex e399543823..12e31ff14d 100644\n--- a/userdiff.c\n+++ b/userdiff.c\n@@ -18,40 +16,19 @@\n#include \"git-compat-util.h\"\n#include \"config.h\"\n#include \"userdiff.h\"\n#include \"strbuf.h\"\n\nPATTERNS(\"javascript\",\n      /* Looks for lines that start with optional whitespace, followed\n      * by 'function'* and any characters (for function declarations),\n      * or valid JavaScript identifiers, equals sign '=', 'function' keyword\n      * and any characters (for function expressions).\n      * Also considers functions defined inside blocks with '{...}'.\n      */\n      \"^[ \\t]*(function[ \\t]*.*|[a-zA-Z_$][0-9a-zA-Z_$]*[ \\t]*=[ \\t]*function[ \\t]*.*|(\\\\{[ \\t]*)?)\\n\",\n      /* This pattern matches JavaScript identifiers */\n      \"[a-zA-Z_$][0-9a-zA-Z_$]*\"\n      \"|[-+0-9.eE]+|0[xX][0-9a-fA-F]+\"\n      \"|[-+*/<>%&^|=!:]=|--|\\\\+\\\\+|<<=?|>>=?|&&|\\\\|\\\\|\"),\n\ndiff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh\nindex 43593866bc..9c3b80665e 100644\n--- a/t/t4018-diff-funcname.sh\n+++ b/t/t4018-diff-funcname.sh\n@@ -18,40 +16,19 @@\ntest_expect_success 'identify builtin patterns in Javascript' '\n    # setup\n    echo \"function myFunction() { return true; }\" > test.js &&\n    echo \"var myVar = function() { return false; }\" >> test.js &&\n    git add test.js &&\n    git commit -m \"add test.js\" &&\n\n    # modify the file\n    echo \"function myFunction() { return false; }\" > test.js &&\n    echo \"var myVar = function() { return true; }\" >> test.js &&\n\n    # command under test\n    git diff >output &&\n\n    # check results\n    test_i18ngrep \"function myFunction() { return true; }\" output &&\n    test_i18ngrep \"function myFunction() { return false; }\" output &&\n    test_i18ngrep \"var myVar = function() { return false; }\" output &&\n    test_i18ngrep \"var myVar = function() { return true; }\" output\n'\n\ntest_done\n--\n2.43.2\n"},{"id":"489659","messageId":"CZHJPF604DV9.X0A0VX1AB7P8@gmail.com","threadId":"60710","inReplyTo":"20240229101131.445405-1-sergiusnyah@gmail.com","subject":"Re: [GSOC][PATCH] userdiff: add builtin patterns for JavaScript.","fromName":"Ghanshyam Thakkar","fromEmail":"shyamthakkar001@gmail.com","sentAt":"2024-02-29T12:01:43Z","receivedAt":"2024-02-29T12:01:51Z","isPatch":true,"sender":{"key":"shyamthakkar001@gmail.com","avatar":"https://avatars.githubusercontent.com/u/72698233?v=4"},"body":"On Thu Feb 29, 2024 at 3:41 PM IST, Sergius Nyah wrote:\n> This commit introduces builtin patterns for JavaScript in userdiff.\n\"This commit introduces ...\" -> \"Introduce ...\". I think describing which\nspecification this adheres to (i.e. ECMA-262) would be helpful for the\nreaders.\n\n> It adds a new test case in t4018-diff-funcname.sh to verify the enhanced\n> JavaScript function detection in Git diffs.\n\n\"It adds ...\" -> \"Add ...\"\n\n> Signed-off-by: Sergius Justus Chesami Nyah <sergiusnyah@gmail.com>\n> ---\n> userdiff.c | 17 +++++++++++++++--\n> t/t4018-diff-funcname.sh | 25 ++++++++-\n> 2 files changed, 38 insertions(+), 4 deletions(-)\n>\n> diff --git a/userdiff.c b/userdiff.c\n> index e399543823..12e31ff14d 100644\n> --- a/userdiff.c\n> +++ b/userdiff.c\n> @@ -18,40 +16,19 @@\n> #include \"git-compat-util.h\"\n> #include \"config.h\"\n> #include \"userdiff.h\"\n> #include \"strbuf.h\"\n>\n> PATTERNS(\"javascript\",\n>       /* Looks for lines that start with optional whitespace, followed\n>       * by 'function'* and any characters (for function declarations),\n>       * or valid JavaScript identifiers, equals sign '=', 'function' keyword\n>       * and any characters (for function expressions).\n>       * Also considers functions defined inside blocks with '{...}'.\n>       */\n>       \"^[ \\t]*(function[ \\t]*.*|[a-zA-Z_$][0-9a-zA-Z_$]*[ \\t]*=[ \\t]*function[ \\t]*.*|(\\\\{[ \\t]*)?)\\n\",\n>       /* This pattern matches JavaScript identifiers */\n>       \"[a-zA-Z_$][0-9a-zA-Z_$]*\"\n>       \"|[-+0-9.eE]+|0[xX][0-9a-fA-F]+\"\n>       \"|[-+*/<>%&^|=!:]=|--|\\\\+\\\\+|<<=?|>>=?|&&|\\\\|\\\\|\"),\n\nIt seems like you manually manipulated the diff/format-patch output that\nis not the commit message. Usually all the new lines have '+' sign\nprefixed and all the removed lines have '-' sign prefixed. git am gives\nthe following error:\n\n    Applying: userdiff: add builtin patterns for JavaScript.\n    error: corrupt patch at line 11\n    Patch failed at 0022 userdiff: add builtin patterns for JavaScript.\n\nIf you find it difficult to use send-email/format-patch, you can always\nmake a pull request on git/git or gitgitgadget/git on GitHub and\nGitGitGadget[1] will take care of the rest. If you still want to use\nformat-patch, it is a good practice to version your patches\n(i.e. [PATCH v2 1/2] ...) so that it is easy to follow.\n(cf. Documentation/SubmittingPatches or Documentation/MyFirstContribution)\n\n[1]: https://gitgitgadget.github.io/\n\nThanks.\n> diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh\n> index 43593866bc..9c3b80665e 100644\n> --- a/t/t4018-diff-funcname.sh\n> +++ b/t/t4018-diff-funcname.sh\n> @@ -18,40 +16,19 @@\n> test_expect_success 'identify builtin patterns in Javascript' '\n>     # setup\n>     echo \"function myFunction() { return true; }\" > test.js &&\n>     echo \"var myVar = function() { return false; }\" >> test.js &&\n>     git add test.js &&\n>     git commit -m \"add test.js\" &&\n>\n>     # modify the file\n>     echo \"function myFunction() { return false; }\" > test.js &&\n>     echo \"var myVar = function() { return true; }\" >> test.js &&\n>\n>     # command under test\n>     git diff >output &&\n>\n>     # check results\n>     test_i18ngrep \"function myFunction() { return true; }\" output &&\n>     test_i18ngrep \"function myFunction() { return false; }\" output &&\n>     test_i18ngrep \"var myVar = function() { return false; }\" output &&\n>     test_i18ngrep \"var myVar = function() { return true; }\" output\n> '\n>\n> test_done\n> --\n> 2.43.2\n\n"},{"id":"489731","messageId":"20240301074048.188835-1-sergiusnyah@gmail.com","threadId":"60710","inReplyTo":"xmqqttlsjvsi.fsf@gitster.g","subject":"[GSOC][PATCH] userdiff: Add JavaScript function patterns","fromName":"Sergius Nyah","fromEmail":"sergiusnyah@gmail.com","sentAt":"2024-03-01T07:40:48Z","receivedAt":"2024-03-01T07:40:57Z","isPatch":true,"sender":{"key":"sergiusnyah@gmail.com","avatar":null},"body":"This commit adds a patterns used to match JavaScript functions.\nIt now correctly identifies function declarations, function expressions,\nand functions defined inside blocks. Add test for corresponding change in userdiff.\n\nSigned-off-by: Sergius Nyah <sergiusnyah@gmail.com>\n---\n t/t4018-diff-funcname.sh | 22 ++++++++++++++++++++++\n userdiff.c               | 12 ++++++++++++\n 2 files changed, 34 insertions(+)\n\ndiff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh\nindex e026fac1f4..d35cce18a0 100755\n--- a/t/t4018-diff-funcname.sh\n+++ b/t/t4018-diff-funcname.sh\n@@ -120,3 +120,25 @@ do\n done\n\n test_done\n+\n+test_expect_success 'identify builtin patterns in JavaScript' '\n+\t# setup\n+\techo \"function myFunction() { return true; }\" > test.js &&\n+\techo \"var myVar = function() { return false; }\" >> test.js &&\n+\tgit add test.js &&\n+\tgit commit -m \"add test.js\" &&\n+\n+\t# modify the file\n+\techo \"function myFunction() { return false; }\" > test.js &&\n+\techo \"var myVar = function() { return true; }\" >> test.js &&\n+\n+\t# command under test\n+\tgit diff >output &&\n+\n+\t# check results\n+\ttest_i18ngrep \"function myFunction() { return true; }\" output &&\n+\ttest_i18ngrep \"function myFunction() { return false; }\" output &&\n+\ttest_i18ngrep \"var myVar = function() { return false; }\" output &&\n+\ttest_i18ngrep \"var myVar = function() { return true; }\" output\n+'\n+test_done\n\\ No newline at end of file\ndiff --git a/userdiff.c b/userdiff.c\nindex 2b1dab2649..bbe2bcb9a3 100644\n--- a/userdiff.c\n+++ b/userdiff.c\n+PATTERNS(\"javascript\",\n+      /* Looks for lines that start with optional whitespace, followed\n+      * by 'function'* and any characters (for function declarations),\n+      * or valid JavaScript identifiers, equals sign '=', 'function' keyword\n+      * and any characters (for function expressions).\n+      * Also considers functions defined inside blocks with '{...}'.\n+      */\n+      \"^[ \\t]*(function[ \\t]*.*|[a-zA-Z_$][0-9a-zA-Z_$]*[ \\t]*=[ \\t]*function[ \\t]*.*|(\\\\{[ \\t]*)?)\\n\",\n+      /* This pattern matches JavaScript identifiers */\n+      \"[a-zA-Z_$][0-9a-zA-Z_$]*\"\n+      \"|[-+0-9.eE]+|0[xX][0-9a-fA-F]+\"\n+      \"|[-+*/<>%&^|=!:]=|--|\\\\+\\\\+|<<=?|>>=?|&&|\\\\|\\\\|\"),\n--\n2.43.2\n\n"},{"id":"489767","messageId":"CAP8UFD1sAYORc_q20t4Y28mSjNa0BZ69XQ-hGFsNTzbThsG1KQ@mail.gmail.com","threadId":"60710","inReplyTo":"20240301074048.188835-1-sergiusnyah@gmail.com","subject":"Re: [GSOC][PATCH] userdiff: Add JavaScript function patterns","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2024-03-02T10:28:48Z","receivedAt":"2024-03-02T10:29:02Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"The subject should be \"userdiff: add JavaScript function patterns\" so\nwith \"add\" instead of \"Add\". See the SubmittingPatches document which\ncontains:\n\n\"The title sentence after the \"area:\" prefix omits the full stop at the\nend, and its first word is not capitalized (the omission\nof capitalization applies only to the word after the \"area:\"\nprefix of the title) unless there is a reason to\ncapitalize it other than because it is the first word in the sentence.\"\n\n\nOn Fri, Mar 1, 2024 at 8:40 AM Sergius Nyah <sergiusnyah@gmail.com> wrote:\n>\n> This commit adds a patterns used to match JavaScript functions.\n\nIt should be either \"add patterns\" or \"add a pattern\".\n\nAlso instead of \"This commit\" please use the imperative mood or\n\"Let's\". See the SubmittingPatches document which contains:\n\n\"Describe your changes in imperative mood, e.g. \"make xyzzy do frotz\"\ninstead of \"[This patch] makes xyzzy do frotz\" or \"[I] changed xyzzy\nto do frotz\", as if you are giving orders to the codebase to change\nits behavior.\"\n\n> It now correctly identifies function declarations, function expressions,\n> and functions defined inside blocks. Add test for corresponding change in userdiff.\n>\n> Signed-off-by: Sergius Nyah <sergiusnyah@gmail.com>\n> ---\n>  t/t4018-diff-funcname.sh | 22 ++++++++++++++++++++++\n>  userdiff.c               | 12 ++++++++++++\n>  2 files changed, 34 insertions(+)\n\nIn t4034-diff-words.sh there is:\n\ntest_language_driver ada\ntest_language_driver bibtex\ntest_language_driver cpp\ntest_language_driver csharp\ntest_language_driver css\ntest_language_driver dts\ntest_language_driver fortran\ntest_language_driver html\ntest_language_driver java\ntest_language_driver kotlin\ntest_language_driver matlab\ntest_language_driver objc\ntest_language_driver pascal\ntest_language_driver perl\ntest_language_driver php\ntest_language_driver python\ntest_language_driver ruby\ntest_language_driver scheme\ntest_language_driver tex\n\nSo I would have thought that you would just add a\n`test_language_driver javascript` line in this file and associated\nmaterial in the t/t4034/ directory.\n\n> diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh\n> index e026fac1f4..d35cce18a0 100755\n> --- a/t/t4018-diff-funcname.sh\n> +++ b/t/t4018-diff-funcname.sh\n> @@ -120,3 +120,25 @@ do\n>  done\n>\n>  test_done\n> +\n> +test_expect_success 'identify builtin patterns in JavaScript' '\n> +       # setup\n> +       echo \"function myFunction() { return true; }\" > test.js &&\n> +       echo \"var myVar = function() { return false; }\" >> test.js &&\n> +       git add test.js &&\n> +       git commit -m \"add test.js\" &&\n> +\n> +       # modify the file\n> +       echo \"function myFunction() { return false; }\" > test.js &&\n> +       echo \"var myVar = function() { return true; }\" >> test.js &&\n> +\n> +       # command under test\n> +       git diff >output &&\n> +\n> +       # check results\n> +       test_i18ngrep \"function myFunction() { return true; }\" output &&\n> +       test_i18ngrep \"function myFunction() { return false; }\" output &&\n> +       test_i18ngrep \"var myVar = function() { return false; }\" output &&\n> +       test_i18ngrep \"var myVar = function() { return true; }\" output\n\nI think we try to use just test_grep instead of test_i18ngrep these days.\n\n> +'\n> +test_done\n> \\ No newline at end of file\n\nPlease add a new line at the end of this file if you still change it.\n\nThanks!\n"},{"id":"489768","messageId":"CAP8UFD0DAX_7srT5-AhdrWCj7nOKUCFBdwBph=4YnydvKdgFzw@mail.gmail.com","threadId":"60710","inReplyTo":"CAP8UFD1sAYORc_q20t4Y28mSjNa0BZ69XQ-hGFsNTzbThsG1KQ@mail.gmail.com","subject":"Re: [GSOC][PATCH] userdiff: Add JavaScript function patterns","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2024-03-02T10:54:32Z","receivedAt":"2024-03-02T10:54:46Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Sat, Mar 2, 2024 at 11:28 AM Christian Couder\n<christian.couder@gmail.com> wrote:\n>\n> The subject should be \"userdiff: add JavaScript function patterns\" so\n> with \"add\" instead of \"Add\". See the SubmittingPatches document which\n> contains:\n>\n> \"The title sentence after the \"area:\" prefix omits the full stop at the\n> end, and its first word is not capitalized (the omission\n> of capitalization applies only to the word after the \"area:\"\n> prefix of the title) unless there is a reason to\n> capitalize it other than because it is the first word in the sentence.\"\n\nAlso about the subject, please use v2, v3, v4 when you resend a patch\nor a patch series that you have already sent. `git format-patch` has a\n\"-v <n>\" or \"--reroll-count=<n>\" option for that purpose.\n"},{"id":"489782","messageId":"xmqq5xy4zhdc.fsf@gitster.g","threadId":"60710","inReplyTo":"CAP8UFD1sAYORc_q20t4Y28mSjNa0BZ69XQ-hGFsNTzbThsG1KQ@mail.gmail.com","subject":"Re: [GSOC][PATCH] userdiff: Add JavaScript function patterns","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-03-02T17:13:51Z","receivedAt":"2024-03-02T17:13:54Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Christian Couder <christian.couder@gmail.com> writes:\n\n>> +       # check results\n>> +       test_i18ngrep \"function myFunction() { return true; }\" output &&\n>> +       test_i18ngrep \"function myFunction() { return false; }\" output &&\n>> +       test_i18ngrep \"var myVar = function() { return false; }\" output &&\n>> +       test_i18ngrep \"var myVar = function() { return true; }\" output\n>\n> I think we try to use just test_grep instead of test_i18ngrep these days.\n\nThanks for reminding.  I am tempted to suggest doing this.\n\n------ >8 ----------- >8 ----------- >8 ----------- >8 ------\nSubject: test_i18ngrep: hard deprecate and forbid its use\n\nSince v2.44.0-rc0~109 (Merge branch 'sp/test-i18ngrep', 2023-12-27)\nnone of the tests we have, either in 'master' or in flight and\ncollected in 'seen', use test_i18ngrep.\n\nPerhaps it is good time to update test_i18ngrep to BUG to avoid\npeople adding new calls to it.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n t/test-lib-functions.sh | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git c/t/test-lib-functions.sh w/t/test-lib-functions.sh\nindex b5eaf7fdc1..6eaf116346 100644\n--- c/t/test-lib-functions.sh\n+++ w/t/test-lib-functions.sh\n@@ -1263,9 +1263,8 @@ test_cmp_bin () {\n \tcmp \"$@\"\n }\n \n-# Deprecated - do not use this in new code\n test_i18ngrep () {\n-\ttest_grep \"$@\"\n+\tBUG \"do not use test_i18ngrep---use test_grep instead\"\n }\n \n test_grep () {\n"},{"id":"489848","messageId":"ZeWOhxBDvyjH8gW7@tanuki","threadId":"60710","inReplyTo":"20240301074048.188835-1-sergiusnyah@gmail.com","subject":"Re: [GSOC][PATCH] userdiff: Add JavaScript function patterns","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-03-04T09:04:07Z","receivedAt":"2024-03-04T09:04:14Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Fri, Mar 01, 2024 at 08:40:48AM +0100, Sergius Nyah wrote:\n> This commit adds a patterns used to match JavaScript functions.\n> It now correctly identifies function declarations, function expressions,\n> and functions defined inside blocks. Add test for corresponding change in userdiff.\n> \n> Signed-off-by: Sergius Nyah <sergiusnyah@gmail.com>\n> ---\n>  t/t4018-diff-funcname.sh | 22 ++++++++++++++++++++++\n>  userdiff.c               | 12 ++++++++++++\n>  2 files changed, 34 insertions(+)\n> \n> diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh\n> index e026fac1f4..d35cce18a0 100755\n> --- a/t/t4018-diff-funcname.sh\n> +++ b/t/t4018-diff-funcname.sh\n> @@ -120,3 +120,25 @@ do\n>  done\n> \n>  test_done\n> +\n> +test_expect_success 'identify builtin patterns in JavaScript' '\n> +\t# setup\n> +\techo \"function myFunction() { return true; }\" > test.js &&\n> +\techo \"var myVar = function() { return false; }\" >> test.js &&\n> +\tgit add test.js &&\n> +\tgit commit -m \"add test.js\" &&\n> +\n> +\t# modify the file\n> +\techo \"function myFunction() { return false; }\" > test.js &&\n> +\techo \"var myVar = function() { return true; }\" >> test.js &&\n> +\n> +\t# command under test\n> +\tgit diff >output &&\n> +\n> +\t# check results\n> +\ttest_i18ngrep \"function myFunction() { return true; }\" output &&\n> +\ttest_i18ngrep \"function myFunction() { return false; }\" output &&\n> +\ttest_i18ngrep \"var myVar = function() { return false; }\" output &&\n> +\ttest_i18ngrep \"var myVar = function() { return true; }\" output\n> +'\n> +test_done\n> \\ No newline at end of file\n\nThis `test_done` only needs to be added because you add the new test\nbefore the preceding `test_done`. Instead, you should move up this test\nso that it comes before it.\n\n> diff --git a/userdiff.c b/userdiff.c\n> index 2b1dab2649..bbe2bcb9a3 100644\n> --- a/userdiff.c\n> +++ b/userdiff.c\n> +PATTERNS(\"javascript\",\n> +      /* Looks for lines that start with optional whitespace, followed\n\nMulti-line comments should start with their delimiters on separate\nlines. So the \"/*\" should be on its own line.\n\nAlso, the code should be indented with tabs and not spaces. It might\nhelp to read through Documentation/CodingGuidelines to get more familiar\nwith Git's coding style.\n\nPatrick\n\n> +      * by 'function'* and any characters (for function declarations),\n> +      * or valid JavaScript identifiers, equals sign '=', 'function' keyword\n> +      * and any characters (for function expressions).\n> +      * Also considers functions defined inside blocks with '{...}'.\n> +      */\n> +      \"^[ \\t]*(function[ \\t]*.*|[a-zA-Z_$][0-9a-zA-Z_$]*[ \\t]*=[ \\t]*function[ \\t]*.*|(\\\\{[ \\t]*)?)\\n\",\n> +      /* This pattern matches JavaScript identifiers */\n> +      \"[a-zA-Z_$][0-9a-zA-Z_$]*\"\n> +      \"|[-+0-9.eE]+|0[xX][0-9a-fA-F]+\"\n> +      \"|[-+*/<>%&^|=!:]=|--|\\\\+\\\\+|<<=?|>>=?|&&|\\\\|\\\\|\"),\n> --\n> 2.43.2\n> \n"},{"id":"490481","messageId":"20240312131448.638472-1-sergiusnyah@gmail.com","threadId":"60710","inReplyTo":"ZeWOhxBDvyjH8gW7@tanuki","subject":"[GSOC][PATCH v2 1/3]t4018-diff-funcname: use test_grep instead of test_i18ngrep","fromName":"Sergius Nyah","fromEmail":"sergiusnyah@gmail.com","sentAt":"2024-03-12T13:14:46Z","receivedAt":"2024-03-12T13:14:56Z","isPatch":true,"sender":{"key":"sergiusnyah@gmail.com","avatar":null},"body":"Signed-off-by: Sergius Nyah <sergiusnyah@gmail.com>\n---\n t/t4018-diff-funcname.sh | 14 +++++++-------\n 1 file changed, 7 insertions(+), 7 deletions(-)\n\ndiff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh\nindex d35cce18a0..e6d2f1c215 100755\n--- a/t/t4018-diff-funcname.sh\n+++ b/t/t4018-diff-funcname.sh\n@@ -119,8 +119,6 @@ do\n \t\"\n done\n\n-test_done\n-\n test_expect_success 'identify builtin patterns in JavaScript' '\n \t# setup\n \techo \"function myFunction() { return true; }\" > test.js &&\n@@ -136,9 +134,11 @@ test_expect_success 'identify builtin patterns in JavaScript' '\n \tgit diff >output &&\n\n \t# check results\n-\ttest_i18ngrep \"function myFunction() { return true; }\" output &&\n-\ttest_i18ngrep \"function myFunction() { return false; }\" output &&\n-\ttest_i18ngrep \"var myVar = function() { return false; }\" output &&\n-\ttest_i18ngrep \"var myVar = function() { return true; }\" output\n+\ttest_grep \"function myFunction() { return true; }\" output &&\n+\ttest_grep \"function myFunction() { return false; }\" output &&\n+\ttest_grep \"var myVar = function() { return false; }\" output &&\n+\ttest_grep \"var myVar = function() { return true; }\" output\n '\n-test_done\n\\ No newline at end of file\n+\n+test_done\n+\n--\n2.43.2\n\n"},{"id":"490482","messageId":"20240312131448.638472-2-sergiusnyah@gmail.com","threadId":"60710","inReplyTo":"20240312131448.638472-1-sergiusnyah@gmail.com","subject":"[GSOC][PATCH v2 2/3]t4034-diff-words: add javascript language driver","fromName":"Sergius Nyah","fromEmail":"sergiusnyah@gmail.com","sentAt":"2024-03-12T13:14:47Z","receivedAt":"2024-03-12T13:15:00Z","isPatch":true,"sender":{"key":"sergiusnyah@gmail.com","avatar":null},"body":"---\n t/t4034-diff-words.sh | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh\nindex 74586f3813..cf2374af2c 100755\n--- a/t/t4034-diff-words.sh\n+++ b/t/t4034-diff-words.sh\n@@ -328,6 +328,7 @@ test_language_driver dts\n test_language_driver fortran\n test_language_driver html\n test_language_driver java\n+test_language_driver javascript\n test_language_driver kotlin\n test_language_driver matlab\n test_language_driver objc\n--\n2.43.2\n\n"},{"id":"490483","messageId":"20240312131448.638472-3-sergiusnyah@gmail.com","threadId":"60710","inReplyTo":"20240312131448.638472-1-sergiusnyah@gmail.com","subject":"[GSOC][PATCH v2 3/3]userdiff: remove trailing whitespaces, fix multiline comments","fromName":"Sergius Nyah","fromEmail":"sergiusnyah@gmail.com","sentAt":"2024-03-12T13:14:48Z","receivedAt":"2024-03-12T13:15:03Z","isPatch":true,"sender":{"key":"sergiusnyah@gmail.com","avatar":null},"body":"This patch removes trailing whitespaces and fixes multiline comments in the `userdiff.c` file\nto match Gits coding standards as seen in [1].\n\nSigned-off-by: Sergius Nyah <sergiusnyah@gmail.com>\n---\n userdiff.c | 23 ++++++++++++-----------\n 1 file changed, 12 insertions(+), 11 deletions(-)\n\ndiff --git a/userdiff.c b/userdiff.c\nindex bbe2bcb9a3..15342c8662 100644\n--- a/userdiff.c\n+++ b/userdiff.c\n@@ -184,17 +184,18 @@ PATTERNS(\"java\",\n \t \"|[-+*/<>%&^|=!]=\"\n \t \"|--|\\\\+\\\\+|<<=?|>>>?=?|&&|\\\\|\\\\|\"),\n PATTERNS(\"javascript\",\n-      /* Looks for lines that start with optional whitespace, followed\n-      * by 'function'* and any characters (for function declarations),\n-      * or valid JavaScript identifiers, equals sign '=', 'function' keyword\n-      * and any characters (for function expressions).\n-      * Also considers functions defined inside blocks with '{...}'.\n-      */\n-      \"^[ \\t]*(function[ \\t]*.*|[a-zA-Z_$][0-9a-zA-Z_$]*[ \\t]*=[ \\t]*function[ \\t]*.*|(\\\\{[ \\t]*)?)\\n\",\n-      /* This pattern matches JavaScript identifiers */\n-      \"[a-zA-Z_$][0-9a-zA-Z_$]*\"\n-      \"|[-+0-9.eE]+|0[xX][0-9a-fA-F]+\"\n-      \"|[-+*/<>%&^|=!:]=|--|\\\\+\\\\+|<<=?|>>=?|&&|\\\\|\\\\|\"),\n+\t/*\n+\t * Look for lines that start with optional whitespace, followed\n+\t * by 'function' and any characters (for function declarations),\n+\t * or valid JavaScript identifiers, equals sign '=', 'function' keyword\n+\t * and any characters (for function expressions).\n+\t * Also consider functions defined inside blocks with '{...}'.\n+\t */\n+\t \"^[ \\t]*(function[ \\t]*.*|[a-zA-Z_$][0-9a-zA-Z_$]*[ \\t]*=[ \\t]*function[ \\t]*.*|(\\\\{[ \\t]*)?)\\n\",\n+\t /* Match JavaScript identifiers with this pattern */\n+\t \"[a-zA-Z_$][0-9a-zA-Z_$]*\"\n+\t \"|[-+0-9.eE]+|0[xX][0-9a-fA-F]+\"\n+\t \"|[-+*/<>%&^|=!:]=|--|\\\\+\\\\+|<<=?|>>=?|&&|\\\\|\\\\|\"),\n PATTERNS(\"kotlin\",\n \t \"^[ \\t]*(([a-z]+[ \\t]+)*(fun|class|interface)[ \\t]+.*)$\",\n \t /* -- */\n--\n2.43.2\n\n[1]:\nhttps://github.com/git/git/blob/master/Documentation/CodingGuidelines\n"},{"id":"490923","messageId":"20240319101000.76767-1-sergiusnyah@gmail.com","threadId":"60710","inReplyTo":"ZeWOhxBDvyjH8gW7@tanuki","subject":"[GSOC][PATCH v2]userdiff: improve code quality and add JavaScript language driver.","fromName":"Sergius Nyah","fromEmail":"sergiusnyah@gmail.com","sentAt":"2024-03-19T10:10:00Z","receivedAt":"2024-03-19T10:10:26Z","isPatch":true,"sender":{"key":"sergiusnyah@gmail.com","avatar":null},"body":"This commit introduces several improvements to the codebase:\n\n- replace the use of `test_i18ngrep` with `test_grep` in\n`t/t4018-diff-funcname.sh` for better pattern matching and improved\nperformance.\n- add a JavaScript language driver to enhance the functionality of the\napplication.\n- clean up the code by removing trailing whitespaces and fix multiline\ncomments in `t/t4034-diff-words.sh` and `userdiff.c`.\n\nSigned-off-by: Sergius Nyah <sergiusnyah@gmail.com>\n---\n t/t4018-diff-funcname.sh | 14 +++++++-------\n t/t4034-diff-words.sh    |  1 +\n userdiff.c               | 23 ++++++++++++-----------\n 3 files changed, 20 insertions(+), 18 deletions(-)\n\ndiff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh\nindex d35cce18a0..e6d2f1c215 100755\n--- a/t/t4018-diff-funcname.sh\n+++ b/t/t4018-diff-funcname.sh\n@@ -119,8 +119,6 @@ do\n \t\"\n done\n\n-test_done\n-\n test_expect_success 'identify builtin patterns in JavaScript' '\n \t# setup\n \techo \"function myFunction() { return true; }\" > test.js &&\n@@ -136,9 +134,11 @@ test_expect_success 'identify builtin patterns in JavaScript' '\n \tgit diff >output &&\n\n \t# check results\n-\ttest_i18ngrep \"function myFunction() { return true; }\" output &&\n-\ttest_i18ngrep \"function myFunction() { return false; }\" output &&\n-\ttest_i18ngrep \"var myVar = function() { return false; }\" output &&\n-\ttest_i18ngrep \"var myVar = function() { return true; }\" output\n+\ttest_grep \"function myFunction() { return true; }\" output &&\n+\ttest_grep \"function myFunction() { return false; }\" output &&\n+\ttest_grep \"var myVar = function() { return false; }\" output &&\n+\ttest_grep \"var myVar = function() { return true; }\" output\n '\n-test_done\n\\ No newline at end of file\n+\n+test_done\n+\ndiff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh\nindex 74586f3813..cf2374af2c 100755\n--- a/t/t4034-diff-words.sh\n+++ b/t/t4034-diff-words.sh\n@@ -328,6 +328,7 @@ test_language_driver dts\n test_language_driver fortran\n test_language_driver html\n test_language_driver java\n+test_language_driver javascript\n test_language_driver kotlin\n test_language_driver matlab\n test_language_driver objc\ndiff --git a/userdiff.c b/userdiff.c\nindex bbe2bcb9a3..15342c8662 100644\n--- a/userdiff.c\n+++ b/userdiff.c\n\n PATTERNS(\"javascript\",\n-      /* Looks for lines that start with optional whitespace, followed\n-      * by 'function'* and any characters (for function declarations),\n-      * or valid JavaScript identifiers, equals sign '=', 'function' keyword\n-      * and any characters (for function expressions).\n-      * Also considers functions defined inside blocks with '{...}'.\n-      */\n-      \"^[ \\t]*(function[ \\t]*.*|[a-zA-Z_$][0-9a-zA-Z_$]*[ \\t]*=[ \\t]*function[ \\t]*.*|(\\\\{[ \\t]*)?)\\n\",\n-      /* This pattern matches JavaScript identifiers */\n-      \"[a-zA-Z_$][0-9a-zA-Z_$]*\"\n-      \"|[-+0-9.eE]+|0[xX][0-9a-fA-F]+\"\n-      \"|[-+*/<>%&^|=!:]=|--|\\\\+\\\\+|<<=?|>>=?|&&|\\\\|\\\\|\"),\n+\t/*\n+\t * Look for lines that start with optional whitespace, followed\n+\t * by 'function' and any characters (for function declarations),\n+\t * or valid JavaScript identifiers, equals sign '=', 'function' keyword\n+\t * and any characters (for function expressions).\n+\t * Also consider functions defined inside blocks with '{...}'.\n+\t */\n+\t \"^[ \\t]*(function[ \\t]*.*|[a-zA-Z_$][0-9a-zA-Z_$]*[ \\t]*=[ \\t]*function[ \\t]*.*|(\\\\{[ \\t]*)?)\\n\",\n+\t /* Match JavaScript identifiers with this pattern */\n+\t \"[a-zA-Z_$][0-9a-zA-Z_$]*\"\n+\t \"|[-+0-9.eE]+|0[xX][0-9a-fA-F]+\"\n+\t \"|[-+*/<>%&^|=!:]=|--|\\\\+\\\\+|<<=?|>>=?|&&|\\\\|\\\\|\"),\n\n2.43.2\n\n"},{"id":"490961","messageId":"xmqqh6h2lyul.fsf@gitster.g","threadId":"60710","inReplyTo":"20240319101000.76767-1-sergiusnyah@gmail.com","subject":"Re: [GSOC][PATCH v2]userdiff: improve code quality and add JavaScript language driver.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-03-19T21:02:10Z","receivedAt":"2024-03-19T21:02:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sergius Nyah <sergiusnyah@gmail.com> writes:\n\n> This commit introduces several improvements to the codebase:\n>\n> - replace the use of `test_i18ngrep` with `test_grep` in\n> `t/t4018-diff-funcname.sh` for better pattern matching and improved\n> performance.\n> - add a JavaScript language driver to enhance the functionality of the\n> application.\n> - clean up the code by removing trailing whitespaces and fix multiline\n> comments in `t/t4034-diff-words.sh` and `userdiff.c`.\n\nDoing too many unrelated things that may appear semi-related only\nbecause they are about the same files?  Don't.\n\n>\n> Signed-off-by: Sergius Nyah <sergiusnyah@gmail.com>\n> ---\n>  t/t4018-diff-funcname.sh | 14 +++++++-------\n>  t/t4034-diff-words.sh    |  1 +\n>  userdiff.c               | 23 ++++++++++++-----------\n>  3 files changed, 20 insertions(+), 18 deletions(-)\n>\n> diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh\n> index d35cce18a0..e6d2f1c215 100755\n> --- a/t/t4018-diff-funcname.sh\n> +++ b/t/t4018-diff-funcname.sh\n> @@ -119,8 +119,6 @@ do\n>  \t\"\n>  done\n>\n> -test_done\n> -\n>  test_expect_success 'identify builtin patterns in JavaScript' '\n>  \t# setup\n>  \techo \"function myFunction() { return true; }\" > test.js &&\n> @@ -136,9 +134,11 @@ test_expect_success 'identify builtin patterns in JavaScript' '\n>  \tgit diff >output &&\n>\n>  \t# check results\n> -\ttest_i18ngrep \"function myFunction() { return true; }\" output &&\n> -\ttest_i18ngrep \"function myFunction() { return false; }\" output &&\n> -\ttest_i18ngrep \"var myVar = function() { return false; }\" output &&\n> -\ttest_i18ngrep \"var myVar = function() { return true; }\" output\n> +\ttest_grep \"function myFunction() { return true; }\" output &&\n> +\ttest_grep \"function myFunction() { return false; }\" output &&\n> +\ttest_grep \"var myVar = function() { return false; }\" output &&\n> +\ttest_grep \"var myVar = function() { return true; }\" output\n>  '\n> -test_done\n> \\ No newline at end of file\n> +\n> +test_done\n> +\n\nTo which version of Git source code are the above hunks meant to\napply?  Hopefully we do not have a test that says \"test_done\"\nfollowed by another \"test_expect_success\" in our tree.\n\n> diff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh\n> index 74586f3813..cf2374af2c 100755\n> --- a/t/t4034-diff-words.sh\n> +++ b/t/t4034-diff-words.sh\n> @@ -328,6 +328,7 @@ test_language_driver dts\n>  test_language_driver fortran\n>  test_language_driver html\n>  test_language_driver java\n> +test_language_driver javascript\n>  test_language_driver kotlin\n>  test_language_driver matlab\n>  test_language_driver objc\n\nIt is unclear what \"clean-up\" was done to this file, as claimed in\nthe proposed log message.  Puzzled...\n\n> diff --git a/userdiff.c b/userdiff.c\n> index bbe2bcb9a3..15342c8662 100644\n> --- a/userdiff.c\n> +++ b/userdiff.c\n>\n>  PATTERNS(\"javascript\",\n> -      /* Looks for lines that start with optional whitespace, followed\n> -      * by 'function'* and any characters (for function declarations),\n> -      * or valid JavaScript identifiers, equals sign '=', 'function' keyword\n> -      * and any characters (for function expressions).\n> -      * Also considers functions defined inside blocks with '{...}'.\n> -      */\n> -      \"^[ \\t]*(function[ \\t]*.*|[a-zA-Z_$][0-9a-zA-Z_$]*[ \\t]*=[ \\t]*function[ \\t]*.*|(\\\\{[ \\t]*)?)\\n\",\n> -      /* This pattern matches JavaScript identifiers */\n> -      \"[a-zA-Z_$][0-9a-zA-Z_$]*\"\n> -      \"|[-+0-9.eE]+|0[xX][0-9a-fA-F]+\"\n> -      \"|[-+*/<>%&^|=!:]=|--|\\\\+\\\\+|<<=?|>>=?|&&|\\\\|\\\\|\"),\n> +\t/*\n> +\t * Look for lines that start with optional whitespace, followed\n> +\t * by 'function' and any characters (for function declarations),\n> +\t * or valid JavaScript identifiers, equals sign '=', 'function' keyword\n> +\t * and any characters (for function expressions).\n> +\t * Also consider functions defined inside blocks with '{...}'.\n> +\t */\n> +\t \"^[ \\t]*(function[ \\t]*.*|[a-zA-Z_$][0-9a-zA-Z_$]*[ \\t]*=[ \\t]*function[ \\t]*.*|(\\\\{[ \\t]*)?)\\n\",\n> +\t /* Match JavaScript identifiers with this pattern */\n> +\t \"[a-zA-Z_$][0-9a-zA-Z_$]*\"\n> +\t \"|[-+0-9.eE]+|0[xX][0-9a-fA-F]+\"\n> +\t \"|[-+*/<>%&^|=!:]=|--|\\\\+\\\\+|<<=?|>>=?|&&|\\\\|\\\\|\"),\n\nI do not see trailing whitespaces getting fixed, as claimed in the\nproposed log message.  Puzzled, again...\n\n\n"}]}