SVN: "Inconsistent line ending style" - Checking in a file with ^M intentionally
Using svn version 1.3.1 (unable to upgrade due to a configuration controlled CM server) on CentOS 4.2.
My code (a bash script) specifically has a ^M in it for an important reason. Unfortunately, subversion will not let me check this file in. It complains that:
svn: Commit failed (details fol开发者_如何学Clow):
svn: Inconsistent line ending style svn: Your commit message was left in a temporary file:I have proven that removing the single ^M from my code allows it to be checked in. How do I tell subversion that the ^M is intentional and that it should allow the file to be checked in?
You need to remove the svn:eol-style property from your file. Subversion didn't care about line endings in your file until this property was added. To quote the subversion book:
This means that by default, Subversion doesn't pay any attention to the type of end-of-line (EOL) markers used in your files.
The book then goes on describing how you can make subversion care about the line endings by setting the svn:eol-style
, which is exactly what you don't want.
Another approach would be to get rid of the control character in the program in the first place; this might have other compatibility benefits, and might avoid problems with editing in the future.
You can generate a \r
in bash easily with
`printf '%b' '\015'`
So, for example:
$ echo abc`printf %b '\015'`def
def
$
Or:
$ c=`printf %b '\015'`
$ set | grep ^c=
c=$'\r'
$
(Note: I know there are easier ways than by calling printf. Unfortunately, those easier ways are different in bash and posix shells. A bash-only solution is quite nice: $'\r'
. Ash-only even nicer: c='\r
. I'm not sure if ash
does this because it's ash or because it's posix.)
I'm assuming it's being used as a string or something. Doesn't bash have a way to encode characters?
I think you need to use the svn:eol-style
property:
svn propset svn:eol-style LF myscript.sh
will cause Subversion to always treat the file as having LF-style line-endings.
I think you can set the svn:mime-type property to something none-text based (like application/octet-stream ?). This might make subversion ignore the line endings.
Have a look at the File Content Type section of the svnbook.
精彩评论