From mark@thuvia.demon.co.uk  Fri Jun 15 20:14:57 2001
Return-Path: <mark@thuvia.demon.co.uk>
Received: from phaidor.thuvia.org (thuvia.demon.co.uk [193.237.34.248])
	by hub.freebsd.org (Postfix) with ESMTP id 04B6737B401
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 15 Jun 2001 20:14:56 -0700 (PDT)
	(envelope-from mark@thuvia.demon.co.uk)
Received: from dotar-sojat.thuvia.org (dotar-sojat.thuvia.org [10.0.0.4])
	by phaidor.thuvia.org (8.11.3/8.11.3) with ESMTP id f5G3F6S02031
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 16 Jun 2001 04:15:18 +0100 (BST)
	(envelope-from mark@dotar-sojat.thuvia.org)
Received: (from mark@localhost)
	by dotar-sojat.thuvia.org (8.11.4/8.11.4) id f5G3En399530;
	Sat, 16 Jun 2001 04:14:49 +0100 (BST)
	(envelope-from mark)
Message-Id: <200106160314.f5G3En399530@dotar-sojat.thuvia.org>
Date: Sat, 16 Jun 2001 04:14:49 +0100 (BST)
From: Mark Valentine <mark@thuvia.demon.co.uk>
Reply-To: Mark Valentine <mark@thuvia.demon.co.uk>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] fix for detecting empty CVS commit log message
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         28189
>Category:       gnu
>Synopsis:       [PATCH] fix for detecting empty CVS commit log message
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jun 15 20:20:04 PDT 2001
>Closed-Date:    Sat Jun 21 02:15:15 UTC 2008
>Last-Modified:  Sat Jun 21 02:15:15 UTC 2008
>Originator:     Mark Valentine
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
Thuvia Labs
>Environment:
System: FreeBSD dotar-sojat.thuvia.org 5.0-CURRENT FreeBSD 5.0-CURRENT #7: Thu Jun 7 16:34:58 BST 2001 root@dotar-sojat:/usr/obj/usr/src/sys/DOTAR i386
>Description:
	CVS attempts to detect an empty or unchanged log message from a commit
	log editing session, but misses a case where someone tries to abort a
	commit by deleting all but the CVS: lines before quitting the editor
	(it does detect the case where the leading blank line inserted by cvs
	is left in; note that the latest CVS sources don't appear to insert
	this blank line).

	The patch below detects this case, which I know has caught many people
	out over the years, but I'd always put down to the effects of a very
	simple detection algorithm rather than a bug (until I finally looked
	at the code just now, trying to be more clever than I'd had it down
	for).

	With this fix, all of the following ways of aborting a commit work:

	 a) quit the edit without saving the temp file
	 b) delete all lines in the file before saving and quitting
	 c) delete all non-CVS: prefix lines before saving and quitting
	 d) delete all non-CVS: prefix lines but for a single blank line
	    before saving and quitting

	That is, the file must be either untouched after the edit (mtime),
	or must be empty or contain a single newline apart from any CVS:
	prefixed lines.  You can do whatever you want with the CVS: lines,
	it's what's left once these are stripped which counts.

	Specifically, the patch fixes case (c).
>How-To-Repeat:
	Delete all lines _not_ beginning with ``CVS:'' before quitting the
	editor when creating a cvs commit log message; watch your commit go
	through with an empty log message.
>Fix:

A version of this fix against the current CVS sources has been submitted
to bug-cvs@gnu.org.

Index: contrib/cvs/src/logmsg.c
===================================================================
RCS file: /usr/cvs/src/contrib/cvs/src/logmsg.c,v
retrieving revision 1.7
diff -u -r1.7 logmsg.c
--- contrib/cvs/src/logmsg.c	2000/10/02 06:43:56	1.7
+++ contrib/cvs/src/logmsg.c	2001/06/16 02:20:58
@@ -339,7 +339,7 @@
 	error (0, errno, "warning: cannot close %s", fname);
 
     if (pre_stbuf.st_mtime == post_stbuf.st_mtime ||
-	*messagep == NULL ||
+	*messagep == NULL || (*messagep)[0] == '\0' ||
 	strcmp (*messagep, "\n") == 0)
     {
 	for (;;)
>Release-Note:
>Audit-Trail:

From: Mark Valentine <mark@thuvia.demon.co.uk>
To: FreeBSD-gnats-submit@freebsd.org
Cc:  
Subject: Re: gnu/28189: [PATCH] fix for detecting empty CVS commit log message
Date: Wed, 20 Jun 2001 22:22:26 +0100 (BST)

 Here's a new patch incorporating the official fix which was checked into the
 cvs cvs(!) tree; it also fixes a related memory leak.
 
 ChangeLog entry as follows:
 
 2001-06-20  Derek Price  <dprice@collab.net>
 
 	* logmsg.c (do_editor): Abort in the case that the file has only
 	comment lines.
 	(Original patch from Mark Valentine <mark@thuvia.demon.co.uk>.)
 
 	* logmsg.c (do_editor): Fix rare memory leak.
 
 Index: contrib/cvs/src/logmsg.c
 ===================================================================
 RCS file: /usr/cvs/src/contrib/cvs/src/logmsg.c,v
 retrieving revision 1.7
 diff -u -r1.7 logmsg.c
 --- contrib/cvs/src/logmsg.c	2000/10/02 06:43:56	1.7
 +++ contrib/cvs/src/logmsg.c	2001/06/20 17:08:31
 @@ -307,7 +307,7 @@
  	/* On NT, we might read less than st_size bytes, but we won't
  	   read more.  So this works.  */
  	*messagep = (char *) xmalloc (post_stbuf.st_size + 1);
 - 	*messagep[0] = '\0';
 + 	(*messagep)[0] = '\0';
      }
  
      line = NULL;
 @@ -340,8 +340,14 @@
  
      if (pre_stbuf.st_mtime == post_stbuf.st_mtime ||
  	*messagep == NULL ||
 +	(*messagep)[0] == '\0' ||
  	strcmp (*messagep, "\n") == 0)
      {
 +	if (*messagep)
 +	{
 +	    free (*messagep);
 +	    *messagep = NULL;
 +	}
  	for (;;)
  	{
  	    (void) printf ("\nLog message unchanged or not specified\n");
 
 -- 
 Mark Valentine, Thuvia Labs <mark@thuvia.co.uk>       <http://www.thuvia.co.uk>
 "Tigers will do ANYTHING for a tuna fish sandwich."       Mark Valentine uses
 "We're kind of stupid that way."   *munch* *munch*        and endorses FreeBSD
   -- <http://www.calvinandhobbes.com>                  <http://www.freebsd.org>
State-Changed-From-To: open->analyzed 
State-Changed-By: asmodai 
State-Changed-When: Tue Jul 31 09:24:28 PDT 2001 
State-Changed-Why:  
I am currently raising the issue to import cvs 1.11.1p1, don't know 
yet if this release contains this fix.  Will look tonight. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=28189 
State-Changed-From-To: analyzed->closed 
State-Changed-By: linimon 
State-Changed-When: Sat Jun 21 02:14:42 UTC 2008 
State-Changed-Why:  
Apparently fixed in all supported versions of FreeBSD. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=28189 
>Unformatted:
