bug-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CVS -m sanity check patch


From: Mark D. Baushke
Subject: CVS -m sanity check patch
Date: Thu, 27 Jul 2006 18:14:31 -0700

Hi Folks,

The following patch was submitted to me directly rather than through the
normal address@hidden address. For folks that might find it useful,
here it is.

I have not looked closely at the patch myself as yet.

Does anyone have any comments on this patch (other than the obvious one
of conforming to the CVS coding standards)?

        -- Mark

  ------- forwarded message -------
Date: Fri, 28 Jul 2006 01:18:34 +0200
From: "Simon 'corecode' Schubert" <address@hidden>
To: address@hidden
Subject: cvs -m sanity check patch


[[PGP Signed Part:Simon 'corecode' Schubert <address@hidden>
Untrusted, Fingerprint: 61EB 641D 0754 B87D E50D E96B AF94 BE76 4EB3 F39A]]
Hey,

I was told I should send you the patch which we are running CVS with since 
several months at DragonFly.  It checks arguments to -m if they are indeed 
files and if they are asks if the user is serious.  This is because it turned 
out that it is a fairly common mistake to use -m instead of -F and then to 
produce meaningless log messages like "/tmp/cvsuutRZzd" :)

you of course can use the patch under the license CVS published under, or under 
a BSD style license, at your discretion.

cheers
  simon

-- 
Serve - BSD     +++  RENT this banner advert  +++    ASCII Ribbon   /"\
Work - Mac      +++  space for low €€€ NOW!1  +++      Campaign     \ /
Party Enjoy Relax   |   http://dragonflybsd.org      Against  HTML   \
Dude 2c 2 the max   !   http://golden-apple.biz       Mail + News   / \
$DragonFly: src/gnu/usr.bin/cvs/cvs/commit.c.patch,v 1.1 2006/05/27 11:59:44 
corecode Exp $
Index: src/commit.c
===================================================================
RCS file: /cvs/src/contrib/cvs-1.12/src/commit.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 commit.c
--- src/commit.c        7 Dec 2005 00:15:16 -0000       1.1.1.1
+++ src/commit.c        27 May 2006 09:20:10 -0000
@@ -443,6 +443,58 @@
            ++saved_tag;
     }
 
+    /* Check if the user passed -m, but wanted -F */
+    if (saved_message)
+    {
+       int fd;
+
+       fd = open(saved_message, O_RDONLY);
+       /* valid fd -> possibly wrong flag? */
+       if (fd >= 0)
+       {
+           char *line = NULL;
+           size_t line_alloced = 0;
+           int line_len;
+
+           close(fd);
+
+           for (;;) {
+               printf("The message you passed exists as a file\n");
+               printf("a)bort, c)ontinue, treat as f)ile name\n");
+               printf("Action: (abort) ");
+               fflush(stdout);
+               line_len = getline(&line, &line_alloced, stdin);
+               if (line_len < 0)
+               {
+                   error(0, errno, "cannot read from stdin");
+                   error(1, 0, "aborting");
+               }
+               else if (line_len == 0 || *line == '\n' || *line == 'a' || 
*line == 'A')
+               {
+                   error(1, 0, "aborted by user");
+               }
+               else if (*line == 'c' || *line == 'C')
+               {
+                   break;
+               }
+               else if (*line == 'f' || *line == 'F')
+               {
+                   /*
+                    * We are leaking the memory for the file name,
+                    * but who really cares?
+                    */
+                   logfile = saved_message;
+                   saved_message = NULL;
+                   break;
+               }
+               printf("Unknown input\n");
+           }
+
+           if (line != NULL)
+               free(line);
+       }
+    }
+
     /* some checks related to the "-F logfile" option */
     if (logfile)
     {

[[End of PGP Signed Part]]




reply via email to

[Prev in Thread] Current Thread [Next in Thread]