diff options
author | obrien <obrien@FreeBSD.org> | 2008-01-13 06:10:18 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2008-01-13 06:10:18 +0000 |
commit | 89cdc741853eb82b998a9f575b1d1c29e1310d0c (patch) | |
tree | aa985ec0bcd54313779564f6a7974badbf652792 /contrib | |
parent | 8981de8610656b8476315defa8a082640b08616a (diff) | |
download | FreeBSD-src-89cdc741853eb82b998a9f575b1d1c29e1310d0c.zip FreeBSD-src-89cdc741853eb82b998a9f575b1d1c29e1310d0c.tar.gz |
Merge rev 1.25 ("iso8601" option keyword), rev 1.23 (blame),
rev 1.17 (environtmental var "CVS_OPTIONS"), rev 1.14 ('-g' option to
support shared-group access), rev 1.7 ('-R' read-only repository mode),
rev 1.6 (support for checking out from a read-only repository),
revs 1.4 & 1.5 ("tagexpand=") into version 1.11.22.
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/cvs/src/main.c | 246 |
1 files changed, 110 insertions, 136 deletions
diff --git a/contrib/cvs/src/main.c b/contrib/cvs/src/main.c index 932dbd2..1365321 100644 --- a/contrib/cvs/src/main.c +++ b/contrib/cvs/src/main.c @@ -1,9 +1,14 @@ /* - * Copyright (c) 1992, Brian Berliner and Jeff Polk - * Copyright (c) 1989-1992, Brian Berliner + * Copyright (C) 1986-2006 The Free Software Foundation, Inc. * - * You may distribute under the terms of the GNU General Public License - * as specified in the README file that comes with the CVS source distribution. + * Portions Copyright (C) 1998-2006 Derek Price, Ximbiot <http://ximbiot.com>, + * and others. + * + * Portions Copyright (C) 1992, Brian Berliner and Jeff Polk + * Portions 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 source distribution. * * This is the main C driver for the CVS system. * @@ -47,6 +52,12 @@ int readonlyfs = 0; int require_real_user = 0; int logoff = 0; +/* + * Zero if compression isn't supported or requested; non-zero to indicate + * a compression level to request from gzip. + */ +int gzip_level; + /* Set if we should be writing CVSADM directories at top level. At least for now we'll make the default be off (the CVS 1.9, not CVS 1.9.2, behavior). */ @@ -67,15 +78,6 @@ char *Editor = EDITOR_DFLT; values in CVS/Root files, we maintain a list of them. */ List *root_directories = NULL; -/* We step through the above values. This variable is set to reflect - * the currently active value. - * - * Now static. FIXME - this variable should be removable (well, localizable) - * with a little more work. - */ -static char *current_root = NULL; - - static const struct cmd { char *fullname; /* Full name of the function (e.g. "commit") */ @@ -191,8 +193,7 @@ static const char *const usg[] = version control means. */ "For CVS updates and additional information, see\n", - " the CVS home page at http://www.cvshome.org/ or\n", - " Pascal Molli's CVS site at http://www.loria.fr/~molli/cvs-index.html\n", + " the CVS home page at http://cvs.nongnu.org/\n", NULL, }; @@ -278,9 +279,9 @@ set_root_directory (p, ignored) Node *p; void *ignored; { - if (current_root == NULL && p->data == NULL) + if (current_parsed_root == NULL && p->data != NULL) { - current_root = p->key; + current_parsed_root = p->data; return 1; } return 0; @@ -400,12 +401,12 @@ main (argc, argv) int argc; char **argv; { - char *CVSroot = CVSROOT_DFLT; + cvsroot_t *CVSroot_parsed = NULL; + int cvsroot_update_env = 1; char *cp, *end; const struct cmd *cm; int c, err = 0; - int tmpdir_update_env, cvs_update_env; - int free_CVSroot = 0; + int tmpdir_update_env; int free_Editor = 0; int free_Tmpdir = 0; @@ -455,7 +456,6 @@ main (argc, argv) * Query the environment variables up-front, so that * they can be overridden by command line arguments */ - cvs_update_env = 0; tmpdir_update_env = *Tmpdir; /* TMPDIR_DFLT must be set */ if ((cp = getenv (TMPDIR_ENV)) != NULL) { @@ -468,11 +468,6 @@ main (argc, argv) Editor = cp; else if ((cp = getenv (EDITOR3_ENV)) != NULL) Editor = cp; - if ((cp = getenv (CVSROOT_ENV)) != NULL) - { - CVSroot = cp; - cvs_update_env = 0; /* it's already there */ - } if (getenv (CVSREAD_ENV) != NULL) cvswrite = 0; if (getenv (CVSREADONLYFS_ENV) != NULL) { @@ -566,8 +561,12 @@ main (argc, argv) version (0, (char **) NULL); (void) fputs ("\n", stdout); (void) fputs ("\ -Copyright (c) 1989-2004 Brian Berliner, david d `zoo' zuhn, \n\ - Jeff Polk, and other authors\n", stdout); +Copyright (C) 2006 Free Software Foundation, Inc.\n\ +\n\ +Senior active maintainers include Larry Jones, Derek R. Price,\n\ +and Mark D. Baushke. Please see the AUTHORS and README files from the CVS\n\ +distribution kit for a complete list of contributors and copyrights.\n", + stdout); (void) fputs ("\n", stdout); (void) fputs ("CVS may be copied only under the terms of the GNU General Public License,\n", stdout); (void) fputs ("a copy of which can be found with the CVS distribution kit.\n", stdout); @@ -575,6 +574,12 @@ Copyright (c) 1989-2004 Brian Berliner, david d `zoo' zuhn, \n\ (void) fputs ("Specify the --help option for further information about CVS\n", stdout); +#ifdef SYSTEM_CLEANUP + /* Hook for OS-specific behavior, for example socket subsystems + * on NT and OS2 or dealing with windows and arguments on Mac. + */ + SYSTEM_CLEANUP (); +#endif exit (0); break; case 'b': @@ -585,11 +590,13 @@ Copyright (c) 1989-2004 Brian Berliner, david d `zoo' zuhn, \n\ either new or old CVS. */ break; case 'T': + if (free_Tmpdir) free (Tmpdir); Tmpdir = xstrdup (optarg); free_Tmpdir = 1; tmpdir_update_env = 1; /* need to update environment */ break; case 'e': + if (free_Editor) free (Editor); Editor = xstrdup (optarg); free_Editor = 1; break; @@ -597,11 +604,6 @@ Copyright (c) 1989-2004 Brian Berliner, david d `zoo' zuhn, \n\ if (CVSroot_cmdline != NULL) free (CVSroot_cmdline); CVSroot_cmdline = xstrdup (optarg); - if (free_CVSroot) - free (CVSroot); - CVSroot = xstrdup (optarg); - free_CVSroot = 1; - cvs_update_env = 1; /* need to update environment */ break; case 'H': help = 1; @@ -610,12 +612,10 @@ Copyright (c) 1989-2004 Brian Berliner, david d `zoo' zuhn, \n\ use_cvsrc = 0; /* unnecessary, since we've done it above */ break; case 'z': -#ifdef CLIENT_SUPPORT gzip_level = strtol (optarg, &end, 10); if (*end != '\0' || gzip_level < 0 || gzip_level > 9) error (1, 0, "gzip compression level must be between 0 and 9"); -#endif /* CLIENT_SUPPORT */ /* If no CLIENT_SUPPORT, we just silently ignore the gzip * level, so that users can have it in their .cvsrc and not * cause any trouble. @@ -744,21 +744,18 @@ Copyright (c) 1989-2004 Brian Berliner, david d `zoo' zuhn, \n\ cvs_cmd_name = "server"; } # endif /* AUTH_SERVER_SUPPORT || HAVE_GSSAPI */ +#endif /* SERVER_SUPPORT */ server_active = strcmp (cvs_cmd_name, "server") == 0; -#endif /* SERVER_SUPPORT */ - /* This is only used for writing into the history file. For remote connections, it might be nice to have hostname and/or remote path, on the other hand I'm not sure whether it is worth the trouble. */ -#ifdef SERVER_SUPPORT if (server_active) CurDir = xstrdup ("<remote>"); else -#endif { CurDir = xgetwd (); if (CurDir == NULL) @@ -766,7 +763,10 @@ Copyright (c) 1989-2004 Brian Berliner, david d `zoo' zuhn, \n\ } if (Tmpdir == NULL || Tmpdir[0] == '\0') + { + if (free_Tmpdir) free (Tmpdir); Tmpdir = "/tmp"; + } #ifdef HAVE_PUTENV if (tmpdir_update_env) @@ -820,68 +820,66 @@ Copyright (c) 1989-2004 Brian Berliner, david d `zoo' zuhn, \n\ if (use_cvsrc) read_cvsrc (&argc, &argv, cvs_cmd_name); -#ifdef SERVER_SUPPORT /* Fiddling with CVSROOT doesn't make sense if we're running - in server mode, since the client will send the repository - directory after the connection is made. */ - + * in server mode, since the client will send the repository + * directory after the connection is made. + */ if (!server_active) -#endif { - char *CVSADM_Root; - - /* See if we are able to find a 'better' value for CVSroot - in the CVSADM_ROOT directory. */ - - CVSADM_Root = NULL; - - /* "cvs import" shouldn't check CVS/Root; in general it - ignores CVS directories and CVS/Root is likely to - specify a different repository than the one we are - importing to. */ - - if (!(cm->attr & CVS_CMD_IGNORE_ADMROOT) - - /* -d overrides CVS/Root, so don't give an error if the - latter points to a nonexistent repository. */ - && CVSroot_cmdline == NULL) + /* First check if a root was set via the command line. */ + if (CVSroot_cmdline) { - CVSADM_Root = Name_Root((char *) NULL, (char *) NULL); + if (!(CVSroot_parsed = parse_cvsroot (CVSroot_cmdline))) + error (1, 0, "Bad CVSROOT: `%s'.", CVSroot_cmdline); } - if (CVSADM_Root != NULL) + /* See if we are able to find a 'better' value for CVSroot + * in the CVSADM_ROOT directory. + * + * "cvs import" shouldn't check CVS/Root; in general it + * ignores CVS directories and CVS/Root is likely to + * specify a different repository than the one we are + * importing to, but if this is not import and no root was + * specified on the command line, set the root from the + * CVS/Root file. + */ + if (!CVSroot_parsed + && !(cm->attr & CVS_CMD_IGNORE_ADMROOT) + ) + CVSroot_parsed = Name_Root (NULL, NULL); + + /* Now, if there is no root on the command line and we didn't find + * one in a file, set it via the $CVSROOT env var. + */ + if (!CVSroot_parsed) { - if (CVSroot == NULL || !cvs_update_env) + char *tmp = getenv (CVSROOT_ENV); + if (tmp) { - CVSroot = CVSADM_Root; - cvs_update_env = 1; /* need to update environment */ + if (!(CVSroot_parsed = parse_cvsroot (tmp))) + error (1, 0, "Bad CVSROOT: `%s'.", tmp); + cvsroot_update_env = 0; } } +#ifdef CVSROOT_DFLT + if (!CVSroot_parsed) + { + if (!(CVSroot_parsed = parse_cvsroot (CVSROOT_DFLT))) + error (1, 0, "Bad CVSROOT: `%s'.", CVSROOT_DFLT); + } +#endif /* CVSROOT_DFLT */ + /* Now we've reconciled CVSROOT from the command line, the CVS/Root file, and the environment variable. Do the last sanity checks on the variable. */ - - if (! CVSroot) + if (!CVSroot_parsed) { error (0, 0, "No CVSROOT specified! Please use the `-d' option"); error (1, 0, "or set the %s environment variable.", CVSROOT_ENV); } - - if (! *CVSroot) - { - error (0, 0, - "CVSROOT is set but empty! Make sure that the"); - error (0, 0, - "specification of CVSROOT is valid, either via the"); - error (0, 0, - "`-d' option, the %s environment variable, or the", - CVSROOT_ENV); - error (1, 0, - "CVS/Root file (if any)."); - } } /* Here begins the big loop over unique cvsroot values. We @@ -893,19 +891,19 @@ Copyright (c) 1989-2004 Brian Berliner, david d `zoo' zuhn, \n\ root_directories = getlist (); /* Prime it. */ - if (CVSroot != NULL) + if (CVSroot_parsed) { Node *n; n = getnode (); n->type = NT_UNKNOWN; - n->key = xstrdup (CVSroot); - n->data = NULL; + n->key = xstrdup (CVSroot_parsed->original); + n->data = CVSroot_parsed; if (addnode (root_directories, n)) error (1, 0, "cannot add initial CVSROOT %s", n->key); } - assert (current_root == NULL); + assert (current_parsed_root == NULL); /* If we're running the server, we want to execute this main loop once and only once (we won't be serving multiple roots @@ -913,70 +911,58 @@ Copyright (c) 1989-2004 Brian Berliner, david d `zoo' zuhn, \n\ once). To get out of the loop, we perform a "break" at the end of things. */ - while ( -#ifdef SERVER_SUPPORT - server_active || -#endif - walklist (root_directories, set_root_directory, NULL) - ) + while (server_active || + walklist (root_directories, set_root_directory, NULL)) { -#ifdef SERVER_SUPPORT /* Fiddling with CVSROOT doesn't make sense if we're running in server mode, since the client will send the repository directory after the connection is made. */ if (!server_active) -#endif { /* Now we're 100% sure that we have a valid CVSROOT variable. Parse it to see if we're supposed to do remote accesses or use a special access method. */ - if (current_parsed_root != NULL) - free_cvsroot_t (current_parsed_root); - if ((current_parsed_root = parse_cvsroot (current_root)) == NULL) - error (1, 0, "Bad CVSROOT: `%s'.", current_root); - if (trace) fprintf (stderr, "%s-> main loop with CVSROOT=%s\n", - CLIENT_SERVER_STR, current_root); + CLIENT_SERVER_STR, current_parsed_root->original); /* * Check to see if the repository exists. */ -#ifdef CLIENT_SUPPORT if (!current_parsed_root->isremote) -#endif /* CLIENT_SUPPORT */ { char *path; int save_errno; path = xmalloc (strlen (current_parsed_root->directory) - + sizeof (CVSROOTADM) - + 2); - (void) sprintf (path, "%s/%s", current_parsed_root->directory, CVSROOTADM); + + strlen (CVSROOTADM) + 2); + sprintf (path, "%s/%s", current_parsed_root->directory, + CVSROOTADM); if (!isaccessible (path, R_OK | X_OK)) { save_errno = errno; - /* If this is "cvs init", the root need not exist yet. */ - if (strcmp (cvs_cmd_name, "init") != 0) - { + /* If this is "cvs init", the root need not exist yet. + */ + if (strcmp (cvs_cmd_name, "init")) error (1, save_errno, "%s", path); } - } free (path); } #ifdef HAVE_PUTENV - /* Update the CVSROOT environment variable if necessary. */ - /* FIXME (njc): should we always set this with the CVSROOT from the command line? */ - if (cvs_update_env) + /* Update the CVSROOT environment variable. */ + if (cvsroot_update_env) { static char *prev; char *env; - env = xmalloc (strlen (CVSROOT_ENV) + strlen (CVSroot) - + 1 + 1); - (void) sprintf (env, "%s=%s", CVSROOT_ENV, CVSroot); + + env = xmalloc (strlen (CVSROOT_ENV) + + strlen (current_parsed_root->original) + + 2); + sprintf (env, "%s=%s", CVSROOT_ENV, + current_parsed_root->original); (void) putenv (env); /* do not free env yet, as putenv has control of it */ /* but do free the previous value, if any */ @@ -994,14 +980,7 @@ Copyright (c) 1989-2004 Brian Berliner, david d `zoo' zuhn, \n\ predetermine whether CVSROOT/config overrides things from read_cvsrc and other such places or vice versa. That sort of thing probably needs more thought. */ - if (1 -#ifdef SERVER_SUPPORT - && !server_active -#endif -#ifdef CLIENT_SUPPORT - && !current_parsed_root->isremote -#endif - ) + if (!server_active && !current_parsed_root->isremote) { /* If there was an error parsing the config file, parse_config already printed an error. We keep going. Why? Because @@ -1031,31 +1010,28 @@ Copyright (c) 1989-2004 Brian Berliner, david d `zoo' zuhn, \n\ err = (*(cm->func)) (argc, argv); /* Mark this root directory as done. When the server is - active, current_root will be NULL -- don't try and + active, our list will be empty -- don't try and remove it from the list. */ - if (current_root != NULL) + if (!server_active) { - Node *n = findnode (root_directories, current_root); + Node *n = findnode (root_directories, + current_parsed_root->original); assert (n != NULL); - n->data = (void *) 1; - current_root = NULL; + assert (n->data != NULL); + free_cvsroot_t (n->data); + n->data = NULL; + current_parsed_root = NULL; } - -#if 0 - /* This will not work yet, since it tries to free (void *) 1. */ - dellist (&root_directories); -#endif -#ifdef SERVER_SUPPORT if (server_active) { server_active = 0; break; } -#endif } /* end of loop for cvsroot values */ + dellist (&root_directories); } /* end of stuff that gets done if the user DOESN'T ask for help */ Lock_Cleanup (); @@ -1067,8 +1043,6 @@ Copyright (c) 1989-2004 Brian Berliner, david d `zoo' zuhn, \n\ free ((char *)program_path); if (CVSroot_cmdline != NULL) free (CVSroot_cmdline); - if (free_CVSroot) - free (CVSroot); if (free_Editor) free (Editor); if (free_Tmpdir) |