gitattributes: Cover Objective-C source files
PATCH 1/1 gitattributes: Cover Objective-C source files
From: Philippe Mathieu-Daudé <[email protected]>
See comments in commit 29cf16db23 ("buildsys: Help git-diff adding .gitattributes config file") for details.
--- .gitattributes | 1 + 1 file changed, 1 insertion(+)
.gitattributes +1 -0
@@ -1,3 +1,4 @@ *.c.inc diff=c *.h.inc diff=c +*.m diff=objc *.py diff=python
Signature · 1 line
2.34.1
+qemu-trivial@
Quoted 19 lines · Philippe Mathieu-Daudé
From: Philippe Mathieu-Daudé <[email protected]>
See comments in commit
29cf16db23("buildsys: Help git-diff adding .gitattributes config file") for details.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- .gitattributes | 1 + 1 file changed, 1 insertion(+).gitattributes +1
-0@@ -1,3 +1,4 @@ *.c.inc diff=c *.h.inc diff=c +*.m diff=objc *.py diff=python
I don't think this is needed. I could see a diff annotated with a method name even without this change:
% git diff
ui/cocoa.m +1 -0
@@ -1264,6 +1264,7 @@ - (id) init [pauseLabel setTextColor: [NSColor blackColor]]; [pauseLabel sizeToFit]; } + // return self; }
Commit 29cf16db23 says:
Quoted 4 lines
Since commits
0979ed017f0("meson: rename.inc.hfiles to .h.inc") and139c1837db7("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.
Regards,
Akihiko Odaki
Quoted 23 lines · Philippe Mathieu-Daudé
+qemu-trivial@
Quoted 19 lines · Philippe Mathieu-Daudé
From: Philippe Mathieu-Daudé <[email protected]>
See comments in commit
29cf16db23("buildsys: Help git-diff adding .gitattributes config file") for details.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
.gitattributes | 1 +1 file changed, 1 insertion(+).gitattributes +1
-0@@ -1,3 +1,4 @@ *.c.inc diff=c *.h.inc diff=c +*.m diff=objc *.py diff=python
Quoted 15 lines · Akihiko Odaki
I don't think this is needed. I could see a diff annotated with a method name even without this change:
% git diffui/cocoa.m +1
-0@@ -1264,6 +1264,7 @@ - (id) init [pauseLabel setTextColor: [NSColor blackColor]]; [pauseLabel sizeToFit]; } + // return self; }Commit
29cf16db23says:
Quoted 6 lines
Quoted 4 lines
Since commits
0979ed017f0("meson: rename.inc.hfiles to .h.inc") and139c1837db7("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.
Quoted 9 lines · Philippe Mathieu-Daudé
Quoted 7 lines
Commit
29cf16db23says:Quoted 4 lines
Since commits
0979ed017f0("meson: rename.inc.hfiles to .h.inc") and139c1837db7("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
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
In conclusion, *.m should be listed in gitattributes but *.c.inc and *.h.inc should not be if my understanding is correct.
Paolo Bonzini, I found you are the author of commit 29cf16db23. Can you test the above conclusion?
Regards,
Akihiko Odaki
Quoted 7 lines · Akihiko Odaki
Quoted 6 lines · Philippe Mathieu-Daudé
Quoted 6 lines
Commit
29cf16db23says:Quoted 4 lines
Since commits
0979ed017f0("meson: rename.inc.hfiles to .h.inc") and139c1837db7("meson: rename included C source files to .c.inc") 'git-diff --function-context' stopped displaying C function context correctly.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
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.
Quoted 2 lines
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?
Quoted 1 line
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.
Quoted 4 lines
Paolo Bonzini, I found you are the author of commit
29cf16db23. Can you test the above conclusion?Regards,
Akihiko Odaki
Quoted 15 lines · Philippe Mathieu-Daudé
Quoted 7 lines · Akihiko Odaki
Quoted 6 lines · Philippe Mathieu-Daudé
Quoted 6 lines
Commit
29cf16db23says:Quoted 4 lines
Since commits
0979ed017f0("meson: rename.inc.hfiles to .h.inc") and139c1837db7("meson: rename included C source files to .c.inc") 'git-diff --function-context' stopped displaying C function context correctly.Quoted 6 lines
Quoted 3 lines
Quoted 1 line
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
Quoted 7 lines
I see, I'm using the Homebrew git. Anyway this change helps non-native Darwin users to review these .m files.
Quoted 2 lines
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.
Quoted 5 lines
Quoted 2 lines
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
Quoted 6 lines
Quoted 5 lines
Paolo Bonzini, I found you are the author of commit
29cf16db23. Can you test the above conclusion?Regards,
Akihiko Odaki
Quoted 7 lines · On Donnerstag, 17. März 2022 14:03:26 CET Philippe Mathieu-Daudé wrote:
From: Philippe Mathieu-Daudé <[email protected]>
See comments in commit
29cf16db23("buildsys: Help git-diff adding .gitattributes config file") for details.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
Quoted 12 lines
.gitattributes | 1 + 1 file changed, 1 insertion(+).gitattributes +1
-0@@ -1,3 +1,4 @@ *.c.inc diff=c *.h.inc diff=c +*.m diff=objc *.py diff=python
Quoted 9 lines · Philippe Mathieu-Daudé
From: Philippe Mathieu-Daudé <[email protected]>
See comments in commit
29cf16db23("buildsys: Help git-diff adding .gitattributes config file") for details.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- .gitattributes | 1 + 1 file changed, 1 insertion(+)
Not a fix bug queued to darwin-fixes.