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

Re: [PATCH v2] userdiff: add support for Swift

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 21, 2026, 19:33 UTC
Message-ID
<xmqqmrvkw31z.fsf@gitster.g>
In-Reply-To
<20260721065736.8747-1-diy2903@gmail.com>
Shlok Kulshreshtha <diy2903@gmail.com> writes:
Show 30 quoted lines
> Add a built-in userdiff driver for the Swift programming language so that
> diff hunk headers and word diffs work out of the box for ".swift" files.
>
> The funcname pattern is built for Swift's own declaration grammar: an
> optional run of attributes ("@objc", "@available(iOS 13, *)", ...),
> followed by an optional run of lowercase modifiers ("public", "static",
> "final", ...), followed by a declaration keyword (func, class, struct,
> enum, protocol, extension, actor, init, deinit, subscript). The keyword
> is followed by a boundary that allows whitespace, "(" (init/subscript),
> "?" or "!" (failable init), or "<" (generics), while still acting as a
> word boundary so e.g. "initialize(" does not match.
>
> The word regex recognizes Swift identifiers, hexadecimal, octal, binary,
> integer and floating-point literals, and the language's operators.
>
> Signed-off-by: Shlok Kulshreshtha <diy2903@gmail.com>
> ---
> v2, addressing Johannes Sixt's review of v1
> (<2a3a73c5-5e90-44a3-bf6a-6e98ce5e5a59@kdbg.org>).  Changes since v1:
>
>  - t4018/swift-{init,failable-init,generic-subscript}: "RIGHT" now
>    appears only once, on the declaration line, so the expected header is
>    unambiguous.
>  - word regex: dropped the redundant "?" after the single-character
>    operator class.  Single characters are already covered by the
>    "|[^[:space:]]" fallback that the PATTERNS macro appends, so only the
>    two-character forms need to be spelled out.
>
> (A couple of Hannes's other suggestions I kept as-is; I have explained
> the reasoning in a reply to his review.)
Thanks for an update.

Let's wait for a few days to see if we hear more comments and otherwise mark the topic for 'next'.

Previous: Shlok KulshreshthaNext: Johannes Sixt
Message 8 of 12 in “userdiff: add support for Swift”
  1. userdiff: add support for SwiftShlok Kulshreshtha, Jul 17, 2026
  2. Junio C HamanoJul 17, 2026
  3. Johannes SixtJul 18, 2026
  4. Junio C HamanoJul 20, 2026
  5. Johannes SixtJul 20, 2026
  6. Shlok KulshreshthaJul 20, 2026
  7. userdiff: add support for SwiftShlok Kulshreshtha, Jul 21, 2026
  8. Junio C HamanoJul 21, 2026
  9. Johannes SixtJul 23, 2026
  10. Michael MontalboJul 27, 2026
  11. Johannes SixtJul 27, 2026
  12. Michael MontalboJul 27, 2026

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.