summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/cvs/commit.c10
-rw-r--r--usr.bin/cvs/file.c81
-rw-r--r--usr.bin/cvs/file.h5
-rw-r--r--usr.bin/cvs/modules.c18
-rw-r--r--usr.bin/cvs/repository.c12
5 files changed, 77 insertions, 49 deletions
diff --git a/usr.bin/cvs/commit.c b/usr.bin/cvs/commit.c
index 4163bdf9631..6accad5063a 100644
--- a/usr.bin/cvs/commit.c
+++ b/usr.bin/cvs/commit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: commit.c,v 1.146 2009/03/25 21:50:33 joris Exp $ */
+/* $OpenBSD: commit.c,v 1.147 2009/03/26 22:54:37 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
@@ -420,17 +420,17 @@ next:
cf->file_status != FILE_MODIFIED)
return;
- cvs_file_get(cf->file_path, 0, &files_affected);
+ cvs_file_get(cf->file_path, 0, &files_affected, CVS_FILE);
switch (cf->file_status) {
case FILE_ADDED:
- cvs_file_get(cf->file_path, 0, &files_added);
+ cvs_file_get(cf->file_path, 0, &files_added, CVS_FILE);
break;
case FILE_REMOVED:
- cvs_file_get(cf->file_path, 0, &files_removed);
+ cvs_file_get(cf->file_path, 0, &files_removed, CVS_FILE);
break;
case FILE_MODIFIED:
- cvs_file_get(cf->file_path, 0, &files_modified);
+ cvs_file_get(cf->file_path, 0, &files_modified, CVS_FILE);
break;
}
}
diff --git a/usr.bin/cvs/file.c b/usr.bin/cvs/file.c
index ab37beea288..f3ecd4cbbe0 100644
--- a/usr.bin/cvs/file.c
+++ b/usr.bin/cvs/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.256 2009/03/25 21:50:33 joris Exp $ */
+/* $OpenBSD: file.c,v 1.257 2009/03/26 22:54:37 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
@@ -191,15 +191,17 @@ cvs_file_run(int argc, char **argv, struct cvs_recursion *cr)
RB_INIT(&fl);
- for (i = 0; i < argc; i++)
- cvs_file_get(argv[i], FILE_USER_SUPPLIED, &fl);
+ for (i = 0; i < argc; i++) {
+ STRIP_SLASH(argv[i]);
+ cvs_file_get(argv[i], FILE_USER_SUPPLIED, &fl, 0);
+ }
cvs_file_walklist(&fl, cr);
cvs_file_freelist(&fl);
}
struct cvs_filelist *
-cvs_file_get(char *name, int flags, struct cvs_flisthead *fl)
+cvs_file_get(char *name, int flags, struct cvs_flisthead *fl, int type)
{
char *p;
struct cvs_filelist *l, find;
@@ -215,6 +217,7 @@ cvs_file_get(char *name, int flags, struct cvs_flisthead *fl)
l = (struct cvs_filelist *)xmalloc(sizeof(*l));
l->file_path = xstrdup(p);
l->flags = flags;
+ l->type = type;
RB_INSERT(cvs_flisthead, fl, l);
return (l);
@@ -274,24 +277,26 @@ cvs_file_walklist(struct cvs_flisthead *fl, struct cvs_recursion *cr)
if ((d = dirname(l->file_path)) == NULL)
fatal("cvs_file_walklist: dirname failed");
- type = CVS_FILE;
+ type = l->type;
if ((fd = open(l->file_path, O_RDONLY)) != -1) {
- if (fstat(fd, &st) == -1) {
- cvs_log(LP_ERRNO, "%s", l->file_path);
- (void)close(fd);
- goto next;
- }
+ if (type == 0) {
+ if (fstat(fd, &st) == -1) {
+ cvs_log(LP_ERRNO, "%s", l->file_path);
+ (void)close(fd);
+ goto next;
+ }
- if (S_ISDIR(st.st_mode))
- type = CVS_DIR;
- else if (S_ISREG(st.st_mode))
- type = CVS_FILE;
- else {
- cvs_log(LP_ERR,
- "ignoring bad file type for %s",
- l->file_path);
- (void)close(fd);
- goto next;
+ if (S_ISDIR(st.st_mode))
+ type = CVS_DIR;
+ else if (S_ISREG(st.st_mode))
+ type = CVS_FILE;
+ else {
+ cvs_log(LP_ERR,
+ "ignoring bad file type for %s",
+ l->file_path);
+ (void)close(fd);
+ goto next;
+ }
}
} else if (current_cvsroot->cr_method == CVS_METHOD_LOCAL) {
/*
@@ -314,7 +319,7 @@ cvs_file_walklist(struct cvs_flisthead *fl, struct cvs_recursion *cr)
fd = open(fpath, O_RDONLY);
}
- if (fd != -1) {
+ if (fd != -1 && type == 0) {
if (fstat(fd, &st) == -1)
fatal("cvs_file_walklist: %s: %s",
fpath, strerror(errno));
@@ -334,11 +339,13 @@ cvs_file_walklist(struct cvs_flisthead *fl, struct cvs_recursion *cr)
/* this file is not in our working copy yet */
(void)close(fd);
fd = -1;
+ } else if (fd != -1) {
+ close(fd);
+ fd = -1;
}
}
- cf = cvs_file_get_cf(d, f, l->file_path,
- fd, type, l->flags);
+ cf = cvs_file_get_cf(d, f, l->file_path, fd, type, l->flags);
if (cf->file_type == CVS_DIR) {
cvs_file_walkdir(cf, cr);
} else {
@@ -536,10 +543,10 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr)
switch (type) {
case CVS_DIR:
if (cr->flags & CR_RECURSE_DIRS)
- cvs_file_get(fpath, 0, &dl);
+ cvs_file_get(fpath, 0, &dl, CVS_DIR);
break;
case CVS_FILE:
- cvs_file_get(fpath, 0, &fl);
+ cvs_file_get(fpath, 0, &fl, CVS_FILE);
break;
default:
fatal("type %d unknown, shouldn't happen",
@@ -572,9 +579,9 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr)
ent->ce_type == CVS_ENT_DIR)
continue;
if (ent->ce_type == CVS_ENT_DIR)
- cvs_file_get(fpath, 0, &dl);
+ cvs_file_get(fpath, 0, &dl, CVS_DIR);
else if (ent->ce_type == CVS_ENT_FILE)
- cvs_file_get(fpath, 0, &fl);
+ cvs_file_get(fpath, 0, &fl, CVS_FILE);
cvs_ent_free(ent);
}
@@ -667,6 +674,23 @@ cvs_file_classify(struct cvs_file *cf, const char *tag)
cf->file_ent = NULL;
if (cf->file_ent != NULL) {
+ if (cf->file_ent->ce_tag != NULL && cvs_specified_tag == NULL)
+ tag = cf->file_ent->ce_tag;
+
+ if (cf->file_flags & FILE_ON_DISK &&
+ cf->file_ent->ce_type == CVS_ENT_FILE &&
+ cf->file_type == CVS_DIR && tag != NULL) {
+ cf->file_status = FILE_SKIP;
+ return;
+ }
+
+ if (cf->file_flags & FILE_ON_DISK &&
+ cf->file_ent->ce_type == CVS_ENT_DIR &&
+ cf->file_type == CVS_FILE && tag != NULL) {
+ cf->file_status = FILE_SKIP;
+ return;
+ }
+
if (cf->file_flags & FILE_ON_DISK &&
cf->file_ent->ce_type == CVS_ENT_DIR &&
cf->file_type != CVS_DIR)
@@ -677,9 +701,6 @@ cvs_file_classify(struct cvs_file *cf, const char *tag)
cf->file_type != CVS_FILE)
fatal("%s is supposed to be a file, but it is not",
cf->file_path);
-
- if (cf->file_ent->ce_tag != NULL && cvs_specified_tag == NULL)
- tag = cf->file_ent->ce_tag;
}
if (cf->file_type == CVS_DIR) {
diff --git a/usr.bin/cvs/file.h b/usr.bin/cvs/file.h
index c7902a5e2fc..8c7e19972bf 100644
--- a/usr.bin/cvs/file.h
+++ b/usr.bin/cvs/file.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.h,v 1.52 2009/03/25 21:50:33 joris Exp $ */
+/* $OpenBSD: file.h,v 1.53 2009/03/26 22:54:37 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
@@ -80,6 +80,7 @@ struct cvs_filelist {
RB_ENTRY(cvs_filelist) flist;
char *file_path;
int flags;
+ int type;
};
RB_HEAD(cvs_flisthead, cvs_filelist);
@@ -108,7 +109,7 @@ void cvs_file_run(int, char **, struct cvs_recursion *);
void cvs_file_walklist(struct cvs_flisthead *, struct cvs_recursion *);
void cvs_file_walkdir(struct cvs_file *, struct cvs_recursion *);
void cvs_file_freelist(struct cvs_flisthead *);
-struct cvs_filelist *cvs_file_get(char *, int, struct cvs_flisthead *);
+struct cvs_filelist *cvs_file_get(char *, int, struct cvs_flisthead *, int);
int cvs_filelist_cmp(struct cvs_filelist *, struct cvs_filelist *);
int cvs_file_chkign(const char *);
diff --git a/usr.bin/cvs/modules.c b/usr.bin/cvs/modules.c
index b1565f36bae..09eb6e81e92 100644
--- a/usr.bin/cvs/modules.c
+++ b/usr.bin/cvs/modules.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: modules.c,v 1.14 2009/03/25 21:50:33 joris Exp $ */
+/* $OpenBSD: modules.c,v 1.15 2009/03/26 22:54:37 joris Exp $ */
/*
* Copyright (c) 2008 Joris Vink <joris@openbsd.org>
*
@@ -173,9 +173,11 @@ modules_parse_line(char *line, int lineno)
if (sp[0] == '!') {
if (strlen(sp) < 2)
fatal("invalid ! pattern");
- cvs_file_get((sp + 1), 0, &(mi->mi_ignores));
+ cvs_file_get((sp + 1), 0,
+ &(mi->mi_ignores), 0);
} else {
- cvs_file_get(sp, 0, &(mi->mi_modules));
+ cvs_file_get(sp, 0,
+ &(mi->mi_modules), 0);
}
} else if (sp == val) {
dirname = sp;
@@ -187,17 +189,19 @@ modules_parse_line(char *line, int lineno)
sp++;
(void)xsnprintf(fpath, sizeof(fpath), "%s/%s",
dirname, sp);
- cvs_file_get(fpath, 0, &(mi->mi_ignores));
+ cvs_file_get(fpath, 0,
+ &(mi->mi_ignores), 0);
} else {
(void)xsnprintf(fpath, sizeof(fpath), "%s/%s",
dirname, sp);
- cvs_file_get(fpath, 0, &(mi->mi_modules));
+ cvs_file_get(fpath, 0,
+ &(mi->mi_modules), 0);
}
}
}
if (!(mi->mi_flags & MODULE_ALIAS) && RB_EMPTY(&(mi->mi_modules)))
- cvs_file_get(dirname, 0, &(mi->mi_modules));
+ cvs_file_get(dirname, 0, &(mi->mi_modules), 0);
TAILQ_INSERT_TAIL(&modules, mi, m_list);
return (0);
@@ -232,7 +236,7 @@ cvs_module_lookup(char *name)
RB_INIT(&(mc->mc_modules));
RB_INIT(&(mc->mc_ignores));
- cvs_file_get(name, 0, &(mc->mc_modules));
+ cvs_file_get(name, 0, &(mc->mc_modules), 0);
mc->mc_canfree = 1;
mc->mc_name = name;
mc->mc_flags = MODULE_ALIAS;
diff --git a/usr.bin/cvs/repository.c b/usr.bin/cvs/repository.c
index 78153f1512b..ebe88c0d3b2 100644
--- a/usr.bin/cvs/repository.c
+++ b/usr.bin/cvs/repository.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: repository.c,v 1.21 2009/02/21 13:44:18 joris Exp $ */
+/* $OpenBSD: repository.c,v 1.22 2009/03/26 22:54:37 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -157,8 +157,10 @@ cvs_repository_getdir(const char *dir, const char *wdir,
}
}
- if (!(flags & REPOSITORY_DODIRS) && type == CVS_DIR)
- continue;
+ if (!(flags & REPOSITORY_DODIRS) && type == CVS_DIR) {
+ if (strcmp(dp->d_name, CVS_PATH_ATTIC))
+ continue;
+ }
switch (type) {
case CVS_DIR:
@@ -166,7 +168,7 @@ cvs_repository_getdir(const char *dir, const char *wdir,
cvs_repository_getdir(rpath, wdir, fl, dl,
REPOSITORY_IS_ATTIC);
} else {
- cvs_file_get(fpath, 0, dl);
+ cvs_file_get(fpath, 0, dl, CVS_DIR);
}
break;
case CVS_FILE:
@@ -175,7 +177,7 @@ cvs_repository_getdir(const char *dir, const char *wdir,
*s = '\0';
cvs_file_get(fpath,
(flags & REPOSITORY_IS_ATTIC) ?
- FILE_INSIDE_ATTIC : 0, fl);
+ FILE_INSIDE_ATTIC : 0, fl, CVS_FILE);
}
break;
default: