0

In .gitattributes I see things like:

*.htm           text diff=html
*.html          text diff=html
*.java          text diff=java
...                  diff=astextplain

How are those called, diff formats, diff outputs ?

Where is the list of all supported diff formats ?

Christophe Roussy
  • 16,299
  • 4
  • 85
  • 85
  • 1
    Well, a google for "gitattributes diff" provides a very relevant manual page which has a list of built-in ones: https://git-scm.com/docs/gitattributes – Gimby Jul 15 '16 at 13:05
  • @Gimby ^^ ashamed, was probably using find on 'diff=java' or something like that... I stumbled on this link which looked like the big doc: https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes, but had no such list – Christophe Roussy Jul 15 '16 at 13:09
  • Is it reasonable to suppose that `html/xhtml` would work on `xml` too ? – Christophe Roussy Jul 15 '16 at 13:12

1 Answers1

3

Git just refers to these as "attributes" in general, and describes them in the gitattributes documentation. The diff= setting is the "diff attribute", and for whatever reason, the list of built-in attributes is in the section titled Defining a custom hunk-header:

First, in .gitattributes, you would assign the diff attribute for paths.

*.tex   diff=tex

(this is where Git labels this the "diff attribute").

There are a few built-in patterns to make this easier, and tex is one of them, so you do not have to write the above in your configuration file (you still need to enable this with the attribute mechanism, via .gitattributes). The following built in patterns are available: ...

(I won't reproduce the whole list here, which is fairly long. Note that different versions of Git have different built-in patterns, so you should look at the documentation for your specific version of Git, which you should be able to view with git help gitattributes.)

torek
  • 448,244
  • 59
  • 642
  • 775
  • Also here (see comment of Gimby): https://git-scm.com/docs/gitattributes#_defining_a_custom_hunk_header – Christophe Roussy Jul 15 '16 at 13:13
  • Anyone know where to find the specific configurations for these presets? – DylanYoung Nov 05 '19 at 19:09
  • 1
    @DylanYoung: last time I checked, I found them built into the C source. Ah, here they are, in [userdiff.c](https://github.com/git/git/blob/master/userdiff.c). (Er, that is, assuming you mean specifically the `diff=` ones. If you mean attributes in general, Git has ones *it* uses but you can *define* your own and use them for your own purposes, so there is no master list of all attributes.) – torek Nov 05 '19 at 19:40