cvs-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Cvs-cvs] ccvs/src ChangeLog checkout.c create_adm.c rcs....


From: Derek Robert Price
Subject: [Cvs-cvs] ccvs/src ChangeLog checkout.c create_adm.c rcs....
Date: Thu, 25 Sep 2008 18:45:17 +0000

CVSROOT:        /cvsroot/cvs
Module name:    ccvs
Changes by:     Derek Robert Price <dprice>     08/09/25 18:45:17

Modified files:
        src            : ChangeLog checkout.c create_adm.c rcs.c repos.c 
                         subr.c 

Log message:
        * checkout.c: Some Traces.  Some cleanup.
        (checkout_proc): Pass empty update_dir to build_one_dir.
        * create_adm.c: Some cleanup.
        * rcs.c (RCS_setattic): Simplify via cvs_mkdir().
        * repos.c (Sanitize_Repository_Name): Strip any number of /.?
        * subr.c (mkdir_i): Assume UPDATE_DIR is a full path when set.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/ChangeLog?cvsroot=cvs&r1=1.3614&r2=1.3615
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/checkout.c?cvsroot=cvs&r1=1.153&r2=1.154
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/create_adm.c?cvsroot=cvs&r1=1.56&r2=1.57
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/rcs.c?cvsroot=cvs&r1=1.397&r2=1.398
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/repos.c?cvsroot=cvs&r1=1.46&r2=1.47
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/subr.c?cvsroot=cvs&r1=1.175&r2=1.176

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/ChangeLog,v
retrieving revision 1.3614
retrieving revision 1.3615
diff -u -b -r1.3614 -r1.3615
--- ChangeLog   25 Sep 2008 13:24:35 -0000      1.3614
+++ ChangeLog   25 Sep 2008 18:45:07 -0000      1.3615
@@ -1,5 +1,12 @@
 2008-09-25  Derek R. Price  <address@hidden>
 
+       * checkout.c: Some Traces.  Some cleanup.
+       (checkout_proc): Pass empty update_dir to build_one_dir.
+       * create_adm.c: Some cleanup.
+       * rcs.c (RCS_setattic): Simplify via cvs_mkdir().
+       * repos.c (Sanitize_Repository_Name): Strip any number of /.?
+       * subr.c (mkdir_i): Assume UPDATE_DIR is a full path when set.
+
        * status.c, update.c: Some cleanup.
        * subr.c (dir_append_dirs): Extend to ignore ./*.  Improve header block
        comment.

Index: checkout.c
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/checkout.c,v
retrieving revision 1.153
retrieving revision 1.154
diff -u -b -r1.153 -r1.154
--- checkout.c  19 Sep 2008 16:15:44 -0000      1.153
+++ checkout.c  25 Sep 2008 18:45:15 -0000      1.154
@@ -43,6 +43,9 @@
 # include <config.h>
 #endif
 
+/* GNULIB */
+#include "quote.h"
+
 /* CVS */
 #include "ignore.h"
 #include "parseinfo.h"
@@ -574,6 +577,9 @@
 {
     FILE *fp;
 
+    TRACE (TRACE_FUNCTION, "build_one_dir (%s, %s, %d)",
+          repository, dirpath, sticky);
+
     if (isfile (CVSADM))
     {
        if (m_type == EXPORT)
@@ -630,14 +636,11 @@
     char *oldupdate = NULL;
     char *where;
 
+    assert (argc);
+
     TRACE (TRACE_FUNCTION, "checkout_proc (%s, %s, %s, %d, %d, %s, %s)\n",
-          where_orig ? where_orig : "(null)",
-          mwhere ? mwhere : "(null)",
-          mfile ? mfile : "(null)",
-          shorten, local_specified,
-          omodule ? omodule : "(null)",
-          msg ? msg : "(null)"
-         );
+          TRACE_NULL (where_orig), TRACE_NULL (mwhere), TRACE_NULL (mfile),
+          shorten, local_specified, TRACE_NULL (omodule), TRACE_NULL (msg));
 
     /*
      * OK, so we're doing the checkout! Our args are as follows: 
@@ -652,12 +655,7 @@
     /* Set up the repository (maybe) for the bottom directory.
        Allocate more space than we need so we don't need to keep
        reallocating this string. */
-    repository = xmalloc (strlen (current_parsed_root->directory)
-                         + strlen (argv[0])
-                         + (mfile == NULL ? 0 : strlen (mfile))
-                         + 10);
-    (void) sprintf (repository, "%s/%s",
-                    current_parsed_root->directory, argv[0]);
+    repository = Xasprintf ("%s/%s", current_parsed_root->directory, argv[0]);
     Sanitize_Repository_Name (repository);
 
 
@@ -685,28 +683,22 @@
     
     if (shorten)
     {
-       if (where_orig != NULL)
-       {
+       if (where_orig)
            /* If the user has specified a directory with `-d' on the
-              command line, use it preferentially, even over the `-d'
-              flag in the modules file. */
-    
-           (void) strcpy (where, where_orig);
-       }
-       else if (mwhere != NULL)
-       {
+            * command line, use it preferentially, even over the `-d'
+            * flag in the modules file.
+            */
+           strcpy (where, where_orig);
+       else if (mwhere)
            /* Second preference is the value of mwhere, which is from
-              the `-d' flag in the modules file. */
-
-           (void) strcpy (where, mwhere);
-       }
+            * the `-d' flag in the modules file.
+            */
+           strcpy (where, mwhere);
        else
-       {
            /* Third preference is the directory specified in argv[0]
-              which is this module'e directory in the repository. */
-           
-           (void) strcpy (where, argv[0]);
-       }
+            * which is this module'e directory in the repository.
+            */
+           strcpy (where, argv[0]);
     }
     else
     {
@@ -715,10 +707,10 @@
 
        *where = '\0';
 
-       if (where_orig != NULL)
+       if (where_orig)
        {
-           (void) strcat (where, where_orig);
-           (void) strcat (where, "/");
+           strcat (where, where_orig);
+           strcat (where, "/");
        }
 
        /* If the -d flag in the modules file specified an absolute
@@ -726,9 +718,9 @@
            -d option. */
 
        if (mwhere && !ISABSOLUTE (mwhere))
-           (void) strcat (where, mwhere);
+           strcat (where, mwhere);
        else
-           (void) strcat (where, argv[0]);
+           strcat (where, argv[0]);
     }
     strip_trailing_slashes (where); /* necessary? */
 
@@ -737,7 +729,7 @@
        directory from within a module.  In that case, we should modify
        where, repository, and argv as appropriate. */
 
-    if (mfile != NULL)
+    if (mfile)
     {
        /* The mfile variable can have one or more path elements.  If
           it has multiple elements, we want to tack those onto both
@@ -754,24 +746,21 @@
 
 
        /* Paranoia check. */
-
-       if (mfile[strlen (mfile) - 1] == '/')
-       {
+       if (ISSLASH (mfile[strlen (mfile) - 1]))
            error (0, 0, "checkout_proc: trailing slash on mfile (%s)!",
-                  mfile);
-       }
+                  quote (mfile));
 
 
        /* Does mfile have multiple path elements? */
-
        cp = strrchr (mfile, '/');
-       if (cp != NULL)
+       if (cp)
        {
            *cp = '\0';
-           (void) strcat (repository, "/");
-           (void) strcat (repository, mfile);
-           (void) strcat (where, "/");
-           (void) strcat (where, mfile);
+           xrealloc (repository, strlen (repository) + strlen (mfile) + 2);
+           strcat (repository, "/");
+           strcat (repository, mfile);
+           strcat (where, "/");
+           strcat (where, mfile);
            mfile = cp + 1;
        }
        
@@ -783,11 +772,11 @@
        {
            /* It's a directory, so tack it on to repository and
                where, as we did above. */
-
-           (void) strcat (repository, "/");
-           (void) strcat (repository, mfile);
-           (void) strcat (where, "/");
-           (void) strcat (where, mfile);
+           xrealloc (repository, strlen (repository) + strlen (mfile) + 2);
+           strcat (repository, "/");
+           strcat (repository, mfile);
+           strcat (where, "/");
+           strcat (where, mfile);
        }
        else
        {
@@ -801,11 +790,11 @@
        free (path);
     }
 
-    if (preload_update_dir != NULL)
+    if (preload_update_dir)
     {
        preload_update_dir =
            xrealloc (preload_update_dir,
-                     strlen (preload_update_dir) + strlen (where) + 5);
+                     strlen (preload_update_dir) + strlen (where) + 2);
        strcat (preload_update_dir, "/");
        strcat (preload_update_dir, where);
     }
@@ -834,8 +823,8 @@
 
        if (!STRNEQ (repository, current_parsed_root->directory,
                     strlen (current_parsed_root->directory)))
-           error (1, 0, "\
-internal error: %s doesn't start with %s in checkout_proc",
+           error (1, 0,
+"internal error: %s doesn't start with %s in checkout_proc",
                   repository, current_parsed_root->directory);
 
        /* We always create at least one directory, which corresponds to
@@ -860,7 +849,7 @@
            struct dir_to_build *new;
 
            cp = findslash (where, cp - 1);
-           if (cp == NULL)
+           if (!cp)
                break;          /* we're done */
 
            new = xmalloc (sizeof (struct dir_to_build));
@@ -878,7 +867,7 @@
            else
            {
                /* where should always be at least one character long. */
-               assert (where[0] != '\0');
+               assert (*where);
                strcpy (new->dirpath, "/");
            }
            new->next = head;
@@ -905,7 +894,7 @@
            {
                /* We can't walk up past CVSROOT.  Instead, the
                    repository should be Emptydir. */
-               new->repository = emptydir_name ();
+               new->repository = emptydir_name();
            }
            else
            {
@@ -916,23 +905,12 @@
                /* We'll always be below CVSROOT, but check for
                   paranoia's sake. */
                rp = strrchr (reposcopy, '/');
-               if (rp == NULL)
+               if (!rp)
                    error (1, 0,
                           "internal error: %s doesn't contain a slash",
                           reposcopy);
                           
                *rp = '\0';
-                   
-               if (STREQ (reposcopy, current_parsed_root->directory))
-               {
-                   /* Special case -- the repository name needs
-                      to be "/path/to/repos/." (the trailing dot
-                      is important).  We might be able to get rid
-                      of this after the we check out the other
-                      code that handles repository names. */
-                   new-> repository = Xasprintf ("%s/.", reposcopy);
-               }
-               else
                    new->repository = xstrdup (reposcopy);
            }
        }
@@ -956,7 +934,7 @@
        {
            /* It may be argued that we shouldn't set any sticky
               bits for the top-level repository.  FIXME?  */
-           build_one_dir (current_parsed_root->directory, ".", argc <= 1);
+           build_one_dir (current_parsed_root->directory, "", argc <= 1);
 
 #ifdef SERVER_SUPPORT
            /* We _always_ want to have a top-level admin
@@ -978,7 +956,7 @@
           contain a CVS subdir yet, but all the others contain
           CVS and Entries.Static files */
 
-       if (build_dirs_and_chdir (head, argc <= 1) != 0)
+       if (build_dirs_and_chdir (head, argc <= 1))
        {
            error (0, 0, "ignoring module %s", omodule);
            err = 1;

Index: create_adm.c
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/create_adm.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -b -r1.56 -r1.57
--- create_adm.c        12 Sep 2007 18:27:07 -0000      1.56
+++ create_adm.c        25 Sep 2008 18:45:16 -0000      1.57
@@ -21,7 +21,10 @@
 # include <config.h>
 #endif
 
-/* CVS Headers.  */
+/* GNULIB */
+#include "quote.h"
+
+/* CVS */
 #include "repos.h"
 
 #include "cvs.h"
@@ -44,111 +47,78 @@
     FILE *fout;
     char *cp;
     char *reposcopy;
-    char *tmp;
-    bool ud;
+    char *tmp, *ud;
 
     TRACE (TRACE_FUNCTION, "Create_Admin (%s, %s, %s, %s, %s, %d, %d, %d)",
-          dir, update_dir, repository, tag ? tag : "",
-          date ? date : "", nonbranch, warn, dotemplate);
+          dir, update_dir, repository, TRACE_NULL (tag),
+          TRACE_NULL (date), nonbranch, warn, dotemplate);
 
     if (noexec)
        return 0;
 
     /* A leading "./" looks bad in error messages.  */
-    ud = STREQ (dir, ".");
-    tmp = Xasprintf ("%s%s%s", ud ? "" : dir, ud ? "" : "/", CVSADM);
+    tmp = dir_append (dir, CVSADM);
     if (isfile (tmp))
-       error (1, 0, "there is a version in %s already", update_dir);
+       error (1, 0, "there is a version in %s already", quote (update_dir));
 
-    if (!cvs_mkdir (tmp, update_dir, warn ? 0 : MD_FATAL))
+    ud = dir_append (update_dir, CVSADM);
+    if (!cvs_mkdir (tmp, ud, warn ? 0 : MD_FATAL))
     {
        free (tmp);
-       tmp = NULL;
+       free (ud);
        return 1;
     }
     /* else */
 
     free (tmp);
-    tmp = NULL;
+    free (ud);
 
     /* record the current cvs root for later use */
 
     Create_Root (dir, original_parsed_root->original);
-    if (dir != NULL)
-       tmp = Xasprintf ("%s/%s", dir, CVSADM_REP);
-    else
-       tmp = xstrdup (CVSADM_REP);
+
+    tmp = dir_append (dir, CVSADM_REP);
     fout = CVS_FOPEN (tmp, "w+");
-    if (fout == NULL)
-    {
-       if (update_dir[0] == '\0')
-           error (1, errno, "cannot open %s", tmp);
-       else
-           error (1, errno, "cannot open %s/%s", update_dir, CVSADM_REP);
-    }
+    if (!fout)
+       error (1, errno, "cannot open %s",
+              quote (dir_append (update_dir, CVSADM_REP)));
+
     reposcopy = xstrdup (repository);
     Sanitize_Repository_Name (reposcopy);
 
-    /* The top level of the repository is a special case -- we need to
-       write it with an extra dot at the end.  This trailing `.' stuff
-       rubs me the wrong way -- on the other hand, I don't want to
-       spend the time making sure all of the code can handle it if we
-       don't do it. */
-
-    if (STREQ (reposcopy, current_parsed_root->directory))
-    {
-       reposcopy = xrealloc (reposcopy, strlen (reposcopy) + 3);
-       strcat (reposcopy, "/.");
-    }
-
     cp = reposcopy;
 
     /*
      * If the Repository file is to hold a relative path, try to strip off
      * the leading CVSroot argument.
      */
+    if (STRNEQ (cp, current_parsed_root->directory,
+               strlen (current_parsed_root->directory)))
     {
-       char *path = Xasprintf ("%s/", current_parsed_root->directory);
-       if (STRNEQ (cp, path, strlen (path)))
-           cp += strlen (path);
-       free (path);
+       cp += strlen (current_parsed_root->directory);
+       if (ISSLASH (*cp))
+           cp += 1;
+       else if (*cp)
+           cp = reposcopy;
     }
 
-    if (fprintf (fout, "%s\n", cp) < 0)
-    {
-       if (update_dir[0] == '\0')
-           error (1, errno, "write to %s failed", tmp);
-       else
-           error (1, errno, "write to %s/%s failed", update_dir, CVSADM_REP);
-    }
+    if (fprintf (fout, "%s\n", NULL2DOT (cp)) < 0)
+       error (1, errno, "write to %s failed",
+              quote (dir_append (update_dir, CVSADM_REP)));
     if (fclose (fout) == EOF)
-    {
-       if (update_dir[0] == '\0')
-           error (1, errno, "cannot close %s", tmp);
-       else
-           error (1, errno, "cannot close %s/%s", update_dir, CVSADM_REP);
-    }
+       error (1, errno, "cannot close %s",
+              quote (dir_append (update_dir, CVSADM_REP)));
 
     /* now, do the Entries file */
-    if (dir != NULL)
-       (void) sprintf (tmp, "%s/%s", dir, CVSADM_ENT);
-    else
-       (void) strcpy (tmp, CVSADM_ENT);
+    free (tmp);
+    tmp = dir_append (dir, CVSADM_ENT);
     fout = CVS_FOPEN (tmp, "w+");
-    if (fout == NULL)
-    {
-       if (update_dir[0] == '\0')
-           error (1, errno, "cannot open %s", tmp);
-       else
-           error (1, errno, "cannot open %s/%s", update_dir, CVSADM_ENT);
-    }
+    if (!fout)
+       error (1, errno, "cannot open %s",
+              quote (dir_append (update_dir, CVSADM_ENT)));
     if (fclose (fout) == EOF)
-    {
-       if (update_dir[0] == '\0')
-           error (1, errno, "cannot close %s", tmp);
-       else
-           error (1, errno, "cannot close %s/%s", update_dir, CVSADM_ENT);
-    }
+           error (1, errno, "cannot close %s",
+                  quote (dir_append (update_dir, CVSADM_ENT)));
 
     /* Create a new CVS/Tag file */
     WriteTag (dir, tag, date, nonbranch, update_dir, repository);

Index: rcs.c
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/rcs.c,v
retrieving revision 1.397
retrieving revision 1.398
diff -u -b -r1.397 -r1.398
--- rcs.c       22 Sep 2008 17:36:28 -0000      1.397
+++ rcs.c       25 Sep 2008 18:45:16 -0000      1.398
@@ -690,8 +690,6 @@
 
     if (toattic)
     {
-       mode_t omask;
-
        if (rcs->flags & INATTIC)
            return 0;
 
@@ -702,10 +700,7 @@
        strcpy (newpath + (p - rcs->path), CVSATTIC);
 
        /* Create the Attic directory if it doesn't exist.  */
-       omask = umask (cvsumask);
-       if (CVS_MKDIR (newpath, 0777) < 0 && errno != EEXIST)
-           error (0, errno, "cannot make directory %s", newpath);
-       (void) umask (omask);
+       cvs_mkdir (newpath, NULL, MD_REPO | MD_EXIST_OK); /* Prints errors.  */
 
        strcat (newpath, "/");
        strcat (newpath, p);

Index: repos.c
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/repos.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -b -r1.46 -r1.47
--- repos.c     22 Sep 2008 18:01:01 -0000      1.46
+++ repos.c     25 Sep 2008 18:45:17 -0000      1.47
@@ -186,15 +186,23 @@
 {
     size_t len;
 
-    assert (repository != NULL);
+    assert (repository);
 
     strip_trailing_slashes (repository);
-
     len = strlen (repository);
-    if (len >= 2
+    while (len >= 2
        && repository[len - 1] == '.'
        && ISSLASH (repository[len - 2]))
     {
-       repository[len - 2] = '\0';
+       /* Beware the case where the string is exactly "/." or "//.".
+        * Paths with a leading "//" are special on some early UNIXes.
+        */
+       if (strlen (repository) == 2
+           || strlen (repository) == 3 && ISSLASH (*repository))
+           repository[strlen (repository) - 1] = '\0';
+       else
+           repository[strlen (repository) - 2] = '\0';
+       strip_trailing_slashes (repository);
+       len = strlen (repository);
     }
 }

Index: subr.c
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/subr.c,v
retrieving revision 1.175
retrieving revision 1.176
diff -u -b -r1.175 -r1.176
--- subr.c      25 Sep 2008 13:24:36 -0000      1.175
+++ subr.c      25 Sep 2008 18:45:17 -0000      1.176
@@ -2220,13 +2220,9 @@
 
     if (err && !(flags & MD_EXIST_OK && (errno == EEXIST || isdir (name)))
        && (flags & MD_FATAL || !(flags & MD_QUIET)))
-    {
-       bool uud = update_dir && strlen (update_dir)
-                  && !STREQ (update_dir, ".");
+       error (flags & MD_FATAL, saved_errno, "cannot make directory %s",
+              quote (update_dir ? update_dir : name));
        errno = saved_errno;
-       error (flags & MD_FATAL, errno, "cannot make directory `%s%s%s'",
-              uud ? update_dir : "", uud ? "/" : "", name);
-    }
     return !err;
 }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]