8

For background on my question: svn won't diff a file it thinks is binary

$ svn diff data/assets/site/ir_gallery/images.kml
Index: data/assets/site/ir_gallery/images.kml
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/vnd.google-earth.kml+xml

A recent stack overflow answer ( svn diff: file marked as binary type ) showed you can force a mime type:

$ svn propset svn:mime-type 'text/plain' data/assets/site/ir_gallery/images.kml
property 'svn:mime-type' set on 'data/assets/site/ir_gallery/images.kml'

Note that prior answer is incomplete... you also have to:

$ svn commit

Now my new question is: can I set a default, so all future "vnd.google-earth.kml+xml" files are treated as text by svn? The redbook appears silent on this topic: http://svnbook.red-bean.com/en/1.2/svn.advanced.props.html saying only:

...if a file's svn:mime-type property is set to a non-text MIME type
(generally, something that doesn't begin with text/, though there are
exceptions) then...

What exceptions? Are these exceptions baked into the svn code, or accessible?

Community
  • 1
  • 1
Bryce
  • 8,313
  • 6
  • 55
  • 73

1 Answers1

6

The answer depends on the svn client that you are using. In the official svn client, the option you are looking for is Automatic Property Setting. The tl;dr version is you need to update your user or system config, set the enable-auto-props setting to yes in the miscellany section, and create a new section called auto-props which defines the patterns you want to match and the properties you are looking to set.

For your example of kml files:

### Section for configuring miscelleneous Subversion options.
[miscellany]
enable-auto-props = yes

[auto-props]
*.kml = svn:mime-type=text/plain;svn:eol-style=native

This will ensure that when you add a .kml file to your repository, it will have a mime-type of text/plain and will use line endings native to the platform of the client.

Tel Janin
  • 161
  • 1
  • 5
  • 1
    he may prefer `*.xml = svn:mime-type=text/xml` because kml is an xml IIRC – akostadinov Aug 30 '13 at 15:05
  • 1
    By the way, the svn:mime-type=text/...; part is critical, because if it is not there, there is an initial-property-set that sets it to non-text, application/xml, which would cause the svn:eol-style=native to error-out, preventing the whole file-add step. The mime-type=text/... overrides the binary nature of the file first such that the eol-style-native can be set. – macetw Nov 11 '14 at 21:07