=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/cvs/file.c,v retrieving revision 1.256 retrieving revision 1.257 diff -c -r1.256 -r1.257 *** src/usr.bin/cvs/file.c 2009/03/25 21:50:33 1.256 --- src/usr.bin/cvs/file.c 2009/03/26 22:54:37 1.257 *************** *** 1,4 **** ! /* $OpenBSD: file.c,v 1.256 2009/03/25 21:50:33 joris Exp $ */ /* * Copyright (c) 2006 Joris Vink * Copyright (c) 2004 Jean-Francois Brousseau --- 1,4 ---- ! /* $OpenBSD: file.c,v 1.257 2009/03/26 22:54:37 joris Exp $ */ /* * Copyright (c) 2006 Joris Vink * Copyright (c) 2004 Jean-Francois Brousseau *************** *** 191,205 **** RB_INIT(&fl); ! for (i = 0; i < argc; i++) ! cvs_file_get(argv[i], FILE_USER_SUPPLIED, &fl); cvs_file_walklist(&fl, cr); cvs_file_freelist(&fl); } struct cvs_filelist * ! cvs_file_get(char *name, int flags, struct cvs_flisthead *fl) { char *p; struct cvs_filelist *l, find; --- 191,207 ---- RB_INIT(&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, int type) { char *p; struct cvs_filelist *l, find; *************** *** 215,220 **** --- 217,223 ---- 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,297 **** 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); ! (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) { /* --- 277,302 ---- if ((d = dirname(l->file_path)) == NULL) fatal("cvs_file_walklist: dirname failed"); ! type = l->type; if ((fd = open(l->file_path, O_RDONLY)) != -1) { ! 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; ! } } } else if (current_cvsroot->cr_method == CVS_METHOD_LOCAL) { /* *************** *** 314,320 **** fd = open(fpath, O_RDONLY); } ! if (fd != -1) { if (fstat(fd, &st) == -1) fatal("cvs_file_walklist: %s: %s", fpath, strerror(errno)); --- 319,325 ---- fd = open(fpath, O_RDONLY); } ! if (fd != -1 && type == 0) { if (fstat(fd, &st) == -1) fatal("cvs_file_walklist: %s: %s", fpath, strerror(errno)); *************** *** 334,344 **** /* this file is not in our working copy yet */ (void)close(fd); fd = -1; } } ! 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 { --- 339,351 ---- /* 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); if (cf->file_type == CVS_DIR) { cvs_file_walkdir(cf, cr); } else { *************** *** 536,545 **** switch (type) { case CVS_DIR: if (cr->flags & CR_RECURSE_DIRS) ! cvs_file_get(fpath, 0, &dl); break; case CVS_FILE: ! cvs_file_get(fpath, 0, &fl); break; default: fatal("type %d unknown, shouldn't happen", --- 543,552 ---- switch (type) { case CVS_DIR: if (cr->flags & CR_RECURSE_DIRS) ! cvs_file_get(fpath, 0, &dl, CVS_DIR); break; case CVS_FILE: ! cvs_file_get(fpath, 0, &fl, CVS_FILE); break; default: fatal("type %d unknown, shouldn't happen", *************** *** 572,580 **** ent->ce_type == CVS_ENT_DIR) continue; if (ent->ce_type == CVS_ENT_DIR) ! cvs_file_get(fpath, 0, &dl); else if (ent->ce_type == CVS_ENT_FILE) ! cvs_file_get(fpath, 0, &fl); cvs_ent_free(ent); } --- 579,587 ---- ent->ce_type == CVS_ENT_DIR) continue; if (ent->ce_type == CVS_ENT_DIR) ! cvs_file_get(fpath, 0, &dl, CVS_DIR); else if (ent->ce_type == CVS_ENT_FILE) ! cvs_file_get(fpath, 0, &fl, CVS_FILE); cvs_ent_free(ent); } *************** *** 667,674 **** --- 674,698 ---- 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) fatal("%s is supposed to be a directory, but it is not", cf->file_path); *************** *** 677,685 **** 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) { --- 701,706 ----