gitgitattributes

What is the difference between diff and diff=astextplain?


Can someone help me. I am using Git (GitHub) and trying to decide what to set my *.sql files to in the gitattributes. I've seen people use

*.sql diff=astextplain
*.sql diff
*.sql text=auto

I was advised to set this to the second option, but I am just wondering what is the difference between that and the other two.


Solution

  • TL;DR

    More details

    diff=astextplain

    The string value astextplain is not part of Git core: in fact, running

    git grep "astextplain"
    

    in the Git project repository returns nothing. As far as I can tell, it's a shell script that ships with msysGit and allows you to convert files such as

    to a text format before generating their diff.

    diff

    According to the gitattributes man page:

    The attribute diff affects how Git generates diffs for particular files. [...]

    A path to which the diff attribute is set is treated as text, even when they contain byte values that normally never appear in text files, such as NUL.

    text=auto

    According to the gitattributes man page:

    When text is set to "auto", the path is marked for automatic end-of-line normalization. If Git decides that the content is text, its line endings are normalized to LF on checkin.