{"thread":{"id":"60709","subject":"Add more builtin patterns for userdiff, as Microproject.","startedAt":"2024-01-09T19:54:19Z","lastAt":"2024-01-09T19:54:19Z","messageCount":1,"participants":["Sergius Nyah"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"486467","messageId":"CANAnif8L3+CoVdvcUntWz_JoDvubityXPsouLqgvca=BrtqR8g@mail.gmail.com","threadId":"60709","inReplyTo":null,"subject":"Add more builtin patterns for userdiff, as Microproject.","fromName":"Sergius Nyah","fromEmail":"sergiusnyah@gmail.com","sentAt":"2024-01-09T19:54:07Z","receivedAt":"2024-01-09T19:54:19Z","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 with 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"}]}