{"thread":{"id":"58689","subject":"Re: [PATCH] Set git diff driver for C source code files.","startedAt":"2022-10-25T19:27:11Z","lastAt":"2022-10-25T19:27:11Z","messageCount":1,"participants":["Alejandro Colomar"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"465727","messageId":"242e6a00-a2ad-4b7b-3643-41cf49d4432a@gmail.com","threadId":"58689","inReplyTo":"20221025191552.60658-1-a.clayton@nginx.com","subject":"Re: [PATCH] Set git diff driver for C source code files.","fromName":"Alejandro Colomar","fromEmail":"alx.manpages@gmail.com","sentAt":"2022-10-25T19:26:55Z","receivedAt":"2022-10-25T19:27:11Z","isPatch":true,"sender":{"key":"alx.manpages@gmail.com","avatar":null},"body":"Hi Andrew,\n\nOn 10/25/22 21:15, Andrew Clayton wrote:\n> Git can be told to apply language-specific rules when generating diffs.\n> Enable this for C source code files (*.c and *.h) so that function names\n> are printed right. Specifically, doing so prevents \"git diff\" from\n> mistakenly considering unindented goto labels as function names.\n> \n> This has the same effect as adding\n> \n>      [diff \"default\"]\n>          xfuncname = \"^[[:alpha:]$_].*[^:]$\"\n\nWhere does that regex come from?\n\n> \n> to your git config file.\n> \n> e.g get\n> \n>      @@ -10,7 +10,7 @@ int main(void)\n> \n> instead of\n> \n>      @@ -10,7 +10,7 @@ again:\n> \n> This makes use of the gitattributes(5) infrastructure.\n> \n> Signed-off-by: Andrew Clayton <a.clayton@nginx.com>\n\nWow!  git(1) is showing C functions incorrectly?!  The last language I expected \nthis to happen with.  I had to use this for man(7) pages, but for C files?!\n\nI mean, we have one of the simplest and most consistent coding styles I've seen \nregarding placement of function definitions (no false negatives or positives in \ngrepc(1)).\n\nShould we report a bug to <mailto:Git <git@vger.kernel.org>> too :)\n\n> ---\n>   .gitattributes | 2 ++\n>   1 file changed, 2 insertions(+)\n>   create mode 100644 .gitattributes\n> \n> diff --git a/.gitattributes b/.gitattributes\n> new file mode 100644\n> index 00000000..45ec5156\n> --- /dev/null\n> +++ b/.gitattributes\n> @@ -0,0 +1,2 @@\n> +*.c\tdiff=cpp\n> +*.h\tdiff=cpp\n\nWhy cpp?\n\nThanks,\n\nAlex\n\n-- \n<http://www.alejandro-colomar.es/>\n"}]}