diff options
-rw-r--r-- | usr.bin/cvs/checkout.c | 102 | ||||
-rw-r--r-- | usr.bin/cvs/config.h | 11 | ||||
-rw-r--r-- | usr.bin/cvs/cvs.h | 3 | ||||
-rw-r--r-- | usr.bin/cvs/file.c | 12 | ||||
-rw-r--r-- | usr.bin/cvs/modules.c | 64 | ||||
-rw-r--r-- | usr.bin/cvs/repository.c | 7 |
6 files changed, 155 insertions, 44 deletions
diff --git a/usr.bin/cvs/checkout.c b/usr.bin/cvs/checkout.c index 8ace925fbde..4fecb920c85 100644 --- a/usr.bin/cvs/checkout.c +++ b/usr.bin/cvs/checkout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: checkout.c,v 1.122 2008/02/03 20:01:37 joris Exp $ */ +/* $OpenBSD: checkout.c,v 1.123 2008/02/03 22:50:28 joris Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -153,10 +153,12 @@ static void checkout_check_repository(int argc, char **argv) { int i; - char *wdir; - char repo[MAXPATHLEN]; + char *wdir, *d; struct cvs_recursion cr; struct module_checkout *mc; + struct cvs_ignpat *ip; + struct cvs_filelist *fl, *nxt; + char repo[MAXPATHLEN], fpath[MAXPATHLEN], *f[1]; build_dirs = print_stdout ? 0 : 1; @@ -211,41 +213,74 @@ checkout_check_repository(int argc, char **argv) mc = cvs_module_lookup(argv[i]); current_module = mc; - (void)xsnprintf(repo, sizeof(repo), "%s/%s", - current_cvsroot->cr_dir, mc->mc_repo); + TAILQ_FOREACH(fl, &(mc->mc_ignores), flist) + cvs_file_ignore(fl->file_path, &checkout_ign_pats); - if (!(mc->mc_flags & MODULE_ALIAS) || dflag != NULL) - module_repo_root = mc->mc_repo; + TAILQ_FOREACH(fl, &(mc->mc_modules), flist) { + (void)xsnprintf(repo, sizeof(repo), "%s/%s", + current_cvsroot->cr_dir, fl->file_path); - if (mc->mc_flags & MODULE_NORECURSE) - flags &= ~CR_RECURSE_DIRS; + if (!(mc->mc_flags & MODULE_ALIAS) || dflag != NULL) + module_repo_root = fl->file_path; - if (dflag != NULL) - wdir = dflag; - else - wdir = mc->mc_wdir; + if (mc->mc_flags & MODULE_NORECURSE) + flags &= ~CR_RECURSE_DIRS; - switch (checkout_classify(repo, mc->mc_repo)) { - case CVS_FILE: - cr.fileproc = cvs_update_local; - cr.flags = flags; + if (dflag != NULL) + wdir = dflag; + else + wdir = mc->mc_wdir; + + switch (checkout_classify(repo, fl->file_path)) { + case CVS_FILE: + cr.fileproc = cvs_update_local; + cr.flags = flags; + + if (!(mc->mc_flags & MODULE_ALIAS)) { + module_repo_root = + dirname(fl->file_path); + d = wdir; + (void)xsnprintf(fpath, sizeof(fpath), + "%s/%s", d, + basename(fl->file_path)); + } else { + d = dirname(wdir); + strlcpy(fpath, fl->file_path, + sizeof(fpath)); + } + + if (build_dirs == 1) + cvs_mkpath(d, cvs_specified_tag); + + f[0] = fpath; + cvs_file_run(1, f, &cr); + break; + case CVS_DIR: + if (build_dirs == 1) + cvs_mkpath(wdir, cvs_specified_tag); + checkout_repository(repo, wdir); + break; + default: + break; + } + } - if (build_dirs == 1) - cvs_mkpath(dirname(wdir), - cvs_specified_tag); - cvs_file_run(1, &(mc->mc_repo), &cr); - break; - case CVS_DIR: - if (build_dirs == 1) - cvs_mkpath(wdir, cvs_specified_tag); - checkout_repository(repo, wdir); - break; - default: - break; + if (mc->mc_canfree == 1) { + for (fl = TAILQ_FIRST(&(mc->mc_modules)); + fl != TAILQ_END(&(mc->mc_modules)); fl = nxt) { + nxt = TAILQ_NEXT(fl, flist); + TAILQ_REMOVE(&(mc->mc_modules), fl, flist); + xfree(fl->file_path); + xfree(fl); + } + } + + while ((ip = TAILQ_FIRST(&checkout_ign_pats)) != NULL) { + TAILQ_REMOVE(&checkout_ign_pats, ip, ip_list); + xfree(ip); } xfree(mc->mc_wdir); - xfree(mc->mc_repo); xfree(mc); } } @@ -257,11 +292,8 @@ checkout_classify(const char *repo, const char *arg) struct stat sb; if (stat(repo, &sb) == 0) { - if (!S_ISDIR(sb.st_mode)) { - cvs_log(LP_ERR, "ignoring %s: not a directory", arg); - return 0; - } - return CVS_DIR; + if (S_ISDIR(sb.st_mode)) + return CVS_DIR; } d = dirname(repo); diff --git a/usr.bin/cvs/config.h b/usr.bin/cvs/config.h index fb2cd1a9ab5..19506f3a48a 100644 --- a/usr.bin/cvs/config.h +++ b/usr.bin/cvs/config.h @@ -1,4 +1,4 @@ -/* $OpenBSD: config.h,v 1.4 2008/02/03 17:20:14 joris Exp $ */ +/* $OpenBSD: config.h,v 1.5 2008/02/03 22:50:28 joris Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -27,17 +27,23 @@ void config_parse_line(char *); void modules_parse_line(char *); #include <sys/queue.h> +#include "file.h" /* module stuff */ #define MODULE_ALIAS 0x01 #define MODULE_TARGETDIR 0x02 #define MODULE_NORECURSE 0x04 +#define MODULE_RUN_ON_COMMIT 0x08 struct module_checkout { char *mc_repo; char *mc_wdir; int mc_flags; + + int mc_canfree; + struct cvs_flisthead mc_modules; + struct cvs_flisthead mc_ignores; }; struct module_info { @@ -45,6 +51,9 @@ struct module_info { char *mi_repository; int mi_flags; + struct cvs_flisthead mi_modules; + struct cvs_flisthead mi_ignores; + TAILQ_ENTRY(module_info) m_list; }; diff --git a/usr.bin/cvs/cvs.h b/usr.bin/cvs/cvs.h index d65441c6fe4..d8be3b4a7ff 100644 --- a/usr.bin/cvs/cvs.h +++ b/usr.bin/cvs/cvs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cvs.h,v 1.151 2008/02/03 17:20:14 joris Exp $ */ +/* $OpenBSD: cvs.h,v 1.152 2008/02/03 22:50:28 joris Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -290,6 +290,7 @@ typedef struct cvs_entries { extern struct module_checkout *current_module; extern char *module_repo_root; +extern struct ignore_head checkout_ign_pats; extern struct cvs_wklhead temp_files; extern volatile sig_atomic_t sig_received; extern volatile sig_atomic_t cvs_quit; diff --git a/usr.bin/cvs/file.c b/usr.bin/cvs/file.c index c9d72fe518c..ae82919f1f6 100644 --- a/usr.bin/cvs/file.c +++ b/usr.bin/cvs/file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.213 2008/02/03 15:08:04 tobias Exp $ */ +/* $OpenBSD: file.c,v 1.214 2008/02/03 22:50:28 joris Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> @@ -78,6 +78,7 @@ static const char *cvs_ign_std[] = { char *cvs_directory_tag = NULL; struct ignore_head cvs_ign_pats; struct ignore_head dir_ign_pats; +struct ignore_head checkout_ign_pats; void cvs_file_init(void) @@ -88,6 +89,7 @@ cvs_file_init(void) TAILQ_INIT(&cvs_ign_pats); TAILQ_INIT(&dir_ign_pats); + TAILQ_INIT(&checkout_ign_pats); /* standard patterns to ignore */ for (i = 0; i < (int)(sizeof(cvs_ign_std)/sizeof(char *)); i++) @@ -167,6 +169,14 @@ cvs_file_chkign(const char *file) return (1); } + TAILQ_FOREACH(ip, &checkout_ign_pats, ip_list) { + if (ip->ip_flags & CVS_IGN_STATIC) { + if (cvs_file_cmpname(file, ip->ip_pat) == 0) + return (1); + } else if (fnmatch(ip->ip_pat, file, flags) == 0) + return (1); + } + return (0); } diff --git a/usr.bin/cvs/modules.c b/usr.bin/cvs/modules.c index b7eb4021fe0..f966664aa38 100644 --- a/usr.bin/cvs/modules.c +++ b/usr.bin/cvs/modules.c @@ -1,4 +1,4 @@ -/* $OpenBSD: modules.c,v 1.3 2008/02/03 17:20:14 joris Exp $ */ +/* $OpenBSD: modules.c,v 1.4 2008/02/03 22:50:28 joris Exp $ */ /* * Copyright (c) 2008 Joris Vink <joris@openbsd.org> * @@ -43,8 +43,10 @@ void modules_parse_line(char *line) { int flags; - char *val, *p, *module; + struct cvs_filelist *fl, *nxt; + char *val, *p, *module, *sp, *dp; struct module_info *mi; + char *dirname, fpath[MAXPATHLEN]; flags = 0; p = val = line; @@ -102,15 +104,62 @@ modules_parse_line(char *line) case 'l': flags |= MODULE_NORECURSE; break; + case 'i': + if (flags != 0) { + cvs_log(LP_NOTICE, + "-i cannot be used with other flags"); + return; + } + flags |= MODULE_RUN_ON_COMMIT; + break; } val = p; } + /* XXX: until we support it */ + if (flags & MODULE_RUN_ON_COMMIT) + return; + mi = xmalloc(sizeof(*mi)); mi->mi_name = xstrdup(module); - mi->mi_repository = xstrdup(val); mi->mi_flags = flags; + + dirname = NULL; + TAILQ_INIT(&(mi->mi_modules)); + TAILQ_INIT(&(mi->mi_ignores)); + for (sp = val; sp != NULL; sp = dp) { + dp = strchr(sp, ' '); + if (dp != NULL) + *(dp++) = '\0'; + + if (mi->mi_flags & MODULE_ALIAS) { + if (sp[0] == '!') + cvs_file_get((sp + 1), 0, &(mi->mi_ignores)); + else + cvs_file_get(sp, 0, &(mi->mi_modules)); + } else if (sp == val) { + dirname = sp; + } else { + if (sp[0] == '!') { + sp++; + (void)xsnprintf(fpath, sizeof(fpath), "%s/%s", + dirname, sp); + cvs_file_get(fpath, 0, &(mi->mi_ignores)); + } else { + (void)xsnprintf(fpath, sizeof(fpath), "%s/%s", + dirname, sp); + cvs_file_get(fpath, 0, &(mi->mi_modules)); + } + } + } + + if (!(mi->mi_flags & MODULE_ALIAS) && TAILQ_EMPTY(&(mi->mi_modules))) + cvs_file_get(dirname, 0, &(mi->mi_modules)); + + fl = TAILQ_FIRST(&(mi->mi_modules)); + mi->mi_repository = xstrdup(fl->file_path); + TAILQ_INSERT_TAIL(&modules, mi, m_list); } @@ -125,7 +174,9 @@ cvs_module_lookup(char *name) TAILQ_FOREACH(mi, &modules, m_list) { if (!strcmp(name, mi->mi_name)) { mc = xmalloc(sizeof(*mc)); - mc->mc_repo = xstrdup(mi->mi_repository); + mc->mc_modules = mi->mi_modules; + mc->mc_ignores = mi->mi_ignores; + mc->mc_canfree = 0; if (mi->mi_flags & MODULE_ALIAS) mc->mc_wdir = xstrdup(mi->mi_repository); else @@ -135,7 +186,10 @@ cvs_module_lookup(char *name) } } - mc->mc_repo = xstrdup(name); + TAILQ_INIT(&(mc->mc_modules)); + TAILQ_INIT(&(mc->mc_ignores)); + cvs_file_get(name, 0, &(mc->mc_modules)); + mc->mc_canfree = 1; mc->mc_wdir = xstrdup(name); mc->mc_flags |= MODULE_ALIAS; diff --git a/usr.bin/cvs/repository.c b/usr.bin/cvs/repository.c index 4ef127ee509..9d2c8d2033f 100644 --- a/usr.bin/cvs/repository.c +++ b/usr.bin/cvs/repository.c @@ -1,4 +1,4 @@ -/* $OpenBSD: repository.c,v 1.17 2008/01/31 13:54:12 tobias Exp $ */ +/* $OpenBSD: repository.c,v 1.18 2008/02/03 22:50:28 joris Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -107,6 +107,11 @@ cvs_repository_getdir(const char *dir, const char *wdir, (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", wdir, dp->d_name); (void)xsnprintf(rpath, MAXPATHLEN, "%s/%s", dir, dp->d_name); + if (!TAILQ_EMPTY(&checkout_ign_pats)) { + if (cvs_file_chkign(fpath)) + continue; + } + /* * nfs and afs will show d_type as DT_UNKNOWN * for files and/or directories so when we encounter |