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@xxxxxxxxx> --- t/t4018/python-async-def | 4 ++++ t/t4018/python-class | 4 ++++ t/t4018/python-def | 4 ++++ userdiff.c | 2 +- 4 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 t/t4018/python-async-def create mode 100644 t/t4018/python-class create mode 100644 t/t4018/python-def diff --git a/t/t4018/python-async-def b/t/t4018/python-async-def new file mode 100644 index 000000000..87640e03d --- /dev/null +++ b/t/t4018/python-async-def @@ -0,0 +1,4 @@ +async def RIGHT(pi: int = 3.14): + while True: + break + return ChangeMe() diff --git a/t/t4018/python-class b/t/t4018/python-class new file mode 100644 index 000000000..ba9e74143 --- /dev/null +++ b/t/t4018/python-class @@ -0,0 +1,4 @@ +class RIGHT(int, str): + # comment + # another comment + # ChangeMe diff --git a/t/t4018/python-def b/t/t4018/python-def new file mode 100644 index 000000000..e50b31b0a --- /dev/null +++ b/t/t4018/python-def @@ -0,0 +1,4 @@ +def RIGHT(pi: int = 3.14): + while True: + break + return ChangeMe() diff --git a/userdiff.c b/userdiff.c index e74a6d402..057fdcc55 100644 --- a/userdiff.c +++ b/userdiff.c @@ -124,7 +124,7 @@ PATTERNS("php", "[a-zA-Z_][a-zA-Z0-9_]*" "|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+" "|[-+*/<>%&^|=!.]=|--|\\+\\+|<<=?|>>=?|===|&&|\\|\\||::|->"), -PATTERNS("python", "^[ \t]*((class|def)[ \t].*)$", +PATTERNS("python", "^[ \t]*((class|(async[ \t]+)?def)[ \t].*)$", /* -- */ "[a-zA-Z_][a-zA-Z0-9_]*" "|[-+0-9.e]+[jJlL]?|0[xX]?[0-9a-fA-F]+[lL]?" -- 2.24.0