Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 272
Alan2 Avatar asked Jan 26 '15 07:01

Alan2


Video Answer


1 Answers

TL;DR

  • diff=astextplain (msysGit only): converts those files (under the condition that their extension be *.doc, *.pdf, *.rtf, etc.) to a text format before generating their diff.
  • diff: treat those files as plain text for generating their diff.
  • text=auto: automatically normalize EOL characters (to LF) in files deemed to be text files by Git.

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

  • Word documents,
  • PDF,
  • RTF

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.

like image 71
jub0bs Avatar answered Oct 16 '22 16:10

jub0bs