summaryrefslogtreecommitdiffstats
path: root/contrib/cvs/src/create_adm.c
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1998-01-26 03:09:57 +0000
committerpeter <peter@FreeBSD.org>1998-01-26 03:09:57 +0000
commite6e45661e44f15cb8c5c6f063080509bd910b98d (patch)
treea9812ba7ade0fde6f62c1626b45d522ba104c314 /contrib/cvs/src/create_adm.c
parent571cfa0005d94d99d1341bf8ab02be04d4df5f9f (diff)
downloadFreeBSD-src-e6e45661e44f15cb8c5c6f063080509bd910b98d.zip
FreeBSD-src-e6e45661e44f15cb8c5c6f063080509bd910b98d.tar.gz
Import cvs-1.9.23 as at 19980123. There are a number of really nice
things fixed in here, including the '-ko' vs. -A problem with remote cvs which caused all files with -ko to be resent each time (which is damn painful over a modem, I can tell you). It also found a heap of stray empty directories that should have been pruned with the -P flag to cvs update but were not for some reason. It also has the fully integrated rcs and diff, so no more fork/exec overheads for rcs,ci,patch,diff,etc. This means that it parses the control data in the rcs files only once rather than twice or more. If the 'cvs diff' vs. Index thing is going to be fixed for future patch compatability, this is the place to do it.
Diffstat (limited to 'contrib/cvs/src/create_adm.c')
-rw-r--r--contrib/cvs/src/create_adm.c66
1 files changed, 51 insertions, 15 deletions
diff --git a/contrib/cvs/src/create_adm.c b/contrib/cvs/src/create_adm.c
index 0ef6e57..c1772b2 100644
--- a/contrib/cvs/src/create_adm.c
+++ b/contrib/cvs/src/create_adm.c
@@ -3,7 +3,7 @@
* Copyright (c) 1989-1992, Brian Berliner
*
* You may distribute under the terms of the GNU General Public License as
- * specified in the README file that comes with the CVS 1.4 kit.
+ * specified in the README file that comes with the CVS source distribution.
*
* Create Administration.
*
@@ -13,35 +13,41 @@
#include "cvs.h"
-/* update_dir includes dir as its last component. */
+/* update_dir includes dir as its last component.
-void
-Create_Admin (dir, update_dir, repository, tag, date, nonbranch)
+ Return value is 0 for success, or 1 if we printed a warning message.
+ Note that many errors are still fatal; particularly for unlikely errors
+ a fatal error is probably better than a warning which might be missed
+ or after which CVS might do something non-useful. If WARN is zero, then
+ don't print warnings; all errors are fatal then. */
+
+int
+Create_Admin (dir, update_dir, repository, tag, date, nonbranch, warn)
char *dir;
char *update_dir;
char *repository;
char *tag;
char *date;
int nonbranch;
+ int warn;
{
FILE *fout;
char *cp;
+ char *reposcopy;
char *tmp;
#ifdef SERVER_SUPPORT
if (trace)
{
- char *wd = xgetwd ();
- fprintf (stderr, "%c-> Create_Admin (%s, %s, %s, %s, %s) in %s\n",
+ fprintf (stderr, "%c-> Create_Admin (%s, %s, %s, %s, %s, %d, %d)\n",
(server_active) ? 'S' : ' ',
- dir, update_dir, repository, tag ? tag : "",
- date ? date : "", wd);
- free (wd);
+ dir, update_dir, repository, tag ? tag : "",
+ date ? date : "", nonbranch, warn);
}
#endif
if (noexec)
- return;
+ return 0;
tmp = xmalloc (strlen (dir) + 100);
if (dir != NULL)
@@ -51,7 +57,21 @@ Create_Admin (dir, update_dir, repository, tag, date, nonbranch)
if (isfile (tmp))
error (1, 0, "there is a version in %s already", update_dir);
- make_directory (tmp);
+ if (CVS_MKDIR (tmp, 0777) < 0)
+ {
+ if (warn)
+ {
+ /* The reason that this is a warning, rather than silently
+ just skipping creating the directory, is that we don't want
+ CVS's behavior to vary subtly based on factors (like directory
+ permissions) which are not made clear to the user. With
+ the warning at least we let them know what is going on. */
+ error (0, errno, "warning: cannot make directory %s", tmp);
+ return 1;
+ }
+ else
+ error (1, errno, "cannot make directory %s", tmp);
+ }
/* record the current cvs root for later use */
@@ -68,8 +88,22 @@ Create_Admin (dir, update_dir, repository, tag, date, nonbranch)
else
error (1, errno, "cannot open %s/%s", update_dir, CVSADM_REP);
}
- cp = repository;
- strip_trailing_slashes (cp);
+ 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 (strcmp (reposcopy, CVSroot_directory) == 0)
+ {
+ reposcopy = xrealloc (reposcopy, strlen (reposcopy) + 3);
+ strcat (reposcopy, "/.");
+ }
+
+ cp = reposcopy;
#ifdef RELATIVE_REPOS
/*
@@ -81,8 +115,8 @@ Create_Admin (dir, update_dir, repository, tag, date, nonbranch)
char *path = xmalloc (strlen (CVSroot_directory) + 10);
(void) sprintf (path, "%s/", CVSroot_directory);
- if (strncmp (repository, path, strlen (path)) == 0)
- cp = repository + strlen (path);
+ if (strncmp (cp, path, strlen (path)) == 0)
+ cp += strlen (path);
free (path);
}
#endif
@@ -139,5 +173,7 @@ Create_Admin (dir, update_dir, repository, tag, date, nonbranch)
}
#endif
+ free (reposcopy);
free (tmp);
+ return 0;
}
OpenPOWER on IntegriCloud