Git fork

userdiff: support Python async functions

Python's async functions (declared with "async def" rather than "def")
were not being displayed in hunk headers. This commit teaches git about
the async function syntax, and adds tests for the Python userdiff regex.

Signed-off-by: Josh Holland <anowlcalledjosh@gmail.com>
Acked-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Josh Holland and committed by
Junio C Hamano
077a1fda 5fa0f523

+32 -1
+4
t/t4018/python-async-def
··· 1 + async def RIGHT(pi: int = 3.14): 2 + while True: 3 + break 4 + return ChangeMe()
+4
t/t4018/python-class
··· 1 + class RIGHT(int, str): 2 + # comment 3 + # another comment 4 + # ChangeMe
+4
t/t4018/python-def
··· 1 + def RIGHT(pi: int = 3.14): 2 + while True: 3 + break 4 + return ChangeMe()
+7
t/t4018/python-indented-async-def
··· 1 + class Foo: 2 + async def RIGHT(self, x: int): 3 + return [ 4 + 1, 5 + 2, 6 + ChangeMe, 7 + ]
+5
t/t4018/python-indented-class
··· 1 + if TYPE_CHECKING: 2 + class RIGHT: 3 + # comment 4 + # another comment 5 + # ChangeMe
+7
t/t4018/python-indented-def
··· 1 + class Foo: 2 + def RIGHT(self, x: int): 3 + return [ 4 + 1, 5 + 2, 6 + ChangeMe, 7 + ]
+1 -1
userdiff.c
··· 124 124 "[a-zA-Z_][a-zA-Z0-9_]*" 125 125 "|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+" 126 126 "|[-+*/<>%&^|=!.]=|--|\\+\\+|<<=?|>>=?|===|&&|\\|\\||::|->"), 127 - PATTERNS("python", "^[ \t]*((class|def)[ \t].*)$", 127 + PATTERNS("python", "^[ \t]*((class|(async[ \t]+)?def)[ \t].*)$", 128 128 /* -- */ 129 129 "[a-zA-Z_][a-zA-Z0-9_]*" 130 130 "|[-+0-9.e]+[jJlL]?|0[xX]?[0-9a-fA-F]+[lL]?"