Subject: [GSoC PATCH 0/1] userdiff: add javascript diff driver

From: "Derick W. de M. Frias" <[email-masked]>
Date: Wed, 4 Jun 2025 06:35:45 -0300

Hi, I'm Derick and this is one of my first contributions. I'm a CS
undergrad student and I'm really excited to start learning more about
Git's internals.

As it is in 2025, javascript is amongst the most prevalent programming
languages and yet it it not beeing supported by a diff driver in Git.
I do believe that the addition of this functionality is a good
contribution that will benefit tons of developers that work with
javascript.

For me, it was a surprise to discover that javascript isn't supported
yet, so the first thing that came to mind was if someone had already
tried to work on the problem. Searching at Git's lore, I found some
previous atempts at tacking it and I tried to learn from them and to 
guide my work along what I believe were good paths taken.

The pattern I added to userdiff.c to recognize functions groups them in
some categories, that are: conventional functions (Those that are
declared in outer scope, and not assigned to any variable), assigned
functions (those that ARE assigned to a variable), arrow functions and
functions declared inside classes or objects.

For js literals, the regex matches valid alphanumerical literals that
are valid in javascript. It also matches numerical literals in binary,
octal, decimal and hexadecimal bases, and punctuations.

I also added test cases for instances of function declarations.

I tried to keep things simple, my idea is to make it work well while
thinking 'vanilla' javascript-first. I'm quite sure the contribution
still can be improved so I'm looking foward for feedback on what is
important/interesting to be made.

Derick W. de M. Frias (1):
  userdiff: add javascript diff driver

 .../javascript-anonymous-function-assigned    |  4 +++
 t/t4018/javascript-arrow-function-assigned    |  4 +++
 t/t4018/javascript-arrow-function-assigned-2  |  1 +
 t/t4018/javascript-async-function             |  4 +++
 t/t4018/javascript-async-function-assigned    |  4 +++
 t/t4018/javascript-class-function             |  6 ++++
 t/t4018/javascript-function                   |  4 +++
 t/t4018/javascript-function-assigned          |  4 +++
 t/t4018/javascript-generator-function         |  5 ++++
 t/t4018/javascript-generator-function-2       |  5 ++++
 .../javascript-generator-function-assigned    |  5 ++++
 .../javascript-generator-function-assigned-2  |  5 ++++
 t/t4018/javascript-method-function            |  6 ++++
 userdiff.c                                    | 28 +++++++++++++++++++
 14 files changed, 85 insertions(+)
 create mode 100644 t/t4018/javascript-anonymous-function-assigned
 create mode 100644 t/t4018/javascript-arrow-function-assigned
 create mode 100644 t/t4018/javascript-arrow-function-assigned-2
 create mode 100644 t/t4018/javascript-async-function
 create mode 100644 t/t4018/javascript-async-function-assigned
 create mode 100644 t/t4018/javascript-class-function
 create mode 100644 t/t4018/javascript-function
 create mode 100644 t/t4018/javascript-function-assigned
 create mode 100644 t/t4018/javascript-generator-function
 create mode 100644 t/t4018/javascript-generator-function-2
 create mode 100644 t/t4018/javascript-generator-function-assigned
 create mode 100644 t/t4018/javascript-generator-function-assigned-2
 create mode 100644 t/t4018/javascript-method-function

-- 
2.50.0.rc0.62.g658f0ae201.dirty