gitattributes: make diffs easier to read

Andrei Rybak rybak.a.v at
Wed Aug 16 21:26:40 UTC 2023

Hello skara-dev mailing list,

I would like to propose a change to the root .gitattributes file in the
main-line JDK repository, which would make Git produce diffs, which are
slightly nicer to read.  The proposed change is to add:

     *.java  diff=java
     *.c     diff=cpp
     *.h     diff=cpp
     *.cpp   diff=cpp
     *.hpp   diff=cpp
     *.md    diff=markdown
     *.sh    diff=bash
     *.html  diff=html
     *.css   diff=css

to the file.  This list of file extensions and corresponding values for
attribute "diff" was chosen based on the currently available built in
patterns for custom hunk-headers.  For details about the "diff" attribute
and the list of built in patterns see section "Generating diff text" of
`git help gitattributes`, also available online.[1]

As far as I can tell, the only other time .gitattributes files were
edited in the main-line JDK repository is JDK-8241768.[2]  I CC'd people
involved in the development of that issue.  Mailing list skara-dev seemed
like the most appropriate place to "Socialize your change".[3]  Please do
let me know if another mailing list is better suited for this proposal.

The proposed change is also available on GitHub, with an example of
how these hunk-headers will look like in the commit message.[4]

[2] issue:

More information about the skara-dev mailing list