84

I'm doing an svn diff on one of my files and svn is detecting it as a binary type. The file is readable plain text and I would like to be able to get a diff of this file. How do I tell SVN that this is not a binary file?

Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Beryllium
  • 12,164
  • 9
  • 52
  • 81
Charles Ma
  • 41,485
  • 21
  • 80
  • 98

2 Answers2

116

You can get diff even for a file marked as binary by using --force.

svn diff --force path/to/file

Evgeny Remizov
  • 1,352
  • 1
  • 9
  • 6
  • 5
    this is a much better answer for something like application/json – Steven R. Loomis Jan 18 '13 at 22:06
  • 2
    @BrettZamir but that could be done with almost anything that has an output. – entonio Jun 23 '14 at 16:46
  • 1
    @entonio : Yes, I know...just thought I should point it out as I ran into this error using a GUI client and as I could not resolve within it as far as I could tell, thought maybe others who do not frequently use the command line could be informed of this. – Brett Zamir Jun 23 '14 at 21:43
82

You can use the Subversion property svn:mime-type to set an explicit mimetype on the file:

svn propset svn:mime-type 'text/plain' path/to/file

Alternatively, you can delete this property (since Subversion assumes plaintext, otherwise) using:

svn propdel svn:mime-type path/to/file
Michael Aaron Safyan
  • 87,518
  • 14
  • 130
  • 194
  • 4
    But why was it marked as binary in the first place? I am having the same issue for many of my source files, and it is a pain to delete the properties every time. – angularsen Oct 07 '11 at 06:13
  • Sounds like you should ask another question ... and maybe add a link here. – Eric Wilson Oct 27 '11 at 18:03
  • 1
    @EricWilson -- asked: http://stackoverflow.com/questions/19499334/svn-diff-why-are-some-files-marked-as-binary – drzaus Oct 21 '13 at 16:00
  • Does this (changing the mime type of a file) change the way files are executed when someone checks out a fresh copy from svn? In such a case I think using --force option just for viewing the diff makes more sense. – Rishi May 09 '14 at 17:52
  • @Rishi, no, it doesn't; there is a separate "svn:executable" property which determines whether the file should have executable permission bits. – Michael Aaron Safyan May 11 '14 at 21:13