summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/cvs/checkout.c5
-rw-r--r--usr.bin/cvs/commit.c7
-rw-r--r--usr.bin/cvs/cvs.h7
-rw-r--r--usr.bin/cvs/diff.c8
-rw-r--r--usr.bin/cvs/file.c31
-rw-r--r--usr.bin/cvs/repository.c7
-rw-r--r--usr.bin/cvs/repository.h2
-rw-r--r--usr.bin/cvs/status.c8
-rw-r--r--usr.bin/cvs/update.c7
9 files changed, 63 insertions, 19 deletions
diff --git a/usr.bin/cvs/checkout.c b/usr.bin/cvs/checkout.c
index b6d98afab33..c14c50e458f 100644
--- a/usr.bin/cvs/checkout.c
+++ b/usr.bin/cvs/checkout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: checkout.c,v 1.55 2006/05/27 05:59:32 joris Exp $ */
+/* $OpenBSD: checkout.c,v 1.56 2006/05/27 15:14:27 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -94,9 +94,10 @@ checkout_repository(const char *repobase, const char *wdbase)
cr.leavedir = cvs_update_leavedir;
cr.local = cvs_update_local;
cr.remote = NULL;
+ cr.flags = CR_REPO | CR_RECURSE_DIRS;
cvs_repository_lock(repobase);
- cvs_repository_getdir(repobase, wdbase, &fl, &dl);
+ cvs_repository_getdir(repobase, wdbase, &fl, &dl, 1);
cvs_file_walklist(&fl, &cr);
cvs_file_freelist(&fl);
diff --git a/usr.bin/cvs/commit.c b/usr.bin/cvs/commit.c
index 524c7babee9..f8a2020b167 100644
--- a/usr.bin/cvs/commit.c
+++ b/usr.bin/cvs/commit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: commit.c,v 1.57 2006/05/27 14:05:53 joris Exp $ */
+/* $OpenBSD: commit.c,v 1.58 2006/05/27 15:14:27 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -47,8 +47,11 @@ cvs_commit(int argc, char **argv)
{
int ch;
char *arg = ".";
+ int flags;
struct cvs_recursion cr;
+ flags = CR_RECURSE_DIRS;
+
while ((ch = getopt(argc, argv, cvs_cmd_commit.cmd_opts)) != -1) {
switch (ch) {
case 'f':
@@ -56,6 +59,7 @@ cvs_commit(int argc, char **argv)
case 'F':
break;
case 'l':
+ flags &= ~CR_RECURSE_DIRS;
break;
case 'm':
logmsg = xstrdup(optarg);
@@ -82,6 +86,7 @@ cvs_commit(int argc, char **argv)
cr.leavedir = NULL;
cr.local = cvs_commit_check_conflicts;
cr.remote = NULL;
+ cr.flags = flags;
if (argc > 0)
cvs_file_run(argc, argv, &cr);
diff --git a/usr.bin/cvs/cvs.h b/usr.bin/cvs/cvs.h
index 22e471ed8da..d0bda653934 100644
--- a/usr.bin/cvs/cvs.h
+++ b/usr.bin/cvs/cvs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cvs.h,v 1.105 2006/05/27 05:20:25 joris Exp $ */
+/* $OpenBSD: cvs.h,v 1.106 2006/05/27 15:14:27 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -158,8 +158,13 @@ struct cvs_recursion {
void (*leavedir)(struct cvs_file *);
void (*local)(struct cvs_file *);
void (*remote)(struct cvs_file *, struct cvsroot *);
+ int flags;
};
+#define CR_RECURSE_DIRS 0x01
+#define CR_ATTIC 0x02
+#define CR_REPO 0x04
+
struct cvs_var {
char *cv_name;
char *cv_val;
diff --git a/usr.bin/cvs/diff.c b/usr.bin/cvs/diff.c
index d3a4500bbee..9abdf7aeec0 100644
--- a/usr.bin/cvs/diff.c
+++ b/usr.bin/cvs/diff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diff.c,v 1.91 2006/05/27 03:30:30 joris Exp $ */
+/* $OpenBSD: diff.c,v 1.92 2006/05/27 15:14:27 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -41,8 +41,10 @@ cvs_diff(int argc, char **argv)
{
int ch;
char *arg = ".";
+ int flags;
struct cvs_recursion cr;
+ flags = CR_RECURSE_DIRS;
strlcpy(diffargs, argv[0], sizeof(diffargs));
while ((ch = getopt(argc, argv, cvs_cmd_diff.cmd_opts)) != -1) {
@@ -51,6 +53,9 @@ cvs_diff(int argc, char **argv)
strlcat(diffargs, " -c", sizeof(diffargs));
diff_format = D_CONTEXT;
break;
+ case 'l':
+ flags &= ~CR_RECURSE_DIRS;
+ break;
case 'n':
strlcat(diffargs, " -n", sizeof(diffargs));
diff_format = D_RCSDIFF;
@@ -85,6 +90,7 @@ cvs_diff(int argc, char **argv)
cr.leavedir = NULL;
cr.local = cvs_diff_local;
cr.remote = NULL;
+ cr.flags = flags;
if (argc > 0)
cvs_file_run(argc, argv, &cr);
diff --git a/usr.bin/cvs/file.c b/usr.bin/cvs/file.c
index feec3546bbb..bcc30f38a67 100644
--- a/usr.bin/cvs/file.c
+++ b/usr.bin/cvs/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.139 2006/05/27 06:15:50 joris Exp $ */
+/* $OpenBSD: file.c,v 1.140 2006/05/27 15:14:27 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
@@ -366,7 +366,6 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr)
if (cr->local != NULL)
cr->local(cf);
- repo = xmalloc(MAXPATHLEN);
fpath = xmalloc(MAXPATHLEN);
/*
@@ -378,7 +377,6 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr)
fatal("cvs_file_walkdir: overflow");
if (stat(fpath, &st) == -1) {
- xfree(repo);
xfree(fpath);
return;
}
@@ -433,6 +431,13 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr)
continue;
}
+ if (!(cr->flags & CR_RECURSE_DIRS) &&
+ dp->d_type == DT_DIR) {
+ printf("Skipping %s\n", dp->d_name);
+ cp += dp->d_reclen;
+ continue;
+ }
+
l = snprintf(fpath, MAXPATHLEN, "%s/%s",
cf->file_path, dp->d_name);
if (l == -1 || l >= MAXPATHLEN)
@@ -473,6 +478,10 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr)
if (l == -1 || l >= MAXPATHLEN)
fatal("cvs_file_walkdir: overflow");
+ if (!(cr->flags & CR_RECURSE_DIRS) &&
+ ent->ce_type == CVS_ENT_DIR)
+ continue;
+
if (ent->ce_type == CVS_ENT_DIR)
cvs_file_get(fpath, &dl);
else if (ent->ce_type == CVS_ENT_FILE)
@@ -483,20 +492,26 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr)
cvs_ent_close(entlist, ENT_NOSYNC);
- cvs_get_repo(cf->file_path, repo, MAXPATHLEN);
- cvs_repository_lock(repo);
+ if (cr->flags & CR_REPO) {
+ repo = xmalloc(MAXPATHLEN);
+ cvs_get_repo(cf->file_path, repo, MAXPATHLEN);
+ cvs_repository_lock(repo);
- cvs_repository_getdir(repo, cf->file_path, &fl, &dl);
+ cvs_repository_getdir(repo, cf->file_path, &fl, &dl,
+ (cr->flags & CR_RECURSE_DIRS));
+ }
cvs_file_walklist(&fl, cr);
cvs_file_freelist(&fl);
- cvs_repository_unlock(repo);
+ if (cr->flags & CR_REPO) {
+ cvs_repository_unlock(repo);
+ xfree(repo);
+ }
cvs_file_walklist(&dl, cr);
cvs_file_freelist(&dl);
- xfree(repo);
xfree(fpath);
if (cr->leavedir != NULL)
diff --git a/usr.bin/cvs/repository.c b/usr.bin/cvs/repository.c
index 5bea74ffcb1..be60d2bd3cc 100644
--- a/usr.bin/cvs/repository.c
+++ b/usr.bin/cvs/repository.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: repository.c,v 1.1 2006/05/27 03:30:31 joris Exp $ */
+/* $OpenBSD: repository.c,v 1.2 2006/05/27 15:14:27 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -89,7 +89,7 @@ cvs_repository_lock(const char *repo)
void
cvs_repository_getdir(const char *dir, const char *wdir,
- struct cvs_flisthead *fl, struct cvs_flisthead *dl)
+ struct cvs_flisthead *fl, struct cvs_flisthead *dl, int dodirs)
{
int l;
DIR *dirp;
@@ -109,6 +109,9 @@ cvs_repository_getdir(const char *dir, const char *wdir,
if (cvs_file_chkign(dp->d_name))
continue;
+ if (dodirs == 0 && dp->d_type == DT_DIR)
+ continue;
+
l = snprintf(fpath, sizeof(fpath), "%s/%s", wdir, dp->d_name);
if (l == -1 || l >= (int)sizeof(fpath))
fatal("cvs_repository_getdir: overflow");
diff --git a/usr.bin/cvs/repository.h b/usr.bin/cvs/repository.h
index 167a77ba389..57233adfcb9 100644
--- a/usr.bin/cvs/repository.h
+++ b/usr.bin/cvs/repository.h
@@ -26,6 +26,6 @@ extern struct cvs_wklhead repo_locks;
void cvs_repository_unlock(const char *);
void cvs_repository_lock(const char *);
void cvs_repository_getdir(const char *, const char *,
- struct cvs_flisthead *, struct cvs_flisthead *);
+ struct cvs_flisthead *, struct cvs_flisthead *, int);
#endif
diff --git a/usr.bin/cvs/status.c b/usr.bin/cvs/status.c
index 57901f34b25..955f663fbc7 100644
--- a/usr.bin/cvs/status.c
+++ b/usr.bin/cvs/status.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: status.c,v 1.57 2006/05/27 03:30:31 joris Exp $ */
+/* $OpenBSD: status.c,v 1.58 2006/05/27 15:14:27 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -55,13 +55,16 @@ const char *status_tab[] = {
int
cvs_status(int argc, char **argv)
{
- int ch;
+ int ch, flags;
char *arg = ".";
struct cvs_recursion cr;
+ flags = CR_REPO | CR_RECURSE_DIRS;
+
while ((ch = getopt(argc, argv, cvs_cmd_status.cmd_opts)) != -1) {
switch (ch) {
case 'l':
+ flags &= ~CR_RECURSE_DIRS;
break;
case 'R':
break;
@@ -79,6 +82,7 @@ cvs_status(int argc, char **argv)
cr.leavedir = NULL;
cr.local = cvs_status_local;
cr.remote = NULL;
+ cr.flags = flags;
if (argc > 0)
cvs_file_run(argc, argv, &cr);
diff --git a/usr.bin/cvs/update.c b/usr.bin/cvs/update.c
index 72e3bad258c..1986dfab76e 100644
--- a/usr.bin/cvs/update.c
+++ b/usr.bin/cvs/update.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: update.c,v 1.60 2006/05/27 05:20:25 joris Exp $ */
+/* $OpenBSD: update.c,v 1.61 2006/05/27 15:14:27 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -41,8 +41,11 @@ cvs_update(int argc, char **argv)
{
int ch;
char *arg = ".";
+ int flags;
struct cvs_recursion cr;
+ flags = CR_RECURSE_DIRS;
+
while ((ch = getopt(argc, argv, cvs_cmd_update.cmd_opts)) != -1) {
switch (ch) {
case 'A':
@@ -61,6 +64,7 @@ cvs_update(int argc, char **argv)
case 'k':
break;
case 'l':
+ flags &= ~CR_RECURSE_DIRS;
break;
case 'P':
prune_dirs = 1;
@@ -86,6 +90,7 @@ cvs_update(int argc, char **argv)
cr.leavedir = cvs_update_leavedir;
cr.local = cvs_update_local;
cr.remote = NULL;
+ cr.flags = flags;
if (argc > 0)
cvs_file_run(argc, argv, &cr);