Reputation: 3598
When I add a shell script (foo.sh) to subversion, by default it sets the svn:mime-type
to application/x-shellscript
. Since this does not start with text/
, diff and blame essentially ignore the file. I looked at the official list of text mime-types but did not see anything that looked like a shell script.
Is there a good value to set it to?
Following the advice below, I set the mime-type to text/x-shellscript. However, blame still thinks that it is a binary file.
$ svn blame file.sh
Skipping binary file: 'file.sh'
$ svn proplist file.sh
Properties on 'file.sh':
svn:executable
svn:mime-type
$ svn propget svn:mime-type file.sh
text/x-shellscript
Is there something else that I need to do to convince subversion that it is a text file?
Upvotes: 15
Views: 13897
Reputation: 1265
Subversion rarely sets mime types by itself; either your client did it by itself (in which case you will probably want to adjust its configuration), or some form of standard svn auto-props processing is active (again, you will want to adjust it - for shell scripts you'll also want to set svn:eol-style to LF; some shells will barf on DOS/Windows line endings, and by ensuring Unix line endings are used everywhere, you avoid issues with using the files via a network share, or some Windows builds of shells (e.g. Cygwin)).
The problem with svn blame is that the property is versioned. Any revision of the file from before the property change is still binary (because the mime type does not start with text/), so diffs (and blames) will not work (easily) against those revisions.
I think the only fix for this is to get an admin to modify the repository to remove the "bad" mime type.
However, as a workaround, you should be able to pass --force to blame, to tell it to treat all files as text.
In fact, looking at http://subversion.1072662.n5.nabble.com/svn-blame-not-working-for-files-which-had-binary-mime-type-in-a-previous-revision-td177847.html, recent subversion clients will tell you to use --force.
Upvotes: 1
Reputation: 97325
Auto-properties are fully-client-side feature. With auto=properties you can also define|redefine some properties for added to Subversion repository objects (i.e for old adds you have to redefine wrong mime-type)
In config
file of your subversion (platform-dependent location)
[miscellany]
section uncomment # enable-auto-props = yes
string[auto-props]
section uncomment # *.sh = svn:eol-style=native;svn:executable
and edit accordinly (remove unwanted, add needed like svn:mime-type=text/plain
)After this all new *.sh files in repo will appear as text/plain.
But, because config is client-side and changes in it does not populated in repo, any other Subversion client will continue to add *.sh files as text/x-shellscript unless your changes are not repeated
Upvotes: 1
Reputation: 50094
The file
utility uses `text/x-shellscript' for shell scripts:
$ file --mime-type /tmp/test.sh
/tmp/test.sh: text/x-shellscript
Upvotes: 17