cvs-cvs
[Top][All Lists]
Advanced

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

[Cvs-cvs] ccvs/src sanity.sh mkmodules.c ChangeLog


From: Derek Robert Price
Subject: [Cvs-cvs] ccvs/src sanity.sh mkmodules.c ChangeLog
Date: Wed, 22 Aug 2007 20:57:01 +0000

CVSROOT:        /cvsroot/cvs
Module name:    ccvs
Changes by:     Derek Robert Price <dprice>     07/08/22 20:57:01

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

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/sanity.sh?cvsroot=cvs&r1=1.1183&r2=1.1184
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/mkmodules.c?cvsroot=cvs&r1=1.100&r2=1.101
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/ChangeLog?cvsroot=cvs&r1=1.3520&r2=1.3521

Patches:
Index: sanity.sh
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/sanity.sh,v
retrieving revision 1.1183
retrieving revision 1.1184
diff -u -b -r1.1183 -r1.1184
--- sanity.sh   22 Aug 2007 19:56:36 -0000      1.1183
+++ sanity.sh   22 Aug 2007 20:57:00 -0000      1.1184
@@ -3400,8 +3400,11 @@
 ###
 if $remote; then
        localonly init-2
+       localonly init-3
 else
        dotest init-2 "$testcvs init"
+       dotest_fail init-3 "$testcvs -d $CVSROOT/sdir init" \
+"$CPROG \[init aborted\]: Cannot initialize repository under existing CVSROOT: 
\`$CVSROOT_DIRNAME'"
 fi
 
 

Index: mkmodules.c
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/mkmodules.c,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -b -r1.100 -r1.101
--- mkmodules.c 8 May 2007 12:35:53 -0000       1.100
+++ mkmodules.c 22 Aug 2007 20:57:00 -0000      1.101
@@ -1148,6 +1148,43 @@
     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 = Xasprintf ("%s/%s", cp, CVSROOTADM);
+           bool 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, "."))
+           break;
+
+       p = dir_name (cp);
+       free (cp);
+
+       cp = p;
+    }
+
+    return NULL;
+}
+
+
 const char *const init_usage[] = {
     "Usage: %s %s\n",
     "(Specify the --help global option for a list of other help options)\n",
@@ -1186,6 +1223,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: ChangeLog
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/ChangeLog,v
retrieving revision 1.3520
retrieving revision 1.3521
diff -u -b -r1.3520 -r1.3521
--- ChangeLog   22 Aug 2007 19:56:35 -0000      1.3520
+++ ChangeLog   22 Aug 2007 20:57:00 -0000      1.3521
@@ -1,5 +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.
+
        * add.c (add): Check last component of argument paths instead of the
        entire argument.
        (add_directory): Change error messages to assertions since the check




reply via email to

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