All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Packham <judge.packham@gmail.com>
To: jelly <sinojelly@163.com>
Cc: "\"Git讨论组(无须订阅)\"" <git@vger.kernel.org>
Subject: Re: How to use .gitattributes to tell git that .ini is text file?
Date: Sat, 20 Aug 2011 21:59:26 +1200	[thread overview]
Message-ID: <4E4F857E.9030907@gmail.com> (raw)
In-Reply-To: <bfe44ee.e467.131e4f0b471.Coremail.sinojelly@163.com>

On 20/08/11 14:06, jelly wrote:
> When I use like this, it takes no effect.
> C:\Users\jelly\Documents\My Knowledge\Plugins>cat .gitattributes*.ini     text
> 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

I think you might be running into some problems with the end of line
detection. What git version are you running? I think what you want in
.gitattributes is '*.ini diff' (see below)

I did some quick tests with 1.7.5 and I seem to get sane behaviour
without needing .gitattributes

  printf '\r\nfoo\r\n' > foo.ini
  git commit -m"" foo.ini

  # change content
  printf '\r\nbar\r\n' > foo.ini
  git diff
  diff --git a/foo.ini b/foo.ini
  index 35c61a9..b2b98e6 100644
  --- a/foo.ini
  +++ b/foo.ini
  @@ -1,2 +1,2 @@

  -foo
  +bar

  # insert non-printable character
  printf '\nbar\0\n' > foo.ini
  git diff
  diff --git a/foo.ini b/foo.ini
  index 35c61a9..aff5caf 100644
  Binary files a/foo.ini and b/foo.ini differ

Even with the binary content I can tell git diff to treat the files as
text (not that you can see it in the email but with less as my pager I
actually get an indication that there is a funny character there)

  git diff -a
  diff --git a/foo.ini b/foo.ini
  index 35c61a9..aff5caf 100644
  --- a/foo.ini
  +++ b/foo.ini
  @@ -1,2 +1,2 @@
  -
  -foo
  +
  +bar

If you want to tell git diff to always use the -a option for .ini files
try this

  echo '*.ini diff' > .gitattributes
  git diff
  diff --git a/foo.ini b/foo.ini
  index 35c61a9..aff5caf 100644
  --- a/foo.ini
  +++ b/foo.ini
  @@ -1,2 +1,2 @@
  -
  -foo
  +
  +bar

      reply	other threads:[~2011-08-20 10:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-20  2:06 How to use .gitattributes to tell git that .ini is text file? jelly
2011-08-20  9:59 ` Chris Packham [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E4F857E.9030907@gmail.com \
    --to=judge.packham@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=sinojelly@163.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.