You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Patrik Rådman <pr...@abo.fi> on 2004/03/26 19:20:53 UTC

[PATCH][REPOST] Don't add extra blank line to log messages

Hi,

I didn't receive any comments to the first posting of this patch, so here
it is again, this time with commented code, and a better explanation: :)

If you commit with 'svn ci . -m "Oneliner comment"' you get this:

------------------------------------------------------------------------
r18 | patrik | 2004-03-26 20:52:58 +0200 (Fri, 26 Mar 2004) | 1 line

Oneliner comment
------------------------------------------------------------------------

...but if you enter the log message via $EDITOR, you get this:

------------------------------------------------------------------------
r19 | patrik | 2004-03-26 20:53:45 +0200 (Fri, 26 Mar 2004) | 2 lines

Oneliner comment

------------------------------------------------------------------------

The patch below removes the extra blank line.


Index: subversion/clients/cmdline/util.c
===================================================================
--- subversion/clients/cmdline/util.c   (revision 9214)
+++ subversion/clients/cmdline/util.c   (working copy)
@@ -384,6 +384,13 @@
           || (*(substring - 1) == '\n'))
         {
           *substring = '\0';
+          /* Remove the newline character(s) before PREFIX in order to
+             avoid an extra blank line after the log message. */
+          while ((*(substring - 1) == '\r') || (*(substring - 1) == '\n'))
+            {
+              substring--;
+              *substring = '\0';
+            }
           if (new_len)
             *new_len = substring - buffer;
         }

-- 
Patrik Rådman
patrik at iki dot fi

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org


Re: [PATCH][REPOST] Don't add extra blank line to log messages

Posted by "C. Michael Pilato" <cm...@collab.net>.
Patrik Rådman <pr...@abo.fi> writes:

> C. Michael Pilato <cm...@collab.net> wrote:
> [snip]
> > 
> > ### Finally, I change the file again, and commit using $EDITOR.  My
> > ### editor pops up and I type "No extra lines, please", then strip all
> > ### the rest of the junk out of the file -- including the newline at
> > ### the end of my message.  Again, this is to ensure a fair comparison.
> 
> Uh... So your opinion is that the user should always have to do the
> tedious work of deleting the lines from "--This line, and those below,
> will be ignored--" onwards? Why, when it's so easy to patch the svn client
> to completely remove them?
> 
> In my opinion the line isn't "ignored" in the current code, it's turned
> into a blank line. :)

Cute, but that's not what's going on.  If I make a commit and my
$EDITOR log message looks thusly:

   No extra lines, please.
   --This line, and those below, will be ignored--
   
   M    foo

I should expect that my log message has exactly one EOL marker -- the
one after "please." and before "--This".  So let's see if that's the
case:

   $ svnlook info repos
   cmpilato
   2004-03-28 19:51:57 -0600 (Sun, 28 Mar 2004)
   24
   No extra lines, please.
   
   $ 

'svnlook info' tells me that my log message contains 24 characters.
That's 23 characters for "No extra lines, please." plus 1 EOL
character -- exactly what I expected.

What is causing confusion is that 'svn log' (and 'svnlook info' and
'svnlook log', for that matter) *always* prints an extra newline just
in case your log message *didn't* end in one (so that formatting
doesn't get all wonky).  Nobody wants to see:

   $ svn log
   ------------------------------------------------------------------------
   r4 | cmpilato | 2004-03-28 19:47:35 -0600 (Sun, 28 Mar 2004) | 1 line
   
   No extra lines, please.------------------------------------------------------------------------
   r3 | cmpilato | 2004-03-27 14:44:44 -0600 (Sat, 27 Mar 2004) | 1 line
   ...

Know what I mean?

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org


Re: [PATCH][REPOST] Don't add extra blank line to log messages

Posted by Patrik Rådman <pr...@abo.fi>.
C. Michael Pilato <cm...@collab.net> wrote:
[snip]
> 
> ### Finally, I change the file again, and commit using $EDITOR.  My
> ### editor pops up and I type "No extra lines, please", then strip all
> ### the rest of the junk out of the file -- including the newline at
> ### the end of my message.  Again, this is to ensure a fair comparison.

Uh... So your opinion is that the user should always have to do the
tedious work of deleting the lines from "--This line, and those below,
will be ignored--" onwards? Why, when it's so easy to patch the svn client
to completely remove them?

In my opinion the line isn't "ignored" in the current code, it's turned
into a blank line. :)

 -- Patrik Rådman

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org


Re: [PATCH][REPOST] Don't add extra blank line to log messages

Posted by "C. Michael Pilato" <cm...@collab.net>.
Patrik Rådman <pr...@abo.fi> writes:

> I didn't receive any comments to the first posting of this patch, so here
> it is again, this time with commented code, and a better
> explanation: :)

Your explanation was fine.  I'd been meaning to respond, but obviously
did not.

The "bug" you're seeing is driver error.  You can't compare the usage
of -m with an $EDITOR unless you make sure you don't add extra
newlines at the end of your $EDITOR message (or *do* add them at the
end of your -m message).  Allow me to demonstrate.

### First, create a new repos, checkout a working copy, and enter the wc.

$ svnadmin create repos; svn co file://`pwd`/repos wc; cd wc
Checked out revision 0.

### Now, add a file, and commit with -m.

$ echo `date` > foo
$ svn add foo > /dev/null
$ svn ci -m "No extra lines, please" > /dev/null

### Now, change the file, and commit with an external message file.
### Note that I make the external message file using 'echo -n', which
### doesn't add an extra newline.  This is consistent with our use of -m.

$ echo `date` > foo
$ echo -n "No extra lines, please" > msg
$ svn ci -F msg > /dev/null

### Finally, I change the file again, and commit using $EDITOR.  My
### editor pops up and I type "No extra lines, please", then strip all
### the rest of the junk out of the file -- including the newline at
### the end of my message.  Again, this is to ensure a fair comparison.

$ echo `date` > foo
$ svn ci > /dev/null

### Alrighty, the moment of truth.  I update my working copy, and run
### 'svn log'...

$ svn up > /dev/null
$ svn log
------------------------------------------------------------------------
r3 | cmpilato | 2004-03-27 14:44:44 -0600 (Sat, 27 Mar 2004) | 1 line

No extra lines, please
------------------------------------------------------------------------
r2 | cmpilato | 2004-03-27 14:44:09 -0600 (Sat, 27 Mar 2004) | 1 line

No extra lines, please
------------------------------------------------------------------------
r1 | cmpilato | 2004-03-27 14:43:47 -0600 (Sat, 27 Mar 2004) | 1 line

No extra lines, please
------------------------------------------------------------------------
$ 

### And, as you can see, when comparing apples to apples, they look
### strangely similar.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org


Re: [PATCH][REPOST] Don't add extra blank line to log messages

Posted by Garrett Rooney <ro...@electricjellyfish.net>.
On Mar 26, 2004, at 2:20 PM, Patrik Rådman wrote:

> Hi,
>
> I didn't receive any comments to the first posting of this patch, so  
> here
> it is again, this time with commented code, and a better explanation:  
> :)
>
> If you commit with 'svn ci . -m "Oneliner comment"' you get this:
>
> ----------------------------------------------------------------------- 
> -
> r18 | patrik | 2004-03-26 20:52:58 +0200 (Fri, 26 Mar 2004) | 1 line
>
> Oneliner comment
> ----------------------------------------------------------------------- 
> -
>
> ...but if you enter the log message via $EDITOR, you get this:
>
> ----------------------------------------------------------------------- 
> -
> r19 | patrik | 2004-03-26 20:53:45 +0200 (Fri, 26 Mar 2004) | 2 lines
>
> Oneliner comment
>
> ----------------------------------------------------------------------- 
> -
>
> The patch below removes the extra blank line.

Ironically, I always go out of my way to add the extra newline when  
specifying my commit message on the command line because I think it  
looks nicer in the log output ;-)

So yeah, I'd rather just leave it the way it is, or if I thought I  
could get away with it I'd love to add the newline at the end of  
whatever we got from the command line.

-garrett


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org