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

patch newline in log messages

From: Olleg Samoylov <olleg_at_mipt.ru>
Date: 2006-02-17 15:57:02 CET

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.

-- 
Olleg Samoylov

Index: subversion/svn/log-cmd.c
===================================================================
--- subversion/svn/log-cmd.c (revision 18503)
+++ 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;
+
   if (lb->cancel_func)
     SVN_ERR(lb->cancel_func(lb->cancel_baton));
 
@@ -179,9 +183,17 @@
                              SEP_STRING "r%ld | %s | %s",
                              rev, author, date));
 
+ /* check trailing newline */
+ int len=strlen(msg);
+ if (len>0)
+ hasnt_trailing_newline = 0==svn_cstring_count_newlines(msg+len-1);
+ else
+ hasnt_trailing_newline=FALSE;
   if (! lb->omit_log_message)
     {
- lines = svn_cstring_count_newlines(msg) + 1;
+ lines = svn_cstring_count_newlines(msg);
+ if (hasnt_trailing_newline)
+ ++lines;
       SVN_ERR(svn_cmdline_printf(pool,
                                  (lines != 1)
                                  ? " | %d lines"
@@ -228,7 +240,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 Fri Feb 17 15:58:42 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.