{"thread":{"id":"52294","subject":"[PATCH v2] userdiff: support Python async functions","startedAt":"2019-11-19T15:09:44Z","lastAt":"2019-11-20T06:49:01Z","messageCount":3,"participants":["Josh Holland","Junio C Hamano","Johannes Sixt"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"386520","messageId":"20191119150807.8206-1-anowlcalledjosh@gmail.com","threadId":"52294","inReplyTo":null,"subject":"[PATCH v2] userdiff: support Python async functions","fromName":"Josh Holland","fromEmail":"anowlcalledjosh@gmail.com","sentAt":"2019-11-19T15:08:10Z","receivedAt":"2019-11-19T15:09:44Z","isPatch":true,"sender":{"key":"anowlcalledjosh@gmail.com","avatar":null},"body":"Python's async functions (declared with \"async def\" rather than \"def\")\nwere not being displayed in hunk headers. This commit teaches git about\nthe async function syntax, and adds tests for the Python userdiff regex.\n\nSigned-off-by: Josh Holland <anowlcalledjosh@gmail.com>\n---\nThis patch now includes tests for indented declarations, as well as the\nunindented versions which were present before. Apologies for the delay\nin preparing this patch.\n\n t/t4018/python-async-def          | 4 ++++\n t/t4018/python-class              | 4 ++++\n t/t4018/python-def                | 4 ++++\n t/t4018/python-indented-async-def | 7 +++++++\n t/t4018/python-indented-class     | 5 +++++\n t/t4018/python-indented-def       | 7 +++++++\n userdiff.c                        | 2 +-\n 7 files changed, 32 insertions(+), 1 deletion(-)\n create mode 100644 t/t4018/python-async-def\n create mode 100644 t/t4018/python-class\n create mode 100644 t/t4018/python-def\n create mode 100644 t/t4018/python-indented-async-def\n create mode 100644 t/t4018/python-indented-class\n create mode 100644 t/t4018/python-indented-def\n\ndiff --git a/t/t4018/python-async-def b/t/t4018/python-async-def\nnew file mode 100644\nindex 000000000..87640e03d\n--- /dev/null\n+++ b/t/t4018/python-async-def\n@@ -0,0 +1,4 @@\n+async def RIGHT(pi: int = 3.14):\n+    while True:\n+        break\n+    return ChangeMe()\ndiff --git a/t/t4018/python-class b/t/t4018/python-class\nnew file mode 100644\nindex 000000000..ba9e74143\n--- /dev/null\n+++ b/t/t4018/python-class\n@@ -0,0 +1,4 @@\n+class RIGHT(int, str):\n+    # comment\n+    # another comment\n+    # ChangeMe\ndiff --git a/t/t4018/python-def b/t/t4018/python-def\nnew file mode 100644\nindex 000000000..e50b31b0a\n--- /dev/null\n+++ b/t/t4018/python-def\n@@ -0,0 +1,4 @@\n+def RIGHT(pi: int = 3.14):\n+    while True:\n+        break\n+    return ChangeMe()\ndiff --git a/t/t4018/python-indented-async-def b/t/t4018/python-indented-async-def\nnew file mode 100644\nindex 000000000..f5d03258a\n--- /dev/null\n+++ b/t/t4018/python-indented-async-def\n@@ -0,0 +1,7 @@\n+class Foo:\n+    async def RIGHT(self, x: int):\n+        return [\n+            1,\n+            2,\n+            ChangeMe,\n+        ]\ndiff --git a/t/t4018/python-indented-class b/t/t4018/python-indented-class\nnew file mode 100644\nindex 000000000..19b4f35c4\n--- /dev/null\n+++ b/t/t4018/python-indented-class\n@@ -0,0 +1,5 @@\n+if TYPE_CHECKING:\n+    class RIGHT:\n+        # comment\n+        # another comment\n+        # ChangeMe\ndiff --git a/t/t4018/python-indented-def b/t/t4018/python-indented-def\nnew file mode 100644\nindex 000000000..208fbadd2\n--- /dev/null\n+++ b/t/t4018/python-indented-def\n@@ -0,0 +1,7 @@\n+class Foo:\n+    def RIGHT(self, x: int):\n+        return [\n+            1,\n+            2,\n+            ChangeMe,\n+        ]\ndiff --git a/userdiff.c b/userdiff.c\nindex e187d356f..3fd324e61 100644\n--- a/userdiff.c\n+++ b/userdiff.c\n@@ -133,7 +133,7 @@ PATTERNS(\"php\",\n \t \"[a-zA-Z_][a-zA-Z0-9_]*\"\n \t \"|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+\"\n \t \"|[-+*/<>%&^|=!.]=|--|\\\\+\\\\+|<<=?|>>=?|===|&&|\\\\|\\\\||::|->\"),\n-PATTERNS(\"python\", \"^[ \\t]*((class|def)[ \\t].*)$\",\n+PATTERNS(\"python\", \"^[ \\t]*((class|(async[ \\t]+)?def)[ \\t].*)$\",\n \t /* -- */\n \t \"[a-zA-Z_][a-zA-Z0-9_]*\"\n \t \"|[-+0-9.e]+[jJlL]?|0[xX]?[0-9a-fA-F]+[lL]?\"\n-- \n2.24.0\n\n"},{"id":"386608","messageId":"xmqqeey3ci61.fsf@gitster-ct.c.googlers.com","threadId":"52294","inReplyTo":"20191119150807.8206-1-anowlcalledjosh@gmail.com","subject":"Re: [PATCH v2] userdiff: support Python async functions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-11-20T03:59:02Z","receivedAt":"2019-11-20T03:59:09Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Josh Holland <anowlcalledjosh@gmail.com> writes:\n\n> This patch now includes tests for indented declarations, as well as the\n> unindented versions which were present before.\n\nVery much appreciated.\n\nI wondered if something like\n\ndiff --git a/t/t4018/python-indented-async-def b/t/t4018/python-indented-async-def\nindex f5d03258af..567c1dafcb 100644\n--- a/t/t4018/python-indented-async-def\n+++ b/t/t4018/python-indented-async-def\n@@ -1,3 +1,6 @@\n+async def not_this_one(self):\n+    return []\n+\n class Foo:\n     async def RIGHT(self, x: int):\n         return [\n\nwould further help, but if a breakage makes us ignore a start of\ndefinition that is indented, we would hit \"class Foo:\" you added\nand notice such a breakage anyway, without additional definition\nbefore it.  So I think what we see in this patch is good.\n\nThanks.\n\n> ...\n>  t/t4018/python-indented-async-def | 7 +++++++\n> ...\n> diff --git a/t/t4018/python-indented-async-def b/t/t4018/python-indented-async-def\n> new file mode 100644\n> index 000000000..f5d03258a\n> --- /dev/null\n> +++ b/t/t4018/python-indented-async-def\n> @@ -0,0 +1,7 @@\n> +class Foo:\n> +    async def RIGHT(self, x: int):\n> +        return [\n> +            1,\n> +            2,\n> +            ChangeMe,\n> +        ]\n> ...\n"},{"id":"386617","messageId":"7821ee2c-e778-5760-16d4-eba1a7b64400@kdbg.org","threadId":"52294","inReplyTo":"xmqqeey3ci61.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH v2] userdiff: support Python async functions","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2019-11-20T06:48:55Z","receivedAt":"2019-11-20T06:49:01Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 20.11.19 um 04:59 schrieb Junio C Hamano:\n> Josh Holland <anowlcalledjosh@gmail.com> writes:\n> \n>> This patch now includes tests for indented declarations, as well as the\n>> unindented versions which were present before.\n> \n> Very much appreciated.\n> \n> I wondered if something like\n> \n> diff --git a/t/t4018/python-indented-async-def b/t/t4018/python-indented-async-def\n> index f5d03258af..567c1dafcb 100644\n> --- a/t/t4018/python-indented-async-def\n> +++ b/t/t4018/python-indented-async-def\n> @@ -1,3 +1,6 @@\n> +async def not_this_one(self):\n> +    return []\n> +\n>  class Foo:\n>      async def RIGHT(self, x: int):\n>          return [\n> \n> would further help, but if a breakage makes us ignore a start of\n> definition that is indented, we would hit \"class Foo:\" you added\n> and notice such a breakage anyway, without additional definition\n> before it.  So I think what we see in this patch is good.\n\nGood point raised and fine analysis!\n\nThis patch is\n\nAcked-by: Johannes Sixt <j6t@kdbg.org>\n\n-- Hannes\n"}]}