subversion-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bert Huijben" <b...@qqmail.nl>
Subject RE: Bug report: The auto-props setting of svn:mime-type is impossible to avoid.
Date Tue, 06 Oct 2015 11:13:13 GMT


> -----Original Message-----
> From: edward.dauvergne@gmail.com
> [mailto:edward.dauvergne@gmail.com] On Behalf Of Edward d'Auvergne
> Sent: dinsdag 6 oktober 2015 12:21
> To: Edward d'Auvergne <true.bugman@gmail.com>; Greg Stein
> <gstein@gmail.com>; users@subversion.apache.org
> Subject: Re: Bug report: The auto-props setting of svn:mime-type is
> impossible to avoid.
> 
> On 4 October 2015 at 13:32, Stefan Sperling <stsp@elego.de> wrote:
> > On Sun, Oct 04, 2015 at 12:52:33PM +0200, Edward d'Auvergne wrote:
> >> I would maybe suggest introducing an option for disabling the entire
> >> automatic property subsystem, i.e. it combines both of these, and
> >> overrides them.  This is an interesting thought experiment - devise
> >> any name for such a top level automatic property override - and this
> >> should convincingly demonstrate the confusion that the current setting
> >> names induces.
> >
> > I think that would just make the situation worse by adding to
> > the current mess.
> >
> > I agree the documentation needs to be improved. Would you have time
> > to update the documentation and send patches for it?
> 
> Ok, I can look into it.  Hpwever the instructions for setting the
> MAGIC environmental variable needs some discussion (see below).
> 
> 
> >> The problem with the svn:mime-type block is that for svn clients <
> >> 1.9, 'svn import' can never work.  Specifically because the libmagic
> >> layer overwrites any user decision to disable automatic properties.
> >
> > There's another trick to disable libmagic which works with all
> > client versions. I just tested it with 1.8.
> >
> > Set the MAGIC environment variable to a file which does not exist.
> >
> >   env MAGIC=/nonexistent svn import ...
> >
> > This effectively disabled libmagic support.
> 
> I've tried all combinations and nothing works (on my Linux system with
> svn 1.8.14).  For example:
> 
> $ env MAGIC=/nonexistent svn import ...
> $ MAGIC=/nonexistent svn import ...
> [block]
> 
> $ env MAGIC=False svn import ...
> $ MAGIC=False svn import ...
> [block]
> 
> $ export MAGIC=/nonexistent
> $ svn import ...
> [block]
> 
> $ export MAGIC=False
> $ svn import ...
> [block]
> 
> $ touch empty_magic
> $ MAGIC=$BASE_DIR/empty_magic svn import ...
> [block]
> 
> $ env MAGIC=$BASE_DIR/empty_magic svn import ...
> [block]
> 
> $ head -n 1 /usr/share/mime/magic > empty_magic
> $ MAGIC=$BASE_DIR/empty_magic svn import ...
> [block]
> 
> Not a single one of these combinations work - svn:mime-type is always
> being set by 'svn import'.  Therefore blocking svn:mime-type in a
> pre-commit hook completely kills the option of using 'svn import', and
> there is no way to avoid this.  Looking more carefully at what is
> happening:
> 
> $ cd $BASE_DIR
> $ cp dash/Images/DashBoot_logo_Mod.png test4
> $ cp dash/dash-set.xml test4
> $ cd test4
> $ svn add DashBoot_logo_Mod.png
> $ svn add dash-set.xml
> $ svn plist -R
> Properties on 'DashBoot_logo_Mod.png':
>   svn:mime-type
> $ svn pget svn:mime-type DashBoot_logo_Mod.png
> application/octet-stream
> 
> So setting MAGIC is having an effect, but Subversion is falling back,
> probably via a non-magic internal code path, to the default
> svn:mime-type of "application/octet-stream" for PNG and some other

When a file is clearly binary we set application/octet stream, but that is not what we were
discussing here. (We check the first 4 Kbyte or something and perform some statistics on that.
See the source of svn_io_detect_mimetype2() for details)

If we don't do that we would try to perform text translations and text merges on files that
contain '\0' bytes.... That is simply not going to work. That trigger shouldn't apply to xml
files though, unless it starts with a huge amount of non ASCII characters.

In some old versions of Subversion the test would say that a file is binary if it only contained
a UTF-8 byte order mark, but we filter that one now as some common tools (read: Microsoft
Visual Studio) often creates new files with just that content.


There is also an option to set your own mimetype map before we call into magic.


But looking at this... the way to disable the option with 1.9+ is

$ svn add --config-option config:miscellany:enable-magic-file=no file.xml

That doesn't depend on libmagic implementation details such as the environment variable.



With 1.7 and 1.8 you can use the mimetype file with your overrides, as this is processed before
libmagic

$ svn add --config-option config:miscellany: mime-types-file=mimemap file.xml

(the mime-types-file option was added to the config in 1.5, but we didn't have --config-option
there)


The file 'mimemap' can then contain something like
[[
text/plain .xml
]]
(First token on the line is the mimetype. All further tokens are extensions. # lines allowed)



	Bert


Mime
View raw message