{"thread":{"id":"65378","subject":"[PATCH 0/2] [GSoC] userdiff: adding typescript pattern","startedAt":"2026-03-28T21:40:07Z","lastAt":"2026-03-29T14:39:56Z","messageCount":6,"participants":["Dhruv Arora via GitGitGadget","Junio C Hamano","Johannes Sixt","Ben Knoble"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"540302","messageId":"pull.2251.git.git.1774734004.gitgitgadget@gmail.com","threadId":"65378","inReplyTo":null,"subject":"[PATCH 0/2] [GSoC] userdiff: adding typescript pattern","fromName":"Dhruv Arora via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-03-28T21:40:02Z","receivedAt":"2026-03-28T21:40:07Z","isPatch":true,"sender":{"key":"name:Dhruv Arora","avatar":null},"body":"\nDescription\n===========\n\n * Add builtin userdiff pattern for TypeScript files. Recognizes function\n   declarations, class definitions, arrow functions, and method definitions.\n   \n   * Handles common modifiers like export, async, static, etc\n\n * Added tests for the typescript pattern in userdiff.\n\nDhruv Arora (2):\n  userdiff: adding typescript pattern\n  fix(userdiff): sorted pattern and tests\n\n t/t4018/typescript-class-method         |  7 +++++++\n t/t4018/typescript-export-default-class |  7 +++++++\n t/t4018/typescript-export-function      |  7 +++++++\n userdiff.c                              | 15 +++++++++++++++\n 4 files changed, 36 insertions(+)\n create mode 100644 t/t4018/typescript-class-method\n create mode 100644 t/t4018/typescript-export-default-class\n create mode 100644 t/t4018/typescript-export-function\n\n\nbase-commit: ce74208c2fa13943fffa58f168ac27a76d0eb789\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2251%2FDhruv-0-Arora%2Fuserdiff%2Ftypescript-pattern-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2251/Dhruv-0-Arora/userdiff/typescript-pattern-v1\nPull-Request: https://github.com/git/git/pull/2251\n-- \ngitgitgadget\n"},{"id":"540303","messageId":"f3bb69dbfc628d88075ee9a5a9b549e73cb487fe.1774734004.git.gitgitgadget@gmail.com","threadId":"65378","inReplyTo":"pull.2251.git.git.1774734004.gitgitgadget@gmail.com","subject":"[PATCH 1/2] userdiff: adding typescript pattern","fromName":"Dhruv Arora via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-03-28T21:40:03Z","receivedAt":"2026-03-28T21:40:09Z","isPatch":true,"sender":{"key":"name:Dhruv Arora","avatar":null},"body":"From: Dhruv Arora <a_dhruv@outlook.com>\n\nAdd builtin userdiff pattern for TypeScript files.\nRecognizes function declarations, class definitions,\narrow functions, and method definitions.\n\nHandles common modifiers like export, async, static, etc..\n\nSigned-off-by: Dhruv Arora <a_dhruv@outlook.com>\n---\n userdiff.c | 13 +++++++++++++\n 1 file changed, 13 insertions(+)\n\ndiff --git a/userdiff.c b/userdiff.c\nindex fe710a68bf..086e3fa002 100644\n--- a/userdiff.c\n+++ b/userdiff.c\n@@ -337,6 +337,19 @@ PATTERNS(\"ruby\",\n \t \"(@|@@|\\\\$)?[a-zA-Z_][a-zA-Z0-9_]*\"\n \t \"|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+|\\\\?(\\\\\\\\C-)?(\\\\\\\\M-)?.\"\n \t \"|//=?|[-+*/<>%&^|=!]=|<<=?|>>=?|===|\\\\.{1,3}|::|[!=]~\"),\n+PATTERNS(\"typescript\",\n+\t/* Starting with optional whitespace */\n+\t\"^[ \\t]*\"\n+\t/* Followed by an optional export and/or async keyword */\n+\t\"((export[ \\t]+)?(async[ \\t]+)?\"\n+\t/* Followed by either a function or class declaration */\n+\t\"((function|class)[ \\t]+[a-zA-Z_][a-zA-Z0-9_]*[^{]*)\"\n+\t/* or */\n+\t\"|\"\n+\t/* a variable declaration with const, let, or var */\n+\t\"([ \\t]*(const|let|var)[ \\t]+[a-zA-Z_][a-zA-Z0-9_]*[ \\t]*=))\",\n+\t/* -- */\n+\t\"[a-zA-Z_][a-zA-Z0-9_]*\"),\n PATTERNS(\"rust\",\n \t \"^[\\t ]*((pub(\\\\([^\\\\)]+\\\\))?[\\t ]+)?((async|const|unsafe|extern([\\t ]+\\\"[^\\\"]+\\\"))[\\t ]+)?(struct|enum|union|mod|trait|fn|impl|macro_rules!)[< \\t]+[^;]*)$\",\n \t /* -- */\n-- \ngitgitgadget\n\n"},{"id":"540304","messageId":"d684d938fb794fd858d49665e2b5b03aa0319f06.1774734004.git.gitgitgadget@gmail.com","threadId":"65378","inReplyTo":"pull.2251.git.git.1774734004.gitgitgadget@gmail.com","subject":"[PATCH 2/2] fix(userdiff): sorted pattern and tests","fromName":"Dhruv Arora via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-03-28T21:40:04Z","receivedAt":"2026-03-28T21:40:10Z","isPatch":true,"sender":{"key":"name:Dhruv Arora","avatar":null},"body":"From: Dhruv Arora <a_dhruv@outlook.com>\n\n- Typescript pattern was not in alphabetical order, causing failing tests.\n- Added 3 new typescript tests.\n- Fixed pattern bug - incorrectly identifying const|let|var instead of\nfunction or class.\n\nSigned-off-by: Dhruv Arora <a_dhruv@outlook.com>\n---\n t/t4018/typescript-class-method         |  7 +++++++\n t/t4018/typescript-export-default-class |  7 +++++++\n t/t4018/typescript-export-function      |  7 +++++++\n userdiff.c                              | 28 +++++++++++++------------\n 4 files changed, 36 insertions(+), 13 deletions(-)\n create mode 100644 t/t4018/typescript-class-method\n create mode 100644 t/t4018/typescript-export-default-class\n create mode 100644 t/t4018/typescript-export-function\n\ndiff --git a/t/t4018/typescript-class-method b/t/t4018/typescript-class-method\nnew file mode 100644\nindex 0000000000..6de6eff2e7\n--- /dev/null\n+++ b/t/t4018/typescript-class-method\n@@ -0,0 +1,7 @@\n+export class RIGHT {\n+    unique = 0\n+    constructor () {\n+        this.doNothing()\n+    }\n+    function ChangeMe() { }\n+}\ndiff --git a/t/t4018/typescript-export-default-class b/t/t4018/typescript-export-default-class\nnew file mode 100644\nindex 0000000000..aaede0dce3\n--- /dev/null\n+++ b/t/t4018/typescript-export-default-class\n@@ -0,0 +1,7 @@\n+export default class RIGHT {\n+\tprivate x = 0;\n+\tprivate y = 0;\n+\tprivate z = 0;\n+\t// ChangeMe\n+\trender() {}\n+}\ndiff --git a/t/t4018/typescript-export-function b/t/t4018/typescript-export-function\nnew file mode 100644\nindex 0000000000..ba5bf71e80\n--- /dev/null\n+++ b/t/t4018/typescript-export-function\n@@ -0,0 +1,7 @@\n+export async function RIGHT(url: string): Promise<string> {\n+\tconst a = 1;\n+\tconst b = 2;\n+\tconst c = 3;\n+\tChangeMe\n+\treturn url;\n+}\ndiff --git a/userdiff.c b/userdiff.c\nindex 086e3fa002..7f5cadb30b 100644\n--- a/userdiff.c\n+++ b/userdiff.c\n@@ -337,19 +337,6 @@ PATTERNS(\"ruby\",\n \t \"(@|@@|\\\\$)?[a-zA-Z_][a-zA-Z0-9_]*\"\n \t \"|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+|\\\\?(\\\\\\\\C-)?(\\\\\\\\M-)?.\"\n \t \"|//=?|[-+*/<>%&^|=!]=|<<=?|>>=?|===|\\\\.{1,3}|::|[!=]~\"),\n-PATTERNS(\"typescript\",\n-\t/* Starting with optional whitespace */\n-\t\"^[ \\t]*\"\n-\t/* Followed by an optional export and/or async keyword */\n-\t\"((export[ \\t]+)?(async[ \\t]+)?\"\n-\t/* Followed by either a function or class declaration */\n-\t\"((function|class)[ \\t]+[a-zA-Z_][a-zA-Z0-9_]*[^{]*)\"\n-\t/* or */\n-\t\"|\"\n-\t/* a variable declaration with const, let, or var */\n-\t\"([ \\t]*(const|let|var)[ \\t]+[a-zA-Z_][a-zA-Z0-9_]*[ \\t]*=))\",\n-\t/* -- */\n-\t\"[a-zA-Z_][a-zA-Z0-9_]*\"),\n PATTERNS(\"rust\",\n \t \"^[\\t ]*((pub(\\\\([^\\\\)]+\\\\))?[\\t ]+)?((async|const|unsafe|extern([\\t ]+\\\"[^\\\"]+\\\"))[\\t ]+)?(struct|enum|union|mod|trait|fn|impl|macro_rules!)[< \\t]+[^;]*)$\",\n \t /* -- */\n@@ -367,6 +354,21 @@ PATTERNS(\"scheme\",\n \t \"|([^][)(}{[ \\t])+\"),\n PATTERNS(\"tex\", \"^(\\\\\\\\((sub)*section|chapter|part)\\\\*{0,1}\\\\{.*)$\",\n \t \"\\\\\\\\[a-zA-Z@]+|\\\\\\\\.|([a-zA-Z0-9]|[^\\x01-\\x7f])+\"),\n+PATTERNS(\"typescript\",\n+\t/* Starting with optional whitespace */\n+\t\"^[ \\t]*\"\n+\t\"(\"\n+\t/* Followed by an optional export and/or async and/or default keyword */\n+\t\"(export[ \\t]+)?(default[ \\t]+)?(async[ \\t]+)?\"\n+\t/* Followed by either a function or class declaration */\n+\t\"((function|class)[ \\t]+[a-zA-Z_][a-zA-Z0-9_]*[^{]*)\"\n+\t/* or */\n+\t\"|\"\n+\t/* a variable declaration with const, let, or var */\n+\t\"^(const|let|var)[ \\\\t]+[a-zA-Z_][a-zA-Z0-9_]*[ \\\\t]*=\"\n+\t\")\",\n+\t/* -- */\n+\t\"[a-zA-Z_][a-zA-Z0-9_]*\"),\n { .name = \"default\", .binary = -1 },\n };\n #undef PATTERNS\n-- \ngitgitgadget\n"},{"id":"540306","messageId":"xmqqtstzh3f1.fsf@gitster.g","threadId":"65378","inReplyTo":"pull.2251.git.git.1774734004.gitgitgadget@gmail.com","subject":"Re: [PATCH 0/2] [GSoC] userdiff: adding typescript pattern","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-29T00:42:26Z","receivedAt":"2026-03-29T00:42:29Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":null},"body":"\"Dhruv Arora via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> Description\n> ===========\n>\n>  * Add builtin userdiff pattern for TypeScript files. Recognizes function\n>    declarations, class definitions, arrow functions, and method definitions.\n>    \n>    * Handles common modifiers like export, async, static, etc\n>\n>  * Added tests for the typescript pattern in userdiff.\n>\n> Dhruv Arora (2):\n>   userdiff: adding typescript pattern\n>   fix(userdiff): sorted pattern and tests\n\nWe frown upon a patch series that makes mistakes in an earlier step,\nonly to fix them in a later step.  The \"git rebase -i\" command helps\nus pretend to be more perfect developers than we actually are,\nwhipping your patch series into a shape that builds one small step\non top of another in a logical succession.  Such a patch series is\neasier to understand than a history that faithfully records all the\nstumbles the developer made until they reached the final solution.\n\nJust have a single patch that adds the right pattern at the right\nplace and add necessary tests.\n\nWhen/if your reviewers suggest further changes, the way you should\nwork on them is the same.  Pretend as if you discarded everything\nyou did, started from scratch, and reached the ideal result without\nmaking any mistakes or taking any detours along the way.\n\nThanks.\n\n>  t/t4018/typescript-class-method         |  7 +++++++\n>  t/t4018/typescript-export-default-class |  7 +++++++\n>  t/t4018/typescript-export-function      |  7 +++++++\n>  userdiff.c                              | 15 +++++++++++++++\n>  4 files changed, 36 insertions(+)\n>  create mode 100644 t/t4018/typescript-class-method\n>  create mode 100644 t/t4018/typescript-export-default-class\n>  create mode 100644 t/t4018/typescript-export-function\n>\n>\n> base-commit: ce74208c2fa13943fffa58f168ac27a76d0eb789\n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2251%2FDhruv-0-Arora%2Fuserdiff%2Ftypescript-pattern-v1\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2251/Dhruv-0-Arora/userdiff/typescript-pattern-v1\n> Pull-Request: https://github.com/git/git/pull/2251\n"},{"id":"540316","messageId":"08f1c2b1-5f2c-40e9-ba87-f45cae6af541@kdbg.org","threadId":"65378","inReplyTo":"pull.2251.git.git.1774734004.gitgitgadget@gmail.com","subject":"Re: [PATCH 0/2] [GSoC] userdiff: adding typescript pattern","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2026-03-29T09:31:43Z","receivedAt":"2026-03-29T09:31:53Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":null},"body":"Am 28.03.26 um 22:40 schrieb Dhruv Arora via GitGitGadget:\n> \n> Description\n> ===========\n> \n>  * Add builtin userdiff pattern for TypeScript files. Recognizes function\n>    declarations, class definitions, arrow functions, and method definitions.\n>    \n>    * Handles common modifiers like export, async, static, etc\n> \n>  * Added tests for the typescript pattern in userdiff.\n> \n> Dhruv Arora (2):\n>   userdiff: adding typescript pattern\n>   fix(userdiff): sorted pattern and tests\n> \n>  t/t4018/typescript-class-method         |  7 +++++++\n>  t/t4018/typescript-export-default-class |  7 +++++++\n>  t/t4018/typescript-export-function      |  7 +++++++\n>  userdiff.c                              | 15 +++++++++++++++\n>  4 files changed, 36 insertions(+)\n>  create mode 100644 t/t4018/typescript-class-method\n>  create mode 100644 t/t4018/typescript-export-default-class\n>  create mode 100644 t/t4018/typescript-export-function\n> \n> \n> base-commit: ce74208c2fa13943fffa58f168ac27a76d0eb789\n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2251%2FDhruv-0-Arora%2Fuserdiff%2Ftypescript-pattern-v1\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2251/Dhruv-0-Arora/userdiff/typescript-pattern-v1\n> Pull-Request: https://github.com/git/git/pull/2251\n\nJavascript and Typescript are related languages, if I am not mistaken.\nIt would be appreciated if the new language driver could be used for\nboth. Then the driver's name should be the superset language and the\ndocumentation (missing, BTW) should mention that the driver can be used\nfor both languages.\n\nWe have had a number of submissions for Javascript or Typescript drivers\nin the past, but none of them were followed through to be integrated.\n\nTypescript:\n\nhttps://lore.kernel.org/git/20240404163827.5855-1-utsavp0213@gmail.com/\nhttps://lore.kernel.org/git/pull.1746.git.git.1721061218993.gitgitgadget@gmail.com/\n\nJavascript:\n\nhttps://lore.kernel.org/git/20240301074048.188835-1-sergiusnyah@gmail.com/\nhttps://lore.kernel.org/git/20220403132508.28196-1-a97410985new@gmail.com/\nhttps://lore.kernel.org/git/20250604094100.80598-1-derick.william.moraes@gmail.com/\n\nPlease review these submission and the responses that they received.\nPerhaps you can find inspiration for improvement from them.\n\n-- Hannes\n\n"},{"id":"540327","messageId":"74C8BE85-4731-4C02-872D-DFB65D9AA3FB@gmail.com","threadId":"65378","inReplyTo":"08f1c2b1-5f2c-40e9-ba87-f45cae6af541@kdbg.org","subject":"Spelling JavaScript (was: Re: [PATCH 0/2] [GSoC] userdiff: adding typescript pattern)","fromName":"Ben Knoble","fromEmail":"ben.knoble@gmail.com","sentAt":"2026-03-29T14:39:44Z","receivedAt":"2026-03-29T14:39:56Z","isPatch":true,"sender":{"key":"ben.knoble@gmail.com","avatar":null},"body":"\n> Le 29 mars 2026 à 05:32, Johannes Sixt <j6t@kdbg.org> a écrit :\n> \n> Javascript and Typescript are related languages, if I am not mistaken.\n> \n> -- Hannes\n\nFWIW, I believe both languages are officially spelled with a capital S: “JavaScript”, “TypeScript”. At least that is how Wikipedia and official sites present them.\n\nI knew what you meant of course, and will now take my pedant hat off ;)"}]}