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/27 18:34:06 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 Juanma Barranquero <jm...@wke.es>.
On Mon, 29 Mar 2004 06:23:41 -0500
Greg Hudson <gh...@MIT.EDU> wrote:

> My reasoning is that it's more useful to say "a log message is some
> lines of UTF-8 text, each terminated by a newline" than it is to just
> say "a log message is some UTF-8 text."

My reasoning was just the contrary: a log message is arbitrary utf-8
data. Whether that data is composed of lines or not is entirely up to
the commiter (user, program, whatever).

> Since CMike didn't like this part of the idea, I'll elaborate.  If the
> log message doesn't fit into our "lines of text" model, we should
> massage it until it does.  It's not exceptionally important that "svn
> log" convey to us precisely what's in the svn:log property; we have svn
> propget for that.

Hmm... I agree with you here, so I must be wrong on the first paragraph...
:(

My problem with the finishing \n in svn:log was aesthetic: I didn't like
to have svn log output with both

  whatever
  ---------------------

and 

  whatever

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

On second thought, I think you're right: the svn:log should be
considered lines, and svn log should make an effort to show it right.
The property is not called "svn:log" by accident, after all. It is
entirely reasonable to assume things about its contents. And svn log
(with no --xml) is intended for human consumption, so it should help
readability.

> Since the working copy keeps no state about revision
> properties, I think it should be just fine to add a note that it's okay
> to set them in the pre-commit hook.

Glad to hear.


                                                                Juanma



---------------------------------------------------------------------
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 kf...@collab.net.
Greg Hudson <gh...@MIT.EDU> writes:
> That's purely so you don't mess up the working copy which performed the
> commit.  Since the working copy keeps no state about revision
> properties, I think it should be just fine to add a note that it's okay
> to set them in the pre-commit hook.

Done in r9221.

---------------------------------------------------------------------
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 Greg Hudson <gh...@MIT.EDU>.
On Mon, 2004-03-29 at 06:05, Juanma Barranquero wrote:
> Greg Hudson <gh...@MIT.EDU> wrote:
> 
> > I'd say the best behavior would be to ensure at commit time that there
> > is a newline at the end of the log message
> 
> Uh?

My reasoning is that it's more useful to say "a log message is some
lines of UTF-8 text, each terminated by a newline" than it is to just
say "a log message is some UTF-8 text."

> > and to only put an extra
> > newline at the end of the message in "svn log" if there isn't one
> > already there.
> 
> That's cool.

Since CMike didn't like this part of the idea, I'll elaborate.  If the
log message doesn't fit into our "lines of text" model, we should
massage it until it does.  It's not exceptionally important that "svn
log" convey to us precisely what's in the svn:log property; we have svn
propget for that.

> When I was writing my hook I posted a message about whether was kosher
> or not to modify svn:log in a pre-commit hook (as there's a big "NOTE:
> THE HOOK PROGRAM MUST NOT MODIFY THE TXN" in pre-commit.tmpl).

That's purely so you don't mess up the working copy which performed the
commit.  Since the working copy keeps no state about revision
properties, I think it should be just fine to add a note that it's okay
to set them in the pre-commit hook.


---------------------------------------------------------------------
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 Juanma Barranquero <jm...@wke.es>.
On Sat, 27 Mar 2004 23:06:12 -0500
Greg Hudson <gh...@MIT.EDU> wrote:

> I'd say the best behavior would be to ensure at commit time that there
> is a newline at the end of the log message

Uh?

I wrote a pre-commit hook with the exact goal of removing the \n at the
end of the log property, because I hate it...

> and to only put an extra
> newline at the end of the message in "svn log" if there isn't one
> already there.

That's cool.

Related to this issue:

When I was writing my hook I posted a message about whether was kosher
or not to modify svn:log in a pre-commit hook (as there's a big "NOTE:
THE HOOK PROGRAM MUST NOT MODIFY THE TXN" in pre-commit.tmpl).

Someone (I think it was Karl) said that it was probably OK and that the
pre-commit.tmpl comment could be changed to reflect that.

Now I'm even depending on svn:author being changeable in pre-commit. Why?
Because my setup is SSL-only access, with

  SSLOptions +StrictRequire +FakeBasicAuth
  SSLVerifyClient require
  SSLVerifyDepth 1

(I don't want anonymous access,) so commits have author strings like:

  /C=ES/L=Madrid/O=MyCompany/OU=MyDepartment/CN=Juanma Barranquero

which in logs and ViewCVS is, how to say... unwieldy? My hook translates
them into our internal usernames, in this case "jbarranquero". Works
like a charm.

Understandably (I hope :) I'm now still more eager than ever to see
documented the fact that revision properties are changeable in
pre-commit. I could do a patch for subversion/libsvn_repos/repos.c to
adapt the comment, but I'm not sure if there's an agreement on that
issue or not.

                                                                Juanma



---------------------------------------------------------------------
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 Julian Foad <ju...@btopenworld.com>.
Greg Hudson wrote:
> 
> I think it's uncharitable to call it "pilot error"; it's a matter of
> taste how we should be handling newlines in log messages.

Yes.  We already do certain transformations, such as converting all of the line endings to the native type, and, if the message is provided from an editor, converting an all-white-space message to an empty message.

I agree that adding blank lines to log messages is generally an ugly thing to do.  (If one wants an extra blank line before the row of dashes in "svn log" output, that's a separate thing that should not be counted in the log message line count nor be output by "svn propget svn:log" etc.)

> I'd say the best behavior would be to ensure at commit time that there
> is a newline at the end of the log message, and to only put an extra
> newline at the end of the message in "svn log" if there isn't one
> already there.

That sounds like a nice solution.  "svn propget svn:log --strict" could still output the exact store message.

When I brought up something like this before, I was told that we wanted the exact form of the originally provided log message to be recoverable from "svn log" output, including whether it ended with a newline, but I am not sure that that is really a very useful thing to do.

I would very much like the "svn log" output to count a one-line log message as "1 line" and not add a blank line and count it as "2 lines".

I'd also say, make sure that there is _only_ one newline at the end of the message, and strip any extra white space.  This particularly makes sense when the message has been written above the marker line.

The Subversion project has a policy of always writing a log message, but some projects don't and so I would like to see empty log messages handled more neatly in the "svn log" output: instead of

------------------------------------------------------------------------
r91 | julianfoad | 2004-03-26 10:47:05 +0000 (Fri, 26 Mar 2004) | 1 line


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

I would prefer to see

------------------------------------------------------------------------
r91 | julianfoad | 2004-03-26 10:47:05 +0000 (Fri, 26 Mar 2004) | 0 lines

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

or, even better,

------------------------------------------------------------------------
r91 | julianfoad | 2004-03-26 10:47:05 +0000 (Fri, 26 Mar 2004) | 0 lines
------------------------------------------------------------------------

Note that this latter form is still programmatically parseable, but requires an extra step: "if 0 lines then don't expect a blank separator line".  The attached patch changes the display of blank log messages to this latter form, without affecting the display of other log messages.  I haven't posted it before because I think we should form a consensus on all of these log message blank line issues before making a change.

I don't know whether we will alow ourselves to change this now until version 2, but those of us who are interested might as well discuss what we would like to see.

- Julian

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

Posted by "C. Michael Pilato" <cm...@collab.net>.
Nuutti Kotivuori <na...@iki.fi> writes:

> Greg Hudson wrote:
> > I'd say the best behavior would be to ensure at commit time that
> > there is a newline at the end of the log message, and to only put an
> > extra newline at the end of the message in "svn log" if there isn't
> > one already there.
> 
> I'm +1 on the general sentiment. I hate it how I have to type svn
> commit -m "Doodled da dingamajik.\n" to be consistent with the commit
> messages made from an editor, since for me, those always contain a
> final newline.

I'm -0, and further can't believe there actually exist people more
obnoxious about formatting consistency than I am! :-)

---------------------------------------------------------------------
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 Nuutti Kotivuori <na...@iki.fi>.
Greg Hudson wrote:
> I'd say the best behavior would be to ensure at commit time that
> there is a newline at the end of the log message, and to only put an
> extra newline at the end of the message in "svn log" if there isn't
> one already there.

I'm +1 on the general sentiment. I hate it how I have to type svn
commit -m "Doodled da dingamajik.\n" to be consistent with the commit
messages made from an editor, since for me, those always contain a
final newline.

Not to even mention those punks who end up committing a bunch of
newlines after a log message because they've scrolled too far down in
emacs ;-)

-- Naked


---------------------------------------------------------------------
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 Greg Hudson <gh...@MIT.EDU>.
On Sat, 2004-03-27 at 18:36, kfogel@collab.net wrote:
> No need for a patch -- this is almost certainly pilot error.

I think it's uncharitable to call it "pilot error"; it's a matter of
taste how we should be handling newlines in log messages.

I'd say the best behavior would be to ensure at commit time that there
is a newline at the end of the log message, and to only put an extra
newline at the end of the message in "svn log" if there isn't one
already there.

I bet that's how CVS behaves, but I'm too lazy to check. :)


---------------------------------------------------------------------
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 kf...@collab.net.
Patrik Rådman <pr...@abo.fi> writes:
> The output from $EDITOR contains this:
> 
> ---------start cut'n'paste---------
> Oneliner comment
> --This line, and those below, will be ignored--
> 
> M    foobar
> ----------end cut'n'paste----------
> 
> So, the current code removes the comments at the end, but leaves a
> newline. That is what my patch tries to fix.

Sure.  My point was, you could remove every character from after the
word "comment" to the end of the file, *including* the newline that
separates "comment" from "--This line...", and then you'd get the same
behavior.  If you rely on Subversion's own stripping code, then it
will leave that newline in.

So there is a consistency here.

-K

---------------------------------------------------------------------
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>.
kfogel@collab.net wrote:
> This seemed to be posted twice, and Mike Pilato already responded to
> the first one, but I'll respond here just to make sure:

Yes, sorry about that, when the first mail hadn't appeared on the list
after 24 hours I re-sent it, and then of course the original mail arrived
5 minutes later. :P

> No need for a patch -- this is almost certainly pilot error.
> 
> The first log message (from the command line) does not contain a
> newline.  The second one (made with $EDITOR) does.  If you make
> *absolutely sure* that your editor saves the log message without any
> newline -- some editors automatically ensure one at the end of a file,
> so be careful! -- then you will see the 'svn log' output is the same
> as with the -m"Oneliner comment" method.

The output from $EDITOR contains this:

---------start cut'n'paste---------
Oneliner comment
--This line, and those below, will be ignored--

M    foobar
----------end cut'n'paste----------

So, the current code removes the comments at the end, but leaves a
newline. That is what my patch tries to fix.

 -- 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 kf...@collab.net.
This seemed to be posted twice, and Mike Pilato already responded to
the first one, but I'll respond here just to make sure:

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: :)
> 
> 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.

No need for a patch -- this is almost certainly pilot error.

The first log message (from the command line) does not contain a
newline.  The second one (made with $EDITOR) does.  If you make
*absolutely sure* that your editor saves the log message without any
newline -- some editors automatically ensure one at the end of a file,
so be careful! -- then you will see the 'svn log' output is the same
as with the -m"Oneliner comment" method.

Hope this helps,
-Karl

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