From: Alejandro Colomar <alx.manpages@gmail.com>
To: Andrew Clayton <a.clayton@nginx.com>,
Git Mailing List <git@vger.kernel.org>
Cc: Alejandro Colomar <alx@nginx.com>
Subject: Re: [PATCH] Set git diff driver for C source code files.
Date: Tue, 25 Oct 2022 21:26:55 +0200 [thread overview]
Message-ID: <242e6a00-a2ad-4b7b-3643-41cf49d4432a@gmail.com> (raw)
In-Reply-To: <20221025191552.60658-1-a.clayton@nginx.com>
[-- Attachment #1.1: Type: text/plain, Size: 1564 bytes --]
Hi Andrew,
On 10/25/22 21:15, Andrew Clayton wrote:
> Git can be told to apply language-specific rules when generating diffs.
> Enable this for C source code files (*.c and *.h) so that function names
> are printed right. Specifically, doing so prevents "git diff" from
> mistakenly considering unindented goto labels as function names.
>
> This has the same effect as adding
>
> [diff "default"]
> xfuncname = "^[[:alpha:]$_].*[^:]$"
Where does that regex come from?
>
> to your git config file.
>
> e.g get
>
> @@ -10,7 +10,7 @@ int main(void)
>
> instead of
>
> @@ -10,7 +10,7 @@ again:
>
> This makes use of the gitattributes(5) infrastructure.
>
> Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
Wow! git(1) is showing C functions incorrectly?! The last language I expected
this to happen with. I had to use this for man(7) pages, but for C files?!
I mean, we have one of the simplest and most consistent coding styles I've seen
regarding placement of function definitions (no false negatives or positives in
grepc(1)).
Should we report a bug to <mailto:Git <git@vger.kernel.org>> too :)
> ---
> .gitattributes | 2 ++
> 1 file changed, 2 insertions(+)
> create mode 100644 .gitattributes
>
> diff --git a/.gitattributes b/.gitattributes
> new file mode 100644
> index 00000000..45ec5156
> --- /dev/null
> +++ b/.gitattributes
> @@ -0,0 +1,2 @@
> +*.c diff=cpp
> +*.h diff=cpp
Why cpp?
Thanks,
Alex
--
<http://www.alejandro-colomar.es/>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
parent reply other threads:[~2022-10-25 19:27 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20221025191552.60658-1-a.clayton@nginx.com>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=242e6a00-a2ad-4b7b-3643-41cf49d4432a@gmail.com \
--to=alx.manpages@gmail.com \
--cc=a.clayton@nginx.com \
--cc=alx@nginx.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).