git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
DFDerick W. de M. Frias <derick.william.moraes@gmail.com>
Date
Jun 4, 2025, 09:35 UTC
Message-ID
<20250604094100.80598-1-derick.william.moraes@gmail.com>

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
Next: Derick W. de M. Frias
Message 1 of 11 in “userdiff: add javascript diff driver”
  1. 0/1 userdiff: add javascript diff driverDerick W. de M. Frias, Jun 4, 2025
  2. 1/1 userdiff: add javascript diff driverDerick W. de M. Frias, Jun 4, 2025
  3. D. Ben KnobleJun 4, 2025
  4. Johannes SixtJun 5, 2025
  5. 0/4 diff: create pattern for javascript languageDerick W. de M. Frias, Jun 23, 2025
  6. 2/4 t4034: add tests for javascript word literalsDerick W. de M. Frias, Jun 23, 2025
  7. 3/4 t4018: add tests for recognizing javascript function syntaxDerick W. de M. Frias, Jun 23, 2025
  8. 1/4 userdiff: add javascript diff driverDerick W. de M. Frias, Jun 23, 2025
  9. Junio C HamanoJun 23, 2025
  10. 4/4 t4018: add tests for javascript export type function declarationsDerick W. de M. Frias, Jun 23, 2025
  11. Johannes SixtJun 26, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.