=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/cvs/file.c,v retrieving revision 1.127 retrieving revision 1.128 diff -c -r1.127 -r1.128 *** src/usr.bin/cvs/file.c 2005/11/12 21:34:48 1.127 --- src/usr.bin/cvs/file.c 2005/12/03 01:02:08 1.128 *************** *** 1,4 **** ! /* $OpenBSD: file.c,v 1.127 2005/11/12 21:34:48 niallo Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau * All rights reserved. --- 1,4 ---- ! /* $OpenBSD: file.c,v 1.128 2005/12/03 01:02:08 joris Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau * All rights reserved. *************** *** 427,439 **** } cvs_error = CVS_EX_OK; - cvs_file_free(cf); /* * Since some commands don't require any files to operate * we can stop right here for those. */ ! if (cvs_cmdop == CVS_OP_CHECKOUT || cvs_cmdop == CVS_OP_VERSION) return (0); for (i = 0; i < fsn; i++) { --- 427,448 ---- } cvs_error = CVS_EX_OK; /* * Since some commands don't require any files to operate * we can stop right here for those. */ ! if (cf->cf_root != NULL) { ! if (cf->cf_root->cr_method != CVS_METHOD_LOCAL && ! cvs_cmdop == CVS_OP_CHECKOUT) { ! cvs_file_free(cf); ! return (0); ! } ! } ! ! cvs_file_free(cf); ! ! if (cvs_cmdop == CVS_OP_VERSION) return (0); for (i = 0; i < fsn; i++) { *************** *** 838,843 **** --- 847,868 ---- if ((flags & CF_KNOWN) && (cf->cf_cvstat == CVS_FST_UNKNOWN)) return (0); + /* + * if we are working with a repository, fiddle with + * the pathname again. + */ + if (flags & CF_REPO) { + ret = snprintf(fpath, sizeof(fpath), "%s%s%s", + cf->cf_root->cr_dir, + (cf->cf_dir != NULL) ? "/" : "", + (cf->cf_dir != NULL) ? cf->cf_dir : ""); + if (ret == -1 || ret >= (int)sizeof(fpath)) + return (-1); + free(cf->cf_dir); + if ((cf->cf_dir = strdup(fpath)) == NULL) + return (-1); + } + nfiles = ndirs = 0; SIMPLEQ_INIT(&dirs); cvs_file_getpath(cf, fpath, sizeof(fpath)); *************** *** 1199,1214 **** --- 1224,1247 ---- cvs_file_lget(const char *path, int flags, CVSFILE *parent, CVSENTRIES *pent, struct cvs_ent *ent) { + char *c; int ret; u_int type; struct stat st; CVSFILE *cfp; + struct cvsroot *root; type = DT_UNKNOWN; ret = stat(path, &st); if (ret == 0) type = IFTODT(st.st_mode); + if ((flags & CF_REPO) && (type != DT_DIR)) { + if ((c = strrchr(path, ',')) == NULL) + return (NULL); + *c = '\0'; + } + if ((cfp = cvs_file_alloc(path, type)) == NULL) return (NULL); cfp->cf_parent = parent; *************** *** 1268,1273 **** --- 1301,1309 ---- else cfp->cf_cvstat = CVS_FST_LOST; } + + /* XXX assume 0644 ? */ + cfp->cf_mode = 0644; } if (ent != NULL) { *************** *** 1300,1305 **** --- 1336,1369 ---- } } + if (flags & CF_REPO) { + root = CVS_DIR_ROOT(cfp); + + cfp->cf_mode = 0644; + cfp->cf_cvstat = CVS_FST_LOST; + + if ((c = strdup(cfp->cf_dir)) == NULL) { + cvs_file_free(cfp); + return (NULL); + } + + free(cfp->cf_dir); + + if (strcmp(c, root->cr_dir)) { + c += strlen(root->cr_dir) + 1; + if ((cfp->cf_dir = strdup(c)) == NULL) { + cvs_file_free(cfp); + return (NULL); + } + + c -= strlen(root->cr_dir) + 1; + } else { + cfp->cf_dir = NULL; + } + + free(c); + } + if ((cfp->cf_repo != NULL) && (cfp->cf_type == DT_DIR) && !strcmp(cfp->cf_repo, path)) cfp->cf_cvstat = CVS_FST_UPTODATE; *************** *** 1383,1389 **** if (cvs_file_prune(fpath)) { empty--; if (entf) ! cvs_ent_remove(entf, fpath); } else { empty++; } --- 1447,1453 ---- if (cvs_file_prune(fpath)) { empty--; if (entf) ! cvs_ent_remove(entf, fpath, 0); } else { empty++; }