diff options
author | 2005-07-23 00:03:00 +0000 | |
---|---|---|
committer | 2005-07-23 00:03:00 +0000 | |
commit | a4c69cc6c8a2098a78b7f72edae5372b4fd33cd5 (patch) | |
tree | 3420b69ff557a436d27380c85c1ffb5fe4fee199 /usr.bin/cvs/commit.c | |
parent | remove ICH3 workaround. (diff) | |
download | wireguard-openbsd-a4c69cc6c8a2098a78b7f72edae5372b4fd33cd5.tar.xz wireguard-openbsd-a4c69cc6c8a2098a78b7f72edae5372b4fd33cd5.zip |
correctly seperate added, modified and removed files for use in the
construction of the log message in the editor.
ok jfb@
Diffstat (limited to 'usr.bin/cvs/commit.c')
-rw-r--r-- | usr.bin/cvs/commit.c | 74 |
1 files changed, 51 insertions, 23 deletions
diff --git a/usr.bin/cvs/commit.c b/usr.bin/cvs/commit.c index 24e47e91efa..a3d6286ed77 100644 --- a/usr.bin/cvs/commit.c +++ b/usr.bin/cvs/commit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: commit.c,v 1.42 2005/07/22 16:27:29 joris Exp $ */ +/* $OpenBSD: commit.c,v 1.43 2005/07/23 00:03:00 joris Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -68,6 +68,7 @@ static char *mfile = NULL; static char *rev = NULL; static char **commit_files = NULL; static int commit_fcount = 0; +static int wantedstatus = 0; static int cvs_commit_init(struct cvs_cmd *cmd, int argc, char **argv, int *arg) @@ -123,38 +124,67 @@ cvs_commit_init(struct cvs_cmd *cmd, int argc, char **argv, int *arg) int cvs_commit_pre_exec(struct cvsroot *root) { - struct cvs_flist cl; CVSFILE *cfp; CVSFILE *tmp; - int flags = CF_RECURSE | CF_IGNORE | CF_SORT; - - SIMPLEQ_INIT(&cl); + int i, flags = CF_RECURSE | CF_IGNORE | CF_SORT; + struct cvs_flist added, modified, removed, *cl[3]; + int stattype[] = { CVS_FST_ADDED, CVS_FST_MODIFIED, CVS_FST_REMOVED }; + + SIMPLEQ_INIT(&added); + SIMPLEQ_INIT(&modified); + SIMPLEQ_INIT(&removed); + + cl[0] = &added; + cl[1] = &modified; + cl[2] = &removed; + + /* + * Obtain the file lists for the logmessage. + */ + tmp = NULL; + for (i = 0; i < 3; i++) { + if (tmp != NULL) + cvs_file_free(tmp); + + wantedstatus = stattype[i]; + + if (commit_fcount != 0) { + tmp = cvs_file_getspec(commit_files, commit_fcount, + flags, cvs_commit_prepare, cl[i]); + } else { + tmp = cvs_file_get(".", flags, cvs_commit_prepare, + cl[i]); + } - if (commit_fcount != 0) { - tmp = cvs_file_getspec(commit_files, commit_fcount, - flags, cvs_commit_prepare, &cl); - } else { - tmp = cvs_file_get(".", flags, cvs_commit_prepare, &cl); + if (tmp == NULL) + return (CVS_EX_DATA); } - if (tmp == NULL) - return (CVS_EX_DATA); - - if (SIMPLEQ_EMPTY(&cl)) { + /* + * If we didn't catch any file, don't call the editor. + */ + if (SIMPLEQ_EMPTY(&added) && SIMPLEQ_EMPTY(&modified) && + SIMPLEQ_EMPTY(&removed)) { cvs_file_free(tmp); return (0); } + /* + * Fetch the log message for real, with all the files. + */ if (cvs_msg == NULL) - cvs_msg = cvs_logmsg_get(tmp->cf_name, - NULL, &cl, NULL); + cvs_msg = cvs_logmsg_get(tmp->cf_name, &added, &modified, + &removed); cvs_file_free(tmp); - while (!SIMPLEQ_EMPTY(&cl)) { - cfp = SIMPLEQ_FIRST(&cl); - SIMPLEQ_REMOVE_HEAD(&cl, cf_list); - cvs_file_free(cfp); + /* free the file lists */ + for (i = 0; i < 3; i++) { + while (!SIMPLEQ_EMPTY(cl[i])) { + cfp = SIMPLEQ_FIRST(cl[i]); + SIMPLEQ_REMOVE_HEAD(cl[i], cf_list); + cvs_file_free(cfp); + } } if (cvs_msg == NULL) @@ -186,9 +216,7 @@ cvs_commit_prepare(CVSFILE *cf, void *arg) CVSFILE *copy; struct cvs_flist *clp = (struct cvs_flist *)arg; - if ((cf->cf_type == DT_REG) && ((cf->cf_cvstat == CVS_FST_MODIFIED) || - (cf->cf_cvstat == CVS_FST_ADDED) || - (cf->cf_cvstat == CVS_FST_REMOVED))) { + if ((cf->cf_type == DT_REG) && (cf->cf_cvstat == wantedstatus)) { copy = cvs_file_copy(cf); if (copy == NULL) return (CVS_EX_DATA); |