diff options
author | Tobias Stoeckmann <tobias@cvs.openbsd.org> | 2008-01-31 10:15:06 +0000 |
---|---|---|
committer | Tobias Stoeckmann <tobias@cvs.openbsd.org> | 2008-01-31 10:15:06 +0000 |
commit | c9627e39af420c1876b74e97d6e0d257395aaed1 (patch) | |
tree | 139b27acc652675035297a52ae05ea9fe1b4d5f8 /usr.bin/cvs/file.c | |
parent | 0548783dd32716f5c917173e44b9dd2e9ea6cd56 (diff) |
Replaced the unused cvs_command variable cmd_req with cmd_flags, which states
if the current command is supposed to use a working directory or if it is a
repository-only command (as of now checkout -p, rtag, rlog).
Makes the code simpler, easier to read and automagically fixes some issues
we encountered with these commands (for example if a working directory
exists, or "." operations are performed).
OK joris@, niallo@
Diffstat (limited to 'usr.bin/cvs/file.c')
-rw-r--r-- | usr.bin/cvs/file.c | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/usr.bin/cvs/file.c b/usr.bin/cvs/file.c index 20ad6350a08..aef69b652c8 100644 --- a/usr.bin/cvs/file.c +++ b/usr.bin/cvs/file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.210 2008/01/21 16:36:46 tobias Exp $ */ +/* $OpenBSD: file.c,v 1.211 2008/01/31 10:15:05 tobias Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> @@ -370,15 +370,24 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr) return; /* + * If this is a repository-only command, do not touch any + * locally available directories or try to create them. + */ + if (!(cmdp->cmd_flags & CVS_USE_WDIR)) { + TAILQ_INIT(&fl); + TAILQ_INIT(&dl); + goto walkrepo; + } + + /* * If we do not have a admin directory inside here, dont bother, - * unless we are running export, import, rlog or rtag. + * unless we are running export or import. */ (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", cf->file_path, CVS_PATH_CVSDIR); l = stat(fpath, &st); if (cvs_cmdop != CVS_OP_EXPORT && cvs_cmdop != CVS_OP_IMPORT && - cvs_cmdop != CVS_OP_RLOG && cvs_cmdop != CVS_OP_RTAG && (l == -1 || (l == 0 && !S_ISDIR(st.st_mode)))) { return; } @@ -530,6 +539,7 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr) cvs_ent_close(entlist, ENT_NOSYNC); +walkrepo: if (cr->flags & CR_REPO) { cvs_get_repository_path(cf->file_path, repo, MAXPATHLEN); cvs_repository_lock(repo); @@ -550,7 +560,7 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr) if (cr->leavedir != NULL) cr->leavedir(cf); - if (cvs_directory_tag != NULL) { + if (cvs_directory_tag != NULL && cmdp->cmd_flags & CVS_USE_WDIR) { cvs_write_tagfile(cf->file_path, cvs_directory_tag, NULL, 0); xfree(cvs_directory_tag); cvs_directory_tag = NULL; @@ -594,17 +604,20 @@ cvs_file_classify(struct cvs_file *cf, const char *tag) (void)xsnprintf(rcsfile, MAXPATHLEN, "%s/%s", repo, cf->file_name); - if (cvs_cmdop != CVS_OP_RLOG && cvs_cmdop != CVS_OP_RTAG && - cf->file_type == CVS_FILE) { + if (cf->file_type == CVS_FILE) { len = strlcat(rcsfile, RCS_FILE_EXT, MAXPATHLEN); if (len >= MAXPATHLEN) fatal("cvs_file_classify: truncation"); } cf->file_rpath = xstrdup(rcsfile); - entlist = cvs_ent_open(cf->file_wd); - cf->file_ent = cvs_ent_get(entlist, cf->file_name); - cvs_ent_close(entlist, ENT_NOSYNC); + + if (cmdp->cmd_flags & CVS_USE_WDIR) { + entlist = cvs_ent_open(cf->file_wd); + cf->file_ent = cvs_ent_get(entlist, cf->file_name); + cvs_ent_close(entlist, ENT_NOSYNC); + } else + cf->file_ent = NULL; if (cf->file_ent != NULL) { if (cf->file_ent->ce_type == CVS_ENT_DIR && @@ -621,7 +634,9 @@ cvs_file_classify(struct cvs_file *cf, const char *tag) } if (cf->file_type == CVS_DIR) { - if (cf->fd == -1 && stat(rcsfile, &st) != -1) + if (!(cmdp->cmd_flags & CVS_USE_WDIR)) + cf->file_status = FILE_UPTODATE; + else if (cf->fd == -1 && stat(rcsfile, &st) != -1) cf->file_status = DIR_CREATE; else if (cf->file_ent != NULL || cvs_cmdop == CVS_OP_RLOG || cvs_cmdop == CVS_OP_RTAG) |