How to explicity tell SVN to treat a file as text, not binary

泪湿孤枕 提交于 2019-12-20 09:32:36

问题


I have a number of files that I checked into SVN without having set up their Mime types correctly. SVN initially classified them as binary.

I've since set their Mime type in SVN via propset to "text/plain; charset=UTF-8" and I'vc made sure that all the files are UTF-8 signed. When I do 'svn blame filename', svn says that the file is binary and does not give me explicit blame-type output.

Any suggestions on how to persuade SVN that these are truly text files?


回答1:


Setting the svn:mime-type property to just "text/plain" helps:

svn propset svn:mime-type text/plain build.xml
svn commit build.xml

Also, you can force Subversion to treat a file as text when blaming:

svn blame file/to/blame --force



回答2:


I had the same problem: I checked in a number of utf8 files (native encoding for Linux), some of which were picked up wrongly as binary and showing "(bin)". I did not delve into how the error occurred, but checked what was there...

$ svn propget svn:mime-type *

...noted that correctly checked-in text files had no svn:mime property at all, and simply deleted the svn:mime-type property from text files wrongly mislabled binary.

$ svn propdel svn:mime-type [mislabeled-text-file...]
$ svn ci -m "zap binary mime-types" [mislabeled-text-file...]

This seems to have worked with no ill effect. Caveat usor: I have no idea how Windows would behave in this case, though this is easily testable.




回答3:


This answer has the same idea, but in reverse. The citations therein are still relevant to your query.




回答4:


After you've added a file to the repository, you probably also need to set the type on the REPOSITORY. Use the URL to the repository instead of the path to the working copy on your propset command.




回答5:


Looks like manipulations with mime-type do not convince svn to treat a file as a text. But if proper mime-type was set before first commit then svn treat the file properly. For example, svn adds eclipse .project and .classpath as application/xml and treats them as bin. But if before first commit you change it to text/xml they will be treated as text.



来源:https://stackoverflow.com/questions/458609/how-to-explicity-tell-svn-to-treat-a-file-as-text-not-binary

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!