That looks good at first, but this excerpt from the Subversion book explains 
why that’s a bad idea:

While hook scripts can do almost anything, there is one dimension in which hook 
script authors should show restraint: do not modify a commit transaction using 
hook scripts. While it might be tempting to use hook scripts to automatically 
correct errors, shortcomings, or policy violations present in the files being 
committed, doing so can cause problems. Subversion keeps client-side caches of 
certain bits of repository data, and if you change a commit transaction in this 
way, those caches become indetectably stale. This inconsistency can lead to 
surprising and unexpected behavior. Instead of modifying the transaction, you 
should simply validate the transaction in the pre-commit hook and reject the 
commit if it does not meet the desired requirements.

I could of course just reject the commit if it has whitespace, but then that 
means that any commit using the command line editor would be rejected, because 
svn always adds the whitespace.

On Apr 21, 2014, at 6:19 PM, Ryan Schmidt <subversion-2...@ryandesign.com> 
wrote:

> 
> On Apr 21, 2014, at 16:56, Justin Mrkva wrote:
> 
>> I use nano as the editor for command line commits. If I commit with the 
>> command line editor, Subversion adds an extra line to the commit. Observe:
>> 
>> 
>> 
>> justins-macbook-pro:copy1 justinmrkva$ svn log | head -n 15
>> ------------------------------------------------------------------------
>> r16 | justinmrkva | 2014-04-21 17:50:06 -0400 (Mon, 21 Apr 2014) | 2 lines
>> 
>> Commit using nano as editor
>> 
>> ------------------------------------------------------------------------
>> r15 | justinmrkva | 2014-04-21 17:49:16 -0400 (Mon, 21 Apr 2014) | 1 line
>> 
>> Commit with 3rd party GUI client
>> ------------------------------------------------------------------------
>> r14 | justinmrkva | 2014-04-21 17:48:52 -0400 (Mon, 21 Apr 2014) | 1 line
>> 
>> Commit with -m option
>> ------------------------------------------------------------------------
>> 
>> 
>> 
>> Notice that using `svn ci -m "message"` with a single line OR using a 3rd 
>> party GUI client (Cornerstone 2) both produce a single line commit message. 
>> But nano, with the “will be ignored” line as the NEXT line after the 
>> message, produces a commit with the extra line.
>> 
>> You can see in the screenshot here that there is no extra line between the 
>> message and the “will be ignored” line:
>> 
>> <Screen Shot 2014-04-21 at 5.49.51 PM.png>
>> 
>> Is there a solution for this?
> 
> Yes: install the log-police.py hook script in your repository.
> 
> http://svn.apache.org/repos/asf/subversion/trunk/tools/hook-scripts/log-police.py
> 
> 

Reply via email to