SVN Diff: Why are some files marked as binary

落爺英雄遲暮 提交于 2020-01-02 00:53:13

问题


Directly related: svn diff: file marked as binary type (Per the comment on the answer)

Why would my SVN client mark some files as binary?

Specifically, .sql has prop svn:mime-type = application/octet-stream when using TortoiseSVN.

I checked Right-click > Tortoise context menu > Settings > General > Subversion configuration file, and nothing is uncommented in [miscellany] or [auto-props], so where is the decision coming from?

From what I can see in the related posts, I can "fix it" by either deleting the property on affected files, or globally change the behavior on new files via config/setting, but is there a "simple" way to do both for all affected files?

Somewhat related:

  • Persistently overriding svn's mime to binary mapping?
  • svn diff for binary file(excel file)

回答1:


Well, I found the issue in my particular case:

A developer had saved a template .sql file he was using for new scripts. This file, somehow, was saved with UCS-2 (or Unicode) encoding. Whenever he added files, TortoiseSVN determined that it was a binary file. By switching the encoding to UTF-8, the template and files derived from it are added correctly as text/plain.

Additional Info (Edit)

I found what might have been the culprit. When generating some scripts using the GUI, SQL Server Management Studio writes them as Unicode in the query window. If the file is saved, it will be saved as Unicode as well. Interestingly enough, files opened via the File>New don't save like this. An issue was raised with Microsoft about this back in 2007 (found here), that apparently hasn't been resolved.




回答2:


Here's a quick way to fix this problem:

notepad %APPDATA%\Subversion\config

Scroll down to and uncomment this line:

enable-auto-props = yes

Under [auto-props] add this line:

*.sql = svn:mime-type=text/plain

Now when you add .SQL files to SVN, they will automatically be marked as text (not octet-stream).

EDIT: Removed unnecessary line ending file alteration.



来源:https://stackoverflow.com/questions/19499334/svn-diff-why-are-some-files-marked-as-binary

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