Program:        cvs
Version:        1.10

Host:           all
Area:           client

Synopsis:       cvs export fails with rcstemplate

Description:
    "cvs export" fails with the following error message:

benz:/tmp(3)> cvs export -rHEAD TeX
cvs [export aborted]: cannot write <CVS/Template file>: No such file or directory

    This happens under the following conditions:

    1. remote access to the repository is used, i.e. cvs client/server.
    2. a special template is defined for this module in the
       CVSROOT/rcsinfo file.

Reproduce with:
    see above

Fix:
    The problem is in src/client.c, which does not check for the
    "export" command in `template' or `handle_template'.  (Compare with
    `handle_clear_sticky' for example.)

    Perhaps, `template' should also check for `is_cvsroot_level', but
    I'm not sure about this.

    I've fixed the problem with the attached patch, but it's probably
    not the cleanest way to do it.


-- 
Andreas Luik         E-Mail: [EMAIL PROTECTED]
Orthogon GmbH        WWW:    http://www.orthogon.de/~luik
Sys/Net Admin        PGP:    E2 6A 41 70 67 1E 0B 68  94 0D 9E 83 95 16 AF 59

*** cvs-1.10/src/client.c.ORIG  Mon Jul 27 04:54:06 1998
--- cvs-1.10/src/client.c       Thu Jun 15 14:22:25 2000
***************
*** 1249,1255 ****
      size_t nread;
      size_t nwrite;
  
!     FILE *fp;
  
      read_line (&size_string);
      if (size_string[0] == 'z')
--- 1249,1255 ----
      size_t nread;
      size_t nwrite;
  
!     FILE *fp = NULL;
  
      read_line (&size_string);
      if (size_string[0] == 'z')
***************
*** 1270,1278 ****
         is binary or not.  I haven't carefully looked into whether
         CVS/Template files should use local text file conventions or
         not.  */
!     fp = CVS_FOPEN (filename, "wb");
!     if (fp == NULL)
!       error (1, errno, "cannot write %s", fullname);
      nread = size;
      nwrite = 0;
      pread = buf;
--- 1270,1280 ----
         is binary or not.  I haven't carefully looked into whether
         CVS/Template files should use local text file conventions or
         not.  */
!     if (filename) {
!       fp = CVS_FOPEN (filename, "wb");
!       if (fp == NULL)
!           error (1, errno, "cannot write %s", fullname);
!     }
      nread = size;
      nwrite = 0;
      pread = buf;
***************
*** 1291,1305 ****
  
        if (nwrite > 0)
        {
!           n = fwrite (pwrite, 1, nwrite, fp);
!           if (ferror (fp))
!               error (1, errno, "cannot write %s", fullname);
            nwrite -= n;
            pwrite += n;
        }
      }
      free (buf);
!     if (fclose (fp) < 0)
        error (1, errno, "cannot close %s", fullname);
  }
  
--- 1293,1312 ----
  
        if (nwrite > 0)
        {
!           if (fp) {
!               n = fwrite (pwrite, 1, nwrite, fp);
!               if (ferror (fp))
!                   error (1, errno, "cannot write %s", fullname);
!           }
!           else {
!               n = nwrite;
!           }
            nwrite -= n;
            pwrite += n;
        }
      }
      free (buf);
!     if (fp && fclose (fp) < 0)
        error (1, errno, "cannot close %s", fullname);
  }
  
***************
*** 2346,2351 ****
--- 2353,2364 ----
      char *short_pathname;
      char *filename;
  {
+     if (strcmp (command_name, "export") == 0)
+     {
+       read_counted_file (NULL, NULL);
+       return;
+     }
+ 
      /* FIXME: should be computing second argument from CVSADM_TEMPLATE
         and short_pathname.  */
      read_counted_file (CVSADM_TEMPLATE, "<CVS/Template file>");

Reply via email to