Skip to contentSkip to conversation

Add more builtin patterns for userdiff, as Mircroproject.

RFC New Sergius Nyah 5 participants 33 messages Jan 9, 2024 – Mar 19, 2024 3 messages not in the archive

lore
Share & tools
lore
#0 lore raw

Hello everyone,
I'm Sergius, a Computer Science undergraduate student, and I want to begin Contributing to the Git project. So far, I've gone through Matheus' tutorial on First steps Contributing to Git, and I found it very helpful. I've also read the Contribution guidelines keenly and built Git from source.

In accordance to the contributor guidelines, I came across this Mircoproject idea from: https://git.github.io/SoC-2022-Microprojects/
which I'm willing to work on. It talked about enhancing Git's "userdiff" feature in "userdiff.c" which is crucial for identifying function names in various programming languages, thereby improving the readability of "git diff" outputs.

From my understanding, the project involves extending the userdiff feature to support additional programming languages that are currently not covered such as Shell, Swift, Go and the others.

Here is a sample of how a language is defined in userdiff.c:

Quoted 10 lines

#define PATTERNS(lang, rx, wrx) { \
.name = lang, \
.binary = -1, \
.funcname = { \
.pattern = rx, \
.cflags = REG_EXTENDED, \
}, \
.word_regex = wrx "|[^[:space:]]|[\xc0-\xff][\x80-\xbf]+", \
.word_regex_multi_byte = wrx "|[^[:space:]]", \
}

In this code, lang is the name of the language, rx is the regular expression for identifying function names, and wrx is the word regex.

Approach: I Identified the Programming Languages that are not currently supported by the userdiff feature by reviewing the existing patterns in userdiff.c and comparing them with some popular programming languages.
For each supported language, I would define a regular expression that could help identify function names in that language. This could include researching each language's syntax and testing their expressions to ensure that they work well.
Also, I'd add a new IPATTERN definition for each language to the "userdiff.c" file, then rebuild Git and test the changes by creating a repo with files in the newly supported languages then run "git diff" to ensure the line @@ ... @@ produces their correct function names. Then submit a patch.

Best Regards!
Sergius.

#1 lore raw

Hi Sergius,

Quoted 7 lines · Sergius Nyah

Hello everyone,
I'm Sergius, a Computer Science undergraduate student, and I want to begin Contributing to the Git project. So far, I've gone through Matheus' tutorial on First steps Contributing to Git, and I found it very helpful. I've also read the Contribution guidelines keenly and built Git from source.

Thanks for your interest in contributing to Git!

Quoted 2 lines

In accordance to the contributor guidelines, I came across this Mircoproject idea from: https://git.github.io/SoC-2022-Microprojects/

s/Mircoproject/microproject/

There is a similar typo in the subject of your email too.

Quoted 8 lines

which I'm willing to work on. It talked about enhancing Git's "userdiff" feature in "userdiff.c" which is crucial for identifying function names in various programming languages, thereby improving the readability of "git diff" outputs.

From my understanding, the project involves extending the userdiff feature to support additional programming languages that are currently not covered such as Shell, Swift, Go and the others.

As far as I can see in userdiff.c, Golang and Bash seem to be supported.

Quoted 17 lines

Here is a sample of how a language is defined in userdiff.c:

Quoted 10 lines

#define PATTERNS(lang, rx, wrx) { \
.name = lang, \
.binary = -1, \
.funcname = { \
.pattern = rx, \
.cflags = REG_EXTENDED, \
}, \
.word_regex = wrx "|[^[:space:]]|[\xc0-\xff][\x80-\xbf]+", \
.word_regex_multi_byte = wrx "|[^[:space:]]", \
}

In this code, lang is the name of the language, rx is the regular expression for identifying function names, and wrx is the word regex.

Quoted 8 lines

Approach: I Identified the Programming Languages that are not currently supported by the userdiff feature by reviewing the existing patterns in userdiff.c and comparing them with some popular programming languages.
For each supported language, I would define a regular expression that could help identify function names in that language. This could include researching each language's syntax and testing their expressions to ensure that they work well.

In your microproject, you only need to add support for ONE language that is not supported yet. Please don't try to do more than that.

Quoted 5 lines

Also, I'd add a new IPATTERN definition for each language to the "userdiff.c" file, then rebuild Git and test the changes by creating a repo with files in the newly supported languages then run "git diff" to ensure the line @@ ... @@ produces their correct function names. Then submit a patch.

Except for my comments above, this looks like a good plan. Thanks.

A message that is not in the archive (sent off-list or not yet received): CANAnif90Bqp2pWCn_71t-Fss6wspo+==vMdYsX+Wt5m=4Ocpng@mail.gmail.com

A message that is not in the archive (sent off-list or not yet received): CAP8UFD0ELy2WegVYdxi_O5UpHS4MyOPp4tuAQK+XvvNmABc2ZA@mail.gmail.com

A message that is not in the archive (sent off-list or not yet received): CAP8UFD3e=Zv2wkx5tswCz05Vwn3vD68Vw-TD6SoENWK+norYsw@mail.gmail.com

#5 lore raw

---------- Forwarded message ---------
From: Christian Couder <[email protected]>
Date: Thu, Jan 11, 2024 at 11:51 AM
Subject: Re: [GSOC][RFC] Add more builtin patterns for userdiff, as Mircroproject.
To: Sergius Nyah <[email protected]>

Quoted 6 lines · Christian Couder
Quoted 2 lines · Sergius Nyah
Quoted 2 lines

Okay then. I will add support for shell, as it was primarily suggested in the idea itself.

Quoted 6 lines

As Bash is a shell and is already supported, I am not sure which kind of shell you want to support. There are other shells or kinds of shell with different syntax that might be worth supporting, but then you might want to tell us which shell or which new kind of shell.

Thanks!

I've definitely learned one more thing. Thank you!
Also, after taking another keen look at the Patterns defined in userdiff.c, In accordance with what you've said, I realized that Kotlin isn't supported yet.
So, I'd begin working on it.
Thanks!

By the way I realized that you replied privately to me instead of keeping the mailing list in Cc: This made me reply privately to you.

Thank you for the correction Christian. Noted!

I think it would be better if the discussions were all public as this way others could give you their opinion on this.

Definitely True.

#6 lore raw
Quoted 22 lines · Sergius Nyah

---------- Forwarded message ---------
From: Christian Couder <[email protected]>
Date: Thu, Jan 11, 2024 at 11:51 AM
Subject: Re: [GSOC][RFC] Add more builtin patterns for userdiff, as Mircroproject.
To: Sergius Nyah <[email protected]>

Quoted 11 lines · Christian Couder
Quoted 2 lines · Sergius Nyah
Quoted 2 lines

Okay then. I will add support for shell, as it was primarily suggested in the idea itself.

As Bash is a shell and is already supported, I am not sure which kind of shell you want to support. There are other shells or kinds of shell with different syntax that might be worth supporting, but then you might want to tell us which shell or which new kind of shell.

Quoted 6 lines
Quoted 1 line

Thanks!

I've definitely learned one more thing. Thank you!
Also, after taking another keen look at the Patterns defined in userdiff.c, In accordance with what you've said, I realized that Kotlin isn't supported yet.

It is actually already supported too:

$ grep -i -n kotlin userdiff.c
186:PATTERNS("kotlin",

To help you a bit, you can get the list of already supported languages using:

$ perl -ne 'print "$1\n" if m/PATTERNS\(\"(\w+)\"/ or
m/IPATTERN\(\"(\w+)\"/' <userdiff.c
ada
bash
bibtex
cpp
csharp
css
dts
elixir
fortran
fountain
golang
html
java
kotlin
markdown
matlab
objc
pascal
perl
php
python
ruby
rust
scheme
tex
#7 lore raw
Quoted 33 lines · Christian Couder
Quoted 22 lines · Sergius Nyah

---------- Forwarded message ---------
From: Christian Couder <[email protected]>
Date: Thu, Jan 11, 2024 at 11:51 AM
Subject: Re: [GSOC][RFC] Add more builtin patterns for userdiff, as Mircroproject.
To: Sergius Nyah <[email protected]>

Quoted 11 lines · Christian Couder
Quoted 2 lines · Sergius Nyah
Quoted 2 lines

Okay then. I will add support for shell, as it was primarily suggested in the idea itself.

As Bash is a shell and is already supported, I am not sure which kind of shell you want to support. There are other shells or kinds of shell with different syntax that might be worth supporting, but then you might want to tell us which shell or which new kind of shell.

Quoted 6 lines
Quoted 1 line

Thanks!

I've definitely learned one more thing. Thank you!
Also, after taking another keen look at the Patterns defined in userdiff.c, In accordance with what you've said, I realized that Kotlin isn't supported yet.

It is actually already supported too:

Quoted 7 lines
$ grep -i -n kotlin userdiff.c
186:PATTERNS("kotlin",

To help you a bit, you can get the list of already supported languages using:

$ perl -ne 'print "$1\n" if m/PATTERNS\(\"(\w+)\"/ or
m/IPATTERN\(\"(\w+)\"/' <userdiff.c

Thank you for these. $ perl -ne 'print "$1\n" if
m/IPATTERN\(\"(\w+)\"/' userdiff.c works too.

Quoted 17 lines

ada
bash
bibtex
cpp
csharp
css
dts
elixir
fortran
fountain
golang
html
java
kotlin
markdown
matlab
objc

Quoted 8 lines

pascal
perl
php
python
ruby
rust
scheme
tex

Great! JavaScript, despite its widespread use, isn't implemented, so I will take it.
Thank you!

#8 lore raw

cover Add builtin patterns for userdiff in JavaScript, as Microproject.

Firstly, I'm so sorry for the delay between selecting the Microproject and sending the patch series. Learning about regular expressions took me a bit longer than I expected, but it was all worth it. I'm very grateful for the opportunity to work on this project and I'm looking forward to contributing more to Git.

This patch series adds builtin patterns for JavaScript function detection in userdiff, as
my Microproject for GSOC. The first patch adds a regular expression for detecting JavaScript functions in Git diffs while the second adds a test for JavaScript function detection in Git diffs. This new pattern looks for lines that start with optional whitespace, followed by 'function' and any characters (for function declarations), or valid JavaScript identifiers, equals sign '=', 'function' keyword and any characters (for function expressions). It also considers functions defined inside blocks with '{...}'.

 t/t4018-diff-funcname.sh | 25 +++++++++++++++++++++++--
 userdiff.c               | 17 +++++++++++++++--
 2 files changed, 38 insertions(+), 4 deletions(-)

base-commit: c5b454771e6b086f60c7f1f139025f174bcedac9

Signature · 5 lines
2.43.2

I would greatly appreciate any feedback on the patch series.
Best, 
Sergius.
#9 lore raw

PATCH 1/2 Subject: [GSOC][RFC PATCH 1/2] Add builtin patterns for JavaScript function detection in userdiff.

From: Sergius Justus Chesami Nyah <[email protected]>

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.

---
 userdiff.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
userdiff.c +15 -2
index e399543823..12e31ff14d 100644
@@ -1,7 +1,7 @@
 #include "git-compat-util.h"
 #include "config.h"
 #include "userdiff.h"
-#include "attr.h"
+#include "attr.h" 
 #include "strbuf.h"
 
 static struct userdiff_driver *drivers;
@@ -183,6 +183,19 @@ PATTERNS("java",
 	 "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?"
 	 "|[-+*/<>%&^|=!]="
 	 "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"),
+PATTERNS("javascript",
+     /* 
+	  * Looks for lines that start with optional whitespace, followed 
+	  * by 'function'* and any characters (for function declarations), 
+      * or valid JavaScript identifiers, equals sign '=', 'function' keyword
+	  * and any characters (for function expressions).
+      * Also considers functions defined inside blocks with '{...}'.
+	  */ 
+	 "^[ \t]*(function[ \t]*.*|[a-zA-Z_$][0-9a-zA-Z_$]*[ \t]*=[ \t]*function[ \t]*.*|(\\{[ \t]*)?)\n",
+     /* This pattern matches JavaScript identifiers */
+     "[a-zA-Z_$][0-9a-zA-Z_$]*"
+     "|[-+0-9.eE]+|0[xX][0-9a-fA-F]+" 
+     "|[-+*/<>%&^|=!:]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\|"), 
 PATTERNS("kotlin",
 	 "^[ \t]*(([a-z]+[ \t]+)*(fun|class|interface)[ \t]+.*)$",
 	 /* -- */
@@ -192,7 +205,7 @@ PATTERNS("kotlin",
 	 /* integers and floats */
 	 "|[0-9][0-9_]*([.][0-9_]*)?([Ee][-+]?[0-9]+)?[fFlLuU]*"
 	 /* floating point numbers beginning with decimal point */
-	 "|[.][0-9][0-9_]*([Ee][-+]?[0-9]+)?[fFlLuU]?"
+	 "|[.][0-9][0-9_]*([Ee][-+]?[0-9]+ )?[fFlLuU]?"
 	 /* unary and binary operators */
 	 "|[-+*/<>%&^|=!]==?|--|\\+\\+|<<=|>>=|&&|\\|\\||->|\\.\\*|!!|[?:.][.:]"),
 PATTERNS("markdown",
Signature · 1 line
2.43.2
#10 lore raw

PATCH 2/2 Subject:[GSOC] [RFC PATCH 2/2] Add test for JavaScript function detection in Git diffs

In reply to Sergius Nyah

From: Sergius Justus Chesami Nyah <[email protected]>

This 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.

---
 t/t4018-diff-funcname.sh | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)
t/t4018-diff-funcname.sh +23 -2
index e026fac1f4..e88e63bd1f 100755
@@ -11,7 +11,7 @@ test_expect_success 'setup' '
 	# a non-trivial custom pattern
 	git config diff.custom1.funcname "!static
 !String
-[^ 	].*s.*" &&
+[^ 	].*s.*" && 
 
 	# a custom pattern which matches to end of line
 	git config diff.custom2.funcname "......Beer\$" &&
@@ -119,4 +119,25 @@ do
 	"
 done
 
-test_done
+test_expect_success 'identify builtin patterns in Javascript' '
+    # setup
+    echo "function myFunction() { return true; }" > test.js &&
+    echo "var myVar = function() { return false; }" >> test.js &&
+    git add test.js &&
+    git commit -m "add test.js" &&
+
+    # modify the file
+    echo "function myFunction() { return false; }" > test.js &&
+    echo "var myVar = function() { return true; }" >> test.js &&
+
+    # command under test
+    git diff >output &&
+
+    # check results
+    test_i18ngrep "function myFunction() { return true; }" output &&
+    test_i18ngrep "function myFunction() { return false; }" output &&
+    test_i18ngrep "var myVar = function() { return false; }" output &&
+    test_i18ngrep "var myVar = function() { return true; }" output
+'
+
+test_done 
\ No newline at end of file
Signature · 1 line
2.43.2
#11 lore raw

cover Add builtin patterns for userdiff in JavaScript, as Microproject.

In reply to Sergius Nyah

Firstly, I'm so sorry for the delay between selecting the Microproject and sending the patch series. Learning about regular expressions took me a bit longer than I expected, but it was all worth it. I'm very grateful for the opportunity to work on this project and I'm looking forward to contributing more to Git.

This patch series adds builtin patterns for JavaScript function detection in userdiff, as
my Microproject for GSOC. The first patch adds a regular expression for detecting JavaScript functions in Git diffs while the second adds a test for JavaScript function detection in Git diffs. This new pattern looks for lines that start with optional whitespace, followed by 'function' and any characters (for function declarations), or valid JavaScript identifiers, equals sign '=', 'function' keyword and any characters (for function expressions). It also considers functions defined inside blocks with '{...}'.

 t/t4018-diff-funcname.sh | 25 +++++++++++++++++++++++--
 userdiff.c               | 17 +++++++++++++++--
 2 files changed, 38 insertions(+), 4 deletions(-)

base-commit: c5b454771e6b086f60c7f1f139025f174bcedac9

Signature · 5 lines
2.43.2

I would greatly appreciate any feedback on the patch series.
Best, 
Sergius.
#12 lore raw

PATCH 1/2 Subject: [GSOC][RFC PATCH 1/2] Add builtin patterns for JavaScript function detection in userdiff.

From: Sergius Justus Chesami Nyah <[email protected]>

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.

---
 userdiff.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
userdiff.c +15 -2
index e399543823..12e31ff14d 100644
@@ -1,7 +1,7 @@
 #include "git-compat-util.h"
 #include "config.h"
 #include "userdiff.h"
-#include "attr.h"
+#include "attr.h" 
 #include "strbuf.h"
 
 static struct userdiff_driver *drivers;
@@ -183,6 +183,19 @@ PATTERNS("java",
 	 "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?"
 	 "|[-+*/<>%&^|=!]="
 	 "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"),
+PATTERNS("javascript",
+     /* 
+	  * Looks for lines that start with optional whitespace, followed 
+	  * by 'function'* and any characters (for function declarations), 
+      * or valid JavaScript identifiers, equals sign '=', 'function' keyword
+	  * and any characters (for function expressions).
+      * Also considers functions defined inside blocks with '{...}'.
+	  */ 
+	 "^[ \t]*(function[ \t]*.*|[a-zA-Z_$][0-9a-zA-Z_$]*[ \t]*=[ \t]*function[ \t]*.*|(\\{[ \t]*)?)\n",
+     /* This pattern matches JavaScript identifiers */
+     "[a-zA-Z_$][0-9a-zA-Z_$]*"
+     "|[-+0-9.eE]+|0[xX][0-9a-fA-F]+" 
+     "|[-+*/<>%&^|=!:]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\|"), 
 PATTERNS("kotlin",
 	 "^[ \t]*(([a-z]+[ \t]+)*(fun|class|interface)[ \t]+.*)$",
 	 /* -- */
@@ -192,7 +205,7 @@ PATTERNS("kotlin",
 	 /* integers and floats */
 	 "|[0-9][0-9_]*([.][0-9_]*)?([Ee][-+]?[0-9]+)?[fFlLuU]*"
 	 /* floating point numbers beginning with decimal point */
-	 "|[.][0-9][0-9_]*([Ee][-+]?[0-9]+)?[fFlLuU]?"
+	 "|[.][0-9][0-9_]*([Ee][-+]?[0-9]+ )?[fFlLuU]?"
 	 /* unary and binary operators */
 	 "|[-+*/<>%&^|=!]==?|--|\\+\\+|<<=|>>=|&&|\\|\\||->|\\.\\*|!!|[?:.][.:]"),
 PATTERNS("markdown",
Signature · 1 line
2.43.2
#13 lore raw

PATCH 2/2 Subject:[GSOC] [RFC PATCH 2/2] Add test for JavaScript function detection in Git diffs

In reply to Sergius Nyah

From: Sergius Justus Chesami Nyah <[email protected]>

This 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.

---
 t/t4018-diff-funcname.sh | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)
t/t4018-diff-funcname.sh +23 -2
index e026fac1f4..e88e63bd1f 100755
@@ -11,7 +11,7 @@ test_expect_success 'setup' '
 	# a non-trivial custom pattern
 	git config diff.custom1.funcname "!static
 !String
-[^ 	].*s.*" &&
+[^ 	].*s.*" && 
 
 	# a custom pattern which matches to end of line
 	git config diff.custom2.funcname "......Beer\$" &&
@@ -119,4 +119,25 @@ do
 	"
 done
 
-test_done
+test_expect_success 'identify builtin patterns in Javascript' '
+    # setup
+    echo "function myFunction() { return true; }" > test.js &&
+    echo "var myVar = function() { return false; }" >> test.js &&
+    git add test.js &&
+    git commit -m "add test.js" &&
+
+    # modify the file
+    echo "function myFunction() { return false; }" > test.js &&
+    echo "var myVar = function() { return true; }" >> test.js &&
+
+    # command under test
+    git diff >output &&
+
+    # check results
+    test_i18ngrep "function myFunction() { return true; }" output &&
+    test_i18ngrep "function myFunction() { return false; }" output &&
+    test_i18ngrep "var myVar = function() { return false; }" output &&
+    test_i18ngrep "var myVar = function() { return true; }" output
+'
+
+test_done 
\ No newline at end of file
Signature · 1 line
2.43.2
#14 lore raw

cover Add builtin patterns for userdiff in JavaScript, as Microproject.

In reply to Sergius Nyah

From: Sergius Nyah <[email protected]>

Firstly, I'm so sorry for the delay between selecting the Microproject and sending the patch series. Learning about regular expressions took me a bit longer than I expected, but it was all worth it. I'm very grateful for the opportunity to work on this project and I'm looking forward to contributing more to Git.

This patch series adds builtin patterns for JavaScript function detection in userdiff, as
my Microproject for GSOC. The first patch adds a regular expression for detecting JavaScript functions in Git diffs while the second adds a test for JavaScript function detection in Git diffs. This new pattern looks for lines that start with optional whitespace, followed by 'function' and any characters (for function declarations), or valid JavaScript identifiers, equals sign '=', 'function' keyword and any characters (for function expressions). It also considers functions defined inside blocks with '{...}'.

 t/t4018-diff-funcname.sh | 25 +++++++++++++++++++++++--
 userdiff.c               | 17 +++++++++++++++--
 2 files changed, 38 insertions(+), 4 deletions(-)

base-commit: c5b454771e6b086f60c7f1f139025f174bcedac9

Signature · 5 lines
2.43.2

I would greatly appreciate any feedback on the patch series.
Best, 
Sergius.
#15 lore raw

PATCH 1/2 Subject: [GSOC][RFC PATCH 1/2] Add builtin patterns for JavaScript function detection in userdiff.

From: Sergius Justus Chesami Nyah <[email protected]>

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.

---
 userdiff.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
userdiff.c +15 -2
index e399543823..12e31ff14d 100644
@@ -1,7 +1,7 @@
 #include "git-compat-util.h"
 #include "config.h"
 #include "userdiff.h"
-#include "attr.h"
+#include "attr.h" 
 #include "strbuf.h"
 
 static struct userdiff_driver *drivers;
@@ -183,6 +183,19 @@ PATTERNS("java",
 	 "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?"
 	 "|[-+*/<>%&^|=!]="
 	 "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"),
+PATTERNS("javascript",
+     /* 
+	  * Looks for lines that start with optional whitespace, followed 
+	  * by 'function'* and any characters (for function declarations), 
+      * or valid JavaScript identifiers, equals sign '=', 'function' keyword
+	  * and any characters (for function expressions).
+      * Also considers functions defined inside blocks with '{...}'.
+	  */ 
+	 "^[ \t]*(function[ \t]*.*|[a-zA-Z_$][0-9a-zA-Z_$]*[ \t]*=[ \t]*function[ \t]*.*|(\\{[ \t]*)?)\n",
+     /* This pattern matches JavaScript identifiers */
+     "[a-zA-Z_$][0-9a-zA-Z_$]*"
+     "|[-+0-9.eE]+|0[xX][0-9a-fA-F]+" 
+     "|[-+*/<>%&^|=!:]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\|"), 
 PATTERNS("kotlin",
 	 "^[ \t]*(([a-z]+[ \t]+)*(fun|class|interface)[ \t]+.*)$",
 	 /* -- */
@@ -192,7 +205,7 @@ PATTERNS("kotlin",
 	 /* integers and floats */
 	 "|[0-9][0-9_]*([.][0-9_]*)?([Ee][-+]?[0-9]+)?[fFlLuU]*"
 	 /* floating point numbers beginning with decimal point */
-	 "|[.][0-9][0-9_]*([Ee][-+]?[0-9]+)?[fFlLuU]?"
+	 "|[.][0-9][0-9_]*([Ee][-+]?[0-9]+ )?[fFlLuU]?"
 	 /* unary and binary operators */
 	 "|[-+*/<>%&^|=!]==?|--|\\+\\+|<<=|>>=|&&|\\|\\||->|\\.\\*|!!|[?:.][.:]"),
 PATTERNS("markdown",
Signature · 1 line
2.43.2
#16 lore raw

PATCH 2/2 Subject:[GSOC] [RFC PATCH 2/2] Add test for JavaScript function detection in Git diffs

In reply to Sergius Nyah

From: Sergius Justus Chesami Nyah <[email protected]>

This 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.

---
 t/t4018-diff-funcname.sh | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)
t/t4018-diff-funcname.sh +23 -2
index e026fac1f4..e88e63bd1f 100755
@@ -11,7 +11,7 @@ test_expect_success 'setup' '
 	# a non-trivial custom pattern
 	git config diff.custom1.funcname "!static
 !String
-[^ 	].*s.*" &&
+[^ 	].*s.*" && 
 
 	# a custom pattern which matches to end of line
 	git config diff.custom2.funcname "......Beer\$" &&
@@ -119,4 +119,25 @@ do
 	"
 done
 
-test_done
+test_expect_success 'identify builtin patterns in Javascript' '
+    # setup
+    echo "function myFunction() { return true; }" > test.js &&
+    echo "var myVar = function() { return false; }" >> test.js &&
+    git add test.js &&
+    git commit -m "add test.js" &&
+
+    # modify the file
+    echo "function myFunction() { return false; }" > test.js &&
+    echo "var myVar = function() { return true; }" >> test.js &&
+
+    # command under test
+    git diff >output &&
+
+    # check results
+    test_i18ngrep "function myFunction() { return true; }" output &&
+    test_i18ngrep "function myFunction() { return false; }" output &&
+    test_i18ngrep "var myVar = function() { return false; }" output &&
+    test_i18ngrep "var myVar = function() { return true; }" output
+'
+
+test_done 
\ No newline at end of file
Signature · 1 line
2.43.2
#17 lore raw

cover Add builtin patterns for userdiff in JavaScript, as Microproject.

In reply to Sergius Nyah

I would like to apologize for the numerous irrelevant emails that have been sent to this mailing list recently. They were the result of a configuration issue with my setup, which caused my patches to be sent from a noreply GitHub address. This led to a series of failed delivery attempts and unnecessary emails.

Firstly, I'm so sorry for the delay between selecting the Microproject and sending the patch series. Learning about regular expressions took me a bit longer than I expected, but it was all worth it. I'm very grateful for the opportunity to work on this project and I'm looking forward to contributing more to Git.

This patch series adds builtin patterns for JavaScript function detection in userdiff, as
my Microproject for GSOC. The first patch adds a regular expression for detecting JavaScript functions in Git diffs while the second adds a test for JavaScript function detection in Git diffs. This new pattern looks for lines that start with optional whitespace, followed by 'function' and any characters (for function declarations), or valid JavaScript identifiers, equals sign '=', 'function' keyword and any characters (for function expressions). It also considers functions defined inside blocks with '{...}'.

 t/t4018-diff-funcname.sh | 25 +++++++++++++++++++++++--
 userdiff.c               | 17 +++++++++++++++--
 2 files changed, 38 insertions(+), 4 deletions(-)

base-commit: c5b454771e6b086f60c7f1f139025f174bcedac9

Signature · 5 lines
2.43.2

I would greatly appreciate any feedback on the patch series.
Best, 
Sergius.
#18 lore raw

PATCH 1/2 Subject: [GSOC][RFC PATCH 1/2] Add builtin patterns for JavaScript function detection in userdiff.

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.

---
 userdiff.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
userdiff.c +15 -2
index e399543823..12e31ff14d 100644
@@ -1,7 +1,7 @@
 #include "git-compat-util.h"
 #include "config.h"
 #include "userdiff.h"
-#include "attr.h"
+#include "attr.h" 
 #include "strbuf.h"
 
 static struct userdiff_driver *drivers;
@@ -183,6 +183,19 @@ PATTERNS("java",
 	 "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?"
 	 "|[-+*/<>%&^|=!]="
 	 "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"),
+PATTERNS("javascript",
+     /* 
+	  * Looks for lines that start with optional whitespace, followed 
+	  * by 'function'* and any characters (for function declarations), 
+      * or valid JavaScript identifiers, equals sign '=', 'function' keyword
+	  * and any characters (for function expressions).
+      * Also considers functions defined inside blocks with '{...}'.
+	  */ 
+	 "^[ \t]*(function[ \t]*.*|[a-zA-Z_$][0-9a-zA-Z_$]*[ \t]*=[ \t]*function[ \t]*.*|(\\{[ \t]*)?)\n",
+     /* This pattern matches JavaScript identifiers */
+     "[a-zA-Z_$][0-9a-zA-Z_$]*"
+     "|[-+0-9.eE]+|0[xX][0-9a-fA-F]+" 
+     "|[-+*/<>%&^|=!:]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\|"), 
 PATTERNS("kotlin",
 	 "^[ \t]*(([a-z]+[ \t]+)*(fun|class|interface)[ \t]+.*)$",
 	 /* -- */
@@ -192,7 +205,7 @@ PATTERNS("kotlin",
 	 /* integers and floats */
 	 "|[0-9][0-9_]*([.][0-9_]*)?([Ee][-+]?[0-9]+)?[fFlLuU]*"
 	 /* floating point numbers beginning with decimal point */
-	 "|[.][0-9][0-9_]*([Ee][-+]?[0-9]+)?[fFlLuU]?"
+	 "|[.][0-9][0-9_]*([Ee][-+]?[0-9]+ )?[fFlLuU]?"
 	 /* unary and binary operators */
 	 "|[-+*/<>%&^|=!]==?|--|\\+\\+|<<=|>>=|&&|\\|\\||->|\\.\\*|!!|[?:.][.:]"),
 PATTERNS("markdown",
Signature · 2 lines
2.43.2
:wq
#19 lore raw

Re: [PATCH 1/2] Subject: [GSOC][RFC PATCH 1/2] Add builtin patterns for JavaScript function detection in userdiff.

Quoted 1 line · Sergius Nyah

[PATCH 1/2] Subject: [GSOC][RFC PATCH 1/2] Add builtin patterns for JavaScript function detection in userdiff.

I think these prefixes somehow got added twice. In any case, this makes it so that "Subject: [GSOC][RFC PATCH 1/2]" is part of the commit log, which shoud not be. And the subject can be better written as:

userdiff: add builtin patterns for Javascript

Quoted 1 line

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.

commit message should be wrapped at 72 characters.

Quoted 9 lines
---
 userdiff.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
userdiff.c +0 -0
index e399543823..12e31ff14d 100644

userdiff.c line 4

Quoted 5 lines
userdiff.c +1 -1
@@ -1,7 +1,7 @@
 #include "git-compat-util.h"
 #include "config.h"
 #include "userdiff.h"
-#include "attr.h"
+#include "attr.h" 

This change adds trailing whitespace which is not desired.

Quoted 10 lines
userdiff.c +3 -0
 #include "strbuf.h"
 
 static struct userdiff_driver *drivers;
@@ -183,6 +183,19 @@ PATTERNS("java",
 	 "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?"
 	 "|[-+*/<>%&^|=!]="
 	 "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"),
+PATTERNS("javascript",
+     /* 
+	  * Looks for lines that start with optional whitespace, followed 

userdiff.c PATTERNS("java", · line 198

Quoted 10 lines
userdiff.c +10 -0
+	  * by 'function'* and any characters (for function declarations), 
+      * or valid JavaScript identifiers, equals sign '=', 'function' keyword
+	  * and any characters (for function expressions).
+      * Also considers functions defined inside blocks with '{...}'.
+	  */ 
+	 "^[ \t]*(function[ \t]*.*|[a-zA-Z_$][0-9a-zA-Z_$]*[ \t]*=[ \t]*function[ \t]*.*|(\\{[ \t]*)?)\n",
+     /* This pattern matches JavaScript identifiers */
+     "[a-zA-Z_$][0-9a-zA-Z_$]*"
+     "|[-+0-9.eE]+|0[xX][0-9a-fA-F]+" 
+     "|[-+*/<>%&^|=!:]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\|"), 

Majority of the lines above (including comment) have trailing whitespace. Consider removing them. Also, tabs should be used for indentation instead of spaces. (cf. Documentation/CodingGuidelines)

userdiff.c PATTERNS("kotlin", · line 208

Quoted 9 lines
userdiff.c +1 -1
 PATTERNS("kotlin",
 	 "^[ \t]*(([a-z]+[ \t]+)*(fun|class|interface)[ \t]+.*)$",
 	 /* -- */
@@ -192,7 +205,7 @@ PATTERNS("kotlin",
 	 /* integers and floats */
 	 "|[0-9][0-9_]*([.][0-9_]*)?([Ee][-+]?[0-9]+)?[fFlLuU]*"
 	 /* floating point numbers beginning with decimal point */
-	 "|[.][0-9][0-9_]*([Ee][-+]?[0-9]+)?[fFlLuU]?"
+	 "|[.][0-9][0-9_]*([Ee][-+]?[0-9]+ )?[fFlLuU]?"

This adds extra whitespace in the middle. Changes not related to the patch topic should be avoided.

Also this was attempted before, see [1]. I think you can take some inspiration and inputs from that also. Aside from that I think the separate patch which adds tests for this can be squashed into this one.

[1]:
https://lore.kernel.org/git/[email protected]/

Thanks.

#20 lore raw

Re: [PATCH 1/2] Subject: [GSOC][RFC PATCH 1/2] Add builtin patterns for JavaScript function detection in userdiff.

Quoted 10 lines · Ghanshyam Thakkar
Quoted 1 line · Sergius Nyah

[PATCH 1/2] Subject: [GSOC][RFC PATCH 1/2] Add builtin patterns for JavaScript function detection in userdiff.

I think these prefixes somehow got added twice. In any case, this makes it so that "Subject: [GSOC][RFC PATCH 1/2]" is part of the commit log, which shoud not be. And the subject can be better written as:

userdiff: add builtin patterns for Javascript

Noted, thanks!

Quoted 4 lines
Quoted 1 line

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.

commit message should be wrapped at 72 characters.

Quoted 1 line

---

Thank you for the correction.

Quoted 16 lines

userdiff.c line 4

Quoted 13 lines
 userdiff.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
userdiff.c +1 -1
index e399543823..12e31ff14d 100644
@@ -1,7 +1,7 @@
 #include "git-compat-util.h"
 #include "config.h"
 #include "userdiff.h"
-#include "attr.h"
+#include "attr.h"

This change adds trailing whitespace which is not desired.

Okay. Would avoid them in subsequent commits.

Quoted 16 lines
Quoted 16 lines
userdiff.c +9 -0
 #include "strbuf.h"
 
 static struct userdiff_driver *drivers;
@@ -183,6 +183,19 @@ PATTERNS("java",
       "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?"
       "|[-+*/<>%&^|=!]="
       "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"),
+PATTERNS("javascript",
+     /*
+       * Looks for lines that start with optional whitespace, followed
+       * by 'function'* and any characters (for function declarations),
+      * or valid JavaScript identifiers, equals sign '=', 'function' keyword
+       * and any characters (for function expressions).
+      * Also considers functions defined inside blocks with '{...}'.
+       */
+      "^[ \t]*(function[ \t]*.*|[a-zA-Z_$][0-9a-zA-Z_$]*[ \t]*=[ \t]*function[ \t]*.*|(\\{[ \t]*)?)\n",
Quoted 8 lines

userdiff.c PATTERNS("java", · line 198

Quoted 4 lines
userdiff.c +4 -0
+     /* This pattern matches JavaScript identifiers */
+     "[a-zA-Z_$][0-9a-zA-Z_$]*"
+     "|[-+0-9.eE]+|0[xX][0-9a-fA-F]+"
+     "|[-+*/<>%&^|=!:]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\|"),

Majority of the lines above (including comment) have trailing whitespace. Consider removing them. Also, tabs should be used for indentation instead of spaces. (cf. Documentation/CodingGuidelines)

Well received. Thanks!

Quoted 13 lines

userdiff.c PATTERNS("kotlin", · line 208

Quoted 10 lines
userdiff.c +1 -1
 PATTERNS("kotlin",
       "^[ \t]*(([a-z]+[ \t]+)*(fun|class|interface)[ \t]+.*)$",
       /* -- */
@@ -192,7 +205,7 @@ PATTERNS("kotlin",
       /* integers and floats */
       "|[0-9][0-9_]*([.][0-9_]*)?([Ee][-+]?[0-9]+)?[fFlLuU]*"
       /* floating point numbers beginning with decimal point */
-      "|[.][0-9][0-9_]*([Ee][-+]?[0-9]+)?[fFlLuU]?"
+      "|[.][0-9][0-9_]*([Ee][-+]?[0-9]+ )?[fFlLuU]?"

This adds extra whitespace in the middle. Changes not related to the patch topic should be avoided.

Sorry about that, I just touched what I shouldn't have.

Quoted 10 lines

Also this was attempted before, see [1]. I think you can take some inspiration and inputs from that also. Aside from that I think the separate patch which adds tests for this can be squashed into this one.

[1]:
https://lore.kernel.org/git/[email protected]/

Thanks.

Thank you for all the corrections. I'd submit a patch series with the correct practices.

#21 lore raw

PATCH 2/2 Subject:[GSOC] [RFC PATCH 2/2] Add test for JavaScript function detection in Git diffs

In reply to Sergius Nyah

From: Sergius Justus Chesami Nyah <[email protected]>

This 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.

---
 t/t4018-diff-funcname.sh | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)
t/t4018-diff-funcname.sh +23 -2
index e026fac1f4..e88e63bd1f 100755
@@ -11,7 +11,7 @@ test_expect_success 'setup' '
 	# a non-trivial custom pattern
 	git config diff.custom1.funcname "!static
 !String
-[^ 	].*s.*" &&
+[^ 	].*s.*" && 
 
 	# a custom pattern which matches to end of line
 	git config diff.custom2.funcname "......Beer\$" &&
@@ -119,4 +119,25 @@ do
 	"
 done
 
-test_done
+test_expect_success 'identify builtin patterns in Javascript' '
+    # setup
+    echo "function myFunction() { return true; }" > test.js &&
+    echo "var myVar = function() { return false; }" >> test.js &&
+    git add test.js &&
+    git commit -m "add test.js" &&
+
+    # modify the file
+    echo "function myFunction() { return false; }" > test.js &&
+    echo "var myVar = function() { return true; }" >> test.js &&
+
+    # command under test
+    git diff >output &&
+
+    # check results
+    test_i18ngrep "function myFunction() { return true; }" output &&
+    test_i18ngrep "function myFunction() { return false; }" output &&
+    test_i18ngrep "var myVar = function() { return false; }" output &&
+    test_i18ngrep "var myVar = function() { return true; }" output
+'
+
+test_done 
\ No newline at end of file
Signature · 1 line
2.43.2
#22 lore raw

PATCH 1/1 Userdiff: add builtin patterns for JavaScript.

In reply to Sergius Nyah

This commit introduces builtin patterns for JavaScript in userdiff and adds a new test case in t4018-diff-funcname.sh to verify the enhanced JavaScript function detection in Git diffs.

---
...-PATCH-1-2-Add-builtin-patterns-for-.patch | 53 ++++++-------------
t/t4018-diff-funcname.sh | 25 ++++++++-

2 files changed, 38 insertions(+), 40 deletions(-)
Pattern/0001-Subject-GSOC-RFC-PATCH-1-2-Add-builtin-patterns-for-.patch +0 -0
index 43593866bc..9c3b80665e 100644

-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.
----
+This patch adds the regular expression for detecting JavaScript functions and expressions in Git diffs.
userdiff.c | 17 +++++++++++++++--

1 file changed, 15 insertions(+), 2 deletions(-)

@@ -18,40 +16,19 @@ index e399543823..12e31ff14d 100644 #include "git-compat-util.h"
#include "config.h"
#include "userdiff.h"
#include "strbuf.h"

+PATTERNS("javascript",
-+ /*

++      * Looks for lines that start with optional whitespace, followed
++      * by 'function'* and any characters (for function declarations),
++      * or valid JavaScript identifiers, equals sign '=', 'function' keyword
+       * and any characters (for function expressions).
++      * Also considers functions defined inside blocks with '{...}'.
++      */
+      "^[ \t]*(function[ \t]*.*|[a-zA-Z_$][0-9a-zA-Z_$]*[ \t]*=[ \t]*function[ \t]*.*|(\\{[ \t]*)?)\n",
-+     /* This pattern matches JavaScript identifiers */
-+     "[a-zA-Z_$][0-9a-zA-Z_$]*"
-+     "|[-+0-9.eE]+|0[xX][0-9a-fA-F]+"
-+     "|[-+*/<>%&^|=!:]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\|"),

Here is the test file.

-test_done
+test_expect_success 'identify builtin patterns in Javascript' '

+    # setup
+    echo "function myFunction() { return true; }" > test.js &&
+    echo "var myVar = function() { return false; }" >> test.js &&
+    git add test.js &&
+    git commit -m "add test.js" &&
+
+    # modify the file
+    echo "function myFunction() { return false; }" > test.js &&
+    echo "var myVar = function() { return true; }" >> test.js &&

+
+ # command under test
+ git diff >output &&
+

+    # check results
+    test_i18ngrep "function myFunction() { return true; }" output &&
+    test_i18ngrep "function myFunction() { return false; }" output &&
+    test_i18ngrep "var myVar = function() { return false; }" output &&
+    test_i18ngrep "var myVar = function() { return true; }" output

+'
+
+test_done
--
2.43.2

#23 lore raw

Re: [GSOC][PATCH] Userdiff: add builtin patterns for JavaScript.

Quoted 7 lines · Sergius Nyah

This commit introduces builtin patterns for JavaScript in userdiff and adds a new test case in t4018-diff-funcname.sh to verify the enhanced JavaScript function detection in Git diffs.

---
...-PATCH-1-2-Add-builtin-patterns-for-.patch | 53 ++++++-------------
t/t4018-diff-funcname.sh | 25 ++++++++-

2 files changed, 38 insertions(+), 40 deletions(-)

You apparently have done "git add" of a file that is a format-patch output, which led to ...

Pattern/0001-Subject-GSOC-RFC-PATCH-1-2-Add-builtin-patterns-for-.patch

Quoted 4 lines
Pattern/0001-Subject-GSOC-RFC-PATCH-1-2-Add-builtin-patterns-for-.patch +0 -0
index 43593866bc..9c3b80665e 100644

... this thing.

Wrap the proposed commit log message to a reasonable length and have a blank line before your sign-off. Other pieces of advice about formatting and contents found in Documentation/SubmittingPatches are also helpful.

Thanks.

#24 lore raw

PATCH 1/1 userdiff: add builtin patterns for JavaScript.

This commit introduces builtin patterns for JavaScript in userdiff.

It adds a new test case in t4018-diff-funcname.sh to verify the enhanced JavaScript function detection in Git diffs.

---
userdiff.c | 17 +++++++++++++++--
t/t4018-diff-funcname.sh | 25 ++++++++-

2 files changed, 38 insertions(+), 4 deletions(-)
userdiff.c +0 -0
index e399543823..12e31ff14d 100644
@@ -18,40 +16,19 @@

#include "git-compat-util.h"
#include "config.h"
#include "userdiff.h"
#include "strbuf.h"

PATTERNS("javascript",

      /* Looks for lines that start with optional whitespace, followed
      * by 'function'* and any characters (for function declarations),
      * or valid JavaScript identifiers, equals sign '=', 'function' keyword
      * and any characters (for function expressions).
      * Also considers functions defined inside blocks with '{...}'.
      */
      "^[ \t]*(function[ \t]*.*|[a-zA-Z_$][0-9a-zA-Z_$]*[ \t]*=[ \t]*function[ \t]*.*|(\\{[ \t]*)?)\n",
      /* This pattern matches JavaScript identifiers */
      "[a-zA-Z_$][0-9a-zA-Z_$]*"
      "|[-+0-9.eE]+|0[xX][0-9a-fA-F]+"
      "|[-+*/<>%&^|=!:]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\|"),
t/t4018-diff-funcname.sh +0 -0
index 43593866bc..9c3b80665e 100644
@@ -18,40 +16,19 @@

test_expect_success 'identify builtin patterns in Javascript' '

    # setup
    echo "function myFunction() { return true; }" > test.js &&
    echo "var myVar = function() { return false; }" >> test.js &&
    git add test.js &&
    git commit -m "add test.js" &&
    # modify the file
    echo "function myFunction() { return false; }" > test.js &&
    echo "var myVar = function() { return true; }" >> test.js &&
    # command under test
    git diff >output &&
    # check results
    test_i18ngrep "function myFunction() { return true; }" output &&
    test_i18ngrep "function myFunction() { return false; }" output &&
    test_i18ngrep "var myVar = function() { return false; }" output &&
    test_i18ngrep "var myVar = function() { return true; }" output
'

test_done
--
2.43.2

#25 lore raw

Re: [GSOC][PATCH] userdiff: add builtin patterns for JavaScript.

Quoted 1 line · Sergius Nyah

This commit introduces builtin patterns for JavaScript in userdiff.

"This commit introduces ..." -> "Introduce ...". I think describing which specification this adheres to (i.e. ECMA-262) would be helpful for the readers.

Quoted 2 lines

It adds a new test case in t4018-diff-funcname.sh to verify the enhanced JavaScript function detection in Git diffs.

"It adds ..." -> "Add ..."

Quoted 18 lines

---
userdiff.c | 17 +++++++++++++++--
t/t4018-diff-funcname.sh | 25 ++++++++-

2 files changed, 38 insertions(+), 4 deletions(-)
userdiff.c +0 -0
index e399543823..12e31ff14d 100644
@@ -18,40 +16,19 @@
 #include "git-compat-util.h"
 #include "config.h"
 #include "userdiff.h"
 #include "strbuf.h"
 
 PATTERNS("javascript",
      /* Looks for lines that start with optional whitespace, followed

userdiff.c line 32

Quoted 10 lines
userdiff.c +0 -0
      * by 'function'* and any characters (for function declarations),
      * or valid JavaScript identifiers, equals sign '=', 'function' keyword
      * and any characters (for function expressions).
      * Also considers functions defined inside blocks with '{...}'.
      */
      "^[ \t]*(function[ \t]*.*|[a-zA-Z_$][0-9a-zA-Z_$]*[ \t]*=[ \t]*function[ \t]*.*|(\\{[ \t]*)?)\n",
      /* This pattern matches JavaScript identifiers */
      "[a-zA-Z_$][0-9a-zA-Z_$]*"
      "|[-+0-9.eE]+|0[xX][0-9a-fA-F]+"
      "|[-+*/<>%&^|=!:]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\|"),

It seems like you manually manipulated the diff/format-patch output that is not the commit message. Usually all the new lines have '+' sign prefixed and all the removed lines have '-' sign prefixed. git am gives the following error:

Applying: userdiff: add builtin patterns for JavaScript.
error: corrupt patch at line 11
Patch failed at 0022 userdiff: add builtin patterns for JavaScript.

If you find it difficult to use send-email/format-patch, you can always make a pull request on git/git or gitgitgadget/git on GitHub and GitGitGadget[1] will take care of the rest. If you still want to use format-patch, it is a good practice to version your patches (i.e. [PATCH v2 1/2] ...) so that it is easy to follow.
(cf. Documentation/SubmittingPatches or Documentation/MyFirstContribution)

[1]: https://gitgitgadget.github.io/

Thanks.

Quoted 29 lines
t/t4018-diff-funcname.sh +0 -0
index 43593866bc..9c3b80665e 100644
@@ -18,40 +16,19 @@

test_expect_success 'identify builtin patterns in Javascript' '

    # setup
    echo "function myFunction() { return true; }" > test.js &&
    echo "var myVar = function() { return false; }" >> test.js &&
    git add test.js &&
    git commit -m "add test.js" &&
    # modify the file
    echo "function myFunction() { return false; }" > test.js &&
    echo "var myVar = function() { return true; }" >> test.js &&
    # command under test
    git diff >output &&
    # check results
    test_i18ngrep "function myFunction() { return true; }" output &&
    test_i18ngrep "function myFunction() { return false; }" output &&
    test_i18ngrep "var myVar = function() { return false; }" output &&
    test_i18ngrep "var myVar = function() { return true; }" output
'

test_done
--
2.43.2

#26 lore raw

PATCH 1/1 userdiff: Add JavaScript function patterns

In reply to Junio C Hamano

This commit adds a patterns used to match JavaScript functions.
It now correctly identifies function declarations, function expressions, and functions defined inside blocks. Add test for corresponding change in userdiff.

---
 t/t4018-diff-funcname.sh | 22 ++++++++++++++++++++++
 userdiff.c               | 12 ++++++++++++
 2 files changed, 34 insertions(+)
t/t4018-diff-funcname.sh +22 -0
index e026fac1f4..d35cce18a0 100755
@@ -120,3 +120,25 @@ do
 done
 
 test_done
+
+test_expect_success 'identify builtin patterns in JavaScript' '
+	# setup
+	echo "function myFunction() { return true; }" > test.js &&
+	echo "var myVar = function() { return false; }" >> test.js &&
+	git add test.js &&
+	git commit -m "add test.js" &&
+
+	# modify the file
+	echo "function myFunction() { return false; }" > test.js &&
+	echo "var myVar = function() { return true; }" >> test.js &&
+
+	# command under test
+	git diff >output &&
+
+	# check results
+	test_i18ngrep "function myFunction() { return true; }" output &&
+	test_i18ngrep "function myFunction() { return false; }" output &&
+	test_i18ngrep "var myVar = function() { return false; }" output &&
+	test_i18ngrep "var myVar = function() { return true; }" output
+'
+test_done
\ No newline at end of file
userdiff.c +0 -0
index 2b1dab2649..bbe2bcb9a3 100644

+PATTERNS("javascript",

+      /* Looks for lines that start with optional whitespace, followed
+      * by 'function'* and any characters (for function declarations),
+      * or valid JavaScript identifiers, equals sign '=', 'function' keyword
+      * and any characters (for function expressions).
+      * Also considers functions defined inside blocks with '{...}'.
+      */
+      "^[ \t]*(function[ \t]*.*|[a-zA-Z_$][0-9a-zA-Z_$]*[ \t]*=[ \t]*function[ \t]*.*|(\\{[ \t]*)?)\n",
+      /* This pattern matches JavaScript identifiers */
+      "[a-zA-Z_$][0-9a-zA-Z_$]*"
+      "|[-+0-9.eE]+|0[xX][0-9a-fA-F]+"
+      "|[-+*/<>%&^|=!:]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\|"),

--
2.43.2

#27 lore raw

Re: [GSOC][PATCH] userdiff: Add JavaScript function patterns

The subject should be "userdiff: add JavaScript function patterns" so with "add" instead of "Add". See the SubmittingPatches document which contains:

"The title sentence after the "area:" prefix omits the full stop at the end, and its first word is not capitalized (the omission
of capitalization applies only to the word after the "area:" prefix of the title) unless there is a reason to
capitalize it other than because it is the first word in the sentence."

Quoted 2 lines · Sergius Nyah

This commit adds a patterns used to match JavaScript functions.

It should be either "add patterns" or "add a pattern".

Also instead of "This commit" please use the imperative mood or "Let's". See the SubmittingPatches document which contains:

"Describe your changes in imperative mood, e.g. "make xyzzy do frotz" instead of "[This patch] makes xyzzy do frotz" or "[I] changed xyzzy to do frotz", as if you are giving orders to the codebase to change its behavior."

Quoted 8 lines

It now correctly identifies function declarations, function expressions, and functions defined inside blocks. Add test for corresponding change in userdiff.

---
 t/t4018-diff-funcname.sh | 22 ++++++++++++++++++++++
 userdiff.c               | 12 ++++++++++++
 2 files changed, 34 insertions(+)

In t4034-diff-words.sh there is:

test_language_driver ada
test_language_driver bibtex
test_language_driver cpp
test_language_driver csharp
test_language_driver css
test_language_driver dts
test_language_driver fortran
test_language_driver html
test_language_driver java
test_language_driver kotlin
test_language_driver matlab
test_language_driver objc
test_language_driver pascal
test_language_driver perl
test_language_driver php
test_language_driver python
test_language_driver ruby
test_language_driver scheme
test_language_driver tex

So I would have thought that you would just add a test_language_driver javascript line in this file and associated material in the t/t4034/ directory.

Quoted 18 lines
t/t4018-diff-funcname.sh +10 -0
index e026fac1f4..d35cce18a0 100755
@@ -120,3 +120,25 @@ do
 done
 
 test_done
+
+test_expect_success 'identify builtin patterns in JavaScript' '
+       # setup
+       echo "function myFunction() { return true; }" > test.js &&
+       echo "var myVar = function() { return false; }" >> test.js &&
+       git add test.js &&
+       git commit -m "add test.js" &&
+
+       # modify the file
+       echo "function myFunction() { return false; }" > test.js &&

t/t4018-diff-funcname.sh do · line 142

Quoted 10 lines
t/t4018-diff-funcname.sh +10 -0
+       echo "var myVar = function() { return true; }" >> test.js &&
+
+       # command under test
+       git diff >output &&
+
+       # check results
+       test_i18ngrep "function myFunction() { return true; }" output &&
+       test_i18ngrep "function myFunction() { return false; }" output &&
+       test_i18ngrep "var myVar = function() { return false; }" output &&
+       test_i18ngrep "var myVar = function() { return true; }" output

I think we try to use just test_grep instead of test_i18ngrep these days.

t/t4018-diff-funcname.sh do · line 144

Quoted 3 lines
t/t4018-diff-funcname.sh +2 -0
+'
+test_done
\ No newline at end of file

Please add a new line at the end of this file if you still change it.

Thanks!

#28 lore raw

Re: [GSOC][PATCH] userdiff: Add JavaScript function patterns

Quoted 10 lines · Christian Couder

The subject should be "userdiff: add JavaScript function patterns" so with "add" instead of "Add". See the SubmittingPatches document which contains:

"The title sentence after the "area:" prefix omits the full stop at the end, and its first word is not capitalized (the omission
of capitalization applies only to the word after the "area:" prefix of the title) unless there is a reason to
capitalize it other than because it is the first word in the sentence."

Also about the subject, please use v2, v3, v4 when you resend a patch or a patch series that you have already sent. git format-patch has a "-v <n>" or "--reroll-count=<n>" option for that purpose.

#29 lore raw

Re: [GSOC][PATCH] userdiff: Add JavaScript function patterns

In reply to Christian Couder
Quoted 7 lines · Christian Couder

Review

Quoted 5 lines
(quoted diff) +5 -0
+       # check results
+       test_i18ngrep "function myFunction() { return true; }" output &&
+       test_i18ngrep "function myFunction() { return false; }" output &&
+       test_i18ngrep "var myVar = function() { return false; }" output &&
+       test_i18ngrep "var myVar = function() { return true; }" output

I think we try to use just test_grep instead of test_i18ngrep these days.

Thanks for reminding. I am tempted to suggest doing this.

------ >8 ----------- >8 ----------- >8 ----------- >8 ------
Subject: test_i18ngrep: hard deprecate and forbid its use

Since v2.44.0-rc0~109 (Merge branch 'sp/test-i18ngrep', 2023-12-27) none of the tests we have, either in 'master' or in flight and collected in 'seen', use test_i18ngrep.

Perhaps it is good time to update test_i18ngrep to BUG to avoid people adding new calls to it.

---
 t/test-lib-functions.sh | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
t/test-lib-functions.sh +1 -2
index b5eaf7fdc1..6eaf116346 100644
@@ -1263,9 +1263,8 @@ test_cmp_bin () {
 	cmp "$@"
 }
 
-# Deprecated - do not use this in new code
 test_i18ngrep () {
-	test_grep "$@"
+	BUG "do not use test_i18ngrep---use test_grep instead"
 }
 
 test_grep () {
#30 lore raw

Re: [GSOC][PATCH] userdiff: Add JavaScript function patterns

In reply to Sergius Nyah
Quoted 31 lines · Sergius Nyah

This commit adds a patterns used to match JavaScript functions.
It now correctly identifies function declarations, function expressions, and functions defined inside blocks. Add test for corresponding change in userdiff.

---
 t/t4018-diff-funcname.sh | 22 ++++++++++++++++++++++
 userdiff.c               | 12 ++++++++++++
 2 files changed, 34 insertions(+)
t/t4018-diff-funcname.sh +13 -0
index e026fac1f4..d35cce18a0 100755
@@ -120,3 +120,25 @@ do
 done
 
 test_done
+
+test_expect_success 'identify builtin patterns in JavaScript' '
+	# setup
+	echo "function myFunction() { return true; }" > test.js &&
+	echo "var myVar = function() { return false; }" >> test.js &&
+	git add test.js &&
+	git commit -m "add test.js" &&
+
+	# modify the file
+	echo "function myFunction() { return false; }" > test.js &&
+	echo "var myVar = function() { return true; }" >> test.js &&
+
+	# command under test

t/t4018-diff-funcname.sh do · line 144

Quoted 10 lines
t/t4018-diff-funcname.sh +9 -0
+	git diff >output &&
+
+	# check results
+	test_i18ngrep "function myFunction() { return true; }" output &&
+	test_i18ngrep "function myFunction() { return false; }" output &&
+	test_i18ngrep "var myVar = function() { return false; }" output &&
+	test_i18ngrep "var myVar = function() { return true; }" output
+'
+test_done
\ No newline at end of file

This test_done only needs to be added because you add the new test before the preceding test_done. Instead, you should move up this test so that it comes before it.

userdiff.c

Quoted 6 lines
userdiff.c +2 -0
index 2b1dab2649..bbe2bcb9a3 100644
+PATTERNS("javascript",
+      /* Looks for lines that start with optional whitespace, followed

Multi-line comments should start with their delimiters on separate lines. So the "/*" should be on its own line.

Also, the code should be indented with tabs and not spaces. It might help to read through Documentation/CodingGuidelines to get more familiar with Git's coding style.

Patrick

Quoted 13 lines
userdiff.c +10 -1
+      * by 'function'* and any characters (for function declarations),
+      * or valid JavaScript identifiers, equals sign '=', 'function' keyword
+      * and any characters (for function expressions).
+      * Also considers functions defined inside blocks with '{...}'.
+      */
+      "^[ \t]*(function[ \t]*.*|[a-zA-Z_$][0-9a-zA-Z_$]*[ \t]*=[ \t]*function[ \t]*.*|(\\{[ \t]*)?)\n",
+      /* This pattern matches JavaScript identifiers */
+      "[a-zA-Z_$][0-9a-zA-Z_$]*"
+      "|[-+0-9.eE]+|0[xX][0-9a-fA-F]+"
+      "|[-+*/<>%&^|=!:]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\|"),
--

2.43.2

#31 lore raw

PATCH v2 1/3 t4018-diff-funcname: use test_grep instead of test_i18ngrep

---
 t/t4018-diff-funcname.sh | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
t/t4018-diff-funcname.sh +7 -7
index d35cce18a0..e6d2f1c215 100755
@@ -119,8 +119,6 @@ do
 	"
 done
 
-test_done
-
 test_expect_success 'identify builtin patterns in JavaScript' '
 	# setup
 	echo "function myFunction() { return true; }" > test.js &&
@@ -136,9 +134,11 @@ test_expect_success 'identify builtin patterns in JavaScript' '
 	git diff >output &&
 
 	# check results
-	test_i18ngrep "function myFunction() { return true; }" output &&
-	test_i18ngrep "function myFunction() { return false; }" output &&
-	test_i18ngrep "var myVar = function() { return false; }" output &&
-	test_i18ngrep "var myVar = function() { return true; }" output
+	test_grep "function myFunction() { return true; }" output &&
+	test_grep "function myFunction() { return false; }" output &&
+	test_grep "var myVar = function() { return false; }" output &&
+	test_grep "var myVar = function() { return true; }" output
 '
-test_done
\ No newline at end of file
+
+test_done
+

--
2.43.2

#32 lore raw

PATCH v2 2/3 t4034-diff-words: add javascript language driver

---
 t/t4034-diff-words.sh | 1 +
 1 file changed, 1 insertion(+)
t/t4034-diff-words.sh +1 -0
index 74586f3813..cf2374af2c 100755
@@ -328,6 +328,7 @@ test_language_driver dts
 test_language_driver fortran
 test_language_driver html
 test_language_driver java
+test_language_driver javascript
 test_language_driver kotlin
 test_language_driver matlab
 test_language_driver objc

--
2.43.2

#33 lore raw

PATCH v2 3/3 userdiff: remove trailing whitespaces, fix multiline comments

In reply to Sergius Nyah

This patch removes trailing whitespaces and fixes multiline comments in the userdiff.c file to match Gits coding standards as seen in [1].

---
 userdiff.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)
userdiff.c +12 -11
index bbe2bcb9a3..15342c8662 100644
@@ -184,17 +184,18 @@ PATTERNS("java",
 	 "|[-+*/<>%&^|=!]="
 	 "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"),
 PATTERNS("javascript",
-      /* Looks for lines that start with optional whitespace, followed
-      * by 'function'* and any characters (for function declarations),
-      * or valid JavaScript identifiers, equals sign '=', 'function' keyword
-      * and any characters (for function expressions).
-      * Also considers functions defined inside blocks with '{...}'.
-      */
-      "^[ \t]*(function[ \t]*.*|[a-zA-Z_$][0-9a-zA-Z_$]*[ \t]*=[ \t]*function[ \t]*.*|(\\{[ \t]*)?)\n",
-      /* This pattern matches JavaScript identifiers */
-      "[a-zA-Z_$][0-9a-zA-Z_$]*"
-      "|[-+0-9.eE]+|0[xX][0-9a-fA-F]+"
-      "|[-+*/<>%&^|=!:]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\|"),
+	/*
+	 * Look for lines that start with optional whitespace, followed
+	 * by 'function' and any characters (for function declarations),
+	 * or valid JavaScript identifiers, equals sign '=', 'function' keyword
+	 * and any characters (for function expressions).
+	 * Also consider functions defined inside blocks with '{...}'.
+	 */
+	 "^[ \t]*(function[ \t]*.*|[a-zA-Z_$][0-9a-zA-Z_$]*[ \t]*=[ \t]*function[ \t]*.*|(\\{[ \t]*)?)\n",
+	 /* Match JavaScript identifiers with this pattern */
+	 "[a-zA-Z_$][0-9a-zA-Z_$]*"
+	 "|[-+0-9.eE]+|0[xX][0-9a-fA-F]+"
+	 "|[-+*/<>%&^|=!:]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\|"),
 PATTERNS("kotlin",
 	 "^[ \t]*(([a-z]+[ \t]+)*(fun|class|interface)[ \t]+.*)$",
 	 /* -- */

--
2.43.2

[1]:
https://github.com/git/git/blob/master/Documentation/CodingGuidelines

#34 lore raw

PATCH v2 1/1 userdiff: improve code quality and add JavaScript language driver.

In reply to Patrick Steinhardt

This commit introduces several improvements to the codebase:

- replace the use of test_i18ngrep with test_grep in t/t4018-diff-funcname.sh for better pattern matching and improved performance.
- add a JavaScript language driver to enhance the functionality of the application.
- clean up the code by removing trailing whitespaces and fix multiline comments in t/t4034-diff-words.sh and userdiff.c.

---
 t/t4018-diff-funcname.sh | 14 +++++++-------
 t/t4034-diff-words.sh    |  1 +
 userdiff.c               | 23 ++++++++++++-----------
 3 files changed, 20 insertions(+), 18 deletions(-)
t/t4018-diff-funcname.sh +7 -7
index d35cce18a0..e6d2f1c215 100755
@@ -119,8 +119,6 @@ do
 	"
 done
 
-test_done
-
 test_expect_success 'identify builtin patterns in JavaScript' '
 	# setup
 	echo "function myFunction() { return true; }" > test.js &&
@@ -136,9 +134,11 @@ test_expect_success 'identify builtin patterns in JavaScript' '
 	git diff >output &&
 
 	# check results
-	test_i18ngrep "function myFunction() { return true; }" output &&
-	test_i18ngrep "function myFunction() { return false; }" output &&
-	test_i18ngrep "var myVar = function() { return false; }" output &&
-	test_i18ngrep "var myVar = function() { return true; }" output
+	test_grep "function myFunction() { return true; }" output &&
+	test_grep "function myFunction() { return false; }" output &&
+	test_grep "var myVar = function() { return false; }" output &&
+	test_grep "var myVar = function() { return true; }" output
 '
-test_done
\ No newline at end of file
+
+test_done
+
t/t4034-diff-words.sh +1 -0
index 74586f3813..cf2374af2c 100755
@@ -328,6 +328,7 @@ test_language_driver dts
 test_language_driver fortran
 test_language_driver html
 test_language_driver java
+test_language_driver javascript
 test_language_driver kotlin
 test_language_driver matlab
 test_language_driver objc
userdiff.c +0 -0
index bbe2bcb9a3..15342c8662 100644

PATTERNS("javascript",

-      /* Looks for lines that start with optional whitespace, followed
-      * by 'function'* and any characters (for function declarations),
-      * or valid JavaScript identifiers, equals sign '=', 'function' keyword
-      * and any characters (for function expressions).
-      * Also considers functions defined inside blocks with '{...}'.
-      */
-      "^[ \t]*(function[ \t]*.*|[a-zA-Z_$][0-9a-zA-Z_$]*[ \t]*=[ \t]*function[ \t]*.*|(\\{[ \t]*)?)\n",
-      /* This pattern matches JavaScript identifiers */
-      "[a-zA-Z_$][0-9a-zA-Z_$]*"
-      "|[-+0-9.eE]+|0[xX][0-9a-fA-F]+"
-      "|[-+*/<>%&^|=!:]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\|"),

+ /*
+ * Look for lines that start with optional whitespace, followed
+ * by 'function' and any characters (for function declarations),
+ * or valid JavaScript identifiers, equals sign '=', 'function' keyword
+ * and any characters (for function expressions).
+ * Also consider functions defined inside blocks with '{...}'.
+ */
+ "^[ \t]*(function[ \t]*.*|[a-zA-Z_$][0-9a-zA-Z_$]*[ \t]*=[ \t]*function[ \t]*.*|(\\{[ \t]*)?)\n",
+ /* Match JavaScript identifiers with this pattern */
+ "[a-zA-Z_$][0-9a-zA-Z_$]*"
+ "|[-+0-9.eE]+|0[xX][0-9a-fA-F]+"
+ "|[-+*/<>%&^|=!:]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\|"),

2.43.2

#35 lore raw

Re: [GSOC][PATCH v2]userdiff: improve code quality and add JavaScript language driver.

Quoted 9 lines · Sergius Nyah

This commit introduces several improvements to the codebase:

- replace the use of test_i18ngrep with test_grep in t/t4018-diff-funcname.sh for better pattern matching and improved performance.
- add a JavaScript language driver to enhance the functionality of the application.
- clean up the code by removing trailing whitespaces and fix multiline comments in t/t4034-diff-words.sh and userdiff.c.

Doing too many unrelated things that may appear semi-related only because they are about the same files? Don't.

Quoted 29 lines
---
 t/t4018-diff-funcname.sh | 14 +++++++-------
 t/t4034-diff-words.sh    |  1 +
 userdiff.c               | 23 ++++++++++++-----------
 3 files changed, 20 insertions(+), 18 deletions(-)
t/t4018-diff-funcname.sh +0 -6
index d35cce18a0..e6d2f1c215 100755
@@ -119,8 +119,6 @@ do
 	"
 done
 
-test_done
-
 test_expect_success 'identify builtin patterns in JavaScript' '
 	# setup
 	echo "function myFunction() { return true; }" > test.js &&
@@ -136,9 +134,11 @@ test_expect_success 'identify builtin patterns in JavaScript' '
 	git diff >output &&
 
 	# check results
-	test_i18ngrep "function myFunction() { return true; }" output &&
-	test_i18ngrep "function myFunction() { return false; }" output &&
-	test_i18ngrep "var myVar = function() { return false; }" output &&
-	test_i18ngrep "var myVar = function() { return true; }" output

t/t4018-diff-funcname.sh test_expect_success 'identify builtin patterns in JavaScript' ' · line 144

Quoted 10 lines
t/t4018-diff-funcname.sh +7 -1
+	test_grep "function myFunction() { return true; }" output &&
+	test_grep "function myFunction() { return false; }" output &&
+	test_grep "var myVar = function() { return false; }" output &&
+	test_grep "var myVar = function() { return true; }" output
 '
-test_done
\ No newline at end of file
+
+test_done
+

To which version of Git source code are the above hunks meant to apply? Hopefully we do not have a test that says "test_done" followed by another "test_expect_success" in our tree.

t/t4034-diff-words.sh test_language_driver dts · line 334

Quoted 12 lines
t/t4034-diff-words.sh +1 -0
index 74586f3813..cf2374af2c 100755
@@ -328,6 +328,7 @@ test_language_driver dts
 test_language_driver fortran
 test_language_driver html
 test_language_driver java
+test_language_driver javascript
 test_language_driver kotlin
 test_language_driver matlab
 test_language_driver objc

It is unclear what "clean-up" was done to this file, as claimed in the proposed log message. Puzzled...

Quoted 19 lines
userdiff.c +2 -11
index bbe2bcb9a3..15342c8662 100644
 
 PATTERNS("javascript",
-      /* Looks for lines that start with optional whitespace, followed
-      * by 'function'* and any characters (for function declarations),
-      * or valid JavaScript identifiers, equals sign '=', 'function' keyword
-      * and any characters (for function expressions).
-      * Also considers functions defined inside blocks with '{...}'.
-      */
-      "^[ \t]*(function[ \t]*.*|[a-zA-Z_$][0-9a-zA-Z_$]*[ \t]*=[ \t]*function[ \t]*.*|(\\{[ \t]*)?)\n",
-      /* This pattern matches JavaScript identifiers */
-      "[a-zA-Z_$][0-9a-zA-Z_$]*"
-      "|[-+0-9.eE]+|0[xX][0-9a-fA-F]+"
-      "|[-+*/<>%&^|=!:]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\|"),
+	/*
+	 * Look for lines that start with optional whitespace, followed

userdiff.c

Quoted 10 lines
userdiff.c +10 -0
+	 * by 'function' and any characters (for function declarations),
+	 * or valid JavaScript identifiers, equals sign '=', 'function' keyword
+	 * and any characters (for function expressions).
+	 * Also consider functions defined inside blocks with '{...}'.
+	 */
+	 "^[ \t]*(function[ \t]*.*|[a-zA-Z_$][0-9a-zA-Z_$]*[ \t]*=[ \t]*function[ \t]*.*|(\\{[ \t]*)?)\n",
+	 /* Match JavaScript identifiers with this pattern */
+	 "[a-zA-Z_$][0-9a-zA-Z_$]*"
+	 "|[-+0-9.eE]+|0[xX][0-9a-fA-F]+"
+	 "|[-+*/<>%&^|=!:]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\|"),

I do not see trailing whitespaces getting fixed, as claimed in the proposed log message. Puzzled, again...