45

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?

DWright
  • 9,258
  • 4
  • 36
  • 53
  • Does propget return the proper mime-type? – Adam Peck Jan 19 '09 at 18:27
  • Thanks for the interaction! Yes, propget does return proper type. I just did one: svn propget svn:mime-type filename Output: text/plain; charset=UTF-8 – DWright Jan 19 '09 at 18:44
  • 1
    @DWright, just to confirm, svn-propset changes the type in the local working copy and _requires an svn commit_ for the type to be changed in the repository. Both types need to match and be "diff-able" for svn diff/svn blame to be able to work. – Fox Dec 15 '14 at 06:43
  • https://stackoverflow.com/questions/73797/how-do-i-tell-subversion-to-treat-a-file-as-a-binary-file has the same idea, but in reverse. The citations therein are still relevant to your query. – Eddie Parker Jan 19 '09 at 19:12
  • Yeah, I tried that in reverse, setting the property to text/plain. Didn't seem to work. – DWright Jan 19 '09 at 19:24

4 Answers4

62

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
ThisSuitIsBlackNot
  • 23,492
  • 9
  • 63
  • 110
Stefan
  • 43,293
  • 10
  • 75
  • 117
  • 1
    Thank you. The --force flag did what I needed. I also tried only using "text/plain," but that didn't change it. – DWright Jan 19 '09 at 19:22
  • 7
    For future readers: svn propset svn:mime-type text/plain build.xml – david van brink Jan 17 '13 at 19:07
  • Use`find . -name *.proto | xargs svn propset svn:mime-type text/plain` to mark all `proto` file as plain text file: – DawnSong Nov 08 '16 at 11:31
  • 2
    Global setting: edit `~/.subversion/config`, add `*.proto = svn:mime-type=text/plain` as a single line to the file's `[auto-props]` section. – DawnSong Nov 08 '16 at 11:38
5

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.

smaines
  • 51
  • 1
  • 2
0

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.

andrei
  • 1
0

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.

Jim P.
  • 26
  • 2
  • 2
    This is wrong (or unclear enough to be wrong). Subversion properties are committed to the repository when you check them in, just like any other file change. – yam655 Apr 19 '12 at 13:38