summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/cvs/file.c15
-rw-r--r--usr.bin/cvs/file.h4
-rw-r--r--usr.bin/cvs/update.c10
-rw-r--r--usr.bin/cvs/util.c34
-rw-r--r--usr.bin/cvs/util.h5
5 files changed, 42 insertions, 26 deletions
diff --git a/usr.bin/cvs/file.c b/usr.bin/cvs/file.c
index 2901230c708..1b16d080c7e 100644
--- a/usr.bin/cvs/file.c
+++ b/usr.bin/cvs/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.145 2006/05/28 10:14:59 joris Exp $ */
+/* $OpenBSD: file.c,v 1.146 2006/05/28 17:25:18 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
@@ -261,6 +261,7 @@ 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;
if ((fd = open(l->file_path, O_RDONLY)) != -1) {
if (fstat(fd, &st) == -1) {
cvs_log(LP_ERRNO, "%s", l->file_path);
@@ -285,7 +286,7 @@ cvs_file_walklist(struct cvs_flisthead *fl, struct cvs_recursion *cr)
goto next;
}
- cvs_get_repo(d, repo, MAXPATHLEN);
+ cvs_get_repository_path(d, repo, MAXPATHLEN);
len = snprintf(fpath, MAXPATHLEN, "%s/%s",
repo, f);
if (len == -1 || len >= MAXPATHLEN)
@@ -367,6 +368,9 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr)
if (cr->local != NULL)
cr->local(cf);
+ if (cf->file_status == FILE_SKIP)
+ return;
+
fpath = xmalloc(MAXPATHLEN);
/*
@@ -377,7 +381,8 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr)
if (l == -1 || l >= MAXPATHLEN)
fatal("cvs_file_walkdir: overflow");
- if (stat(fpath, &st) == -1) {
+ l = stat(fpath, &st);
+ if (l == -1 || (l == 0 && !S_ISDIR(st.st_mode))) {
xfree(fpath);
return;
}
@@ -494,7 +499,7 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr)
if (cr->flags & CR_REPO) {
repo = xmalloc(MAXPATHLEN);
- cvs_get_repo(cf->file_path, repo, MAXPATHLEN);
+ cvs_get_repository_path(cf->file_path, repo, MAXPATHLEN);
cvs_repository_lock(repo);
cvs_repository_getdir(repo, cf->file_path, &fl, &dl,
@@ -554,7 +559,7 @@ cvs_file_classify(struct cvs_file *cf, int loud)
repo = xmalloc(MAXPATHLEN);
rcsfile = xmalloc(MAXPATHLEN);
- cvs_get_repo(cf->file_wd, repo, MAXPATHLEN);
+ cvs_get_repository_path(cf->file_wd, repo, MAXPATHLEN);
l = snprintf(rcsfile, MAXPATHLEN, "%s/%s",
repo, cf->file_name);
if (l == -1 || l >= MAXPATHLEN)
diff --git a/usr.bin/cvs/file.h b/usr.bin/cvs/file.h
index 00bc0a47af5..017b39231f7 100644
--- a/usr.bin/cvs/file.h
+++ b/usr.bin/cvs/file.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.h,v 1.35 2006/05/28 07:56:44 joris Exp $ */
+/* $OpenBSD: file.h,v 1.36 2006/05/28 17:25:18 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
@@ -61,6 +61,8 @@ struct cvs_file {
#define DIR_CREATE 12
+#define FILE_SKIP 100
+
struct cvs_filelist {
char *file_path;
TAILQ_ENTRY(cvs_filelist) flist;
diff --git a/usr.bin/cvs/update.c b/usr.bin/cvs/update.c
index d963c93143f..a3ee80418a1 100644
--- a/usr.bin/cvs/update.c
+++ b/usr.bin/cvs/update.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: update.c,v 1.66 2006/05/28 07:56:44 joris Exp $ */
+/* $OpenBSD: update.c,v 1.67 2006/05/28 17:25:18 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -28,8 +28,6 @@ int build_dirs = 0;
static void update_clear_conflict(struct cvs_file *);
-#define UPDATE_SKIP 100
-
struct cvs_cmd cvs_cmd_update = {
CVS_OP_UPDATE, CVS_REQ_UPDATE, "update",
{ "up", "upd" },
@@ -133,7 +131,7 @@ cvs_update_enterdir(struct cvs_file *cf)
cvs_ent_close(entlist, ENT_SYNC);
xfree(entry);
} else if (cf->file_status == DIR_CREATE && build_dirs == 0) {
- cf->file_status = UPDATE_SKIP;
+ cf->file_status = FILE_SKIP;
}
}
@@ -151,6 +149,8 @@ cvs_update_leavedir(struct cvs_file *cf)
struct cvs_ent_line *line;
CVSENTRIES *entlist;
+ cvs_log(LP_TRACE, "cvs_update_leavedir(%s)", cf->file_path);
+
if (fstat(cf->fd, &st) == -1)
fatal("cvs_update_leavedir: %s", strerror(errno));
@@ -227,7 +227,7 @@ cvs_update_local(struct cvs_file *cf)
cvs_log(LP_TRACE, "cvs_update_local(%s)", cf->file_path);
if (cf->file_type == CVS_DIR) {
- if (cf->file_status == UPDATE_SKIP)
+ if (cf->file_status == FILE_SKIP)
return;
if (cf->file_status != FILE_UNKNOWN &&
diff --git a/usr.bin/cvs/util.c b/usr.bin/cvs/util.c
index 2c0b9677399..8eacf9ac418 100644
--- a/usr.bin/cvs/util.c
+++ b/usr.bin/cvs/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.80 2006/05/27 16:18:23 joris Exp $ */
+/* $OpenBSD: util.c,v 1.81 2006/05/28 17:25:18 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* Copyright (c) 2005, 2006 Joris Vink <joris@openbsd.org>
@@ -568,31 +568,39 @@ cvs_hack_time(time_t oldtime, int togmt)
}
void
-cvs_get_repo(const char *dir, char *dst, size_t len)
+cvs_get_repository_path(const char *dir, char *dst, size_t len)
{
int l;
- FILE *fp;
- char *s, buf[MAXPATHLEN], fpath[MAXPATHLEN];
+ char buf[MAXPATHLEN];
- if (strlcpy(buf, dir, sizeof(buf)) >= sizeof(buf))
- fatal("cvs_get_repo: truncation");
+ cvs_get_repository_name(dir, buf, sizeof(buf));
+ l = snprintf(dst, len, "%s/%s", current_cvsroot->cr_dir, buf);
+ if (l == -1 || l >= (int)len)
+ fatal("cvs_get_repository_path: overflow");
+}
+
+void
+cvs_get_repository_name(const char *dir, char *dst, size_t len)
+{
+ int l;
+ FILE *fp;
+ char *s, fpath[MAXPATHLEN];
l = snprintf(fpath, sizeof(fpath), "%s/%s", dir, CVS_PATH_REPOSITORY);
if (l == -1 || l >= (int)sizeof(fpath))
- fatal("cvs_get_repo: overflow");
+ fatal("cvs_get_repository_name: overflow");
if ((fp = fopen(fpath, "r")) != NULL) {
- fgets(buf, sizeof(buf), fp);
+ fgets(dst, len, fp);
- if ((s = strrchr(buf, '\n')) != NULL)
+ if ((s = strchr(dst, '\n')) != NULL)
*s = '\0';
(void)fclose(fp);
+ } else {
+ if (strlcpy(dst, dir, len) >= len)
+ fatal("cvs_get_repository_name: overflow");
}
-
- l = snprintf(dst, len, "%s/%s", current_cvsroot->cr_dir, buf);
- if (l == -1 || l >= (int)len)
- fatal("cvs_get_repo: overflow");
}
void
diff --git a/usr.bin/cvs/util.h b/usr.bin/cvs/util.h
index 185b2f9f9a0..352c610e5a2 100644
--- a/usr.bin/cvs/util.h
+++ b/usr.bin/cvs/util.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.h,v 1.6 2006/05/27 16:18:23 joris Exp $ */
+/* $OpenBSD: util.h,v 1.7 2006/05/28 17:25:18 joris Exp $ */
/*
* Copyright (c) 2006 Niall O'Higgins <niallo@openbsd.org>
* All rights reserved.
@@ -27,7 +27,8 @@
#ifndef UTIL_H
#define UTIL_H
-void cvs_get_repo(const char *, char *, size_t);
+void cvs_get_repository_path(const char *, char *, size_t);
+void cvs_get_repository_name(const char *, char *, size_t);
void cvs_modetostr(mode_t, char *, size_t);
void cvs_strtomode(const char *, mode_t *);
void cvs_splitpath(const char *, char *, size_t, char **);