{"thread":{"id":"28171","subject":"How to use .gitattributes to tell git that .ini is text file?","startedAt":"2011-08-20T02:06:45Z","lastAt":"2011-08-20T09:59:26Z","messageCount":2,"participants":["jelly","Chris Packham"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"173907","messageId":"bfe44ee.e467.131e4f0b471.Coremail.sinojelly@163.com","threadId":"28171","inReplyTo":null,"subject":"How to use .gitattributes to tell git that .ini is text file?","fromName":"jelly","fromEmail":"sinojelly@163.com","sentAt":"2011-08-20T02:06:45Z","receivedAt":"2011-08-20T02:06:45Z","isPatch":false,"sender":{"key":"sinojelly@163.com","avatar":"https://gravatar.com/avatar/b0b62bbb9960cfe61ba2b4ccf035442f1117f9c56a31dfb60c543ba7f59956a1?d=mp&s=160"},"body":"When I use like this, it takes no effect.\nC:\\Users\\jelly\\Documents\\My Knowledge\\Plugins>cat .gitattributes*.ini     text\nC:\\Users\\jelly\\Documents\\My Knowledge\\Plugins>git diffdiff --git a/Misc/plugin.ini b/Misc/plugin.iniindex 078c8a9..f73153c 100755Binary files a/Misc/plugin.ini and b/Misc/plugin.ini differ\n"},{"id":"173913","messageId":"4E4F857E.9030907@gmail.com","threadId":"28171","inReplyTo":"bfe44ee.e467.131e4f0b471.Coremail.sinojelly@163.com","subject":"Re: How to use .gitattributes to tell git that .ini is text file?","fromName":"Chris Packham","fromEmail":"judge.packham@gmail.com","sentAt":"2011-08-20T09:59:26Z","receivedAt":"2011-08-20T09:59:26Z","isPatch":false,"sender":{"key":"judge.packham@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155667?v=4"},"body":"On 20/08/11 14:06, jelly wrote:\n> When I use like this, it takes no effect.\n> C:\\Users\\jelly\\Documents\\My Knowledge\\Plugins>cat .gitattributes*.ini     text\n> C:\\Users\\jelly\\Documents\\My Knowledge\\Plugins>git diffdiff --git a/Misc/plugin.ini b/Misc/plugin.iniindex 078c8a9..f73153c 100755Binary files a/Misc/plugin.ini and b/Misc/plugin.ini differ\n\nI think you might be running into some problems with the end of line\ndetection. What git version are you running? I think what you want in\n.gitattributes is '*.ini diff' (see below)\n\nI did some quick tests with 1.7.5 and I seem to get sane behaviour\nwithout needing .gitattributes\n\n  printf '\\r\\nfoo\\r\\n' > foo.ini\n  git commit -m\"\" foo.ini\n\n  # change content\n  printf '\\r\\nbar\\r\\n' > foo.ini\n  git diff\n  diff --git a/foo.ini b/foo.ini\n  index 35c61a9..b2b98e6 100644\n  --- a/foo.ini\n  +++ b/foo.ini\n  @@ -1,2 +1,2 @@\n\n  -foo\n  +bar\n\n  # insert non-printable character\n  printf '\\nbar\\0\\n' > foo.ini\n  git diff\n  diff --git a/foo.ini b/foo.ini\n  index 35c61a9..aff5caf 100644\n  Binary files a/foo.ini and b/foo.ini differ\n\nEven with the binary content I can tell git diff to treat the files as\ntext (not that you can see it in the email but with less as my pager I\nactually get an indication that there is a funny character there)\n\n  git diff -a\n  diff --git a/foo.ini b/foo.ini\n  index 35c61a9..aff5caf 100644\n  --- a/foo.ini\n  +++ b/foo.ini\n  @@ -1,2 +1,2 @@\n  -\n  -foo\n  +\n  +bar\n\nIf you want to tell git diff to always use the -a option for .ini files\ntry this\n\n  echo '*.ini diff' > .gitattributes\n  git diff\n  diff --git a/foo.ini b/foo.ini\n  index 35c61a9..aff5caf 100644\n  --- a/foo.ini\n  +++ b/foo.ini\n  @@ -1,2 +1,2 @@\n  -\n  -foo\n  +\n  +bar\n"}]}