summaryrefslogtreecommitdiff
path: root/usr.bin/cvs/logmsg.c
diff options
context:
space:
mode:
authorTobias Stoeckmann <tobias@cvs.openbsd.org>2008-06-08 20:08:44 +0000
committerTobias Stoeckmann <tobias@cvs.openbsd.org>2008-06-08 20:08:44 +0000
commit4cae2a9aaccefd813f3d221cdc60abc88d3b6df9 (patch)
treebec6e5a3acca206a929fa5c437d610b6ba1673b2 /usr.bin/cvs/logmsg.c
parent7d829f821d596d1784575f3740d354527557e722 (diff)
Handle commits on a per-directory basis instead handling all of them at
once in local setup. Also added '!' to reuse typed log message for all following directories. ok joris
Diffstat (limited to 'usr.bin/cvs/logmsg.c')
-rw-r--r--usr.bin/cvs/logmsg.c55
1 files changed, 43 insertions, 12 deletions
diff --git a/usr.bin/cvs/logmsg.c b/usr.bin/cvs/logmsg.c
index a2d440ce1ad..bf02daf29be 100644
--- a/usr.bin/cvs/logmsg.c
+++ b/usr.bin/cvs/logmsg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: logmsg.c,v 1.48 2008/05/22 15:46:30 tobias Exp $ */
+/* $OpenBSD: logmsg.c,v 1.49 2008/06/08 20:08:43 tobias Exp $ */
/*
* Copyright (c) 2007 Joris Vink <joris@openbsd.org>
*
@@ -21,6 +21,7 @@
#include <errno.h>
#include <fcntl.h>
+#include <libgen.h>
#include <paths.h>
#include <signal.h>
#include <stdlib.h>
@@ -92,14 +93,19 @@ cvs_logmsg_read(const char *path)
}
char *
-cvs_logmsg_create(struct cvs_flisthead *added, struct cvs_flisthead *removed,
- struct cvs_flisthead *modified)
+cvs_logmsg_create(char *dir, struct cvs_flisthead *added,
+ struct cvs_flisthead *removed, struct cvs_flisthead *modified)
{
FILE *fp;
int c, fd, saved_errno;
struct cvs_filelist *cf;
struct stat st1, st2;
char *fpath, *logmsg;
+ static int reuse = 0;
+ static char *prevmsg = NULL;
+
+ if (reuse)
+ return xstrdup(prevmsg);
(void)xasprintf(&fpath, "%s/cvsXXXXXXXXXX", cvs_tmpdir);
@@ -114,31 +120,44 @@ cvs_logmsg_create(struct cvs_flisthead *added, struct cvs_flisthead *removed,
fatal("cvs_logmsg_create: fdopen %s", strerror(saved_errno));
}
- fprintf(fp, "\n%s %s\n%s Enter Log. Lines beginning with `%s' are "
+ if (prevmsg != NULL && prevmsg[0] != '\0')
+ fprintf(fp, "%s", prevmsg);
+ else
+ fputc('\n', fp);
+
+ fprintf(fp, "%s %s\n%s Enter Log. Lines beginning with `%s' are "
"removed automatically\n%s\n", CVS_LOGMSG_PREFIX, CVS_LOGMSG_LINE,
CVS_LOGMSG_PREFIX, CVS_LOGMSG_PREFIX, CVS_LOGMSG_PREFIX);
+ if (cvs_cmdop == CVS_OP_COMMIT) {
+ fprintf(fp, "%s Committing in %s\n%s\n", CVS_LOGMSG_PREFIX,
+ dir != NULL ? dir : ".", CVS_LOGMSG_PREFIX);
+ }
+
if (added != NULL && !TAILQ_EMPTY(added)) {
fprintf(fp, "%s Added Files:", CVS_LOGMSG_PREFIX);
TAILQ_FOREACH(cf, added, flist)
- fprintf(fp, "\n%s\t%s",
- CVS_LOGMSG_PREFIX, cf->file_path);
+ fprintf(fp, "\n%s\t%s", CVS_LOGMSG_PREFIX,
+ dir != NULL ? basename(cf->file_path) :
+ cf->file_path);
fputs("\n", fp);
}
if (removed != NULL && !TAILQ_EMPTY(removed)) {
fprintf(fp, "%s Removed Files:", CVS_LOGMSG_PREFIX);
TAILQ_FOREACH(cf, removed, flist)
- fprintf(fp, "\n%s\t%s",
- CVS_LOGMSG_PREFIX, cf->file_path);
+ fprintf(fp, "\n%s\t%s", CVS_LOGMSG_PREFIX,
+ dir != NULL ? basename(cf->file_path) :
+ cf->file_path);
fputs("\n", fp);
}
if (modified != NULL && !TAILQ_EMPTY(modified)) {
fprintf(fp, "%s Modified Files:", CVS_LOGMSG_PREFIX);
TAILQ_FOREACH(cf, modified, flist)
- fprintf(fp, "\n%s\t%s",
- CVS_LOGMSG_PREFIX, cf->file_path);
+ fprintf(fp, "\n%s\t%s", CVS_LOGMSG_PREFIX,
+ dir != NULL ? basename(cf->file_path) :
+ cf->file_path);
fputs("\n", fp);
}
@@ -166,21 +185,33 @@ cvs_logmsg_create(struct cvs_flisthead *added, struct cvs_flisthead *removed,
if (st1.st_mtime != st2.st_mtime) {
logmsg = cvs_logmsg_read(fpath);
+ if (prevmsg != NULL)
+ xfree(prevmsg);
+ prevmsg = xstrdup(logmsg);
break;
}
printf("\nLog message unchanged or not specified\n"
- "a)bort, c)ontinue, e)dit\nAction: (continue) ");
+ "a)bort, c)ontinue, e)dit, !)reuse this message "
+ "unchanged for remaining dirs\nAction: (continue) ");
(void)fflush(stdout);
c = getc(stdin);
if (c == EOF || c == 'a') {
fatal("Aborted by user");
} else if (c == '\n' || c == 'c') {
- logmsg = xstrdup("");
+ if (prevmsg == NULL)
+ prevmsg = xstrdup("");
+ logmsg = xstrdup(prevmsg);
break;
} else if (c == 'e') {
continue;
+ } else if (c == '!') {
+ reuse = 1;
+ if (prevmsg == NULL)
+ prevmsg = xstrdup("");
+ logmsg = xstrdup(prevmsg);
+ break;
} else {
cvs_log(LP_ERR, "invalid input");
continue;