summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Francois Brousseau <jfb@cvs.openbsd.org>2005-04-18 21:02:51 +0000
committerJean-Francois Brousseau <jfb@cvs.openbsd.org>2005-04-18 21:02:51 +0000
commitec58acf815c07f4f9e34c25790a19fe026229215 (patch)
tree56e2bbc4bcfe60227a6665f4efbe18b1d8945f19
parentfcd7abc72887818d1c3a3765e9f0a1a29cfe306a (diff)
Modify the CVSFILE structure using a union to keep information about
both files and directories. We can now keep the revision number for regular files, and don't need to fetch the appropriate entry in the command callbacks. This saves a huge amount of parsing on Entries files. ok joris@
-rw-r--r--usr.bin/cvs/admin.c13
-rw-r--r--usr.bin/cvs/annotate.c9
-rw-r--r--usr.bin/cvs/cmd.c6
-rw-r--r--usr.bin/cvs/commit.c30
-rw-r--r--usr.bin/cvs/diff.c31
-rw-r--r--usr.bin/cvs/file.c212
-rw-r--r--usr.bin/cvs/file.h69
-rw-r--r--usr.bin/cvs/getlog.c9
-rw-r--r--usr.bin/cvs/logmsg.c4
-rw-r--r--usr.bin/cvs/proto.c20
-rw-r--r--usr.bin/cvs/proto.h4
-rw-r--r--usr.bin/cvs/remove.c18
-rw-r--r--usr.bin/cvs/resp.c12
-rw-r--r--usr.bin/cvs/status.c9
-rw-r--r--usr.bin/cvs/tag.c20
-rw-r--r--usr.bin/cvs/update.c12
-rw-r--r--usr.bin/cvs/util.c8
17 files changed, 199 insertions, 287 deletions
diff --git a/usr.bin/cvs/admin.c b/usr.bin/cvs/admin.c
index 94db0513897..9b3767cdf9e 100644
--- a/usr.bin/cvs/admin.c
+++ b/usr.bin/cvs/admin.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: admin.c,v 1.12 2005/04/16 19:05:02 xsa Exp $ */
+/* $OpenBSD: admin.c,v 1.13 2005/04/18 21:02:49 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
@@ -298,7 +298,6 @@ cvs_admin_file(CVSFILE *cfp, void *arg)
int ret, l;
char *repo, fpath[MAXPATHLEN], rcspath[MAXPATHLEN];
RCSFILE *rf;
- struct cvs_ent *entp;
struct cvsroot *root;
ret = 0;
@@ -319,11 +318,9 @@ cvs_admin_file(CVSFILE *cfp, void *arg)
}
cvs_file_getpath(cfp, fpath, sizeof(fpath));
- entp = cvs_ent_getent(fpath);
if (root->cr_method != CVS_METHOD_LOCAL) {
- if ((entp != NULL) && (cvs_sendentry(root, entp) < 0)) {
- cvs_ent_free(entp);
+ if (cvs_sendentry(root, cfp) < 0) {
return (CVS_EX_PROTO);
}
@@ -355,22 +352,16 @@ cvs_admin_file(CVSFILE *cfp, void *arg)
if (l == -1 || l >= (int)sizeof(rcspath)) {
errno = ENAMETOOLONG;
cvs_log(LP_ERRNO, "%s", rcspath);
-
- cvs_ent_free(entp);
return (-1);
}
rf = rcs_open(rcspath, RCS_READ);
if (rf == NULL) {
- if (entp != NULL)
- cvs_ent_free(entp);
return (CVS_EX_DATA);
}
rcs_close(rf);
}
- if (entp != NULL)
- cvs_ent_free(entp);
return (ret);
}
diff --git a/usr.bin/cvs/annotate.c b/usr.bin/cvs/annotate.c
index deb225b43f2..2562ae21292 100644
--- a/usr.bin/cvs/annotate.c
+++ b/usr.bin/cvs/annotate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: annotate.c,v 1.10 2005/04/13 20:05:37 jfb Exp $ */
+/* $OpenBSD: annotate.c,v 1.11 2005/04/18 21:02:49 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -131,7 +131,6 @@ cvs_annotate_file(CVSFILE *cf, void *arg)
int ret;
char fpath[MAXPATHLEN];
struct cvsroot *root;
- struct cvs_ent *entp;
ret = 0;
root = CVS_DIR_ROOT(cf);
@@ -149,11 +148,9 @@ cvs_annotate_file(CVSFILE *cf, void *arg)
}
cvs_file_getpath(cf, fpath, sizeof(fpath));
- entp = cvs_ent_getent(fpath);
if (root->cr_method != CVS_METHOD_LOCAL) {
- if ((entp != NULL) && (cvs_sendentry(root, entp) < 0)) {
- cvs_ent_free(entp);
+ if (cvs_sendentry(root, cf) < 0) {
return (CVS_EX_PROTO);
}
@@ -181,7 +178,5 @@ cvs_annotate_file(CVSFILE *cf, void *arg)
}
}
- if (entp != NULL)
- cvs_ent_free(entp);
return (ret);
}
diff --git a/usr.bin/cvs/cmd.c b/usr.bin/cvs/cmd.c
index 470ad116be1..14bea0705fb 100644
--- a/usr.bin/cvs/cmd.c
+++ b/usr.bin/cvs/cmd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd.c,v 1.12 2005/04/13 14:49:05 joris Exp $ */
+/* $OpenBSD: cmd.c,v 1.13 2005/04/18 21:02:49 jfb Exp $ */
/*
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
* All rights reserved.
@@ -117,6 +117,10 @@ cvs_startcmd(struct cvs_cmd *cmd, int argc, char **argv)
if (c->cmd_examine != NULL)
cvs_file_examine(cvs_files, c->cmd_examine, NULL);
+ printf("YO BITCH, I'M DONE\n");
+ getchar();
+ exit(0);
+
if (root->cr_method != CVS_METHOD_LOCAL) {
if (c->cmd_flags & CVS_CMD_SENDDIR) {
if (cvs_senddir(root, cvs_files) < 0)
diff --git a/usr.bin/cvs/commit.c b/usr.bin/cvs/commit.c
index 50a08d4d84f..aaa6d4a3387 100644
--- a/usr.bin/cvs/commit.c
+++ b/usr.bin/cvs/commit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: commit.c,v 1.25 2005/04/16 18:01:26 xsa Exp $ */
+/* $OpenBSD: commit.c,v 1.26 2005/04/18 21:02:49 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -109,18 +109,18 @@ cvs_commit_helper(void)
struct cvs_flist cl;
CVSFILE *cfp;
- TAILQ_INIT(&cl);
+ SIMPLEQ_INIT(&cl);
cvs_file_examine(cvs_files, cvs_commit_prepare, &cl);
- if (TAILQ_EMPTY(&cl))
+ if (SIMPLEQ_EMPTY(&cl))
return (0);
if (cvs_msg == NULL)
cvs_msg = cvs_logmsg_get(CVS_FILE_NAME(cvs_files),
NULL, &cl, NULL);
- while (!TAILQ_EMPTY(&cl)) {
- cfp = TAILQ_FIRST(&cl);
- TAILQ_REMOVE(&cl, cfp, cf_list);
+ while (!SIMPLEQ_EMPTY(&cl)) {
+ cfp = SIMPLEQ_FIRST(&cl);
+ SIMPLEQ_REMOVE_HEAD(&cl, cf_list);
cvs_file_free(cfp);
}
@@ -147,7 +147,7 @@ cvs_commit_prepare(CVSFILE *cf, void *arg)
if (copy == NULL)
return (CVS_EX_DATA);
- TAILQ_INSERT_TAIL(clp, copy, cf_list);
+ SIMPLEQ_INSERT_TAIL(clp, copy, cf_list);
}
return (0);
@@ -166,7 +166,6 @@ cvs_commit_file(CVSFILE *cf, void *arg)
char *repo, rcspath[MAXPATHLEN], fpath[MAXPATHLEN];
RCSFILE *rf;
struct cvsroot *root;
- struct cvs_ent *entp;
ret = 0;
rf = NULL;
@@ -185,28 +184,21 @@ cvs_commit_file(CVSFILE *cf, void *arg)
cvs_file_getpath(cf, fpath, sizeof(fpath));
if (cf->cf_parent != NULL)
- repo = cf->cf_parent->cf_ddat->cd_repo;
-
- entp = cvs_ent_getent(fpath);
- if (entp == NULL)
- return (CVS_EX_DATA);
+ repo = cf->cf_parent->cf_repo;
if ((cf->cf_cvstat == CVS_FST_ADDED) ||
(cf->cf_cvstat == CVS_FST_MODIFIED)) {
if (root->cr_method != CVS_METHOD_LOCAL) {
- if (cvs_sendentry(root, entp) < 0) {
- cvs_ent_free(entp);
+ if (cvs_sendentry(root, cf) < 0) {
return (CVS_EX_PROTO);
}
if (cvs_sendreq(root, CVS_REQ_MODIFIED,
CVS_FILE_NAME(cf)) < 0) {
- cvs_ent_free(entp);
return (CVS_EX_PROTO);
}
if (cvs_sendfile(root, fpath) < 0) {
- cvs_ent_free(entp);
return (CVS_EX_PROTO);
}
}
@@ -217,12 +209,8 @@ cvs_commit_file(CVSFILE *cf, void *arg)
if (l == -1 || l >= (int)sizeof(rcspath)) {
errno = ENAMETOOLONG;
cvs_log(LP_ERRNO, "%s", rcspath);
-
- cvs_ent_free(entp);
return (-1);
}
- cvs_ent_free(entp);
-
return (0);
}
diff --git a/usr.bin/cvs/diff.c b/usr.bin/cvs/diff.c
index 210949bcf8c..862d0f99f7b 100644
--- a/usr.bin/cvs/diff.c
+++ b/usr.bin/cvs/diff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diff.c,v 1.30 2005/04/16 19:05:02 xsa Exp $ */
+/* $OpenBSD: diff.c,v 1.31 2005/04/18 21:02:49 jfb Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
* All rights reserved.
@@ -482,19 +482,18 @@ cvs_diff_file(struct cvs_file *cfp, void *arg)
BUF *b1, *b2;
RCSNUM *r1, *r2;
RCSFILE *rf;
- struct cvs_ent *entp;
struct cvsroot *root;
if (cfp->cf_type == DT_DIR) {
if (cfp->cf_cvstat == CVS_FST_UNKNOWN) {
- root = cfp->cf_parent->cf_ddat->cd_root;
+ root = cfp->cf_parent->cf_root;
cvs_sendreq(root, CVS_REQ_QUESTIONABLE,
CVS_FILE_NAME(cfp));
} else {
- root = cfp->cf_ddat->cd_root;
+ root = cfp->cf_root;
#if 0
if ((cfp->cf_parent == NULL) ||
- (root != cfp->cf_parent->cf_ddat->cd_root)) {
+ (root != cfp->cf_parent->cf_root)) {
cvs_connect(root);
cvs_diff_sendflags(root);
}
@@ -516,8 +515,8 @@ cvs_diff_file(struct cvs_file *cfp, void *arg)
if (cfp->cf_parent != NULL) {
dir = cvs_file_getpath(cfp->cf_parent, dfpath, sizeof(dfpath));
- root = cfp->cf_parent->cf_ddat->cd_root;
- repo = cfp->cf_parent->cf_ddat->cd_repo;
+ root = cfp->cf_parent->cf_root;
+ repo = cfp->cf_parent->cf_repo;
} else {
dir = ".";
root = NULL;
@@ -533,13 +532,8 @@ cvs_diff_file(struct cvs_file *cfp, void *arg)
return (0);
}
- entp = cvs_ent_getent(diff_file);
- if (entp == NULL)
- return (CVS_EX_DATA);
-
if (root->cr_method != CVS_METHOD_LOCAL) {
- if (cvs_sendentry(root, entp) < 0) {
- cvs_ent_free(entp);
+ if (cvs_sendentry(root, cfp) < 0) {
return (CVS_EX_PROTO);
}
}
@@ -548,7 +542,6 @@ cvs_diff_file(struct cvs_file *cfp, void *arg)
if (root->cr_method != CVS_METHOD_LOCAL)
cvs_sendreq(root, CVS_REQ_UNCHANGED,
CVS_FILE_NAME(cfp));
- cvs_ent_free(entp);
return (0);
}
@@ -562,14 +555,11 @@ cvs_diff_file(struct cvs_file *cfp, void *arg)
if (l == -1 || l >= (int)sizeof(rcspath)) {
errno = ENAMETOOLONG;
cvs_log(LP_ERRNO, "%s", rcspath);
-
- cvs_ent_free(entp);
return (-1);
}
rf = rcs_open(rcspath, RCS_READ);
if (rf == NULL) {
- cvs_ent_free(entp);
return (CVS_EX_DATA);
}
@@ -577,10 +567,9 @@ cvs_diff_file(struct cvs_file *cfp, void *arg)
RCS_DIFF_DIV, rcspath);
if (dap->rev1 == NULL)
- r1 = entp->ce_rev;
+ r1 = cfp->cf_lrev;
else {
if ((r1 = rcsnum_parse(dap->rev1)) == NULL) {
- cvs_ent_free(entp);
return (CVS_EX_DATA);
}
}
@@ -589,13 +578,12 @@ cvs_diff_file(struct cvs_file *cfp, void *arg)
rcsnum_tostr(r1, buf, sizeof(buf)));
b1 = rcs_getrev(rf, r1);
- if (r1 != entp->ce_rev)
+ if (r1 != cfp->cf_lrev)
rcsnum_free(r1);
if (dap->rev2 != NULL) {
cvs_printf("retrieving revision %s\n", dap->rev2);
if ((r2 = rcsnum_parse(dap->rev2)) == NULL) {
- cvs_ent_free(entp);
return (CVS_EX_DATA);
}
b2 = rcs_getrev(rf, r2);
@@ -632,7 +620,6 @@ cvs_diff_file(struct cvs_file *cfp, void *arg)
(void)unlink(path_tmp2);
}
- cvs_ent_free(entp);
return (0);
}
diff --git a/usr.bin/cvs/file.c b/usr.bin/cvs/file.c
index 56e94691b71..8d4017317a5 100644
--- a/usr.bin/cvs/file.c
+++ b/usr.bin/cvs/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.61 2005/04/16 20:05:05 xsa Exp $ */
+/* $OpenBSD: file.c,v 1.62 2005/04/18 21:02:50 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -107,13 +107,12 @@ static RCSNUM *cvs_addedrev;
TAILQ_HEAD(, cvs_ignpat) cvs_ign_pats;
-static int cvs_file_getdir (CVSFILE *, int);
-static void cvs_file_freedir (struct cvs_dir *);
-static int cvs_file_sort (struct cvs_flist *, u_int);
-static int cvs_file_cmp (const void *, const void *);
-static int cvs_file_cmpname (const char *, const char *);
-static CVSFILE* cvs_file_alloc (const char *, u_int);
-static CVSFILE* cvs_file_lget (const char *, int, CVSFILE *);
+static int cvs_file_getdir (CVSFILE *, int);
+static int cvs_file_sort (struct cvs_flist *, u_int);
+static int cvs_file_cmp (const void *, const void *);
+static int cvs_file_cmpname (const char *, const char *);
+static CVSFILE* cvs_file_alloc (const char *, u_int);
+static CVSFILE* cvs_file_lget (const char *, int, CVSFILE *, struct cvs_ent *);
@@ -251,6 +250,7 @@ cvs_file_create(CVSFILE *parent, const char *path, u_int type, mode_t mode)
int fd;
char fp[MAXPATHLEN];
CVSFILE *cfp;
+ CVSENTRIES *ent;
cfp = cvs_file_alloc(path, type);
if (cfp == NULL)
@@ -260,10 +260,10 @@ cvs_file_create(CVSFILE *parent, const char *path, u_int type, mode_t mode)
cfp->cf_parent = parent;
if (type == DT_DIR) {
- cfp->cf_ddat->cd_root = cvsroot_get(path);
- cfp->cf_ddat->cd_repo = strdup(cvs_file_getpath(cfp,
+ cfp->cf_root = cvsroot_get(path);
+ cfp->cf_repo = strdup(cvs_file_getpath(cfp,
fp, sizeof(fp)));
- if (cfp->cf_ddat->cd_repo == NULL) {
+ if (cfp->cf_repo == NULL) {
cvs_file_free(cfp);
return (NULL);
}
@@ -273,10 +273,9 @@ cvs_file_create(CVSFILE *parent, const char *path, u_int type, mode_t mode)
return (NULL);
}
- cfp->cf_ddat->cd_ent = cvs_ent_open(path, O_RDWR);
- if (cfp->cf_ddat->cd_ent != NULL) {
- cvs_ent_close(cfp->cf_ddat->cd_ent);
- cfp->cf_ddat->cd_ent = NULL;
+ ent = cvs_ent_open(path, O_RDWR);
+ if (ent != NULL) {
+ cvs_ent_close(ent);
}
} else {
fd = open(path, O_WRONLY|O_CREAT|O_EXCL, mode);
@@ -316,10 +315,11 @@ cvs_file_copy(CVSFILE *orig)
cfp->cf_parent = orig->cf_parent;
cfp->cf_mode = orig->cf_mode;
- cfp->cf_mtime = orig->cf_mtime;
cfp->cf_cvstat = orig->cf_cvstat;
- if (orig->cf_type == DT_DIR) {
+ if (orig->cf_type == DT_REG)
+ cfp->cf_mtime = orig->cf_mtime;
+ else if (orig->cf_type == DT_DIR) {
/* XXX copy CVS directory attributes */
}
@@ -346,7 +346,7 @@ cvs_file_copy(CVSFILE *orig)
CVSFILE*
cvs_file_get(const char *path, int flags)
{
- return cvs_file_lget(path, flags, NULL);
+ return cvs_file_lget(path, flags, NULL, NULL);
}
@@ -380,7 +380,7 @@ cvs_file_getspec(char **fspec, int fsn, int flags)
*np = '\0';
nf = cvs_file_find(cf, sp);
if (nf == NULL) {
- nf = cvs_file_lget(pcopy, 0, cf);
+ nf = cvs_file_lget(pcopy, 0, cf, NULL);
if (nf == NULL) {
cvs_file_free(base);
return (NULL);
@@ -442,7 +442,7 @@ cvs_file_find(CVSFILE *hier, const char *path)
continue;
}
- TAILQ_FOREACH(sf, &(cf->cf_ddat->cd_files), cf_list)
+ SIMPLEQ_FOREACH(sf, &(cf->cf_files), cf_list)
if (cvs_file_cmpname(pp, CVS_FILE_NAME(sf)) == 0)
break;
if (sf == NULL)
@@ -512,15 +512,10 @@ cvs_file_getpath(CVSFILE *file, char *buf, size_t len)
int
cvs_file_attach(CVSFILE *parent, CVSFILE *file)
{
- struct cvs_dir *dp;
-
if (parent->cf_type != DT_DIR)
return (-1);
- dp = parent->cf_ddat;
-
- TAILQ_INSERT_TAIL(&(dp->cd_files), file, cf_list);
- dp->cd_nfiles++;
+ SIMPLEQ_INSERT_TAIL(&(parent->cf_files), file, cf_list);
file->cf_parent = parent;
return (0);
@@ -538,25 +533,25 @@ static int
cvs_file_getdir(CVSFILE *cf, int flags)
{
int ret, fd, l;
- u_int ndirs;
+ u_int ndirs, nfiles;
long base;
u_char *dp, *ep;
char fbuf[2048], pbuf[MAXPATHLEN], fpath[MAXPATHLEN];
struct dirent *ent;
CVSFILE *cfp;
+ CVSENTRIES *entfile;
struct stat st;
- struct cvs_dir *cdp;
struct cvs_ent *cvsent;
struct cvs_flist dirs;
ndirs = 0;
- TAILQ_INIT(&dirs);
- cdp = cf->cf_ddat;
+ nfiles = 0;
+ SIMPLEQ_INIT(&dirs);
cvs_file_getpath(cf, fpath, sizeof(fpath));
- cdp->cd_root = cvsroot_get(fpath);
- if (cdp->cd_root == NULL)
+ cf->cf_root = cvsroot_get(fpath);
+ if (cf->cf_root == NULL)
return (-1);
if (cf->cf_cvstat != CVS_FST_UNKNOWN) {
@@ -573,15 +568,15 @@ cvs_file_getdir(CVSFILE *cf, int flags)
if ((stat(pbuf, &st) == 0) && S_ISDIR(st.st_mode)) {
if (cvs_readrepo(fpath, pbuf, sizeof(pbuf)) == 0) {
- cdp->cd_repo = strdup(pbuf);
- if (cdp->cd_repo == NULL) {
+ cf->cf_repo = strdup(pbuf);
+ if (cf->cf_repo == NULL) {
cvs_log(LP_ERRNO,
"failed to dup repository string");
return (-1);
}
}
- cdp->cd_ent = cvs_ent_open(fpath, O_RDONLY);
+ entfile = cvs_ent_open(fpath, O_RDONLY);
}
}
@@ -627,8 +622,8 @@ cvs_file_getdir(CVSFILE *cf, int flags)
continue;
if (!(flags & CF_RECURSE) && (ent->d_type == DT_DIR)) {
- if (cdp->cd_ent != NULL)
- (void)cvs_ent_remove(cdp->cd_ent,
+ if (entfile != NULL)
+ (void)cvs_ent_remove(entfile,
ent->d_name);
continue;
}
@@ -643,28 +638,32 @@ cvs_file_getdir(CVSFILE *cf, int flags)
return (-1);
}
- cfp = cvs_file_lget(pbuf, flags, cf);
+ if (entfile != NULL)
+ cvsent = cvs_ent_get(entfile, ent->d_name);
+ cfp = cvs_file_lget(pbuf, flags, cf, cvsent);
if (cfp == NULL) {
(void)close(fd);
return (-1);
}
+ if (entfile != NULL)
+ cvs_ent_remove(entfile, cfp->cf_name);
if (cfp->cf_type == DT_DIR) {
- TAILQ_INSERT_TAIL(&dirs, cfp, cf_list);
+ SIMPLEQ_INSERT_TAIL(&dirs, cfp, cf_list);
ndirs++;
} else {
- TAILQ_INSERT_TAIL(&(cdp->cd_files), cfp,
+ SIMPLEQ_INSERT_TAIL(&(cf->cf_files), cfp,
cf_list);
- cdp->cd_nfiles++;
+ nfiles++;
}
}
} while (ret > 0);
- if (cdp->cd_ent != NULL) {
+ if (entfile != NULL) {
/* now create file structure for files which have an
* entry in the Entries file but no file on disk
*/
- while ((cvsent = cvs_ent_next(cdp->cd_ent)) != NULL) {
+ while ((cvsent = cvs_ent_next(entfile)) != NULL) {
l = snprintf(pbuf, sizeof(pbuf), "%s/%s", fpath,
cvsent->ce_name);
if (l == -1 || l >= (int)sizeof(pbuf)) {
@@ -675,36 +674,33 @@ cvs_file_getdir(CVSFILE *cf, int flags)
return (-1);
}
- cfp = cvs_file_lget(pbuf, flags, cf);
+ cfp = cvs_file_lget(pbuf, flags, cf, cvsent);
if (cfp != NULL) {
if (cfp->cf_type == DT_DIR) {
- TAILQ_INSERT_TAIL(&dirs, cfp, cf_list);
+ SIMPLEQ_INSERT_TAIL(&dirs, cfp, cf_list);
ndirs++;
} else {
- TAILQ_INSERT_TAIL(&(cdp->cd_files), cfp,
+ SIMPLEQ_INSERT_TAIL(&(cf->cf_files), cfp,
cf_list);
- cdp->cd_nfiles++;
+ nfiles++;
}
}
}
- cvs_ent_close(cdp->cd_ent);
- cdp->cd_ent = NULL;
+ cvs_ent_close(entfile);
}
if (flags & CF_SORT) {
- cvs_file_sort(&(cdp->cd_files), cdp->cd_nfiles);
+ cvs_file_sort(&(cf->cf_files), nfiles);
cvs_file_sort(&dirs, ndirs);
}
- while (!TAILQ_EMPTY(&dirs)) {
- cfp = TAILQ_FIRST(&dirs);
- TAILQ_REMOVE(&dirs, cfp, cf_list);
- TAILQ_INSERT_TAIL(&(cdp->cd_files), cfp, cf_list);
+ while (!SIMPLEQ_EMPTY(&dirs)) {
+ cfp = SIMPLEQ_FIRST(&dirs);
+ SIMPLEQ_REMOVE_HEAD(&dirs, cf_list);
+ SIMPLEQ_INSERT_TAIL(&(cf->cf_files), cfp, cf_list);
}
- cdp->cd_nfiles += ndirs;
(void)close(fd);
-
return (0);
}
@@ -717,10 +713,22 @@ cvs_file_getdir(CVSFILE *cf, int flags)
void
cvs_file_free(CVSFILE *cf)
{
- if (cf->cf_ddat != NULL)
- cvs_file_freedir(cf->cf_ddat);
+ CVSFILE *child;
+
if (cf->cf_name != NULL)
cvs_strfree(cf->cf_name);
+
+ if (cf->cf_type == DT_DIR) {
+ if (cf->cf_root != NULL)
+ cvsroot_free(cf->cf_root);
+ if (cf->cf_repo != NULL)
+ free(cf->cf_repo);
+ while (!SIMPLEQ_EMPTY(&(cf->cf_files))) {
+ child = SIMPLEQ_FIRST(&(cf->cf_files));
+ SIMPLEQ_REMOVE_HEAD(&(cf->cf_files), cf_list);
+ cvs_file_free(child);
+ }
+ }
free(cf);
}
@@ -740,7 +748,7 @@ cvs_file_examine(CVSFILE *cf, int (*exam)(CVSFILE *, void *), void *arg)
if (cf->cf_type == DT_DIR) {
ret = (*exam)(cf, arg);
- TAILQ_FOREACH(fp, &(cf->cf_ddat->cd_files), cf_list) {
+ SIMPLEQ_FOREACH(fp, &(cf->cf_files), cf_list) {
ret = cvs_file_examine(fp, exam, arg);
if (ret != 0)
break;
@@ -751,33 +759,6 @@ cvs_file_examine(CVSFILE *cf, int (*exam)(CVSFILE *, void *), void *arg)
return (ret);
}
-
-/*
- * cvs_file_freedir()
- *
- * Free a cvs_dir structure and its contents.
- */
-static void
-cvs_file_freedir(struct cvs_dir *cd)
-{
- CVSFILE *cfp;
-
- if (cd->cd_root != NULL)
- cvsroot_free(cd->cd_root);
- if (cd->cd_repo != NULL)
- free(cd->cd_repo);
-
- if (cd->cd_ent != NULL)
- cvs_ent_close(cd->cd_ent);
-
- while (!TAILQ_EMPTY(&(cd->cd_files))) {
- cfp = TAILQ_FIRST(&(cd->cd_files));
- TAILQ_REMOVE(&(cd->cd_files), cfp, cf_list);
- cvs_file_free(cfp);
- }
-}
-
-
/*
* cvs_file_sort()
*
@@ -800,12 +781,12 @@ cvs_file_sort(struct cvs_flist *flp, u_int nfiles)
}
i = 0;
- TAILQ_FOREACH(cf, flp, cf_list) {
+ SIMPLEQ_FOREACH(cf, flp, cf_list) {
if (i == (int)nfiles) {
cvs_log(LP_WARN, "too many files to sort");
/* rebuild the list and abort sorting */
while (--i >= 0)
- TAILQ_INSERT_HEAD(flp, cfvec[i], cf_list);
+ SIMPLEQ_INSERT_HEAD(flp, cfvec[i], cf_list);
free(cfvec);
return (-1);
}
@@ -814,18 +795,18 @@ cvs_file_sort(struct cvs_flist *flp, u_int nfiles)
/* now unlink it from the list,
* we'll put it back in order later
*/
- TAILQ_REMOVE(flp, cf, cf_list);
+ SIMPLEQ_REMOVE_HEAD(flp, cf_list);
}
/* clear the list just in case */
- TAILQ_INIT(flp);
+ SIMPLEQ_INIT(flp);
nb = (size_t)i;
heapsort(cfvec, nb, sizeof(cf), cvs_file_cmp);
/* rebuild the list from the bottom up */
for (i = (int)nb - 1; i >= 0; i--)
- TAILQ_INSERT_HEAD(flp, cfvec[i], cf_list);
+ SIMPLEQ_INSERT_HEAD(flp, cfvec[i], cf_list);
free(cfvec);
return (0);
@@ -836,8 +817,8 @@ static int
cvs_file_cmp(const void *f1, const void *f2)
{
const CVSFILE *cf1, *cf2;
- cf1 = *(const CVSFILE **)f1;
- cf2 = *(const CVSFILE **)f2;
+ cf1 = *(CVSFILE * const *)f1;
+ cf2 = *(CVSFILE * const *)f2;
return cvs_file_cmpname(CVS_FILE_NAME(cf1), CVS_FILE_NAME(cf2));
}
@@ -851,7 +832,6 @@ CVSFILE*
cvs_file_alloc(const char *path, u_int type)
{
CVSFILE *cfp;
- struct cvs_dir *ddat;
cfp = (CVSFILE *)malloc(sizeof(*cfp));
if (cfp == NULL) {
@@ -860,26 +840,20 @@ cvs_file_alloc(const char *path, u_int type)
}
memset(cfp, 0, sizeof(*cfp));
+ cfp->cf_type = type;
+ cfp->cf_cvstat = CVS_FST_UNKNOWN;
+
+ if (type == DT_DIR) {
+ SIMPLEQ_INIT(&(cfp->cf_files));
+ }
+
cfp->cf_name = cvs_strdup(basename(path));
if (cfp->cf_name == NULL) {
cvs_log(LP_ERR, "failed to copy file name");
cvs_file_free(cfp);
return (NULL);
}
- cfp->cf_type = type;
- cfp->cf_cvstat = CVS_FST_UNKNOWN;
- if (type == DT_DIR) {
- ddat = (struct cvs_dir *)malloc(sizeof(*ddat));
- if (ddat == NULL) {
- cvs_log(LP_ERRNO, "failed to allocate directory data");
- cvs_file_free(cfp);
- return (NULL);
- }
- memset(ddat, 0, sizeof(*ddat));
- TAILQ_INIT(&(ddat->cd_files));
- cfp->cf_ddat = ddat;
- }
return (cfp);
}
@@ -892,17 +866,18 @@ cvs_file_alloc(const char *path, u_int type)
* failure.
*/
static CVSFILE*
-cvs_file_lget(const char *path, int flags, CVSFILE *parent)
+cvs_file_lget(const char *path, int flags, CVSFILE *parent, struct cvs_ent *ent)
{
int ret, cwd;
u_int type;
struct stat st;
CVSFILE *cfp;
- struct cvs_ent *ent = NULL;
type = DT_UNKNOWN;
cwd = (strcmp(path, ".") == 0) ? 1 : 0;
+ printf("lget(%s)\n", path);
+
ret = stat(path, &st);
if (ret == 0)
type = IFTODT(st.st_mode);
@@ -912,14 +887,12 @@ cvs_file_lget(const char *path, int flags, CVSFILE *parent)
cfp->cf_parent = parent;
if ((cfp->cf_type == DT_DIR) && (cfp->cf_parent == NULL))
- cfp->cf_ddat->cd_flags |= CVS_DIRF_BASE;
-
- if ((parent != NULL) && (CVS_DIR_ENTRIES(parent) != NULL))
- ent = cvs_ent_get(CVS_DIR_ENTRIES(parent), CVS_FILE_NAME(cfp));
+ cfp->cf_flags |= CVS_DIRF_BASE;
if (ret == 0) {
cfp->cf_mode = st.st_mode & ACCESSPERMS;
- cfp->cf_mtime = st.st_mtime;
+ if (cfp->cf_type == DT_REG)
+ cfp->cf_mtime = st.st_mtime;
if (ent == NULL)
cfp->cf_cvstat = (cwd == 1) ?
@@ -948,8 +921,15 @@ cvs_file_lget(const char *path, int flags, CVSFILE *parent)
cfp->cf_cvstat = CVS_FST_LOST;
}
- if (ent != NULL)
- cvs_ent_remove(CVS_DIR_ENTRIES(parent), CVS_FILE_NAME(cfp));
+ if (ent != NULL) {
+ /* steal the RCSNUM */
+ cfp->cf_lrev = ent->ce_rev;
+ if ((cfp->cf_tag = cvs_strdup(ent->ce_tag)) == NULL) {
+ cvs_file_free(cfp);
+ return (NULL);
+ }
+ ent->ce_rev = NULL;
+ }
if ((cfp->cf_type == DT_DIR) && (cvs_file_getdir(cfp, flags) < 0)) {
cvs_file_free(cfp);
diff --git a/usr.bin/cvs/file.h b/usr.bin/cvs/file.h
index 83327181a34..ab5c42e62ae 100644
--- a/usr.bin/cvs/file.h
+++ b/usr.bin/cvs/file.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.h,v 1.15 2005/03/24 14:35:18 jfb Exp $ */
+/* $OpenBSD: file.h,v 1.16 2005/04/18 21:02:50 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -32,13 +32,13 @@
#include <dirent.h>
#include <search.h>
+#include "rcs.h"
+
struct cvs_file;
-struct cvs_dir;
struct cvs_entries;
#define CVS_FILE_MAXDEPTH 32
-#define CVS_FILE_NBUCKETS 256
#define CF_STAT 0x01 /* obsolete */
@@ -60,9 +60,6 @@ struct cvs_entries;
*
* The <cf_cvstat> field gives the file's status with regards to the CVS
* repository. The file can be in any one of the CVS_FST_* states.
- * If the file's type is DT_DIR, then the <cf_ddat> pointer will point to
- * a cvs_dir structure containing data specific to the directory (such as
- * the contents of the directory's CVS/Entries, CVS/Root, etc.).
*/
#define CVS_FST_UNKNOWN 0
#define CVS_FST_UPTODATE 1
@@ -74,21 +71,43 @@ struct cvs_entries;
#define CVS_FST_LOST 7
-TAILQ_HEAD(cvs_flist, cvs_file);
-
+SIMPLEQ_HEAD(cvs_flist, cvs_file);
typedef struct cvs_file {
struct cvs_file *cf_parent; /* parent directory (NULL if none) */
char *cf_name;
mode_t cf_mode;
- time_t cf_mtime;
- u_int16_t cf_cvstat; /* cvs status of the file */
- u_int16_t cf_type; /* uses values from dirent.h */
- struct cvs_dir *cf_ddat; /* only for directories */
-
- TAILQ_ENTRY(cvs_file) cf_list;
+ u_int8_t cf_cvstat; /* cvs status of the file */
+ u_int8_t cf_type; /* uses values from dirent.h */
+ u_int16_t cf_flags;
+
+ union {
+ struct {
+ RCSNUM *cd_lrev; /* local revision */
+ time_t cd_mtime;
+ char *cd_tag;
+ char *cd_opts;
+ } cf_reg;
+ struct {
+ char *cd_repo;
+ struct cvsroot *cd_root;
+ struct cvs_flist cd_files;
+ } cf_dir;
+ } cf_td;
+
+ SIMPLEQ_ENTRY(cvs_file) cf_list;
} CVSFILE;
+/* only valid for regular files */
+#define cf_mtime cf_td.cf_reg.cd_mtime
+#define cf_lrev cf_td.cf_reg.cd_lrev
+#define cf_tag cf_td.cf_reg.cd_tag
+
+/* only valid for directories */
+#define cf_files cf_td.cf_dir.cd_files
+#define cf_repo cf_td.cf_dir.cd_repo
+#define cf_root cf_td.cf_dir.cd_root
+
#define CVS_FILE_NAME(cf) (cf->cf_name)
@@ -97,27 +116,13 @@ typedef struct cvs_file {
#define CVS_DIRF_STICKY 0x02
#define CVS_DIRF_BASE 0x04
-struct cvs_dir {
- struct cvsroot *cd_root;
- char *cd_repo;
- struct cvs_entries *cd_ent;
- struct cvs_flist cd_files;
- u_int16_t cd_nfiles;
- u_int16_t cd_flags;
-};
-
-
#define CVS_DIR_ROOT(f) ((((f)->cf_type == DT_DIR) && \
- ((f)->cf_ddat->cd_root != NULL)) ? (f)->cf_ddat->cd_root : \
- (((f)->cf_parent == NULL) ? NULL : (f)->cf_parent->cf_ddat->cd_root))
-
-#define CVS_DIR_ENTRIES(f) (((f)->cf_type == DT_DIR) ? \
- (f)->cf_ddat->cd_ent : (((f)->cf_parent == NULL) ? \
- NULL : (f)->cf_parent->cf_ddat->cd_ent))
+ ((f)->cf_root != NULL)) ? (f)->cf_root : \
+ (((f)->cf_parent == NULL) ? NULL : (f)->cf_parent->cf_root))
#define CVS_DIR_REPO(f) (((f)->cf_type == DT_DIR) ? \
- (f)->cf_ddat->cd_repo : (((f)->cf_parent == NULL) ? \
- NULL : (f)->cf_parent->cf_ddat->cd_repo))
+ (f)->cf_repo : (((f)->cf_parent == NULL) ? \
+ NULL : (f)->cf_parent->cf_repo))
int cvs_file_init (void);
int cvs_file_ignore (const char *);
diff --git a/usr.bin/cvs/getlog.c b/usr.bin/cvs/getlog.c
index ec0bb9d64b6..5deabf6a310 100644
--- a/usr.bin/cvs/getlog.c
+++ b/usr.bin/cvs/getlog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getlog.c,v 1.22 2005/04/16 20:05:05 xsa Exp $ */
+/* $OpenBSD: getlog.c,v 1.23 2005/04/18 21:02:50 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -109,7 +109,6 @@ cvs_getlog_remote(CVSFILE *cf, void *arg)
int ret;
char *repo, fpath[MAXPATHLEN];
struct cvsroot *root;
- struct cvs_ent *entp;
ret = 0;
root = CVS_DIR_ROOT(cf);
@@ -125,10 +124,8 @@ cvs_getlog_remote(CVSFILE *cf, void *arg)
}
cvs_file_getpath(cf, fpath, sizeof(fpath));
- entp = cvs_ent_getent(fpath);
- if ((entp != NULL) && (cvs_sendentry(root, entp) < 0)) {
- cvs_ent_free(entp);
+ if (cvs_sendentry(root, cf) < 0) {
return (-1);
}
@@ -147,8 +144,6 @@ cvs_getlog_remote(CVSFILE *cf, void *arg)
break;
}
- if (entp != NULL)
- cvs_ent_free(entp);
return (ret);
}
diff --git a/usr.bin/cvs/logmsg.c b/usr.bin/cvs/logmsg.c
index 232ecc93335..759e1625510 100644
--- a/usr.bin/cvs/logmsg.c
+++ b/usr.bin/cvs/logmsg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: logmsg.c,v 1.12 2005/02/26 21:51:33 david Exp $ */
+/* $OpenBSD: logmsg.c,v 1.13 2005/04/18 21:02:50 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -219,7 +219,7 @@ cvs_logmsg_get(const char *dir, struct cvs_flist *added,
fprintf(fp, "%s %s Files:", CVS_LOGMSG_PREFIX,
cvs_logmsg_ops[i]);
nl = 1;
- TAILQ_FOREACH(cvsfp, files[i], cf_list) {
+ SIMPLEQ_FOREACH(cvsfp, files[i], cf_list) {
/* take the space into account */
cvs_file_getpath(cvsfp, fpath, sizeof(fpath));
len = strlen(fpath) + 1;
diff --git a/usr.bin/cvs/proto.c b/usr.bin/cvs/proto.c
index d7261493d4b..0dc39f940a2 100644
--- a/usr.bin/cvs/proto.c
+++ b/usr.bin/cvs/proto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: proto.c,v 1.46 2005/04/03 17:32:50 xsa Exp $ */
+/* $OpenBSD: proto.c,v 1.47 2005/04/18 21:02:50 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -959,15 +959,18 @@ cvs_senddir(struct cvsroot *root, CVSFILE *dir)
{
char lbuf[MAXPATHLEN], rbuf[MAXPATHLEN];
+ if (dir->cf_type != DT_DIR)
+ return (-1);
+
cvs_file_getpath(dir, lbuf, sizeof(lbuf));
if (strcmp(lbuf, cvs_lastdir) == 0 && cvs_cmdop != CVS_OP_CHECKOUT)
return (0);
- if (dir->cf_ddat->cd_repo == NULL)
+ if (dir->cf_repo == NULL)
strlcpy(rbuf, root->cr_dir, sizeof(rbuf));
else
snprintf(rbuf, sizeof(rbuf), "%s/%s", root->cr_dir,
- dir->cf_ddat->cd_repo);
+ dir->cf_repo);
if ((cvs_sendreq(root, CVS_REQ_DIRECTORY, lbuf) < 0) ||
@@ -1002,12 +1005,17 @@ cvs_sendarg(struct cvsroot *root, const char *arg, int append)
* the CVS entry <ent> (which are the name and revision).
*/
int
-cvs_sendentry(struct cvsroot *root, const struct cvs_ent *ent)
+cvs_sendentry(struct cvsroot *root, const CVSFILE *file)
{
char ebuf[128], numbuf[64];
- snprintf(ebuf, sizeof(ebuf), "/%s/%s///", ent->ce_name,
- rcsnum_tostr(ent->ce_rev, numbuf, sizeof(numbuf)));
+ if (file->cf_type != DT_REG) {
+ cvs_log(LP_ERR, "attempt to send Entry for non-regular file");
+ return (-1);
+ }
+
+ snprintf(ebuf, sizeof(ebuf), "/%s/%s///", file->cf_name,
+ rcsnum_tostr(file->cf_lrev, numbuf, sizeof(numbuf)));
return cvs_sendreq(root, CVS_REQ_ENTRY, ebuf);
}
diff --git a/usr.bin/cvs/proto.h b/usr.bin/cvs/proto.h
index 90e0e281dbd..c9be76444d3 100644
--- a/usr.bin/cvs/proto.h
+++ b/usr.bin/cvs/proto.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: proto.h,v 1.5 2004/12/07 17:10:56 tedu Exp $ */
+/* $OpenBSD: proto.h,v 1.6 2005/04/18 21:02:50 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -183,7 +183,7 @@ int cvs_getln (struct cvsroot *, char *, size_t);
int cvs_senddir (struct cvsroot *, CVSFILE *);
int cvs_sendarg (struct cvsroot *, const char *, int);
int cvs_sendln (struct cvsroot *, const char *);
-int cvs_sendentry (struct cvsroot *, const struct cvs_ent *);
+int cvs_sendentry (struct cvsroot *, const CVSFILE *);
int cvs_sendraw (struct cvsroot *, const void *, size_t);
ssize_t cvs_recvraw (struct cvsroot *, void *, size_t);
diff --git a/usr.bin/cvs/remove.c b/usr.bin/cvs/remove.c
index 7cb42b8144b..5268e8ed9d6 100644
--- a/usr.bin/cvs/remove.c
+++ b/usr.bin/cvs/remove.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: remove.c,v 1.7 2005/04/12 14:58:40 joris Exp $ */
+/* $OpenBSD: remove.c,v 1.8 2005/04/18 21:02:50 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* Copyright (c) 2004 Xavier Santolaria <xsa@openbsd.org>
@@ -94,11 +94,8 @@ cvs_remove_file(CVSFILE *cf, void *arg)
int ret;
char fpath[MAXPATHLEN];
struct cvsroot *root;
- CVSENTRIES *entfile;
- struct cvs_ent *ent;
ret = 0;
- ent = NULL;
root = CVS_DIR_ROOT(cf);
if (cf->cf_type == DT_DIR) {
@@ -115,17 +112,8 @@ cvs_remove_file(CVSFILE *cf, void *arg)
cvs_file_getpath(cf, fpath, sizeof(fpath));
- entfile = cvs_ent_open(dirname(fpath), O_RDWR);
- if (entfile == NULL) {
- cvs_log(LP_ERR, "failed to remove `%s'", fpath);
- return (CVS_EX_FILE);
- }
-
- ent = cvs_ent_get(entfile, CVS_FILE_NAME(cf));
-
if (root->cr_method != CVS_METHOD_LOCAL) {
- if (ent != NULL)
- ret = cvs_sendentry(root, ent);
+ ret = cvs_sendentry(root, cf);
} else {
/* if -f option is used, physically remove the file */
if (force_remove == 1) {
@@ -143,7 +131,5 @@ cvs_remove_file(CVSFILE *cf, void *arg)
__progname);
}
- cvs_ent_close(entfile);
-
return (ret);
}
diff --git a/usr.bin/cvs/resp.c b/usr.bin/cvs/resp.c
index 938ea999b13..fb267b6bc60 100644
--- a/usr.bin/cvs/resp.c
+++ b/usr.bin/cvs/resp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: resp.c,v 1.27 2005/04/15 13:14:00 xsa Exp $ */
+/* $OpenBSD: resp.c,v 1.28 2005/04/18 21:02:50 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -389,13 +389,13 @@ cvs_resp_sticky(struct cvsroot *root, int type, char *line)
cf = cvs_file_create(sdir, line, DT_DIR, 0755);
if (cf == NULL)
return (-1);
- cf->cf_ddat->cd_repo = strdup(line);
- if (cf->cf_ddat->cd_repo == NULL) {
+ cf->cf_repo = strdup(line);
+ if (cf->cf_repo == NULL) {
cvs_log(LP_ERRNO, "failed to duplicate `%s'", line);
cvs_file_free(cf);
return (-1);
}
- cf->cf_ddat->cd_root = root;
+ cf->cf_root = root;
root->cr_ref++;
if (cvs_file_attach(sdir, cf) < 0) {
@@ -418,9 +418,9 @@ cvs_resp_sticky(struct cvsroot *root, int type, char *line)
}
if (type == CVS_RESP_CLRSTICKY)
- cf->cf_ddat->cd_flags &= ~CVS_DIRF_STICKY;
+ cf->cf_flags &= ~CVS_DIRF_STICKY;
else if (type == CVS_RESP_SETSTICKY)
- cf->cf_ddat->cd_flags |= CVS_DIRF_STICKY;
+ cf->cf_flags |= CVS_DIRF_STICKY;
return (0);
}
diff --git a/usr.bin/cvs/status.c b/usr.bin/cvs/status.c
index 91d5d5d3a54..b676a574c7b 100644
--- a/usr.bin/cvs/status.c
+++ b/usr.bin/cvs/status.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: status.c,v 1.18 2005/04/16 20:31:18 xsa Exp $ */
+/* $OpenBSD: status.c,v 1.19 2005/04/18 21:02:50 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -116,7 +116,6 @@ cvs_status_file(CVSFILE *cfp, void *arg)
int ret;
char *repo, fpath[MAXPATHLEN];
RCSFILE *rf;
- struct cvs_ent *entp;
struct cvsroot *root;
ret = 0;
@@ -134,10 +133,8 @@ cvs_status_file(CVSFILE *cfp, void *arg)
}
cvs_file_getpath(cfp, fpath, sizeof(fpath));
- entp = cvs_ent_getent(fpath);
- if ((entp != NULL) && (cvs_sendentry(root, entp) < 0)) {
- cvs_ent_free(entp);
+ if (cvs_sendentry(root, cfp) < 0) {
return (-1);
}
@@ -160,8 +157,6 @@ cvs_status_file(CVSFILE *cfp, void *arg)
break;
}
- if (entp != NULL)
- cvs_ent_free(entp);
return (ret);
}
diff --git a/usr.bin/cvs/tag.c b/usr.bin/cvs/tag.c
index 6b1c5991375..8487fabd37f 100644
--- a/usr.bin/cvs/tag.c
+++ b/usr.bin/cvs/tag.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tag.c,v 1.12 2005/04/16 20:31:18 xsa Exp $ */
+/* $OpenBSD: tag.c,v 1.13 2005/04/18 21:02:50 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* Copyright (c) 2004 Joris Vink <joris@openbsd.org>
@@ -158,7 +158,6 @@ cvs_tag_file(CVSFILE *cfp, void *arg)
int ret, l;
char *repo, fpath[MAXPATHLEN], rcspath[MAXPATHLEN];
RCSFILE *rf;
- struct cvs_ent *entp;
struct cvsroot *root;
ret = 0;
@@ -172,11 +171,9 @@ cvs_tag_file(CVSFILE *cfp, void *arg)
}
cvs_file_getpath(cfp, fpath, sizeof(fpath));
- entp = cvs_ent_getent(fpath);
if (root->cr_method != CVS_METHOD_LOCAL) {
- if ((entp != NULL) && (cvs_sendentry(root, entp) < 0)) {
- cvs_ent_free(entp);
+ if (cvs_sendentry(root, cfp) < 0) {
return (CVS_EX_PROTO);
}
@@ -201,33 +198,22 @@ cvs_tag_file(CVSFILE *cfp, void *arg)
return (0);
}
- if (cfp->cf_parent != NULL)
- repo = cfp->cf_parent->cf_ddat->cd_repo;
- else
- repo = NULL;
-
+ repo = CVS_DIR_REPO(cfp);
l = snprintf(rcspath, sizeof(rcspath), "%s/%s/%s%s",
root->cr_dir, repo, CVS_FILE_NAME(cfp), RCS_FILE_EXT);
if (l == -1 || l >= (int)sizeof(rcspath)) {
errno = ENAMETOOLONG;
cvs_log(LP_ERRNO, "%s", rcspath);
-
- cvs_ent_free(entp);
return (-1);
}
rf = rcs_open(rcspath, RCS_READ);
if (rf == NULL) {
- if (entp != NULL)
- cvs_ent_free(entp);
return (CVS_EX_DATA);
}
rcs_close(rf);
}
- if (entp != NULL)
- cvs_ent_free(entp);
-
return (ret);
}
diff --git a/usr.bin/cvs/update.c b/usr.bin/cvs/update.c
index aefe7b0a03a..b405d3cfbd2 100644
--- a/usr.bin/cvs/update.c
+++ b/usr.bin/cvs/update.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: update.c,v 1.22 2005/04/16 20:31:18 xsa Exp $ */
+/* $OpenBSD: update.c,v 1.23 2005/04/18 21:02:50 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -103,7 +103,6 @@ cvs_update_file(CVSFILE *cf, void *arg)
char *fname, *repo, fpath[MAXPATHLEN], rcspath[MAXPATHLEN];
RCSFILE *rf;
struct cvsroot *root;
- struct cvs_ent *entp;
ret = 0;
rf = NULL;
@@ -124,11 +123,9 @@ cvs_update_file(CVSFILE *cf, void *arg)
}
cvs_file_getpath(cf, fpath, sizeof(fpath));
- entp = cvs_ent_getent(fpath);
if (root->cr_method != CVS_METHOD_LOCAL) {
- if ((entp != NULL) && (cvs_sendentry(root, entp) < 0)) {
- cvs_ent_free(entp);
+ if (cvs_sendentry(root, cf) < 0) {
return (CVS_EX_PROTO);
}
@@ -159,22 +156,17 @@ cvs_update_file(CVSFILE *cf, void *arg)
if (l == -1 || l >= (int)sizeof(rcspath)) {
errno = ENAMETOOLONG;
cvs_log(LP_ERRNO, "%s", rcspath);
-
- cvs_ent_free(entp);
return (-1);
}
rf = rcs_open(rcspath, RCS_READ);
if (rf == NULL) {
- cvs_ent_free(entp);
return (CVS_EX_DATA);
}
rcs_close(rf);
}
- if (entp != NULL)
- cvs_ent_free(entp);
return (ret);
}
diff --git a/usr.bin/cvs/util.c b/usr.bin/cvs/util.c
index 47f56fa314c..60416880f96 100644
--- a/usr.bin/cvs/util.c
+++ b/usr.bin/cvs/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.22 2005/04/16 20:05:05 xsa Exp $ */
+/* $OpenBSD: util.c,v 1.23 2005/04/18 21:02:50 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -526,7 +526,7 @@ cvs_mkadmin(CVSFILE *cdir, mode_t mode)
ef = cvs_ent_open(dpath, O_WRONLY);
(void)cvs_ent_close(ef);
- root = cdir->cf_ddat->cd_root;
+ root = cdir->cf_root;
l = snprintf(path, sizeof(path), "%s/" CVS_PATH_ROOTSPEC, dpath);
if (l == -1 || l >= (int)sizeof(path)) {
errno = ENAMETOOLONG;
@@ -567,13 +567,13 @@ cvs_mkadmin(CVSFILE *cdir, mode_t mode)
}
if ((stat(path, &st) != 0) && (errno == ENOENT) &&
- (cdir->cf_ddat->cd_repo != NULL)) {
+ (cdir->cf_repo != NULL)) {
fp = fopen(path, "w");
if (fp == NULL) {
cvs_log(LP_ERRNO, "failed to open %s", path);
return (-1);
}
- fprintf(fp, "%s\n", cdir->cf_ddat->cd_repo);
+ fprintf(fp, "%s\n", cdir->cf_repo);
(void)fclose(fp);
}