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

Re: patch newline in log messages

From: Olleg Samoylov <olleg_at_mipt.ru>
Date: 2006-02-20 10:33:44 CET

Garrett Rooney wrote:

> On 2/17/06, Olleg Samoylov <olleg@mipt.ru> wrote:
>
>> Sometimes newline exits at the end of log messages. Sometimes not. This
>> is patch "svn log" to check of trailing newline and put newline at the
>> end only if it's needed.
>
>
>
> This is because the newline comes from the editor, a lack of a newline
> usually indicates that someone used -m to pass a message. I'm -1 to
> ripping the newlines off, the user put them there (via their text
> editor) and we have no business removing them.

There was several patches to remove newline at the end after text
editor, for instance http://svn.haxx.se/dev/archive-2005-07/0766.shtml.
But Karl Fogel reject all of it. Reason - log messages must have newline
at the end, this is preffered (he like it).

This patch is to hide newline at the end on log output.

I attach new version of patch, some better.

-- 
Olleg Samoylov

Index: subversion/svn/log-cmd.c
===================================================================
--- subversion/svn/log-cmd.c (revision 18529)
+++ subversion/svn/log-cmd.c (working copy)
@@ -149,6 +149,10 @@
   /* Number of lines in the msg. */
   int lines;
 
+ /* Has msg trailig newline?
+ This is preferred, but old client may not put it. */
+ svn_boolean_t hasnt_trailing_newline=FALSE;
+
   if (lb->cancel_func)
     SVN_ERR(lb->cancel_func(lb->cancel_baton));
 
@@ -181,7 +185,14 @@
 
   if (! lb->omit_log_message)
     {
- lines = svn_cstring_count_newlines(msg) + 1;
+ /* check trailing newline */
+ int len=strlen(msg);
+ if (len>0)
+ hasnt_trailing_newline = 0==svn_cstring_count_newlines(msg+len-1);
+
+ lines = svn_cstring_count_newlines(msg);
+ if (hasnt_trailing_newline)
+ ++lines;
       SVN_ERR(svn_cmdline_printf(pool,
                                  (lines != 1)
                                  ? " | %d lines"
@@ -228,7 +239,9 @@
   if (! lb->omit_log_message)
     {
       /* A blank line always precedes the log message. */
- SVN_ERR(svn_cmdline_printf(pool, "\n%s\n", msg));
+ SVN_ERR(svn_cmdline_printf(pool, "\n%s", msg));
+ if (hasnt_trailing_newline)
+ SVN_ERR(svn_cmdline_printf(pool, "\n"));
     }
 
   return SVN_NO_ERROR;

Received on Mon Feb 20 10:34:34 2006

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

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