[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

RE: On commit, svn server to change line ending to unix style for .sh files.

From: Giulio Troccoli <Giulio.Troccoli_at_uk.linedata.com>
Date: Mon, 8 Sep 2008 11:28:49 +0100


Linedata Services (UK) Ltd
Registered Office: Bishopsgate Court, 4-12 Norton Folgate, London, E1 6DB
Registered in England and Wales No 3027851 VAT Reg No 778499447

-----Original Message-----

> From: David Weintraub [mailto:qazwart_at_gmail.com]
> Sent: 07 September 2008 03:52
> To: futung.cheng_at_yahoo.com
> Cc: users_at_subversion.tigris.org
> Subject: Re: On commit, svn server to change line ending to unix style for
> .sh files. [auto-ip]
> You can't
> really do this via server side. However, you can do this via the
> autoproperties in your config file. I setup a company wide config
> file, and after a few rejected commits, people are using it.

That's not totally true. It'd be better to say that it's not advisable to do so. However it is "technically" possible and I have implemented it (and exactly for the OP's issue).

My post-commit hook checks for the svn:eol-style. If it's not defined then it sets it to LF. If it defined but it's not LF then it changes it to LF. Finally a commit is done. To do all this I use a special "admin" working copy I keep on the server. I've never had any problems with that so far.

This is an extract of my post-commit hook (it's a Korn shell script)

$SVN --quiet update src

# Set the flag

$SVNLOOK changed --revision $REVISION $REPOS_PATH | $AWK '{OFS=";"; print $1,$2}' > $TMPDIR/changes_list
for line in `cat $TMPDIR/changes_list`; do
   status=`$ECHO $line | $CUT -d";" -f1`
   file=`$ECHO $line | $CUT -d";" -f2`
   # If the file is a new file
   if [ "$status" == "A" ]; then
      # Set the svn:eol-style property to 'LF'
      $SVN propset svn:eol-style "LF" $WC_ADMIN_BASE_PATH/$file
      # Send an email that a new file has been added
      $MAIL -s "New file in Subversion: $file" $BUILDMASTERS_EMAILS
   elif [ "$status" == "D" ]; then
      # Send an email that an old file has been deleted
      $MAIL -s "Old file in Subversion has been deleted: $file" $BUILDMASTERS_EMAILS
   else # If it's not a new file and it's not been deleted
      # Get the svn:eol-style property, which is the one we are interested in
      eolstyle=`$SVN propget svn:eol-style $WC_ADMIN_BASE_PATH/$file`
      # If svn:eol-style is not 'LF' then change it
      if [ "$eolstyle" != "LF" ]; then
         $SVN propset svn:eol-style "LF" $WC_ADMIN_BASE_PATH/$file

# Remove the temporary list of changes
rm -f $TMPDIR/changes_list

# If we have modified some properties then commit the changes
if [ $propset -eq 1 ]; then
   cd src
   $SVN commit --message "OOP: Setting (or changing) svn:eol-style property to 'LF'"


To unsubscribe, e-mail: users-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: users-help_at_subversion.tigris.org
Received on 2008-09-08 12:30:08 CEST

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.