Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the best way to have svn:eol-style=native for text files by default?

Tags:

I find that it is best practice to have all text files have svn:eol-style=native property set. But what's the most efficient way to do it?

I develop programs mainly on Windows(using TortoiseSVN and svn.exe command line) and sometimes write portable C/C++ libraries for Windows and Linux. In order to prevent the nasty mix-CR,LF problem on my source files, I think svn:eol-style=native should be the "default", but unfortunately it is not.

I know from Subversion Red Book that configuring [auto-props] in ~/.subversion/config or %APPDATA%\Subversion\config helps, however, it is per client setting. What about some developer in my team forget to configure those config files (think about dev on multiple virtual machines)? Even all do remember, what if some new kind of text file extension-name occurs? How do I properly propagate this change to all config file on all dev machines in my team?

All seems to be a cumbersome process.

like image 586
Jimm Chen Avatar asked Nov 06 '11 02:11

Jimm Chen


2 Answers

Subversion 1.8 way

Because Subversion 1.8 got repository dictated configuration (RDC), for mandatory using common settings by all clients for a given repository, property can and have to be configured in the repository root (or trunk)

like image 176
Lazy Badger Avatar answered Sep 28 '22 01:09

Lazy Badger


This should be a quick answer, not "dive into details and get it yourself, here is the link" version.

We'll just f-ing do it, okay? For subversion 1.8+:

$ cd my_checkout_dir

$ svn propset svn:auto-props '
### src
*.c = svn:eol-style=native
*.cpp = svn:eol-style=native
*.h = svn:eol-style=native
*.pch = svn:eol-style=native
*.lua = svn:eol-style=native
*.py = svn:eol-style=native
*.pl = svn:eol-style=native
*.txt = svn:eol-style=native
*.sh = svn:eol-style=native;svn:executable
### ui
*.xib = svn:eol-style=native
*.ui = svn:eol-style=native
*.qrc = svn:eol-style=native
### project
*.pro = svn:eol-style=native
*.pbxproj = svn:eol-style=native
*.json = svn:eol-style=native
*.xcworkspacedata = svn:eol-style=native
*.plist = svn:eol-style=native
' .

$ svn commit -m 'Got really tired of svn:eol-style issues'

Please note closing single-quote and dot (i.e. current dir) at the end. Tune this list for your needs, copy svn propset svn:auto-props '…' . into unix/msys sh-terminal (yes, with Enters). After commit, all files below my_checkout_dir will inherit corresponding properties upon add. Files added before this action will not be modified. As you see in *.sh and below, you can add more properties via ;. If you want to change the list, just repeat everything again.

Here are defaults suggested by svn in my ~/.subversion/config for the reference:

### The format of the entries is:
###   file-name-pattern = propname[=value][;propname[=value]...]
### The file-name-pattern can contain wildcards (such as '*' and
### '?').  All entries which match (case-insensitively) will be
### applied to the file.  Note that auto-props functionality
### must be enabled, which is typically done by setting the
### 'enable-auto-props' option.
# *.c = svn:eol-style=native
# *.cpp = svn:eol-style=native
# *.h = svn:keywords=Author Date Id Rev URL;svn:eol-style=native
# *.dsp = svn:eol-style=CRLF
# *.dsw = svn:eol-style=CRLF
# *.sh = svn:eol-style=native;svn:executable
# *.txt = svn:eol-style=native;svn:keywords=Author Date Id Rev URL;
# *.png = svn:mime-type=image/png
# *.jpg = svn:mime-type=image/jpeg
# Makefile = svn:eol-style=native
like image 36
user3125367 Avatar answered Sep 28 '22 02:09

user3125367