One of the new cvs's features is to be able to run a checker on the
log messages after they've been entered. This is more flexible than using the editinfo script since it works for all log message types and doesn't have to deal with trying to run the editor for the user. The problem is that the verifymsg script can't modify the file like editinfo can, which makes it useless for cleaning up the message (as is needed for remote commits etc). This change causes the verifymsg handler to read back the message after the verify script has run and returned an "OK" exit code.
This commit is contained in:
parent
617293d4e4
commit
e271dbd9f6
@ -486,7 +486,7 @@ commit (argc, argv)
|
||||
/* Run the user-defined script to verify/check information in
|
||||
*the log message
|
||||
*/
|
||||
do_verify (message, (char *)NULL);
|
||||
do_verify (&message, (char *)NULL);
|
||||
|
||||
/* We always send some sort of message, even if empty. */
|
||||
option_with_arg ("-m", message);
|
||||
@ -1110,7 +1110,7 @@ commit_fileproc (callerdat, finfo)
|
||||
got_message = 1;
|
||||
if (use_editor)
|
||||
do_editor (finfo->update_dir, &message, finfo->repository, ulist);
|
||||
do_verify (message, finfo->repository);
|
||||
do_verify (&message, finfo->repository);
|
||||
}
|
||||
|
||||
p = findnode (cilist, finfo->file);
|
||||
@ -1400,7 +1400,7 @@ commit_direntproc (callerdat, dir, repos, update_dir, entries)
|
||||
got_message = 1;
|
||||
if (use_editor)
|
||||
do_editor (update_dir, &message, real_repos, ulist);
|
||||
do_verify (message, real_repos);
|
||||
do_verify (&message, real_repos);
|
||||
free (real_repos);
|
||||
return (R_PROCESS);
|
||||
}
|
||||
|
@ -539,7 +539,7 @@ void Update_Logfile PROTO((char *repository, char *xmessage, FILE * xlogfp,
|
||||
void do_editor PROTO((char *dir, char **messagep,
|
||||
char *repository, List * changes));
|
||||
|
||||
void do_verify PROTO((char *message, char *repository));
|
||||
void do_verify PROTO((char **messagep, char *repository));
|
||||
|
||||
typedef int (*CALLBACKPROC) PROTO((int *pargc, char *argv[], char *where,
|
||||
char *mwhere, char *mfile, int horten, int local_specified,
|
||||
|
@ -195,7 +195,7 @@ import (argc, argv)
|
||||
do_editor ((char *) NULL, &message, repository,
|
||||
(List *) NULL);
|
||||
}
|
||||
do_verify (message, repository);
|
||||
do_verify (&message, repository);
|
||||
msglen = message == NULL ? 0 : strlen (message);
|
||||
if (msglen == 0 || message[msglen - 1] != '\n')
|
||||
{
|
||||
|
@ -377,14 +377,20 @@ do_editor (dir, messagep, repository, changes)
|
||||
independant of the running of an editor for getting a message.
|
||||
*/
|
||||
void
|
||||
do_verify (message, repository)
|
||||
char *message;
|
||||
do_verify (messagep, repository)
|
||||
char **messagep;
|
||||
char *repository;
|
||||
{
|
||||
FILE *fp;
|
||||
char *fname;
|
||||
int retcode = 0;
|
||||
|
||||
char *line;
|
||||
int line_length;
|
||||
size_t line_chars_allocated;
|
||||
char *p;
|
||||
struct stat stbuf;
|
||||
|
||||
#ifdef CLIENT_SUPPORT
|
||||
if (client_active)
|
||||
/* The verification will happen on the server. */
|
||||
@ -398,7 +404,7 @@ do_verify (message, repository)
|
||||
|
||||
/* If there's no message, then we have nothing to verify. Can this
|
||||
case happen? And if so why would we print a message? */
|
||||
if (message == NULL)
|
||||
if (*messagep == NULL)
|
||||
{
|
||||
cvs_output ("No message to verify\n", 0);
|
||||
return;
|
||||
@ -417,9 +423,9 @@ do_verify (message, repository)
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (fp, "%s", message);
|
||||
if ((message)[0] == '\0' ||
|
||||
(message)[strlen (message) - 1] != '\n')
|
||||
fprintf (fp, "%s", *messagep);
|
||||
if ((*messagep)[0] == '\0' ||
|
||||
(*messagep)[strlen (*messagep) - 1] != '\n')
|
||||
(void) fprintf (fp, "%s", "\n");
|
||||
if (fclose (fp) == EOF)
|
||||
error (1, errno, "%s", fname);
|
||||
@ -442,6 +448,55 @@ do_verify (message, repository)
|
||||
"Message verification failed");
|
||||
}
|
||||
|
||||
/* put the entire message back into the *messagep variable */
|
||||
|
||||
fp = open_file (fname, "r");
|
||||
if (fp == NULL)
|
||||
{
|
||||
error (1, errno, "cannot open temporary file %s", fname);
|
||||
return;
|
||||
}
|
||||
|
||||
if (*messagep)
|
||||
free (*messagep);
|
||||
|
||||
if ( CVS_STAT (fname, &stbuf) != 0)
|
||||
error (1, errno, "cannot find size of temp file %s", fname);
|
||||
|
||||
if (stbuf.st_size == 0)
|
||||
*messagep = NULL;
|
||||
else
|
||||
{
|
||||
/* On NT, we might read less than st_size bytes, but we won't
|
||||
read more. So this works. */
|
||||
*messagep = (char *) xmalloc (stbuf.st_size + 1);
|
||||
*messagep[0] = '\0';
|
||||
}
|
||||
|
||||
line = NULL;
|
||||
line_chars_allocated = 0;
|
||||
|
||||
if (*messagep)
|
||||
{
|
||||
p = *messagep;
|
||||
while (1)
|
||||
{
|
||||
line_length = getline (&line, &line_chars_allocated, fp);
|
||||
if (line_length == -1)
|
||||
{
|
||||
if (ferror (fp))
|
||||
error (0, errno, "warning: cannot read %s", fname);
|
||||
break;
|
||||
}
|
||||
if (strncmp (line, CVSEDITPREFIX, CVSEDITPREFIXLEN) == 0)
|
||||
continue;
|
||||
(void) strcpy (p, line);
|
||||
p += line_length;
|
||||
}
|
||||
}
|
||||
if (fclose (fp) < 0)
|
||||
error (0, errno, "warning: cannot close %s", fname);
|
||||
|
||||
/* Close and delete the temp file */
|
||||
|
||||
unlink_file (fname);
|
||||
|
Loading…
Reference in New Issue
Block a user