[BACK]Return to file.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / cvs

Diff for /src/usr.bin/cvs/file.c between version 1.256 and 1.257

version 1.256, 2009/03/25 21:50:33 version 1.257, 2009/03/26 22:54:37
Line 191 
Line 191 
   
         RB_INIT(&fl);          RB_INIT(&fl);
   
         for (i = 0; i < argc; i++)          for (i = 0; i < argc; i++) {
                 cvs_file_get(argv[i], FILE_USER_SUPPLIED, &fl);                  STRIP_SLASH(argv[i]);
                   cvs_file_get(argv[i], FILE_USER_SUPPLIED, &fl, 0);
           }
   
         cvs_file_walklist(&fl, cr);          cvs_file_walklist(&fl, cr);
         cvs_file_freelist(&fl);          cvs_file_freelist(&fl);
 }  }
   
 struct cvs_filelist *  struct cvs_filelist *
 cvs_file_get(char *name, int flags, struct cvs_flisthead *fl)  cvs_file_get(char *name, int flags, struct cvs_flisthead *fl, int type)
 {  {
         char *p;          char *p;
         struct cvs_filelist *l, find;          struct cvs_filelist *l, find;
Line 215 
Line 217 
         l = (struct cvs_filelist *)xmalloc(sizeof(*l));          l = (struct cvs_filelist *)xmalloc(sizeof(*l));
         l->file_path = xstrdup(p);          l->file_path = xstrdup(p);
         l->flags = flags;          l->flags = flags;
           l->type = type;
   
         RB_INSERT(cvs_flisthead, fl, l);          RB_INSERT(cvs_flisthead, fl, l);
         return (l);          return (l);
Line 274 
Line 277 
                 if ((d = dirname(l->file_path)) == NULL)                  if ((d = dirname(l->file_path)) == NULL)
                         fatal("cvs_file_walklist: dirname failed");                          fatal("cvs_file_walklist: dirname failed");
   
                 type = CVS_FILE;                  type = l->type;
                 if ((fd = open(l->file_path, O_RDONLY)) != -1) {                  if ((fd = open(l->file_path, O_RDONLY)) != -1) {
                         if (fstat(fd, &st) == -1) {                          if (type == 0) {
                                 cvs_log(LP_ERRNO, "%s", l->file_path);                                  if (fstat(fd, &st) == -1) {
                                 (void)close(fd);                                          cvs_log(LP_ERRNO, "%s", l->file_path);
                                 goto next;                                          (void)close(fd);
                         }                                          goto next;
                                   }
   
                         if (S_ISDIR(st.st_mode))                                  if (S_ISDIR(st.st_mode))
                                 type = CVS_DIR;                                          type = CVS_DIR;
                         else if (S_ISREG(st.st_mode))                                  else if (S_ISREG(st.st_mode))
                                 type = CVS_FILE;                                          type = CVS_FILE;
                         else {                                  else {
                                 cvs_log(LP_ERR,                                          cvs_log(LP_ERR,
                                     "ignoring bad file type for %s",                                              "ignoring bad file type for %s",
                                     l->file_path);                                              l->file_path);
                                 (void)close(fd);                                          (void)close(fd);
                                 goto next;                                          goto next;
                                   }
                         }                          }
                 } else if (current_cvsroot->cr_method == CVS_METHOD_LOCAL) {                  } else if (current_cvsroot->cr_method == CVS_METHOD_LOCAL) {
                         /*                          /*
Line 314 
Line 319 
                                 fd = open(fpath, O_RDONLY);                                  fd = open(fpath, O_RDONLY);
                         }                          }
   
                         if (fd != -1) {                          if (fd != -1 && type == 0) {
                                 if (fstat(fd, &st) == -1)                                  if (fstat(fd, &st) == -1)
                                         fatal("cvs_file_walklist: %s: %s",                                          fatal("cvs_file_walklist: %s: %s",
                                              fpath, strerror(errno));                                               fpath, strerror(errno));
Line 334 
Line 339 
                                 /* this file is not in our working copy yet */                                  /* this file is not in our working copy yet */
                                 (void)close(fd);                                  (void)close(fd);
                                 fd = -1;                                  fd = -1;
                           } else if (fd != -1) {
                                   close(fd);
                                   fd = -1;
                         }                          }
                 }                  }
   
                 cf = cvs_file_get_cf(d, f, l->file_path,                  cf = cvs_file_get_cf(d, f, l->file_path, fd, type, l->flags);
                     fd, type, l->flags);  
                 if (cf->file_type == CVS_DIR) {                  if (cf->file_type == CVS_DIR) {
                         cvs_file_walkdir(cf, cr);                          cvs_file_walkdir(cf, cr);
                 } else {                  } else {
Line 536 
Line 543 
                         switch (type) {                          switch (type) {
                         case CVS_DIR:                          case CVS_DIR:
                                 if (cr->flags & CR_RECURSE_DIRS)                                  if (cr->flags & CR_RECURSE_DIRS)
                                         cvs_file_get(fpath, 0, &dl);                                          cvs_file_get(fpath, 0, &dl, CVS_DIR);
                                 break;                                  break;
                         case CVS_FILE:                          case CVS_FILE:
                                 cvs_file_get(fpath, 0, &fl);                                  cvs_file_get(fpath, 0, &fl, CVS_FILE);
                                 break;                                  break;
                         default:                          default:
                                 fatal("type %d unknown, shouldn't happen",                                  fatal("type %d unknown, shouldn't happen",
Line 572 
Line 579 
                     ent->ce_type == CVS_ENT_DIR)                      ent->ce_type == CVS_ENT_DIR)
                         continue;                          continue;
                 if (ent->ce_type == CVS_ENT_DIR)                  if (ent->ce_type == CVS_ENT_DIR)
                         cvs_file_get(fpath, 0, &dl);                          cvs_file_get(fpath, 0, &dl, CVS_DIR);
                 else if (ent->ce_type == CVS_ENT_FILE)                  else if (ent->ce_type == CVS_ENT_FILE)
                         cvs_file_get(fpath, 0, &fl);                          cvs_file_get(fpath, 0, &fl, CVS_FILE);
   
                 cvs_ent_free(ent);                  cvs_ent_free(ent);
         }          }
Line 667 
Line 674 
                 cf->file_ent = NULL;                  cf->file_ent = NULL;
   
         if (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 &&                  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_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)                      cf->file_type != CVS_DIR)
                         fatal("%s is supposed to be a directory, but it is not",                          fatal("%s is supposed to be a directory, but it is not",
                             cf->file_path);                              cf->file_path);
Line 677 
Line 701 
                     cf->file_type != CVS_FILE)                      cf->file_type != CVS_FILE)
                         fatal("%s is supposed to be a file, but it is not",                          fatal("%s is supposed to be a file, but it is not",
                             cf->file_path);                              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) {          if (cf->file_type == CVS_DIR) {

Legend:
Removed from v.1.256  
changed lines
  Added in v.1.257