diff options
author | Jean-Francois Brousseau <jfb@cvs.openbsd.org> | 2004-12-02 17:45:45 +0000 |
---|---|---|
committer | Jean-Francois Brousseau <jfb@cvs.openbsd.org> | 2004-12-02 17:45:45 +0000 |
commit | 34ea7e790b2a4ba10e9baf8054e62459100a4643 (patch) | |
tree | b43f2d79e6dfb24385a8fffe8816b23ed84430c0 /usr.bin/cvs | |
parent | 0706df6ac5d7c58ae49f68d8e7c7953d00352112 (diff) |
cvs_logmsg_get() now accepts a list of files that it is getting the
message for and displays those files in the commented part of the
log message
Diffstat (limited to 'usr.bin/cvs')
-rw-r--r-- | usr.bin/cvs/cvs.h | 4 | ||||
-rw-r--r-- | usr.bin/cvs/logmsg.c | 52 |
2 files changed, 39 insertions, 17 deletions
diff --git a/usr.bin/cvs/cvs.h b/usr.bin/cvs/cvs.h index c9915a81e23..9b972c5a971 100644 --- a/usr.bin/cvs/cvs.h +++ b/usr.bin/cvs/cvs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cvs.h,v 1.32 2004/11/26 15:15:36 jfb Exp $ */ +/* $OpenBSD: cvs.h,v 1.33 2004/12/02 17:45:44 jfb Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -282,7 +282,7 @@ int cvs_hist_append (CVSHIST *, struct cvs_hent *); /* from logmsg.c */ char* cvs_logmsg_open (const char *); -char* cvs_logmsg_get (const char *); +char* cvs_logmsg_get (const char *, struct cvs_flist *); int cvs_logmsg_send (struct cvsroot *, const char *); /* from util.c */ diff --git a/usr.bin/cvs/logmsg.c b/usr.bin/cvs/logmsg.c index 5ac6c3ee50d..b9d0ea7ac54 100644 --- a/usr.bin/cvs/logmsg.c +++ b/usr.bin/cvs/logmsg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: logmsg.c,v 1.2 2004/11/26 16:23:50 jfb Exp $ */ +/* $OpenBSD: logmsg.c,v 1.3 2004/12/02 17:45:44 jfb Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -39,10 +39,9 @@ #include "proto.h" -#define CVS_LOGMSG_TERMWIDTH 80 #define CVS_LOGMSG_BIGMSG 32000 #define CVS_LOGMSG_FTMPL "/tmp/cvsXXXXXXXXXX" -#define CVS_LOGMSG_LOGPREFIX "CVS:" +#define CVS_LOGMSG_PREFIX "CVS:" #define CVS_LOGMSG_LOGLINE \ "----------------------------------------------------------------------" @@ -124,8 +123,8 @@ cvs_logmsg_open(const char *path) len = strlen(lbuf); if (len == 0) continue; - else if ((lcont == 0) && (strncmp(lbuf, CVS_LOGMSG_LOGPREFIX, - strlen(CVS_LOGMSG_LOGPREFIX)) == 0)) + else if ((lcont == 0) && (strncmp(lbuf, CVS_LOGMSG_PREFIX, + strlen(CVS_LOGMSG_PREFIX)) == 0)) /* skip lines starting with the prefix */ continue; @@ -150,12 +149,13 @@ cvs_logmsg_open(const char *path) */ char* -cvs_logmsg_get(const char *dir) +cvs_logmsg_get(const char *dir, struct cvs_flist *files) { - int ret, fd, argc, fds[3]; - size_t len; - char *argv[4], buf[16], path[MAXPATHLEN], *msg; + int ret, fd, argc, fds[3], nl; + size_t len, tlen; + char *argv[4], buf[16], path[MAXPATHLEN], fpath[MAXPATHLEN], *msg; FILE *fp; + CVSFILE *cvsfp; struct stat st1, st2; msg = NULL; @@ -176,19 +176,41 @@ cvs_logmsg_get(const char *dir) fp = fdopen(fd, "w"); if (fp == NULL) { cvs_log(LP_ERRNO, "failed to fdopen"); + (void)close(fd); + if (unlink(path) == -1) + cvs_log(LP_ERRNO, "failed to unlink temporary file"); + return (NULL); } else { fprintf(fp, "\n%s %s\n%s Enter Log. Lines beginning with `%s' are " "removed automatically\n%s\n%s Commiting in %s\n" - "%s\n%s Modified Files:\n", - CVS_LOGMSG_LOGPREFIX, CVS_LOGMSG_LOGLINE, - CVS_LOGMSG_LOGPREFIX, CVS_LOGMSG_LOGPREFIX, - CVS_LOGMSG_LOGPREFIX, CVS_LOGMSG_LOGPREFIX, - dir, CVS_LOGMSG_LOGPREFIX, CVS_LOGMSG_LOGPREFIX); + "%s\n", + CVS_LOGMSG_PREFIX, CVS_LOGMSG_LOGLINE, + CVS_LOGMSG_PREFIX, CVS_LOGMSG_PREFIX, + CVS_LOGMSG_PREFIX, CVS_LOGMSG_PREFIX, + dir, CVS_LOGMSG_PREFIX); /* XXX list files here */ + fprintf(fp, "%s Modified Files:", CVS_LOGMSG_PREFIX); + nl = 1; + TAILQ_FOREACH(cvsfp, files, cf_list) { + /* take the space into account */ + cvs_file_getpath(cvsfp, fpath, sizeof(fpath)); + len = strlen(fpath) + 1; + if (tlen + len >= 72) + nl = 1; + + if (nl) { + fprintf(fp, "\n%s\t", CVS_LOGMSG_PREFIX); + tlen = 8; + nl = 0; + } + + fprintf(fp, " %s", fpath); + tlen += len; + } - fprintf(fp, "%s %s\n", CVS_LOGMSG_LOGPREFIX, + fprintf(fp, "\n%s %s\n", CVS_LOGMSG_PREFIX, CVS_LOGMSG_LOGLINE); } (void)fflush(fp); |