int cvsstatus (int argc, char **argv) { int c; int err = 0; supress_extra_fields = compat[compat_level].hide_extended_status; if (argc == -1) usage (status_usage); optind = 0; while ((c = getopt (argc, argv, "+vlRqxX")) != -1) { switch (c) { case 'v': long_format = 1; break; case 'l': local = 1; break; case 'R': local = 0; break; case 'q': quick++; break; case 'x': supress_extra_fields = 0; break; case 'X': supress_extra_fields = 1; break; case '?': default: usage (status_usage); break; } } argc -= optind; argv += optind; if (current_parsed_root->isremote) { if (long_format) send_arg("-v"); if (local) send_arg("-l"); if (supress_extra_fields) send_arg("-X"); for(c=0; c<quick; c++) send_arg("-q"); send_arg("--"); /* For a while, we tried setting SEND_NO_CONTENTS here so this could be a fast operation. That prevents the server from updating our timestamp if the timestamp is changed but the file is unmodified. Worse, it is user-visible (shows "locally modified" instead of "up to date" if timestamp is changed but file is not). And there is no good workaround (you might not want to run "cvs update"; "cvs -n update" doesn't update CVS/Entries; "cvs diff --brief" or something perhaps could be made to work but somehow that seems nonintuitive to me even if so). Given that timestamps seem to have the potential to get munged for any number of reasons, it seems better to not rely too much on them. */ send_files (argc, argv, local, 0, 0); send_file_names (argc, argv, SEND_EXPAND_WILD); send_to_server ("status\n", 0); err = get_responses_and_close (); return err; } /* start the recursion processor */ err = start_recursion (status_fileproc, (FILESDONEPROC) NULL, (PREDIRENTPROC) NULL, status_dirproc, (DIRLEAVEPROC) NULL, NULL, argc, argv, local, W_LOCAL, 0, 1, (char *) NULL, NULL, 1, verify_read); return (err); }
int diff (int argc, char **argv) { char tmp[50]; int c, err = 0; int local = 0; int which; int option_index; is_rcs = (strcmp (command_name, "rcsfile") == 0); if (argc == -1) usage (diff_usage); have_rev1_label = have_rev2_label = 0; /* * Note that we catch all the valid arguments here, so that we can * intercept the -r arguments for doing revision diffs; and -l/-R for a * non-recursive/recursive diff. */ /* Clean out our global variables (multiroot can call us multiple times and the server can too, if the client sends several diff commands). */ if (opts == NULL) { opts_allocated = 1; opts = (char*)xmalloc (opts_allocated); } opts[0] = '\0'; diff_rev1 = NULL; diff_rev2 = NULL; diff_date1 = NULL; diff_date2 = NULL; optind = 0; while ((c = getopt_long (argc, argv, "+abcdefhilnpstuwy0123456789BHNRTC:D:F:I:L:U:V:W:k:r:", longopts, &option_index)) != -1) { switch (c) { case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'h': case 'i': case 'n': case 'p': case 's': case 't': case 'u': case 'w': case 'y': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'B': case 'H': case 'T': (void) sprintf (tmp, " -%c", (char) c); allocate_and_strcat (&opts, &opts_allocated, tmp); break; case 'L': if (have_rev1_label++) if (have_rev2_label++) { error (0, 0, "extra -L arguments ignored"); break; } allocate_and_strcat (&opts, &opts_allocated, " -L"); allocate_and_strcat (&opts, &opts_allocated, optarg); break; case 'C': case 'F': case 'I': case 'U': case 'V': case 'W': (void) sprintf (tmp, " -%c", (char) c); allocate_and_strcat (&opts, &opts_allocated, tmp); allocate_and_strcat (&opts, &opts_allocated, optarg); break; case 131: /* --ifdef. */ allocate_and_strcat (&opts, &opts_allocated, " --ifdef="); allocate_and_strcat (&opts, &opts_allocated, optarg); break; case 129: case 130: case 132: case 133: case 134: case 135: case 136: case 137: case 138: case 139: case 140: case 141: case 142: case 143: case 144: case 145: case 146: allocate_and_strcat (&opts, &opts_allocated, " --"); allocate_and_strcat (&opts, &opts_allocated, longopts[option_index].name); if (longopts[option_index].has_arg == 1 || (longopts[option_index].has_arg == 2 && optarg != NULL)) { allocate_and_strcat (&opts, &opts_allocated, "="); allocate_and_strcat (&opts, &opts_allocated, optarg); } break; case 'R': local = 0; break; case 'l': local = 1; break; case 'k': if (options) xfree (options); options = RCS_check_kflag (optarg,true,true); break; case 'r': if (diff_rev2 != NULL || diff_date2 != NULL) error (1, 0, "no more than two revisions/dates can be specified"); if (diff_rev1 != NULL || diff_date1 != NULL) diff_rev2 = optarg; else diff_rev1 = optarg; break; case 'D': if (diff_rev2 != NULL || diff_date2 != NULL) error (1, 0, "no more than two revisions/dates can be specified"); if (diff_rev1 != NULL || diff_date1 != NULL) diff_date2 = Make_Date (optarg); else diff_date1 = Make_Date (optarg); break; case 'N': empty_files = 1; break; case '?': default: usage (diff_usage); break; } } argc -= optind; argv += optind; /* make sure options is non-null */ if (!options) options = xstrdup (""); if (!is_rcs && current_parsed_root->isremote) { if (local) send_arg("-l"); if (empty_files) send_arg("-N"); send_option_string (opts); if (options[0] != '\0') option_with_arg ("-k", options); if (diff_rev1) option_with_arg ("-r", diff_rev1); if (diff_date1) client_senddate (diff_date1); if (diff_rev2) option_with_arg ("-r", diff_rev2); if (diff_date2) client_senddate (diff_date2); send_arg("--"); /* Send the current files unless diffing two revs from the archive */ if (diff_rev2 == NULL && diff_date2 == NULL) send_files (argc, argv, local, 0, 0); else send_files (argc, argv, local, 0, SEND_NO_CONTENTS); send_file_names (argc, argv, SEND_EXPAND_WILD); send_to_server ("diff\n", 0); err = get_responses_and_close (); xfree (options); options = NULL; return (err); } if(is_rcs) { int n; if(!argc) usage(diff_usage); for(n=0; n<argc; n++) { struct file_info finfo = {0}; const char *name; char *tmp = find_rcs_filename(argv[n]); if(!tmp) error(1,ENOENT,"%s",argv[n]); finfo.fullname=fullpathname(tmp, &name); finfo.file = xstrdup(name); char *ff = xstrdup(finfo.fullname); finfo.update_dir = ff; ff[(name-finfo.fullname)-1]='\0'; finfo.rcs = RCS_fopen(finfo.fullname); if(finfo.rcs) { ff = (char*)finfo.fullname; ff[strlen(finfo.fullname)-2]='\0'; ff = (char*)finfo.file; ff[strlen(finfo.file)-2]='\0'; err+=diff_fileproc(NULL,&finfo); freercsnode(&finfo.rcs); } else { error(1,ENOENT,"%s",tmp); err++; } xfree(finfo.fullname); xfree(finfo.file); xfree(finfo.update_dir); xfree(tmp); } } else { if (diff_rev1 != NULL) tag_check_valid (diff_rev1, argc, argv, local, 0, ""); if (diff_rev2 != NULL) tag_check_valid (diff_rev2, argc, argv, local, 0, ""); which = W_LOCAL; if (diff_rev1 != NULL || diff_date1 != NULL) which |= W_REPOS; /* start the recursion processor */ err = start_recursion (diff_fileproc, diff_filesdoneproc, (PREDIRENTPROC) NULL, diff_dirproc, diff_dirleaveproc, NULL, argc, argv, local, which, 0, 1, (char *) NULL, NULL, 1, verify_read, diff_rev1); } /* clean up */ xfree (options); options = NULL; if (diff_date1 != NULL) xfree (diff_date1); if (diff_date2 != NULL) xfree (diff_date2); return (err); }
int lsacl (int argc, char **argv) { int c; int err = 0; int local = 1; int directories_only = 0; is_rlsacl = !strcmp(command_name,"rlsacl"); if (argc == -1) usage (is_rlsacl?rlsacl_usage:lsacl_usage); optind = 0; while ((c = getopt(argc, argv, "+dR")) != -1) { switch (c) { case 'd': directories_only = 1; break; case 'R': local = 0; break; case '?': default: usage (lsacl_usage); break; } } argc -= optind; argv += optind; if (argc < 0) usage (is_rlsacl?rlsacl_usage:lsacl_usage); if (current_parsed_root->isremote) { if(is_rlsacl) { if (!supported_request ("rlsacl")) error (1, 0, "server does not support rlsacl"); } else { if (!supported_request ("lsacl")) error (1, 0, "server does not support lsacl"); } if(!local) send_arg("-R"); if(directories_only) send_arg("-d"); send_arg("--"); if (is_rlsacl) { int i; for (i = 0; i < argc; i++) send_arg (argv[i]); send_to_server ("rlsacl\n", 0); } else { send_file_names (argc, argv, SEND_EXPAND_WILD); send_files (argc, argv, local, 0, SEND_NO_CONTENTS); send_to_server ("lsacl\n", 0); } return get_responses_and_close (); } if(!acl_mode) error(1,0,"Access control is disabled on this repository."); if (is_rlsacl) { DBM *db; int i; db = open_module (); if(!argc) { err += do_module (db, ".", MISC, "Listing", rlsacl_proc, (char *) NULL, 0, local, 0, 0, (char *) NULL); } else { for (i = 0; i < argc; i++) { err += do_module (db, argv[i], MISC, "Listing", rlsacl_proc, (char *) NULL, 0, local, 0, 0, (char *) NULL); } } close_module (db); } else { /* start the recursion processor */ err = start_recursion (directories_only?NULL:lsacl_fileproc, (FILESDONEPROC) NULL, (PREDIRENTPROC) NULL, lsacl_dirproc, (DIRLEAVEPROC) NULL, NULL, argc, argv, local, W_LOCAL, 0, 1, (char *) NULL, NULL, 1, NULL); } return (err); }
int ls (int argc, char **argv) { int c; int err = 0; is_rls = strcmp (cvs_cmd_name, "rls") == 0; if (argc == -1) usage (ls_usage); entries_format = false; long_format = false; show_tag = NULL; show_date = NULL; tag_validated = false; recurse = false; ls_prune_dirs = false; show_dead_revs = false; getoptreset (); while ((c = getopt (argc, argv, #ifdef SERVER_SUPPORT server_active ? "qdelr:D:PR" : #endif /* SERVER_SUPPORT */ "delr:D:RP" )) != -1) { switch (c) { #ifdef SERVER_SUPPORT case 'q': if (server_active) { error (0, 0, "`%s ls -q' is deprecated. Please use the global `-q' option instead.", program_name); quiet = true; } else usage (ls_usage); break; #endif /* SERVER_SUPPORT */ case 'd': show_dead_revs = true; break; case 'e': entries_format = true; break; case 'l': long_format = true; break; case 'r': parse_tagdate (&show_tag, &show_date, optarg); break; case 'D': if (show_date) free (show_date); show_date = Make_Date (optarg); break; case 'P': ls_prune_dirs = true; break; case 'R': recurse = true; break; case '?': default: usage (ls_usage); break; } } argc -= optind; argv += optind; if (entries_format && long_format) { error (0, 0, "`-e' & `-l' are mutually exclusive."); usage (ls_usage); } wrap_setup (); #ifdef CLIENT_SUPPORT if (current_parsed_root->isremote) { /* We're the local client. Fire up the remote server. */ start_server (); ign_setup (); if (is_rls ? !(supported_request ("rlist") || supported_request ("ls")) : !supported_request ("list")) error (1, 0, "server does not support %s", cvs_cmd_name); if (quiet && !supported_request ("global-list-quiet")) send_arg ("-q"); if (entries_format) send_arg ("-e"); if (long_format) send_arg ("-l"); if (ls_prune_dirs) send_arg ("-P"); if (recurse) send_arg ("-R"); if (show_dead_revs) send_arg ("-d"); if (show_tag) option_with_arg ("-r", show_tag); if (show_date) client_senddate (show_date); send_arg ("--"); if (is_rls) { int i; for (i = 0; i < argc; i++) send_arg (argv[i]); if (supported_request ("rlist")) send_to_server ("rlist\012", 0); else /* For backwards compatibility with CVSNT... */ send_to_server ("ls\012", 0); } else { /* Setting this means, I think, that any empty directories created * by the server will be deleted by the client. Since any dirs * created at all by ls should remain empty, this should cause any * dirs created by the server for the ls command to be deleted. */ client_prune_dirs = 1; /* I explicitly decide not to send contents here. We *could* let * the user pull status information with this command, but why * don't they just use update or status? */ send_files (argc, argv, !recurse, 0, SEND_NO_CONTENTS); send_file_names (argc, argv, SEND_EXPAND_WILD); send_to_server ("list\012", 0); } err = get_responses_and_close (); return err; } #endif if (is_rls) { DBM *db; int i; db = open_module (); if (argc) { for (i = 0; i < argc; i++) { char *mod = xstrdup (argv[i]); char *p; for (p=strchr (mod,'\\'); p; p=strchr (p,'\\')) *p='/'; p = strrchr (mod,'/'); if (p && (strchr (p,'?') || strchr (p,'*'))) { *p='\0'; regexp_match = p+1; } else regexp_match = NULL; /* Frontends like to do 'ls -q /', so we support it explicitly. */ if (!strcmp (mod,"/")) { *mod='\0'; } err += do_module (db, mod, MISC, "Listing", ls_proc, NULL, 0, 0, 0, 0, NULL); free (mod); } } else { /* should be ".", but do_recursion() fails this: assert ( strstr ( repository, "/./" ) == NULL ); */ char *topmod = xstrdup (""); err += do_module (db, topmod, MISC, "Listing", ls_proc, NULL, 0, 0, 0, 0, NULL); free (topmod); } close_module (db); } else ls_proc (argc + 1, argv - 1, NULL, NULL, NULL, 0, 0, NULL, NULL); return err; }
int chacl (int argc, char **argv) { int c; int local = 1; int err = 0; int is_rchacl = !strcmp(command_name,"rchacl"); if (argc == 1 || argc == -1) usage (is_rchacl?rchacl_usage:chacl_usage); memset(&parms,0,sizeof(parms)); optind = 0; while ((c = getopt (argc, argv, "+a:dnRr:u:m:j:p:")) != -1) { switch (c) { case 'a': if(parms.del) error(1,0,"Cannot combine -a and -d"); parms.access = xstrdup(optarg); break; case 'd': if(parms.access) error(1,0,"Cannot combine -a and -d"); parms.del = 1; break; case 'j': parms.merge=xstrdup(optarg); break; case 'm': parms.message=xstrdup(optarg); break; case 'n': parms.noinherit=1; break; case 'p': parms.priority=xstrdup(optarg); break; case 'r': if(parms.branch) error(1,0,"Cannot have multiple -r options"); parms.branch = xstrdup(optarg); break; case 'R': local = 0; break; case 'u': if(parms.user) error(1,0,"Cannot have multiple -u options"); parms.user = xstrdup(optarg); break; case '?': default: usage (chacl_usage); break; } } argc -= optind; argv += optind; if (argc < 0) usage (is_rchacl?rchacl_usage:chacl_usage); if (current_parsed_root->isremote) { if(is_rchacl) { if (!supported_request ("rchacl2")) error (1, 0, "server does not support rchacl"); } else { if (!supported_request ("chacl2")) error (1, 0, "server does not support v2 chacl"); } if(parms.branch) { send_arg("-r"); send_arg(parms.branch); } if(parms.user) { send_arg("-u"); send_arg(parms.user); } if(parms.del) send_arg("-d"); if(parms.noinherit) send_arg("-n"); if(parms.access) { send_arg("-a"); send_arg(parms.access); } if(parms.message) { send_arg("-m"); send_arg(parms.message); } if(parms.merge) { send_arg("-j"); send_arg(parms.merge); } if(parms.priority) { send_arg("-p"); send_arg(parms.priority); } if(!local) { send_arg("-R"); } send_arg("--"); if (is_rchacl) { int i; for (i = 0; i < argc; i++) send_arg (argv[i]); send_to_server ("rchacl2\n", 0); } else { send_file_names (argc, argv, SEND_EXPAND_WILD); send_files (argc, argv, local, 0, SEND_NO_CONTENTS); send_to_server ("chacl2\n", 0); } return get_responses_and_close (); } if(!acl_mode) error(1,0,"Access control is disabled on this repository."); if (is_rchacl) { DBM *db; int i; db = open_module (); for (i = 0; i < argc; i++) { err += do_module (db, argv[i], MISC, "Changing", rchacl_proc, (char *) NULL, 0, local, 0, 0, (char *) NULL); } close_module (db); } else { current_date = date_from_time_t(global_session_time_t); err = start_recursion(chacl_fileproc, NULL, (PREDIRENTPROC) NULL, chacl_dirproc, chacl_dirleaveproc, (void*)NULL, argc, argv, local, W_LOCAL, 0, 0, (char*)NULL, NULL, 1, verify_control, parms.branch); xfree(current_date); } return (err); }
int cvsremove (int argc, char **argv) { int c, err; if (argc == -1) usage (remove_usage); optind = 0; while ((c = getopt (argc, argv, "+flR")) != -1) { switch (c) { case 'f': force = 1; break; case 'l': local = 1; break; case 'R': local = 0; break; case '?': default: usage (remove_usage); break; } } argc -= optind; argv += optind; if (current_parsed_root->isremote) { /* Call expand_wild so that the local removal of files will work. It's ok to do it always because we have to send the file names expanded anyway. */ expand_wild (argc, argv, &argc, &argv); if (force) { if (!noexec) { start_recursion (remove_force_fileproc, (FILESDONEPROC) NULL, (PREDIRENTPROC) NULL, (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL, (void *) NULL, argc, argv, local, W_LOCAL, 0, 0, (char *) NULL, NULL, 0, NULL, NULL); } /* else FIXME should probably act as if the file doesn't exist in doing the following checks. */ } if (local) send_arg("-l"); send_arg("--"); /* FIXME: Can't we set SEND_NO_CONTENTS here? Needs investigation. */ send_files (argc, argv, local, 0, 0); send_file_names (argc, argv, 0); free_names (&argc, argv); send_to_server ("remove\n", 0); return get_responses_and_close (); } /* start the recursion processor */ err = start_recursion (remove_fileproc, (FILESDONEPROC) NULL, (PREDIRENTPROC) NULL, remove_dirproc, (DIRLEAVEPROC) NULL, NULL, argc, argv, local, W_LOCAL, 0, 1, (char *) NULL, NULL, 1, verify_create, NULL); if (removed_files && !really_quiet) error (0, 0, "use '%s commit' to remove %s permanently", program_name, (removed_files == 1) ? "this file" : "these files"); if (existing_files) { error (0, 0, ((existing_files == 1) ? "%d file exists; remove it first" : "%d files exist; remove them first"), existing_files); err=1; } if(bad_files) err=1; return (err); }
/* Start a recursive command. Command line arguments (ARGC, ARGV) dictate the directories and files on which we operate. In the special case of no arguments, we default to ".". */ int start_recursion (FILEPROC fileproc, FILESDONEPROC filesdoneproc, PREDIRENTPROC predirentproc, DIRENTPROC direntproc, DIRLEAVEPROC dirleaveproc, void *callerdat, int argc, char **argv, int local, /* This specifies the kind of recursion. There are several cases: 1. W_LOCAL is not set but W_REPOS is. The current directory when we are called must be the repository and recursion proceeds according to what exists in the repository. 2a. W_LOCAL is set but W_REPOS is not. The current directory when we are called must be the working directory. Recursion proceeds according to what exists in the working directory, never (I think) consulting any part of the repository which does not correspond to the working directory ("correspond" == Name_Repository). 2b. W_LOCAL is set and so is W_REPOS. This is the weird one. The current directory when we are called must be the working directory. We recurse through working directories, but we recurse into a directory if it is exists in the working directory *or* it exists in the repository. If a directory does not exist in the working directory, the direntproc must either tell us to skip it (R_SKIP_ALL), or must create it (I think those are the only two cases). */ int which, int aflag, int readlock, const char *update_preload, const char *repos_preload, int dosrcs, PERMPROC permproc, const char *tag) { int i, err = 0; List *args_to_send_when_finished = NULL; List *files_by_dir = NULL; struct recursion_frame frame; TRACE(3,"start_recursion()"); frame.fileproc = fileproc; frame.filesdoneproc = filesdoneproc; frame.predirentproc = predirentproc; frame.direntproc = direntproc; frame.dirleaveproc = dirleaveproc; frame.callerdat = callerdat; frame.flags = local ? R_SKIP_DIRS : R_PROCESS; frame.which = which; frame.aflag = aflag; frame.readlock = readlock; frame.dosrcs = dosrcs; frame.permproc = permproc; frame.tag = tag; expand_wild (argc, argv, &argc, &argv); if (update_preload == NULL) update_dir = xstrdup (""); else update_dir = xstrdup (update_preload); /* clean up from any previous calls to start_recursion */ xfree (repository); if (filelist) dellist (&filelist); /* FIXME-krp: no longer correct. */ if (dirlist) dellist (&dirlist); update_repos = xstrdup(repos_preload); for (i = 0; i < argc; ++i) { #ifdef SERVER_SUPPORT if (server_active) server_pathname_check (argv[i]); else #endif if(isabsolute(argv[i])) error(1,0,"Absolute filenames not allowed"); } if (argc == 0) { int just_subdirs = (which & W_LOCAL) && !noexec && !isdir (CVSADM); if (!just_subdirs && CVSroot_cmdline == NULL && current_parsed_root->isremote) { char *root = Name_Root (NULL, update_dir); if (root && strcmp (root, current_parsed_root->original) != 0) /* We're skipping this directory because it is for a different root. Therefore, we just want to do the subdirectories only. Processing files would cause a working directory from one repository to be processed against a different repository, which could cause all kinds of spurious conflicts and such. Question: what about the case of "cvs update foo" where we process foo/bar and not foo itself? That seems to be handled somewhere (else) but why should it be a separate case? Needs investigation... */ just_subdirs = 1; xfree (root); } /* * There were no arguments, so we'll probably just recurse. The * exception to the rule is when we are called from a directory * without any CVS administration files. That has always meant to * process each of the sub-directories, so we pretend like we were * called with the list of sub-dirs of the current dir as args */ if (just_subdirs) { dirlist = Find_Directories ((char *) NULL, W_LOCAL, (List *) NULL, NULL); /* If there are no sub-directories, there is a certain logic in favor of doing nothing, but in fact probably the user is just confused about what directory they are in, or whether they cvs add'd a new directory. In the case of at least one sub-directory, at least when we recurse into them we notice (hopefully) whether they are under CVS control. */ if (list_isempty (dirlist) && !noexec) { if (update_dir[0] == '\0') error (0, 0, "in directory .:"); else error (0, 0, "in directory %s:", update_dir); error (1, 0, "there is no version here; run '%s checkout' first", program_name); } else if (current_parsed_root->isremote && server_started) { /* In the the case "cvs update foo bar baz", a call to send_file_names in update.c will have sent the appropriate "Argument" commands to the server. In this case, that won't have happened, so we need to do it here. While this example uses "update", this generalizes to other commands. */ /* This is the same call to Find_Directories as above. FIXME: perhaps it would be better to write a function that duplicates a list. */ args_to_send_when_finished = Find_Directories ((char *) NULL, W_LOCAL, (List *) NULL, NULL); } } else { addlist (&dirlist, "."); } goto do_the_work; } /* * There were arguments, so we have to handle them by hand. To do * that, we set up the filelist and dirlist with the arguments and * call do_recursion. do_recursion recognizes the fact that the * lists are non-null when it starts and doesn't update them. * * explicitly named directories are stored in dirlist. * explicitly named files are stored in filelist. * other possibility is named entities whicha are not currently in * the working directory. */ for (i = 0; i < argc; i++) { /* if this argument is a directory, then add it to the list of directories. */ if (isdir (argv[i])) { strip_trailing_slashes (argv[i]); addlist (&dirlist, argv[i]); } else { /* otherwise, split argument into directory and component names. */ char *dir; char *comp; char *file_to_try; /* Now break out argv[i] into directory part (DIR) and file part (COMP). DIR and COMP will each point to a newly malloc'd string. */ dir = xstrdup (argv[i]); comp = (char*)last_component (dir); if (comp == dir) { /* no dir component. What we have is an implied "./" */ dir = xstrdup("."); } else { char *p = comp; p[-1] = '\0'; comp = xstrdup (p); } /* if this argument exists as a file in the current working directory tree, then add it to the files list. */ if (!(which & W_LOCAL)) { /* If doing rtag, we've done a chdir to the repository. */ file_to_try = (char*)xmalloc (strlen (argv[i]) + sizeof (RCSEXT) + 5); sprintf (file_to_try, "%s%s", argv[i], RCSEXT); } else file_to_try = xstrdup (argv[i]); if (isfile (file_to_try)) { const char *tag; const char *date; int nonbranch; const char *message; const char *v_type; /* before we do anything else, see if we have any per-directory tags */ ParseTag_Dir (dir, &tag, &date, &nonbranch, NULL); if (! verify_access (frame.permproc, dir, file_to_try, update_dir,tag,&message,&v_type)) { if(tag && !quiet && !(which&W_QUIET)) error (0, 0, "User %s is unable to %s %s/%s on branch/tag %s - ignoring",CVS_Username,v_type,dir,file_to_try?file_to_try:"",tag); else if(!quiet && !(which&W_QUIET)) error (0, 0, "User %s is unable to %s %s/%s - ignoring",CVS_Username,v_type,dir,file_to_try?file_to_try:""); if(message && !quiet && !(which&W_QUIET)) error (0, 0, "%s", message); } else { addfile (&files_by_dir, dir, comp); } } else if (isdir (dir)) { if ((which & W_LOCAL) && isdir (CVSADM) && !current_parsed_root->isremote ) { /* otherwise, look for it in the repository. */ char *tmp_update_dir; char *repos; char *reposfile; tmp_update_dir = (char*)xmalloc (strlen (update_dir) + strlen (dir) + 5); strcpy (tmp_update_dir, update_dir); if (*tmp_update_dir != '\0') (void) strcat (tmp_update_dir, "/"); (void) strcat (tmp_update_dir, dir); /* look for it in the repository. */ repos = Name_Repository (dir, tmp_update_dir); reposfile = (char*)xmalloc (strlen (repos) + strlen (comp) + 5); (void) sprintf (reposfile, "%s/%s", repos, comp); xfree (repos); if (isdir (reposfile)) { addlist (&dirlist, argv[i]); } else addfile (&files_by_dir, dir, comp); xfree (tmp_update_dir); xfree (reposfile); } else addfile (&files_by_dir, dir, comp); } else { error (1, 0, "no such directory `%s'", dir); } xfree (file_to_try); xfree (dir); xfree (comp); } } /* At this point we have looped over all named arguments and built a coupla lists. Now we unroll the lists, setting up and calling do_recursion. */ err += walklist (files_by_dir, unroll_files_proc, (void *) &frame); if (files_by_dir) dellist(&files_by_dir); /* then do_recursion on the dirlist. */ if (dirlist != NULL) { do_the_work: err += do_recursion (&frame, 1); } /* Free the data which expand_wild allocated. */ free_names (&argc, argv); xfree (update_dir); xfree (update_repos); if (args_to_send_when_finished != NULL) { /* FIXME (njc): in the multiroot case, we don't want to send argument commands for those top-level directories which do not contain any subdirectories which have files checked out from current_parsed_root->original. If we do, and two repositories have a module with the same name, nasty things could happen. This is hard. Perhaps we should send the Argument commands later in this procedure, after we've had a chance to notice which directores we're using (after do_recursion has been called once). This means a _lot_ of rewriting, however. What we need to do for that to happen is descend the tree and construct a list of directories which are checked out from current_cvsroot. Now, we eliminate from the list all of those directories which are immediate subdirectories of another directory in the list. To say that the opposite way, we keep the directories which are not immediate subdirectories of any other in the list. Here's a picture: a / \ B C / \ D e / \ F G / \ H I The node in capitals are those directories which are checked out from current_cvsroot. We want the list to contain B, C, F, and G. D, H, and I are not included, because their parents are also checked out from current_cvsroot. The algorithm should be: 1) construct a tree of all directory names where each element contains a directory name and a flag which notes if that directory is checked out from current_cvsroot a0 / \ B1 C1 / \ D1 e0 / \ F1 G1 / \ H1 I1 2) Recursively descend the tree. For each node, recurse before processing the node. If the flag is zero, do nothing. If the flag is 1, check the node's parent. If the parent's flag is one, change the current entry's flag to zero. a0 / \ B1 C1 / \ D0 e0 / \ F1 G1 / \ H0 I0 3) Walk the tree and spit out "Argument" commands to tell the server which directories to munge. Yuck. It's not clear this is worth spending time on, since we might want to disable cvs commands entirely from directories that do not have CVSADM files... Anyways, the solution as it stands has modified server.c (dirswitch) to create admin files [via server.c (create_adm_p)] in all path elements for a client's "Directory xxx" command, which forces the server to descend and serve the files there. client.c (send_file_names) has also been modified to send only those arguments which are appropriate to current_parsed_root->original. */ /* Construct a fake argc/argv pair. */ int our_argc = 0, i; char **our_argv = NULL; if (! list_isempty (args_to_send_when_finished)) { Node *head, *p; head = args_to_send_when_finished->list; /* count the number of nodes */ i = 0; for (p = head->next; p != head; p = p->next) i++; our_argc = i; /* create the argument vector */ our_argv = (char **) xmalloc (sizeof (char *) * our_argc); /* populate it */ i = 0; for (p = head->next; p != head; p = p->next) our_argv[i++] = xstrdup (p->key); } /* We don't want to expand widcards, since we've just created a list of directories directly from the filesystem. */ send_file_names (our_argc, our_argv, 0); /* Free our argc/argv. */ if (our_argv != NULL) { for (i = 0; i < our_argc; i++) xfree (our_argv[i]); xfree (our_argv); } if (args_to_send_when_finished) dellist (&args_to_send_when_finished); } return (err); }