From: "tonka3100@gmail.com" <tonka3100@gmail.com>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org
Subject: Re: change the filetype from binary to text after the file is commited to a git repo
Date: Mon, 24 Jul 2017 21:02:12 +0200 [thread overview]
Message-ID: <7DE91669-D603-4C83-9151-78F2D5676E36@gmail.com> (raw)
In-Reply-To: <20170724181835.zo3lcv7pxmkif2jr@sigill.intra.peff.net>
Hey Jeff,
Thx for your answer.
There is no .gitattributes file in the repo. I think that the git heuristic will also detect utf-16 files as binary (in windows), so i think that is the reason why my file is binary (i have to check that tomorrow). If i add a .gitattribute file i have the problem that git diff will treat the old and the new blob as utf-8, which generate garbage.
Do you have another idea?
Could it be possible to add only a space in code (utf-8) and then add the real content in a second commit, so the old and the new one are both utf-8?
> Am 24.07.2017 um 20:18 schrieb Jeff King <peff@peff.net>:
>
>> On Mon, Jul 24, 2017 at 07:11:06AM +0200, tonka tonka wrote:
>>
>> I have a problem with an already committed file into my repo. This git
>> repo was converted from svn to git some years ago. Last week I have
>> change some lines in a file and I saw in the diff that it is marked as
>> binary (it's a simple .cpp file). I think on the first commit it was
>> detected as an utf-16 file (on windows). But no matter what I do I
>> can't get it back to a "normal text" text file (git does not detect
>> that), but I is now only utf-8. I also replace the whole content of
>> the file with just 'a' and git say it's binary.
>
> Git doesn't store a flag for "binary-ness" on each file (though see
> below). As the diffs are generated on the fly when you ask to compare
> two versions, so too is the determination of "is this binary".
>
> The default heuristic looks at file size (by default, if the file is
> over 500MB it's considered binary) and whether it has any zero-byte
> characters in the first few kilobytes. But note that if _either_ side of
> a diff is considered binary, then Git won't show a text diff.
>
> If you want a particular diff to show all content, even if it doesn't
> look like text, add "-a" to your git invocation (e.g., "git show -a").
>
> That said, you can also use .gitattributes (see "git help attributes")
> to mark a file as binary or not-binary, skipping the heuristic check.
> I'm guessing since you converted from svn that you don't have a
> .gitattributes file, but it's possible that somebody later added one
> that marks the file as binary (and so the solution would be to drop that
> entry).
>
> -Peff
next prev parent reply other threads:[~2017-07-24 19:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-24 5:11 change the filetype from binary to text after the file is commited to a git repo tonka tonka
2017-07-24 18:18 ` Jeff King
2017-07-24 19:02 ` tonka3100 [this message]
2017-07-24 19:23 ` Jeff King
[not found] ` <DBBA7352-5276-4972-A437-F27F5F4C2641@gmail.com>
2017-07-24 20:32 ` Jeff King
2017-07-24 20:34 ` tonka3100
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7DE91669-D603-4C83-9151-78F2D5676E36@gmail.com \
--to=tonka3100@gmail.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).