qemu-trivial
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] gitattributes: Cover Objective-C source files


From: Akihiko Odaki
Subject: Re: [PATCH] gitattributes: Cover Objective-C source files
Date: Sat, 19 Mar 2022 23:03:22 +0900
User-agent: Mozilla/5.0 (X11; Linux aarch64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0

On 2022/03/19 22:49, Philippe Mathieu-Daudé wrote:
On 19/3/22 04:25, Akihiko Odaki wrote:
On 2022/03/19 1:14, Philippe Mathieu-Daudé wrote:
Commit 29cf16db23 says:
Since commits 0979ed017f0 ("meson: rename .inc.h files to .h.inc")
and 139c1837db7 ("meson: rename included C source files to .c.inc")
'git-diff --function-context' stopped displaying C function context
correctly.

So I suspect Git has some knowledge of common file extensions like .c, .h and .m although I couldn't find in the source code of Git.

'git-diff --function-context' doesn't work for me without this change.

With some debugging, I found Apple's Git distribution actually carries a default gitattributes file which annotates *.m.
https://github.com/apple-opensource/Git/blob/master/gitattributes

I see, I'm using the Homebrew git. Anyway this change helps non-native
Darwin users to review these .m files.

However, it does not annotate *.c or *.h. Apparently there is no "c" diff pattern and they are handled with the "default" diff pattern which is actually designed for C. In fact, "c" diff pattern is not present in the documentation:
https://git-scm.com/docs/gitattributes#_defining_an_external_diff_driver

'cpp' is listed. Maybe 'c' is aliased to it?

I don't think so. The string 'cpp' is rare in Git code base and I still couldn't find such code.


In conclusion, *.m should be listed in gitattributes but *.c.inc and *.h.inc should not be if my understanding is correct.

But then how git-tools can detect .inc are C files? I remember it was
not working (on Linux hosts) without this change.

It doesn't have to. If files are not listed in gitattributes, it simply applies the "default" diff pattern, which works with C.

I can confirm removing *.c.inc and *.h.inc from gitattributes does not affect the output of git diff -W on git version 2.35.1 which comes with Fedora.

Regards,
Akihiko Odaki


Paolo Bonzini, I found you are the author of commit 29cf16db23. Can you test the above conclusion?

Regards,
Akihiko Odaki





reply via email to

[Prev in Thread] Current Thread [Next in Thread]