cvs-cvs
[Top][All Lists]
Advanced

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

[Cvs-cvs] ccvs/src ChangeLog mkmodules.c sanity.sh [cvs1-11-x-branch]


From: Derek Robert Price
Subject: [Cvs-cvs] ccvs/src ChangeLog mkmodules.c sanity.sh [cvs1-11-x-branch]
Date: Wed, 22 Aug 2007 21:33:21 +0000

CVSROOT:        /cvsroot/cvs
Module name:    ccvs
Branch:         cvs1-11-x-branch
Changes by:     Derek Robert Price <dprice>     07/08/22 21:33:19

Modified files:
        src            : ChangeLog mkmodules.c sanity.sh 

Log message:
        * mkmodules.c (in_root): New function.
        (init): Verify that new roots are not created inside others.
        * sanity.sh (init-3): New test for same.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/ChangeLog?cvsroot=cvs&only_with_tag=cvs1-11-x-branch&r1=1.2336.2.487&r2=1.2336.2.488
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/mkmodules.c?cvsroot=cvs&only_with_tag=cvs1-11-x-branch&r1=1.66.6.9&r2=1.66.6.10
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/sanity.sh?cvsroot=cvs&only_with_tag=cvs1-11-x-branch&r1=1.752.2.212&r2=1.752.2.213

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/ChangeLog,v
retrieving revision 1.2336.2.487
retrieving revision 1.2336.2.488
diff -u -b -r1.2336.2.487 -r1.2336.2.488
--- ChangeLog   16 Aug 2007 18:28:30 -0000      1.2336.2.487
+++ ChangeLog   22 Aug 2007 21:33:17 -0000      1.2336.2.488
@@ -1,3 +1,9 @@
+2007-08-22  Derek Price  <address@hidden>
+
+       * mkmodules.c (in_root): New function.
+       (init): Verify that new roots are not created inside others.
+       * sanity.sh (init-3): New test for same.
+
 2007-08-16  Derek Price  <address@hidden>
 
        * root.c (root_allow_used): New function and...

Index: mkmodules.c
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/mkmodules.c,v
retrieving revision 1.66.6.9
retrieving revision 1.66.6.10
diff -u -b -r1.66.6.9 -r1.66.6.10
--- mkmodules.c 7 May 2007 13:14:28 -0000       1.66.6.9
+++ mkmodules.c 22 Aug 2007 21:33:17 -0000      1.66.6.10
@@ -847,6 +847,42 @@
     free (bak);
 }
 
+/*
+ * Walk PATH backwards to the root directory looking for the root of a
+ * repository.
+ */
+static char *
+in_root (const char *path)
+{
+    char *cp = xstrdup (path);
+
+    for (;;)
+    {
+       char *p;
+
+       if (isdir (cp))
+       {
+           char *adm = xmalloc (strlen(cp) + strlen(CVSROOTADM) + 2);
+           sprintf (adm, "%s/%s", cp, CVSROOTADM);
+           int foundit = isdir (adm);
+           free (adm);
+           if (foundit) return cp;
+       }
+
+       /* If last_component() returns the empty string, then cp either
+        * points at the system root or is the empty string itself.
+        */
+       if (!*last_component (cp) || !strcmp (cp, ".")
+           || last_component(cp) == cp)
+           break;
+
+       cp[strlen(cp) - strlen(last_component(cp)) - 1] = '\0';
+    }
+
+    return NULL;
+}
+
+
 const char *const init_usage[] = {
     "Usage: %s %s\n",
     "(Specify the --help global option for a list of other help options)\n",
@@ -887,6 +923,14 @@
     }
 #endif /* CLIENT_SUPPORT */
 
+    char *root_dir = in_root (current_parsed_root->directory);
+
+    if (root_dir && strcmp (root_dir, current_parsed_root->directory))
+       error (1, 0,
+              "Cannot initialize repository under existing CVSROOT: `%s'",
+              root_dir);
+    free (root_dir);
+
     /* Note: we do *not* create parent directories as needed like the
        old cvsinit.sh script did.  Few utilities do that, and a
        non-existent parent directory is as likely to be a typo as something

Index: sanity.sh
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/sanity.sh,v
retrieving revision 1.752.2.212
retrieving revision 1.752.2.213
diff -u -b -r1.752.2.212 -r1.752.2.213
--- sanity.sh   16 Aug 2007 18:28:30 -0000      1.752.2.212
+++ sanity.sh   22 Aug 2007 21:33:17 -0000      1.752.2.213
@@ -2108,9 +2108,12 @@
 ### The tests
 ###
 if $remote; then
-       localonly init-1a
+       localonly init-2
+       localonly init-3
 else
-       dotest init-1a "$testcvs init"
+       dotest init-2 "$testcvs init"
+       dotest_fail init-3 "$testcvs -d $CVSROOT/sdir init" \
+"$PROG \[init aborted\]: Cannot initialize repository under existing CVSROOT: 
\`$CVSROOT_DIRNAME'"
 fi
 
 




reply via email to

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