summaryrefslogtreecommitdiffstats
path: root/contrib/cvs/src
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1997-05-15 22:46:24 +0000
committerpeter <peter@FreeBSD.org>1997-05-15 22:46:24 +0000
commit4f40fe8334ad5f056e1d9105f23fe7ac859c39ba (patch)
tree3b2f0092fa216d9f61059ba94b7f10b5bacf9496 /contrib/cvs/src
parent8982e501c77217c860f79bba431f46a62b607a21 (diff)
downloadFreeBSD-src-4f40fe8334ad5f056e1d9105f23fe7ac859c39ba.zip
FreeBSD-src-4f40fe8334ad5f056e1d9105f23fe7ac859c39ba.tar.gz
Import of cvs-1.9.9-970515 onto vendor branch.
Obtained from: cyclic.com
Diffstat (limited to 'contrib/cvs/src')
-rw-r--r--contrib/cvs/src/ChangeLog2084
-rw-r--r--contrib/cvs/src/ChangeLog-964434
-rw-r--r--contrib/cvs/src/Makefile.in38
-rw-r--r--contrib/cvs/src/add.c324
-rw-r--r--contrib/cvs/src/admin.c30
-rw-r--r--contrib/cvs/src/buffer.c1294
-rw-r--r--contrib/cvs/src/buffer.h142
-rw-r--r--contrib/cvs/src/checkin.c91
-rw-r--r--contrib/cvs/src/checkout.c469
-rw-r--r--contrib/cvs/src/classify.c107
-rw-r--r--contrib/cvs/src/client.c3028
-rw-r--r--contrib/cvs/src/client.h78
-rw-r--r--contrib/cvs/src/commit.c1136
-rw-r--r--contrib/cvs/src/create_adm.c29
-rw-r--r--contrib/cvs/src/cvs.h476
-rwxr-xr-xcontrib/cvs/src/cvsbug.sh16
-rw-r--r--contrib/cvs/src/cvsrc.c41
-rw-r--r--contrib/cvs/src/diff.c622
-rw-r--r--contrib/cvs/src/edit.c141
-rw-r--r--contrib/cvs/src/edit.h6
-rw-r--r--contrib/cvs/src/entries.c427
-rw-r--r--contrib/cvs/src/error.c127
-rw-r--r--contrib/cvs/src/error.h22
-rw-r--r--contrib/cvs/src/expand_path.c112
-rw-r--r--contrib/cvs/src/fileattr.c95
-rw-r--r--contrib/cvs/src/fileattr.h30
-rw-r--r--contrib/cvs/src/filesubr.c316
-rw-r--r--contrib/cvs/src/find_names.c154
-rw-r--r--contrib/cvs/src/hash.c101
-rw-r--r--contrib/cvs/src/hash.h4
-rw-r--r--contrib/cvs/src/history.c186
-rw-r--r--contrib/cvs/src/ignore.c127
-rw-r--r--contrib/cvs/src/import.c294
-rw-r--r--contrib/cvs/src/lock.c497
-rw-r--r--contrib/cvs/src/log.c1368
-rw-r--r--contrib/cvs/src/login.c595
-rw-r--r--contrib/cvs/src/logmsg.c514
-rw-r--r--contrib/cvs/src/main.c999
-rw-r--r--contrib/cvs/src/mkmodules.c235
-rw-r--r--contrib/cvs/src/modules.c315
-rw-r--r--contrib/cvs/src/myndbm.c25
-rw-r--r--contrib/cvs/src/myndbm.h2
-rw-r--r--contrib/cvs/src/no_diff.c120
-rw-r--r--contrib/cvs/src/options.h.in227
-rw-r--r--contrib/cvs/src/parseinfo.c34
-rw-r--r--contrib/cvs/src/patch.c211
-rw-r--r--contrib/cvs/src/rcs.c2798
-rw-r--r--contrib/cvs/src/rcs.h38
-rw-r--r--contrib/cvs/src/rcscmds.c170
-rw-r--r--contrib/cvs/src/recurse.c431
-rw-r--r--contrib/cvs/src/release.c333
-rw-r--r--contrib/cvs/src/remove.c84
-rw-r--r--contrib/cvs/src/repos.c117
-rw-r--r--contrib/cvs/src/root.c356
-rw-r--r--contrib/cvs/src/rtag.c127
-rw-r--r--contrib/cvs/src/run.c76
-rwxr-xr-xcontrib/cvs/src/sanity.sh4924
-rw-r--r--contrib/cvs/src/server.c4288
-rw-r--r--contrib/cvs/src/server.h50
-rw-r--r--contrib/cvs/src/status.c163
-rw-r--r--contrib/cvs/src/subr.c168
-rw-r--r--contrib/cvs/src/tag.c241
-rw-r--r--contrib/cvs/src/update.c1443
-rw-r--r--contrib/cvs/src/update.h7
-rw-r--r--contrib/cvs/src/vers_ts.c163
-rw-r--r--contrib/cvs/src/version.c2
-rw-r--r--contrib/cvs/src/watch.c62
-rw-r--r--contrib/cvs/src/watch.h6
-rw-r--r--contrib/cvs/src/wrapper.c214
-rw-r--r--contrib/cvs/src/zlib.c429
70 files changed, 28568 insertions, 9845 deletions
diff --git a/contrib/cvs/src/ChangeLog b/contrib/cvs/src/ChangeLog
index 99161b0..e1d4dc0 100644
--- a/contrib/cvs/src/ChangeLog
+++ b/contrib/cvs/src/ChangeLog
@@ -1,1373 +1,1217 @@
-Sun May 5 21:39:02 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+Thu May 15 11:50:15 1997 Norbert Kiesel <nk@cosa.de>
- * vers_ts.c (Version_TS): If sdtp is NULL, go ahead and check
- RCS_getexpand for options. Fixes binaries and non-unix clients.
- * sanity.sh: Fix binfiles-5.5 to test for the correct behavior
- rather than the buggy behavior which existed when the binfiles-5.5
- test was written.
- (binfiles-14c,binfiles-14f): Likewise.
+ * diff.c (diff_fileproc): cosmetic change (whitespace added).
-Sun May 5 17:38:21 1996 Benjamin J. Lee <benjamin@cyclic.com>
+ * checkout.c (checkout): move local variable definition into the
+ block where the variable is used.
- Integrated changes submitted by Ian Taylor <ian@cygnus.com>
+ * client.c (update_entries): initialize some local variables to shut up
+ gcc -O -Wall.
- * update.c (update_dirent_proc): cvs co -p doesn't print
- anything when run from an empty directory.
+ * buffer.c (buf_read_line): initialize a local variable to shut up
+ gcc -O -Wall.
+
- * import.c (import_descend_dir): Check for a file in the
- repository which will be checked out to the same name as the
- directory.
+Wed May 14 16:29:50 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
-Thu May 2 13:34:37 1996 Benjamin J. Lee <benjamin@cyclic.com>
+ * admin.c (admin): When sending options to server, don't try to
+ send av[ac]. It may contain one of the names that we'll send in
+ send_file_names (which caused tests like keyword-6 to work,
+ sort of accidentally), or it may contain NULL (which would tend to
+ cause a coredump).
+ * sanity.sh (basicb): New test basicb-21 tests for above fix.
- * Version 1.7.88
+Mon May 12 16:22:00 1997 Larry Jones <larry.jones@sdrc.com>
-Thu May 2 01:40:55 1996 Benjamin J. Lee <benjamin@cyclic.com>
+ * add.c (add): Free message and repository in client code.
+ * checkout.c (checkout): Don't free repository unless allocated.
+ * client.c (start_rsh_server): Free command.
- * server.c (HAVE_INITGROUPS): Use initgroups() only if
- located by configure, in the event a system has crypt(), but
- no initgroups()
+Sun May 11 11:43:54 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
-Wed May 1 18:05:02 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+ * client.c: Remove all references to USE_DIRECT_TCP; see
+ ../ChangeLog for rationale.
- * sanity.sh (basica): When testing rejection of reserved tag name,
- use BASE instead of RESERVED.
+Fri May 9 22:19:36 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
-Wed May 1 15:15:11 1996 Tom Jarmolowski <tjj@booklink.com>
+ * main.c (main): Add comment explaining why we call exit. Pass 0
+ not EXIT_SUCCESS, because lib/system.h has portability cruft for
+ EXIT_FAILURE but not EXIT_SUCCESS.
- * rcs.c (linevector_delete): Only copy up to vec->nlines - nlines,
- not to vec->nlines.
+Fri May 9 17:25:00 1997 Larry Jones <larry.jones@sdrc.com>
-Wed May 1 15:43:21 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+ Fix miscellaneous memory allocation problems:
+ * add.c (add): Free repository.
+ * client.c (notified_a_file): Free getline buffer.
+ * edit.c (notify_check): Free getline buffer.
+ * hash.c (dellist): Free header node when not caching.
+ * login.c (login): Don't continually free & allocate getline
+ buffer, use xstrdup instead of xmalloc/strcpy, free getline
+ buffer before returning.
+ * main.c (main): Call exit instead of returning so tools like
+ Purify won't consider permanently allocated memory as leaks.
+ * mkmodules.c (mkmodules): Free getline buffer.
+ * modules.c (cat_module): Call close_module.
+ * rcs.c (rcsvers_delproc): Free state.
+ * recurse.c (start_recursion): Free files_by_dir.
+ (unroll_files_proc): NULL out p->data after using it to set
+ filelist to avoid multiple frees.
+ * server.c (check_command_legal_p): Don't continually free &
+ allocate getline buffer, free getline buffer before returning.
+ (check_repository_password): Ditto, use xstrdup instead of
+ xmalloc/strcpy.
+ * wrapper.c (wrap_add_file): Free getline buffer.
- * rcscmds.c (RCS_settag): Instead of reserving all tag names
- containing only uppercase letters, reserve only BASE and HEAD.
- * sanity.sh (mflag): Revert 26 Mar change; use all-uppercase tag
- name again.
+Thu May 8 14:21:00 1997 Larry Jones <larry.jones@sdrc.com>
+ and Jim Kingdon <kingdon@harvey.cyclic.com>
-Wed May 1 15:15:11 1996 Tom Jarmolowski <tjj@booklink.com>
+ * checkout.c (checkout_proc): Free finfo.rcs (memory leak).
- * rcs.c (linevector_add): Move increment of i out of larger
- statement, to avoid assumptions about evaluation order.
+8 May 1997 Larry Jones <larry.jones@sdrc.com>
+ and Jim Kingdon <kingdon@harvey.cyclic.com>
-Tue Apr 30 15:46:03 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+ * hash.c: Add #ifdef's to disable caching. This makes it easier
+ to track down memory allocation problems.
- * Version 1.7.87.
+Thu May 8 11:40:39 1997 Larry Jones <larry.jones@sdrc.com>
- * server.c (check_password): Don't use ANSI string concatenation.
- Reindent function.
+ * sanity.sh: In setting "tests" use a number of statements rather
+ than one very long line.
-Wed Apr 24 17:27:53 1996 Norbert Kiesel <nk@col.sw-ley.de>
+Thu May 8 11:40:39 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
- * vers_ts.c (Version_TS): xmalloc enough space (1 more
- byte). Thanks to purify!
+ * cvsbug.sh: Remove $Id; we decided to get rid of these some time
+ ago.
-Fri Apr 19 11:22:35 1996 Benjamin J. Lee <benjamin@cyclic.com>
+Thu May 8 11:34:02 1997 Larry Jones <larry.jones@sdrc.com>
- * Version 1.7.86
+ * cvsbug.sh: Put separate statements on separate lines, so it
+ works if awk is AT&T nawk.
-Thu Apr 18 1996 Jim Kingdon <kingdon@cyclic.com>
+Tue May 6 16:56:00 1997 Larry Jones <larry.jones@sdrc.com>
+ and Jim Kingdon <kingdon@harvey.cyclic.com>
- * client.c (try_read_from_server): Compare return value from fwrite
- with a size_t not an int (Visual C++ lint).
+ * cvsrc.c (read_cvsrc): Fix various memory allocation problems:
+ rearrange code to avoid leaks, use xrealloc instead of xmalloc/
+ copy/free, make sure there's room for the remaining args before
+ appending them.
-Wed Apr 17 11:56:32 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+Tue May 6 14:20:00 1997 Larry Jones <larry.jones@sdrc.com>
- * client.c (try_read_from_server): New function.
- (read_from_server): Use it.
- (read_counted_file): New function.
- * client.c, server.c: Add Template response.
- * cvs.h (CVSADM_TEMPLATE): Added.
- * logmsg.c (do_editor): If repository is NULL, use CVSADM_TEMPLATE
- file in place of rcsinfo.
- * server.c, server.h (server_template): New function.
- * create_adm.c (Create_Admin): Call it.
+ * edit.c (watch_onoff, edit, unedit, editors): Add -R like
+ other things with -l.
+ * watch.c (watch_addremove, watchers): Ditto.
-Tue Apr 16 13:56:06 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+Mon May 5 18:10:37 1997 larry.jones@sdrc.com
+ and Jim Kingdon <kingdon@harvey.cyclic.com>
- * repos.c (Name_Repository): Fix comments.
- * create_adm.c (Create_Admin): Fix indentation.
+ * sanity.sh: Change all /tmp/cvs-sanity to TESTDIR. If TESTDIR
+ environment variable is set, use it instead of /tmp/cvs-sanity.
+ * sanity.sh: Make TMPPWD the pwd equivalent of TESTDIR, not of /tmp.
-Wed Apr 10 16:46:54 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+4 May 1997 Larry jones <larry.jones@sdrc.com>
+ and Jim Kingdon
- * options.h.in: Include relevant information here rather than
- citing (former) FAQ.
+ * checkout.c, diff.c, patch.c, rcs.c: Update usage messages.
+ * rcs.c (annotate): Add -R like other things with -l.
- * ChangeLog-9395: Fix typo in introductory paragraph.
+Sat May 3 14:57:40 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
-Wed Apr 10 14:55:10 1996 code by Mike Spengler mks@msc.edu
- comments by Jim Kingdon <kingdon@harvey.cyclic.com>
+ * sanity.sh (basic1): Rewrite test (use dotest, unroll the loops
+ which IMHO makes the test a zillion times more understandable, and
+ only do the variant which tests for 4 files at a time--we test one
+ file at a time lots of places).
- * filesubr.c (unlink_file_dir,deep_remove_dir): Don't call unlink
- on something which might be a directory; check using isdir instead.
+2 May 1997 Ziv Gigus <ziv@rest.home.net>
+ and Jim Kingdon
-Wed Apr 10 14:55:10 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+ * client.c, client.h (client_process_import_file): New argument
+ all_files_binary means treat all files as binary.
+ * import.c (import_descend): Pass it if -kb is specified.
+ * client.c (client_process_import_file): In the
+ non-all_files_binary case, call wrap_rcsoption to determine
+ whether the file is binary.
- * checkout.c (build_dirs_and_chdir): Pass path, not cp, to
- Create_Admin. The former is the correct update dir.
- * sanity.sh (modules): New tests modules-155* test, for above fix.
+Thu May 1 13:44:51 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
-Mon Apr 8 13:53:27 1996 Samuel Tardieu <sam@inf.enst.fr>
+ * sanity.sh (binfiles2): New tests, for update -j and binary files.
- * rcs.c (annotate_fileproc): If the file is not under CVS control,
- return instead of dumping a core. Don't bug on files with an empty
- first revision.
+Wed Apr 30 11:18:36 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
-Fri Mar 29 16:08:28 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+ * recurse.c (start_recursion): Also free reposfile.
+ Don't look in repository if client_active (latter bug reported by Paul
+ Sanders <p.sanders@dial.pipex.com>).
- * rcs.c (annotate_fileproc): If last line of add-chunk is not
- newline terminated, end the loop when we find that out.
+Mon Apr 28 22:36:39 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
-Fri Mar 29 16:59:34 1996 Norbert Kiesel <nk@col.sw-ley.de>
+ * diff.c (diff_file_nodiff): Remove SERVER_SUPPORT ifdefs. They
+ were not based on server_active, which doesn't really make any
+ sense (it meant that compiling --disable-server could affect the
+ behavior of the non-client/server CVS). This affected the output
+ in tests death2-diff-11 and death2-diff-12 in the testsuite.
+ * sanity.sh (newb-123j0): Also accept "Needs Checkout", for a
+ --disable-server CVS.
- * rcs.c (annotate_fileproc): allow last line of add-chunk not to
- be newline terminated
+ * main.c (cmd_usage): Change "run diffs" to "show differences";
+ the former is jargon.
+ * edit.c (edit_usage): Fix typo ("." -> ",").
+ * edit.c (editors_usage), watch.c (watchers_usage): Mention -l.
+ * checkout.c (export_usage): Say what -P does.
+ * history.c (history_usg): Add comment about message wording.
-Thu Mar 28 10:56:36 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+Mon Apr 28 14:47:45 1997 Norbert Kiesel <nk@cosa.de>
- Add more diff tests:
- * sanity.sh (basic2): Use dotest for test 61.
- (basica): Add test basica-6.2.
- (branches): Add tests branches-14.4 and branches-14.5.
- (basic1): Remove tests 19, 20, 25, and 26. The only thing this
- might miss out on is diff's interaction with added and removed
- files, but those tests didn't test that very well anyway.
+ * checkin.c (Checkin): use filename without path when calling
+ wrapper (bug found by Michal Schmitz <ms@cosa.de>).
- * rcs.c (RCS_getrevtime): Add comment regarding years after 1999.
+Fri Apr 25 13:28:55 1997 Ian Lance Taylor <ian@cygnus.com>
- * rcs.c: Add "cvs annotate" command and related code.
- (getrcskey): Move special handling of RCSDESC from here to
- callers. Handle those keys (desc, log, text) which do not
- end in a semicolon.
- * rcs.h (RCSVers): Add author field.
- * rcs.c (RCS_reparsercsfile): Set it.
- * cvs.h (annotate), main.c (cmd_usage, cmds), client.h client.c
- (client_annotate), server.c (serve_annotate, requests): Usual
- machinery to add a new command.
- * sanity.sh (basica): Test cvs annotate.
+ * client.c (update_entries): In UPDATE_ENTRIES_RCS_DIFF case,
+ write to a temporary file and then rename it.
- * sanity.sh (branches): More tests, of things like adding files on
- the trunk after a branch has been made.
+Thu Apr 24 11:35:40 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
-Tue Mar 26 09:48:49 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+ * subr.c, cvs.h (pathname_levels): New function, from a piece of
+ send_file_names.
+ * client.c (send_file_names): Call pathname_levels in place of the
+ code which was moved there.
+ * server.c, server.h (server_pathname_check): New function.
+ * recurse.c (start_recursion): Call it.
+ * sanity.sh (modules3): New test modules3-11b tests for above fix.
- * expand_path.c: Don't declare free and xmalloc; cvs.h already
- takes care of that.
+ * filesubr.c: Do not define L_tmpnam. It is in ANSI and SunOS4,
+ so I don't think there will be a problem with it being missing.
+ Defining it too small can cause memory corruption.
+ (cvs_temp_name): Do not use L_tmpnam in the mktemp code; this
+ could cause a buffer overflow if the -T global option was in use.
- * sanity.sh (mflag): Don't use tag name reserved to CVS.
+Thu Apr 24 13:21:15 1997 Norbert Kiesel <nk@cosa.de>
- NT local changes plus miscellaneous things noticed in the process:
- * import.c (add_rcs_file): Use binary mode to write RCS file. Use
- \012 where linefeed is intended. Copy data a small block at a
- time, until we hit EOF, rather than trying to read the whole file
- into memory at once.
- * client.c (send_modified): Add comments regarding st_size.
- * commit.c (commit): Add comments regarding binary mode and read().
- * logmsg.c (do_editor): Add comments regarding st_size.
- * server.c (server_updated): Use binary mode to read file we are
- sending.
+ * filesubr.c (cvs_temp_name): Use tempnam if available, else
+ mktemp, else tmpnam. See the comment for rationale.
- * rcscmds.c (RCS_settag): Complain if user tries to add a tag name
- reserved to CVS.
- * sanity.sh (basica): Test for this behavior.
+ * sanity.sh: use "tar cf - ." instead of "tar cf - *" for
+ directory copies.
- * sanity.sh (binfiles): New tests test ability to change keyword
- expansion.
+Wed Apr 23 23:41:47 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
-Mon Mar 25 1996 Jim Kingdon <kingdon@cyclic.com>
+ * server.c (serve_update_prog): If in readonly mode, give an error.
- * cvs.h, filesubr.c (expand_wild): New function.
- * recurse.c (start_recursion): Call expand_wild at beginning and
- free its results at the end.
- * cvs.h, subr.c (xrealloc): Make argument and return value void *.
- * client.h, client.c (send_file_names): Add flags argument. If
- SEND_EXPAND_WILD flag is passed, call expand_wild at beginning and
- free its results at the end.
- * admin.c, add.c, log.c, tag.c, status.c, edit.c, watch.c,
- update.c, commit.c, remove.c, client.c, diff.c: Update callers.
-
-Fri Mar 22 10:09:55 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
-
- * error.c (error, fperror): Exit with status EXIT_FAILURE rather
- than STATUS. We had been neglecting to check for 256, and the
- value of providing a count of errors is probably minimal anyway.
- * add.c, modules.c, mkmodules.c, tag.c, server.c, main.c,
- import.c, client.c, scramble.c, recurse.c: Exit with status
- EXIT_FAILURE rather than 1. On VMS, 1 is success, not failure.
- * main.c (main): Return EXIT_FAILURE or 0. The value of providing
- a count of errors is minimal.
-
- * client.c (init_sockaddr): Exit with status 1 rather than
- EXIT_FAILURE. The latter apparently doesn't exist on SunOS4.
- Reindent function.
-
-Mon Mar 18 14:28:00 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
-
- * cvs.h, ignore.c: New variable ign_case.
- * ignore.c (ign_name): If it is set, match in a case-insensitive
- fashion.
- * server.c (serve_case): New function.
- (requests): Add Case request.
- * client.c (start_server): If FILENAMES_CASE_INSENSITIVE is
- defined, send Case request.
-
-Sat Mar 16 08:20:01 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
-
- For reference, this change takes cvs's text segment from 315392
- bytes to 311296 bytes (one 4096 byte page).
- * cvs.h (struct file_info): Add fullname field.
- * recurse.c (do_file_proc): Set it.
- * commit.c (find_fileproc), client.c (send_fileproc), commit.c
- (check_fileproc), diff.c (diff_fileproc), edit.c
- (unedit_fileproc), patch.c (patch_fileproc), remove.c
- (remove_fileproc), rtag.c (rtag_fileproc), tag.c (tag_fileproc),
- update.c (update_fileproc), watch.c (watchers_fileproc): Use it
- instead of computing it each time.
- * diff.c (diff_fileproc), remove.c (remove_fileproc): Use fullname
- where we had been (bogusly) omitting the directory from user
- messages.
- * edit.c (unedit_fileproc, edit_fileproc): If we cannot close
- CVSADM_NOTIFY, mention CVSADM_NOTIFY rather than finfo->file in
- error message.
- * rtag.c (rtag_fileproc), tag.c (tag_fileproc): Reindent.
-
-Fri Mar 15 15:12:11 1996 Norbert Kiesel <nk@col.sw-ley.de>
-
- * server.h: fix prototype of server_pause_check (was
- server_check_pause)
-
-Thu Mar 14 1996 Jim Kingdon <kingdon@cyclic.com>
-
- * vers_ts.c (Version_TS), entries.c (Scratch_Entry, AddEntryNode):
- Change findnode to findnode_fn.
-
- * main.c: Depending on HAVE_WINSOCK_H, include winsock.h or
- declare gethostname.
- * cvs.h: Don't declare it here.
+Wed Apr 23 19:07:41 1997 Norbert Kiesel <nk@cosa.de>
-Thu Mar 14 07:06:59 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+ * subr.c (line2argv): Allocate at least 4 slots for argv.
- * commit.c (find_fileproc): If vn_user is NULL and ts_user is not,
- print an error rather than silently succeeding.
- * sanity.sh (basica-notadded): New test, for above fix.
- (dotest_internal): New function.
- (dotest,dotest_fail): Call it instead of duplicating code between
- these two functions.
-
- * sanity.sh: Skip tests binfiles-9 through binfiles-13 for remote.
-
- * options.h.in: Adjust comment to reflect kfogel change.
-
-Thu Mar 14 01:38:30 1996 Karl Fogel <kfogel@floss.red-bean.com>
-
- * options.h.in (AUTH_CLIENT_SUPPORT): turn on by default.
+ * checkout.c (checkout_proc): Add a comment which says why the
+ above change was necessary to avoid writing to unallocated memory.
-Wed Mar 13 09:25:56 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+Wed Apr 23 11:20:40 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
- * vers_ts.c (Version_TS): Don't try to override options from rcs
- file if there isn't an rcs file (e.g. called from send_fileproc).
- This fixes a bug detected by test 59 in "make remotecheck".
+ * entries.c (ParseTag): Always set *NONBRANCHP.
- * rcs.c (RCS_reparsercsfile, RCS_getexpand): Assert that argument
- is not NULL.
+21 Apr 1997 Jim Kingdon
- Fix a gcc -Wall warning:
- * rcs.c, rcs.h (RCS_getexpand): New function.
- * vers_ts.c (Version_TS): Call it.
- * rcs.c (RCS_reparsercsfile): Make static.
+ * client.c (update_entries), rcs.c (expand_keywords): Rewrite
+ test to avoid signed/unsigned warning.
- Add a "cvs init" command. This is needed because cvsinit.sh
- invoked mkmodules which doesn't exist any more.
- * mkmodules.c: Break filelist out of mkmodules function, rename
- struct _checkout_file to struct admin_file (for namespace
- correctness), and add contents field.
- (init,mkdir_if_needed): New functions.
- * cvs.h (init): Declare.
- * main.c (cmds): Add init.
- (main): If command is init, don't require cvsroot to exist.
- * client.c, client.h (client_init, send_init_command): New functions.
- * client.c (start_server): Don't send Root request if command is init.
- * server.c (serve_init): New function.
- (requests): Add "init".
+Mon Apr 21 09:02:22 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
-Wed Mar 13 09:51:03 MET 1996 Norbert Kiesel <nk@col.sw-ley.de>
+ * update.c (patch_file): Add comment about whether auto-detecting
+ features of the DIFF program is a good idea.
- * vers_ts.c (Version_TS): set options to default option if the
- file if no -k option but -A was given. This avoids the (wrong)
- update message for binary files which are up-to-date when
- running 'cvs -A'.
+Mon Apr 21 00:03:34 1997 Ian Lance Taylor <ian@cygnus.com>
- * update.c (checkout_file): remove test of -k option stored in the
- file itself because it was moved to vers_ts.c
+ Don't require the patch program:
+ * client.c (struct update_entries_data): Add
+ UPDATE_ENTRIES_RCS_DIFF to contents enum.
+ (update_entries): Handle UPDATE_ENTRIES_RCS_DIFF.
+ (handle_rcs_diff): New static function.
+ (responses): Add "Rcs-diff".
+ * server.c (server_updated): Handle SERVER_RCS_DIFF.
+ (server_use_rcs_diff): New function.
+ * server.h (enum server_updated_arg4): Add SERVER_RCS_DIFF.
+ (server_use_rcs_diff): Declare.
+ * update.c (rcs_diff_patches): New static variable.
+ (update): Set rcs_diff_patches.
+ (update_fileproc): If rcs_diff_patches, pass SERVER_RCS_DIFF
+ rather than SERVER_PATCHED to server_updated.
+ (patch_file): Correct initial comment to say diff rather than
+ rcsdiff. If rcs_diff_options, pass -n to diff rather than -c.
+ * rcs.c (rcs_change_text): New function.
+ * rcs.h (rcs_change_text): Declare.
- * sanity.sh: added tests for the above fix.
+Mon Apr 21 00:08:59 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
-Tue Mar 12 13:47:09 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+ * diff.c (diff_fileproc): Add comment concerning updating the
+ client timestamp.
- * hash.c (findnode): Adjust comment regarding errors.
+Sun Apr 20 23:20:37 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
- * hash.c (findnode, findnode_fn): Assert that key != NULL. This
- way the check still happens even if the function is later
- rewritten to not start out by calling hashp.
+ * commit.c (commit): Add comment regarding SEND_FORCE rationale.
-Mon Mar 11 10:21:05 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+Sat Apr 19 17:10:36 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
- * sanity.sh: If expr accepts multi-line patterns but is too
- liberal in matching them, print a warning but keep going.
+ * server.c (dirswitch): If directory ends in '/', complain.
- * sanity.sh: Add QUESTION variable, analogous to PLUS. Use it
- instead of \? to match a question mark.
+Fri Apr 18 18:09:57 1997 Ian Lance Taylor <ian@cygnus.com>
- * cvs.h (CVSMODULE_OPTS, CVSMODULE_SPEC): Move from here...
- * modules.c: ...to here. They are only used here and the code to
- handle the syntax of modules files should not be scattered all over.
- * modules.c (CVSMODULE_OPTS): Add "+" as first character.
- * sanity.sh (modules): New tests 148a0 and 148a1 test for
- above-fixed bug.
+ * rcs.c (apply_rcs_changes): New static function, broken out of
+ RCS_deltas.
+ (RCS_deltas): Call it.
+ (linevector_add): Change return type to int. Return an indication
+ of an error for an invalid add, rather than calling error.
-Mon Mar 11 13:11:04 1996 Samuel Tardieu <sam@inf.enst.fr>
+Fri Apr 18 11:24:26 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
- * modules.c (cat_module): set optind to 0 to force getopt() to
- reinitialize its internal nextchar
+ * version.c: Change version number to 1.9.9.
-Mon Mar 11 00:09:14 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+ * version.c: Version 1.9.8.
- * hash.c (findnode, findnode_fn): Revert changes of 7-8 Mar 1996.
- The correct style is to assert() that key != NULL (see HACKING),
- which is already done in the hashp function.
- * fileattr.c (fileattr_delproc): Likewise, assert() that
- node->data != NULL rather than trying to deal with it being NULL.
+ * commit.c (struct find_data): Add field force.
+ (find_fileproc, commit): Use it instead of force_ci to decide
+ whether to send files to server.
+ (commit): Set it if either -f or -r is specified.
+ * sanity.sh (basica): Add tests basica-8a0, basica-8a1, and
+ basica-8a2; tests for above fix.
-Fri Mar 8 01:31:04 1996 Greg A. Woods <woods@most.weird.com>
+Wed Apr 16 11:50:59 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
- * hash.c (findnode_fn): one more place to avoid calling hashp()
- with a NULL key
+ * zlib.c: Remove paragraph with Free Software Foundation address.
+ See 2 Jan 1997 entry in ../ChangeLog for rationale.
-Thu Mar 7 17:30:01 1996 Greg A. Woods <woods@most.weird.com>
+Tue Apr 15 00:36:23 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * update.c (patch_file_write): Always assign to final_nl, so that
+ it ends up reflecting whether the data from the last call had a
+ newline, not whether the data from any of the calls ended in a
+ newline. Doesn't matter with the current RCS_checkout
+ implementation, but it will if RCS_checkout is changed to pass
+ less than the entire file.
- * hash.c (findnode): also return NULL if key is not set
- [[ reported by Chris_Eich@optilink.optilink.dsccc.com, and
- supposedly in a PR that should be marked "fixed"..... ]]
+ * rcs.c (RCS_cmp_file): Change NULL to RUN_TTY in passing sout to
+ RCS_checkout, for clarity.
- * fileattr.c (fileattr_set): set node->data to NULL after freeing
- it to prevent subsequent accesses
- (fileattr_delproc): don't free node->data if it's NULL, and set it
- to NULL after freeing
- [[ reported by Chris_Eich@optilink.optilink.dsccc.com, and
- supposedly in a PR that should be marked "fixed"..... ]]
+ * import.c (update_rcs_file): Remove unused variable ierrno.
-Fri Mar 1 14:56:08 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+ * add.c, checkout.c, commit.c, diff.c, edit.c, import.c,
+ history.c, log.c, main.c, patch.c, release.c, remove.c, rtag.c,
+ status.c, tag.c, update.c, watch.c: Pass "+" to all calls to
+ getopt. This ensures that we maintain existing behavior even with
+ glibc2.
- * sanity.sh (basica): New test basica-4a tests for bug fixed by
- sam@inf.enst.fr on 1 Mar 96.
+ * filesubr.c (fopen_case): Don't set *PATHP if we return an
+ error. Since the 9 Apr 1997 change, the behavior has been to
+ sometimes set it and sometimes not.
+ * rcs.c (RCS_parse): Adjust callers to not free it. Without this
+ change, they could call free() on an uninitialized variable.
+
+ * checkout.c (checkout): Add comment about export -k.
+
+ * root.c (check_root_consistent): Add comment about wording of
+ message.
+
+Mon Apr 14 11:51:49 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * client.c (call_in_directory): If rdirp reaches the end of
+ reposdirname, then just set it to NULL. If server does not create
+ directories one at a time, give a warning.
+ * sanity.sh (modules3): Enable tests modules3-8 through
+ modules3-11 for remote; tests for above fix.
+
+ * client.c (call_in_directory): Don't set short_pathname to
+ pathname for a while; just use pathname itself (cleans up a relic
+ of the old "Repository" (not "Directory") code). Add comment
+ explaining short_pathname.
+
+Sun Apr 13 18:07:50 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * rcs.c (RCS_checkout): Add pfn and callerdat parameters. Change
+ all callers. Move setting of expand after retrieval of file
+ data.
+ (struct cmp_file_data): Define.
+ (RCS_cmp_file): New function.
+ (cmp_file_buffer): New static function.
+ * rcs.h (RCSCHECKOUTPROC): Define type.
+ (RCS_checkout): Update declaration.
+ (RCS_cmp_file): Define.
+ * diff.c (diff_file_nodiff): Call RCS_cmp_file rather than
+ RCS_checkout and xcmp.
+ * import.c (update_rcs_file): Likewise.
+ * no_diff.c (No_Difference): Likewise.
+ * update.c (struct patch_file_data): Define.
+ (patch_file): Just return if noexec, or if binary file. Pass
+ patch_file_write to RCS_checkout. Don't check for newlines or
+ compute checksums here. Stat RCS file to set modes.
+ (patch_file_write): New static function.
-Fri Mar 1 18:10:49 1996 Samuel Tardieu <sam@inf.enst.fr>
+ * update.c (patch_file): Checkout directly to file2, rather than
+ to finfo->file followed by rename. Remove check for whether
+ result of checkout is readable; that was for an old, obsolete,
+ form of death support.
- * tag.c (check_fileproc): Check for file existence before trying
- to tag it.
+Sun Apr 13 13:16:40 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
-Fri Mar 1 07:51:29 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+ * checkout.c (build_one_dir): New function.
+ (struct dir_to_build): New structure.
+ (build_dirs_and_chir): Rewritten to accept a linked list of struct
+ dir_to_build rather than the silly string processing we had been
+ doing before.
+ (checkout_proc): Rewrite code that calls build_dirs_and_chdir
+ accordingly.
+ * sanity.sh: Enable tests modules3-10 and modules3-11 for local CVS;
+ tests for above fix.
- * client.c (update_entries): If command is export, set options to
- NULL.
+ * rcs.h (RCS_CO): Removed; no longer used.
-Thu Feb 29 16:54:14 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+Sun Apr 13 00:04:34 1997 Ian Lance Taylor <ian@cygnus.com>
- * lock.c (write_lock, Reader_Lock): Remove
- BOGUS_UNLESS_PROVEN_OTHERWISE code. It was pretty bogus, and has
- been ifdeffed out for a long time.
- * cvs.h (CVSTFL): Removed; no longer used.
+ Expand RCS keywords internally; never call co:
+ * rcs.h (struct rcsversnode): Add state field.
+ * rcs.c (kflags): Move out of RCS_check_kflag, and make file
+ static.
+ (enum kflag): Define.
+ (RCS_reparsercsfile): Always save lock information. Save state in
+ new state field, rather than other field.
+ (struct rcs_keyword): Define.
+ (keywords): New static variable.
+ (enum keyword): Define.
+ (printable_date, escape_keyword_value): New static functions.
+ (expand_keywords): New static function.
+ (RCS_checkout): Call expand_keywords. Don't call
+ RCS_exec_checkout.
+ (RCS_deltas): Add log and loglen parameters. Change all callers.
+ * log.c (log_version_requested): Use new state field.
+ (log_version): Likewise.
+ * cvs.h (RCS_exec_checkout): Don't declare.
+ * rcscmds.c (RCS_exec_checkout): Remove.
+
+Sat Apr 12 17:32:59 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * sanity.sh (modules3): Remove second-dir at end of tests.
+ (sticky): Correct removal of directories at end of tests.
+
+ * sanity.sh (keyword): New tests for RCS keyword expansion.
+
+Sat Apr 12 16:47:13 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * sanity.sh (basicb): New tests basicb-1b, basicb-1c, basicb-9b,
+ basic-9c test current build_dirs_and_chdir behavior.
+
+Fri Apr 11 23:54:56 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * sanity.sh (modules3): New tests modules3-7* test for ability to
+ supply a path in -d in modules. Similar to modules3-8 through
+ modules3-11 except because the nesting is different, these ones
+ work.
- * cvsrc.c, cvs.h (read_cvsrc): Pass in command name rather than
- using global variable command_name.
- * main.c (command_name): Initialize to "", not "cvs" so that error
- messages don't say "cvs cvs". Update calls to read_cvsrc to pass
- in command_name or "cvs" as appropriate.
- * sanity.sh (basica): New test basica-9 tests for above-fixed bug.
+Thu Apr 10 00:14:47 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
- * lock.c: Rename unlock to lock_simple_remove to avoid conflict
- with builtin function on QNX.
+ * sanity.sh (modules3): New tests modules3-12 through modules3-15
+ test use of a module name which contains a slash.
-Thu Feb 29 17:02:22 1996 Samuel Tardieu <sam@inf.enst.fr>
+ * sanity.sh (basicb): New tests basicb-14 to basicb-20 test use of
+ co -d with two or more arguments.
- * fileattr.c (fileattr_get): Removed NULL pointer dereference
- which occurred in the absence of default attribute.
+ * rcscmds.c: Refer to doc/RCSFILES in comment.
-Thu Feb 29 07:36:57 1996 J.T. Conklin <jtc@rtl.cygnus.com>
+Wed Apr 9 09:49:17 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
- * rcs.c (RCS_isbranch, RCS_whatbranch): Remove no longer used file
- argument, swap order of remaining two arguments to be like other
- RCS_* functions.
- (RCS_nodeisbranch): swap order of arguments to be like other RCS_*
- functions.
- * rcs.h (RCS_isbranch, RCS_whatbranch, RCS_nodeisbranch): Update
- prototypes for above changes.
- * commit.c, rtag.c, status.c, tag.c: Update for above calling
- convention changes.
+ * sanity.sh (basicb): New tests basicb-11 through basicb-13 test
+ ability to specify several directory levels in co -d (commented
+ out).
+
+ * filesubr.c (fopen_case): If CVS_OPENDIR gives an
+ existence_error, return it to the caller instead of giving a fatal
+ error.
+
+ * client.c (update_entries): Fix typo in call to error (1 -> errno).
+
+Tue Apr 8 23:02:22 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * error.h, error.c: Test for #ifdef __STDC__, not #if __STDC__.
+ This is consistent with other parts of CVS; it means that the
+ declaration for fperror will match the definition even if __STDC__
+ is defined to 0 as the SunPro 4.0 compiler does. Reported by
+ Richard Smith <rjsmith@cisco.com>.
+
+2 Apr 1997 Jim Kingdon
+
+ * entries.c (ParseTag): Add "break;" after "default:" to avoid
+ error from Visual C++.
-Thu Feb 29 08:39:03 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+Wed Apr 2 12:06:44 1997 Vince Del Vecchio <vdelvecc@spd.analog.com>
+ and Jim Kingdon
- * client.c (start_server): Revert changes which claimed to fall
- back to a different way of connecting. Add comments explaining
- why. (I don't think the changes did what they claimed, anyway).
- Use indentation rather than comments to line up #if, #else, and
- #endif.
+ * client.c: In reporting errors from socket calls, use
+ SOCK_STRERROR and SOCK_ERRNO since strerror(errno) doesn't work
+ for Win32.
- * patch.c (patch, patch_fileproc): Revert change to add optional
- arguments to -c and -u. Optional arguments are evil and in
- violation of the POSIX argument syntax guidelines. The correct
- way to do this is -C and -U. Also change DIFF back to "diff" in
- output (see comments).
+Tue Apr 8 10:45:32 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
- gcc -Wall lint:
- * client.c (copy_a_file): Declare p inside the #ifdef in which is
- it used.
- * commit.c (remove_file): Remove unused variable p.
- * commit.c (checkaddfile): Remove unused variables p.
- * rcs.c (RCS_isbranch): Remove unused variable p.
- * rcs.c: Remove unused declarations and definitions of
- parse_rcs_proc, rcsnode_delproc, rcslist, and repository.
- * rtag.c (rtag_fileproc): Remove unused variable p.
- * patch.c (patch_fileproc): Remove unused variable p.
- * tag.c (val_fileproc): Remove unused variable node.
- * client.c, import.c, lock.c, server.c: Cast pid_t to long before
- passing it to %ld.
+ * sanity.sh (modules3): Add tests modules3-8 to modules3-11, to
+ test for ability to supply a path to -d in modules. Mostly
+ commented out as CVS is buggy in this area.
- * cvs.h: Don't prototype gethostname; merely declare it (on linux,
- second argument is size_t not int).
+Mon Apr 7 12:41:44 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
-Thu Feb 29 10:29:25 MET 1996 Norbert Kiesel (nk) <nk@col.sw-ley.de>
+ * add.c (add): Add comment about SEND_NO_CONTENTS.
- * sanity.sh: added "cat > /dev/null" to loginfo entry to avoid the
- SIGPIPE signal
+Sun Apr 6 21:46:32 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
-Thu Feb 29 10:28:25 MET 1996 Norbert Kiesel (nk) <nk@col.sw-ley.de>
+ * update.c (update): Add comment about noexec and SEND_NO_CONTENTS.
- * patch.c: added new variable diff_opt
- (patch): allow optional parameter to -c and -u option, send it to
- server
- (patch_fileproc): cleaned up the code which prints the current
- filename. For "-s" option, print the pathname relative to CVSROOT
- instead of just the filename.
+Sun Apr 6 17:34:08 1997 Robert Bihlmeyer <robbe@orcus.priv.at>
- * filesubr.c (xchmod): added cast to shut up gcc
+ * Pass +f not f to getopt_long to prevent options from being
+ permuted with glibc 2.0.1.
- * cvs.h: added prototype for gethostname
+Sun Mar 30 00:07:05 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
-Thu Feb 29 10:27:25 MET 1996 Norbert Kiesel (nk) <nk@col.sw-ley.de>
+ * cvs.h (struct vers_ts): Adjust comment regarding ts_user.
+ * server.c (serve_is_modified): New function. Set entries to show
+ that the file is modified but we don't know the contents.
+ * server.c (requests): Add "Is-modified" request.
+ * vers_ts.c (time_stamp_server): If the timestamp in entdata is
+ "M" or "D", just copy that over into ts_user.
+ * vers_ts.c (Version_TS): If timestamp is "D", use the entries
+ line for the sole purpose of passing it to time_stamp_server.
+ * no_diff.c (No_Difference): If ts_user is "M", conclude the files
+ are different.
+ * client.h, client.c (send_files): Replace arguments build_dirs
+ and force with argument flags. Add flag SEND_NO_CONTENTS and add
+ to struct send_data.
+ (send_fileproc): If no_contents, then send Is-modified instead of
+ Modified.
+ * add.c, admin.c, client.c, commit.c, diff.c, edit.c, log.c,
+ rcs.c, remove.c, status.c, tag.c, update.c, watch.c: Change all
+ send_files callers.
- * lock.c (write_lock), (Reader_Lock), import.c (update_rcs_file),
- client.c (update_entries), (send_modified), server.c (server),
- (receive_file), (server_updated): use %ld for printing pid_t
- variables
+Fri Mar 28 22:32:25 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
-Thu Feb 29 02:22:12 1996 Benjamin J. Lee <benjamin@cyclic.com>
+ * server.c (requests): Change "Repository" to rq_optional. I'm
+ not sure whether I overlooked this when I removed support for
+ Repository, or whether I was thinking that servers would need to
+ support it anyway, for CVS 1.5 to 1.9 clients, but making it
+ optional doesn't prevent the server from supporting it and it
+ seems silly for the client to complain about absence of a request
+ that it never will use.
- * run.c (run_exec): Added VMS return status support.
+Fri Mar 28 10:06:59 1997 Steven Miller <Miller@wingra.com>
-Thu Feb 29 01:07:43 1996 Benjamin J. Lee <benjamin@cyclic.com>
+ * entries.c (Subdirs_Known): Don't create Entries.Log if noexec.
- * client.c (send_to_server): wrtn wasn't being declared under
- VMS for some reason.
+Thu Mar 27 18:14:12 1997 Ian Lance Taylor <ian@cygnus.com>
-Wed Feb 28 23:27:04 1996 Benjamin J. Lee <benjamin@cyclic.com>
+ * sanity.sh (death2): Remove commented out test death2-21. It
+ would now pass, but it duplicates the new test sticky-11.
- * client.c: Changed #ifdef VMS && NO_SOCKET_TO_FD to
- #if defined(VMS) && defined(NO_SOCKET_TO_FD)
+Thu Mar 27 10:21:19 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
-Wed Feb 28 22:28:43 1996 Benjamin J. Lee <benjamin@cyclic.com>
+ * sanity.sh (dotest_internal): Write test output to logfile even
+ if test succeeds. This was the behavior prior to 30 Sep 1996.
+ See the comment for rationale.
- * build_src.com: Added DCL command procedure to build
- and link CVS client for VMS.
+Tue Mar 25 13:26:52 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
-Wed Feb 28 22:07:20 1996 Benjamin J. Lee <benjamin@cyclic.com>
+ * cvs.h, entries.c (WriteTag): Add arguments nonbranch,
+ update_dir, and repository. Move the server_set_sticky call from
+ callers to here.
+ * cvs.h, create_adm.c (Create_Admin): New argument nonbranch.
+ * cvs.h, entries.c (ParseTag): Add argument nonbranchp.
+ * cvs.h (struct stickydirtag): Add field nonbranch.
+ * entries.c (Entries_Open): Set it.
+ * cvs.h (Vers_TS): Add field nonbranch.
+ * vers_ts.c (Version_TS): Copy it from struct stickydirtag.
+ * server.c, server.h (server_set_sticky): Add argument nonbranch.
+ * add.c, client.c, checkout.c, modules.c, update.c, create_adm.c,
+ commit.c: Update callers.
+ * add.c (add): If nonbranch, don't add the file on that "branch".
+ * commit.c (write_dirnonbranch): New variable.
+ (commit_fileproc, commit): Set it.
+ (commit_dirleaveproc): Pass it to WriteTag.
+ * update.c (rewrite_tag, nonbranch): New variables.
+ (update, update_dirent_proc, update_fileproc): Set them.
+ (update_filesdoneproc): If rewrite_tag, call WriteTag.
+ * sanity.sh (sticky): New tests, test for above fix.
- * client.c: VMS CVS client specific changes.
+ * version.c: Change version number to 1.9.7.
- Added USE_DIRECT_TCP to allow CVS_PORT to be used to specify
- a TCP connection port (no Kerberos). Changed
- start_kerberos_server() to start_tcp_server().
+ * version.c: Version 1.9.6.
- In copy_a_file(): transform a backup file to have a
- VMS-friendly name.
+Mon Mar 24 13:02:04 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
- Added HAVE_CONFIG_H to include "config.h".
+ * entries.c (ParseTag): Add comment about unrecognized characters
+ in CVS/Tag file.
- start_server() will starts the first successful of any
- mutually exclusive methods of starting the CVS server
- which might be enabled.
+ * classify.c (Classify_File): Add comment about how specifying a
+ tag (bogusly?) suppresses certain messages.
- Initialized use_socket_style and server_sock for VMS in
- start_server().
+Fri Mar 21 13:37:46 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
-Wed Feb 28 21:49:48 1996 Benjamin J. Lee <benjamin@cyclic.com>
+ * rcs.h (struct rcsnode): Add comment about case of PATH.
+ * rcs.c (RCS_parse): If ign_case, then try opening the file with
+ fopen_case.
+ * ignore.c (ign_case): Adjust comment.
+ * cvs.h, filesubr.c (cvs_casecmp, fopen_case): New functions.
- * find_names.c, recurse.c, cvs.h: Changed Find_Dirs() to
- Find_Directories().
- * cvs.h: Added VMS filenames enabled through USE_VMS_FILENAMES
- VMS POSIX will require to use the regular CVS filenames
- while VMS is #define'd.
+20 Mar 1997 Jim Kingdon
-Wed Feb 28 21:26:22 1996 Benjamin J. Lee <benjamin@cyclic.com>
+ * client.c (send_repository): When sending Directory request,
+ send any ISDIRSEP character as '/'. Fixes
+ "cvs log foo\bar\baz.c" on NT & friends.
- * ignore.c: Added the patterns *.olb *.exe _$* *$ to default
- ignore list for VMS.
+ * client.c (send_file_names): Don't try to read Entries file if
+ CVSADM directory does not exist. Fixes fairly serious regression
+ (warning on all fresh checkouts) introduced by 1997-01-08 change.
+
+Tue Mar 18 13:03:33 1997 Jim Meyering <meyering@totoro.cyclic.com>
+
+ * sanity.sh (RCSINIT): Define to be empty and export, to hide any
+ existing value that might cause spurious failures.
+
+ * Makefile.in: (install): Depend on installdirs.
+ Remove `CYGNUS LOCAL' comment saying not to.
+
+Tue Mar 18 09:36:26 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
-Wed Feb 28 13:32:28 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
-
- * logmsg.c (do_editor): Fix indentation.
-
-Wed Feb 28 12:56:49 1996 Benjamin J. Lee <benjamin@cyclic.com>
-
- * logmsg.c (do_editor): If no editor is defined, exit and print
- a message.
-
-Wed Feb 28 10:40:25 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
-
- * vers_ts.c (time_stamp, time_stamp_server): Reindent and revise
- comments.
-
-Tue Feb 27 23:57:55 1996 Benjamin J. Lee <benjamin@cyclic.com>
-
- * vers_ts.c: gmtime() returns NULL on some systems (VMS)
- revert to local time via ctime() if GMT is not avaiable.
-
-Tue Feb 27 13:07:45 1996 J.T. Conklin <jtc@rtl.cygnus.com>
-
- The changes listed below cause cvs to parse each rcs file (and
- free the associated rcsnode after the file has been processed)
- sequentially. cvs used to parse all files in a directory, an
- approach that does not scale to huge repositories with lots
- of revisions/branches/tags/etc.
-
- * cvs.h (struct file_info): Removed srcfiles field. Added rcs
- (node) field.
- * recurse.c (do_recursion): Removed code that pre-parsed all
- rcs files in the directory.
- (do_file_proc): Parse current rcs file.
- * rcs.c (RCS_parsefiles, parse_rcs_proc, RCS_addnode): Removed.
- (RCS_isbranch, RCS_whatbranch): Changed srcfiles argument to
- rcs (node).
- * rcs.h (RCS_parsefiles, RCS_addnode): Removed prototypes.
- (RCS_isbranch, RCS_whatbranch): Updated prototypes.
- * add.c, admin.c, checkin.c, checkout.c, classify.c, client.c,
- commit.c, diff.c, history.c, import.c, log.c, patch.c, remove.c,
- rtag.c, status.c, tag.c, update.c, vers_ts: Updated for above
- calling convention / data structure changes.
-
-Mon Feb 26 16:07:56 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
-
- * Version 1.7.3.
-
- * Version 1.7.2.
-
-Mon Feb 26 1996 Jim Kingdon <kingdon@cyclic.com>
-
- * recurse.c (start_recursion): Use last_component rather than
- checking for '/' directly.
- (do_dir_proc): Likewise.
-
- Visual C++ lint:
- * client.c (send_to_server): Change wrtn to size_t.
- (connect_to_pserver): Put tofd and fromfd declarations inside
- #ifndef NO_SOCKET_TO_FD.
- * scramble.c (shifts): Change from array of char to array of
- unsigned char.
-
-Mon Feb 26 13:31:25 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
-
- * server.c (check_repository_password): Remove unused variables
- linelen, ch.
-
- * client.c (send_file_names): Translate ISDIRSEP characters to '/'.
-
-Sat Feb 24 21:25:46 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
-
- * checkout.c (safe_location): Re-indent one line.
-
-Sat Feb 24 10:50:42 1996 Karl Fogel <kfogel@floss.red-bean.com>
-
- * checkout.c (safe_location): put assignment to hardpath[x] in an
- `else'-clause, so we don't do it when x == -1.
-
-Sat Feb 24 01:40:28 1996 Marcus Daniels <marcus@sayre.sysc.pdx.edu>
- via Karl Fogel <kfogel@floss.red-bean.com>
-
- * server.c (check_repository_password): Return by reference an
- optional username, the `host_user', from the passwd file. The
- host_user will be the user-id under which the cvs repository is
- run.
- (check_repository_password): Use `read_line' instead of fgets to
- allow for passwords larger than 32 characters, as well as the
- optional host user argument.
- (check_password): Modify to use host_user.
- (authenticate_connection): Modify to use host_user.
-
-Sat Feb 24 01:05:21 1996 Karl Fogel <kfogel@floss.red-bean.com>
-
- * scramble.c (descramble): just shift descrambled string to get
- rid of tag char, instead of allocating a whole new copy.
- (scramble): cast return value of xmalloc to avoid unsightly
- compiler warnings.
-
- * options.h.in (RCSBIN_DFLT): don't refer to AUTH_SERVER_SUPPORT
- in comment anymore, now that it's not defined in this file.
-
-Fri Feb 23 1996 Jim Kingdon <kingdon@cyclic.com>
-
- * client.c: Ifdef HAVE_WINSOCK_H, include winsock.h
- instead of sys/socket.h and friends.
- * login.c: Don't include sys/socket.h and friends.
- * login.c (login): Only fclose fp in the case where it was
- successfully fopen'd.
- * login.c: Declare getpass.
- * filesubr.c, cvs.h (get_homedir): New function.
- * cvsrc.c, expand_path.c, history.c, login.c: Call it instead
- of getenv ("HOME").
-
-Fri Feb 23 09:23:20 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
-
- * client.c (connect_to_pserver): Remove unused variable host.
- * login.c: Include getline.h.
- (login): Remove unused variables i and username.
- (get_cvs_password): Move free of linebuf to where it actually will
- be called. Add a "return NULL" at the end of the function to shut
- up gcc -Wall.
-
- * options.h.in: Remove AUTH_SERVER_SUPPORT.
- * client.h (authenticate_connection): Declare.
- * scramble.c (scramble): Cast char to unsigned char before using
- it to look up in table (char might be signed).
- * server.c [AUTH_SERVER_SUPPORT]: Include grp.h
- (authenticate_connection): Remove unused variables len and
- server_user.
-
- * sanity.sh (basica): Add comments regarding creating a top-level
+ * recurse.c (struct recursion_frame): Reindent.
+ (do_dir_proc): Print message if we try to recurse into a CVSADM
directory.
- (basic1): Don't try to remove first-dir and
- ${CVSROOT_DIRNAME}/first-dir at start of test; tests are now
- responsible for cleaning up at the end.
- (PLUS,DOTSTAR,ENDANCHOR): Add comments regarding fixed GNU expr.
-
-Thu Feb 22 22:34:11 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
-
- * cvs.h: Remove alloca cruft.
+ * sanity.sh (basicb): New test basicb-4a tests for above fix.
+
+Sun Mar 16 10:18:28 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * sanity.sh (death2): Replace regexp matching temporary file name
+ with new variable ${tempname}. For most of the tests this is a
+ cosmetic change, but death2-diff-6 had been missing _ which caused
+ it to fail on Solaris (at least sometimes).
+
+ * sanity.sh (modes): Don't use export -n; it doesn't seem
+ to be sufficiently portable.
+
+ * version.c: Change version number to 1.9.5.
+
+ * version.c: Version 1.9.4.
+
+ * rcscmds.c (RCS_checkin): Preserve the mode of the rcsfile.
+ RCS_CI usually, but not always, does this for us.
+ * commit.c (fix_rcs_modes): Replace algorithm with a more
+ CVSUMASK-friendly one.
+ * sanity.sh (modes): Update tests modes-5, modes-7, modes-10, and
+ modes-15 so they test that CVSUMASK is honored.
+
+Sun Mar 16 10:18:28 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * sanity.sh (modes): New tests modes-7a and modes-7b test behavior
+ if one manually changes the modes in the repository.
+
+ * server.c (server): Revise code which checks for errors creating
+ temporary directory. This won't solve the intermittent
+ can't create temporary directory
+ Unknown error -1
+ but it will mean (a) the right message based on errno gets
+ printed, instead of "unknown error -1", and (b) the message says
+ that it happened in chmod instead of mkdir_p.
+
+Sat Mar 15 16:47:12 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * sanity.sh (modes): New tests. Note that (for now) these are
+ just testing how CVS already behaves; I want to record that before
+ I move on to changing CVS's behavior with modes of RCS files.
+
+13 Mar 1997 Jim Kingdon
+
+ * subr.c (line2argv): Change argv_allocated from size_t to int.
-Wed Feb 21 07:30:16 1996 J.T. Conklin <jtc@rtl.cygnus.com>
+Wed Mar 12 22:16:44 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
- * modules.c (do_module): call free_cwd before exiting.
+ * add.c (add_directory): If repository has an extraneous "."
+ directory at the end, strip it off. This fixes a bug which was
+ introduced when strip_path was nuked (this fix is much more
+ limited in scope than strip_path was; I _think_ that is a good
+ thing).
+ (add): Likewise, for client.
+ (combine_dir): New function, helps with above.
+ * sanity.sh (modules3): Reenable tests for this behavior.
+ (basica-0b, basicb-0e): Adjust test to reflect "foo/bar" instead
+ of "foo/./bar" in message. As with the rest of this, I believe
+ this is just restoring the behavior prior to the strip_path nuking
+ (I tried it with CVS 1.9).
- * recurse.c: Removed entries global variable.
- (do_recursion): Declare entries. Moved call to Entries_Close so
- entries list is closed on all code paths.
- (start_recursion): Removed call to Entries_Close, entries list has
- been moved to do_recursion only.
+Sun Mar 9 10:06:29 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
-Tue Feb 20 22:10:05 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+ * root.c (parse_cvsroot), server.c (serve_root, serve_init):
+ If CVSroot_directory is not an absolute pathname, give a fatal error.
+ * sanity.sh (crerepos): New tests crerepos-6* test for above fixes.
- * update.c (update_dirent_proc): If dir lacks a CVS subdirectory,
- don't recurse into it.
- * sanity.sh (conflicts): Test for above-fixed bug.
+Sat Mar 8 22:06:17 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
- * update.c (merge_file): Use write_letter not printf.
+ This cleans up the last known code which can overflow its buffers
+ (except the Mac client). I've skimmed through much of CVS looking
+ for other such places; but I didn't read everything. If I missed
+ any please report it to bug-cvs.
+ * logmsg.c (logfile_write, title_proc): Realloc str_list as
+ needed; don't assume MAXLISTLEN is enough.
+ * cvs.h (MAXLISTLEN, MAXFILEPERDIR): Removed; no longer used.
+ * add.c, myndbm.c, parseinfo.c, update.c: Nuke MAXLINELEN limit.
+ * parseinfo.c, update.c, mkmodules.c: Check for errors reading file.
+ * cvs.h (MAXLINELEN): Removed; no longer used.
+ * logmsg (MAXHOSTNAMELEN): Removed; not used.
+ * main.c (cmd_synonyms): Allocate based on fullname, nick1, and
+ nick2, just in case someone makes those big enough so that 100
+ bytes is not enough.
+ (Make_Date): Use MAXDATELEN rather than our own fixed size.
+ * mkmodules.c (mkmodules): Nuke arbitrary limit on line length.
+ * rcs.c (ALLOCINCR): Remove; not used.
+ (RCS_check_kflag): Add comment concerning karg size.
+ * run.c: Allocate run_prog to the needed size, rather than
+ allocating a fixed size buffer.
-Tue Feb 20 12:34:07 EST 1996: Gary Oberbrunner <garyo@avs.com>
- and Jim Kingdon <kingdon@cyclic.com>
+Fri Mar 7 22:39:08 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
- * history.c (history_write): Change username to char * and call
- getcaller() to set it. Setting username accidentally got deleted
- 8 Feb 96.
- * sanity.sh: Revise test 64 to test for above-fixed bug.
- * sanity.sh (PLUS): New variable, work around yet another GNU expr
- bug.
-
-Tue Feb 20 14:07:50 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+ * logmsg.c (logfile_write): Allocate prog to needed length rather
+ than assuming MAXPROGLEN is enough.
+ * cvs.h (MAXPROGLEN): Removed; no longer used.
+ * subr.c (MIN_INCR): Update comment to reflect MAXPROGLEN's demise.
- * sanity.sh: Merge test rtags into test basic2. They never were
- capable of running separately of each other.
-
- * sanity.sh (deep): New test, to test ability to operate in deeply
- nested directories (more quickly than basic2 test did).
- (basic2,rtags): Remove directories dir3 and dir4. Remove file8,
- file10, file12, file9, file11, file13, file15, file16, file17.
- These additional files slowed down the tests considerably without
- significantly increasing coverage.
+ * subr.c (free_names): Fix comment: this function is not used to
+ free memory allocated by Find_Names (at least it hasn't for a long
+ time).
+ * subr.c, cvs.h (line2argv): Change calling convention so that we
+ allocate argv array rather than the caller. The previous one had
+ no way of checking whether we overflowed the passed-in buffer.
+ * subr.c (free_names): Free the argv array too.
+ * modules.c (do_module, cat_module): Update callers.
- * sanity.sh (PROG): New variable. Use it instead of "cvs"
- to match the name cvs prints out for itself.
+Thu Mar 6 12:44:42 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
-Mon Feb 19 09:00:29 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+ * import.c: Allocate vhead and vbranch dynamically; removes
+ arbitrary limit.
+ * history.c: Likewise (since_rev, since_tag, backto, rec_types).
+ * ignore.c: Likewise (line). Also check for errors from getline
+ and add 'copyright' notice to top of file.
+ * wrapper.c (wrap_add_file): Likewise (line). Also check for
+ errors from various calls and add 'copyright' notice to top of file.
- This fixes a bug whereby old default attributes would get
- clobbered instead of added to on "cvs watch add".
- * hash.c (findnode): Don't check for key == NULL; let the
- assertion in hashp take care of it.
- * fileattr.h, fileattr.c (fileattr_get): If filename is NULL,
- return default attributes.
+Tue Mar 4 17:39:15 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * client.c (update_entries): Add comment about "move away <file>"
+ message.
- * client.c (send_repository): Fix indentation.
+Mon Mar 3 21:51:40 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
-Mon Feb 19 01:10:01 1996 Karl Fogel <kfogel@floss.red-bean.com>
+ * sanity.sh (basicb): Clean up topfile,v at end of test. Fixes
+ failure in modules-155b.
+
+Sun Mar 2 18:11:09 1997 Dan Wilder <dan@gasboy.com>
+ and Jim Kingdon
+
+ * admin.c (admin): Arrange to perform recursion if "cvs admin"
+ is passed only options.
+
+Sun Mar 2 18:11:09 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
- * login.c (login): print out full repos so user knows which server
- she's logging into.
+ * sanity.sh (basicb): New tests basicb-0* test for files at top
+ level.
- * client.c (send_repository): die if `repos' is NULL. This is a
- lame solution; see comments in code.
+ * error.c (error): Add newline to "out of memory" message. I think
+ that its omission probably could cause the message to be lost in
+ the bowels of server.c and never passed to the user.
-Thu Feb 15 15:04:01 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+ * client.c (start_rsh_server): Add comment about "remsh" vs. "rsh".
+
+ * cvs.h: Move copyright notice to top of file.
+
+Sun Mar 2 13:44:36 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * sanity.sh: Use -n when testing whether rsh works.
+
+ * server.c (serve_root): Free path.
+
+Sun Mar 2 13:12:46 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ The following are things that I noticed in the process of trying
+ to track down:
+ can't create temporary directory
+ Unknown error -1
+ FAIL: test 28
+ from nightly testing. I'm not sure that either item explains that
+ message however.
+ * server.c (server): Allocate pending_error_text;
+ print_pending_error will try to free it so
+ pending_error_text = "foo"
+ won't work.
+ (mkdir_p): Don't assume that isdir will leave errno unmolested.
+
+Thu Feb 27 15:29:58 1997 Ian Lance Taylor <ian@cygnus.com>
+
+ * remove.c (cvsremove): When forcing removal in client mode, use
+ start_recursion rather than calling CVS_UNLINK on each argument.
+ (remove_force_fileproc): New static function.
+ * sanity.sh (deep): Add tests deep-rm7 through deep-rm10 for above
+ patch.
+
+ * sanity.sh (death): Enable death-76a0 and death-76a1 tests for
+ remote, since they now work.
+
+Wed Feb 26 16:13:26 1997 Ian Lance Taylor <ian@cygnus.com>
- * error.c (error): Free entire and mess when done with them.
+ * client.c (add_prune_candidate): Skip adding this directory if
+ it is the same as the first directory already on the list.
- * sanity.sh (info): Correct syntax of .cvsrc file.
+Mon Feb 24 21:36:43 1997 Noel Cragg <noel@gargle.rain.org>
- * cvs.h, expand_path.c, edit.c, parseinfo.c, wrapper.c:
- expand_path now takes arguments containing file and line for error
- message, and it prints the error message itself.
- * sanity.sh (info-6a): Test printing of error message.
-
- * expand_path.c (expand_variable): Add USER internal variable.
- * sanity.sh (info): Test USER and CVSROOT internal variables too.
+ * main.c (lookup_command_attribute): Add the "init" command to the
+ list of commands that don't use the current working directory.
-Wed Feb 14 19:11:08 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+Sun Feb 23 09:54:49 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
- * main.c (usg): Add -s option.
-
-Tue Feb 13 20:26:06 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
-
- gcc -Wall lint:
- * mkmodules.c (mkmodules_usage): Remove declaration of
- non-existent function.
- * cvs.h (mkmodules): Declare.
-
-Mon Feb 12 12:20:04 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
-
- * mkmodules.c: Rename main to mkmodules and remove various pieces
- of scaffolding which it used to emulate non-existent parts of CVS.
- Change calling convention to just take a char * not argc,argv.
- Save and restore working directory.
- * commit.c (commit_filesdoneproc): Call it if checking files into
- CVSROOT.
- * Makefile.in (SOURCES): Add mkmodules.c.
- (OBJECTS): Add mkmodules.o.
- (MSOURCES,MOBJECTS): Removed.
- (COMMON_OBJECTS): Removed; move former contents into OBJECTS.
- Update other rules accordingly.
- * sanity.sh: Adjust to reflect nonexistence of mkmodules.
-
- These changes introduce functions cvs_output and cvs_outerr;
- eventually all server output will go through them rather than
- stdio directly.
- * server.c (saved_output, saved_outerr): New variables.
- (do_cvs_command): Initialize them.
- (buf_output): Don't require that buf->output be set; saved_* use
- this to shove some data in a buffer which buf_copy_lines will
- later want to get data from.
- * server.c, cvs.h (cvs_output, cvs_outerr): New functions.
- * mkmodules.c (cvs_outerr): New function, so error() works.
- * error.c: Reindent. Don't declare program_name and command_name;
- cvs.h declares them.
- (error): Use vasprintf and cvs_outerr (or fputs in the
- error_use_protocol case) rather than stdio directly.
- * import.c (import_descend_dir): Remove kludge which had prevented
- messages from error() from being out of order with respect to
- messages from printf; cvs_output and cvs_outerr are a cleaner
- solution to the problem.
- (add_log, import): Use cvs_output not printf.
- * update.c (write_letter): Use cvs_output not printf.
- (checkout_file): Use write_letter not printf.
- * sanity.sh: Use dotest for test 56 (test that output is actually
- correct). In theory should test that the import.c bug is fixed,
- but I was unable to reproduce the bug (it is timing dependent).
-
-Mon Feb 12 16:07:45 1996 Norbert Kiesel <nk@col.sw-ley.de>
-
- * commit.c: define last_register_time
- (commit): make sure cvs doesn't exit in the same second it wrote
- the last timestamp
- (commit_fileproc): set last_register_time
- (finaladd): set last_register_time
-
- * run.c, cvs.h: Changed more Popen() to run_popen()
-
-Mon Feb 12 03:06:50 1996 Benjamin J. Lee <benjamin@cyclic.com>
-
- * release.c, rtag.c, tag.c: changed 'delete' to 'delete_flag'
- to avoid symbol collision with DEC C RTL function delete()
-
-Mon Feb 12 03:01:48 1996 Benjamin J. Lee <benjamin@cyclic.com>
-
- * mkmodules.c: changed 'void Lock_Cleanup()' to 'void static
- Lock_Cleanup() to avoid conflict with more substantial
- Lock_Cleanup() in lock.c
-
-Mon Feb 12 02:50:19 1996 Benjamin J. Lee <benjamin@cyclic.com>
-
- * edit.c, logmsg.c, release.c, run.c: Changed Popen() to
- run_popen(). VMS' linker is not case sensitive and considered
- popen() and Popen() to be identical symbols.
-
-Sun Feb 11 10:51:14 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
-
- * main.c (main) [!CLIENT_SUPPORT]: Silently ignore gzip level
- rather than printing usage message.
-
- * cvs.h, expand_path.c (variable_list): New variable.
- (variable_set): New function.
- * hash.h (enum ntype), hash.c (nodetypestring): Add VARIABLE.
- * expand_path.c (expand_path, expand_variable): Reindent.
- (expand_variable): Use user variables not environment variables
- for ${=VAR} syntax. The environment variables didn't work
- client/server.
- * main.c (main): Process new -s global option.
- * client.c (send_variable_proc): New function.
- (start_server): Call it, to send user variables.
- * server.c (serve_set): New function.
- (requests): Add Set request.
- * sanity.sh: Revise info test to use user variables rather than
- environment variables.
-
-Sat Feb 10 16:55:37 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
-
- By itself this is only a small cleanup, but in the long run it
- will be way cool (for reference, it takes CVS's text segment from
- 290816 bytes to 294912, which I expect will be made up by future
- changes which this enables):
- * cvs.h (struct file_info): Added.
- (FILEPROC): Replace 5 args with single struct file_info *.
- * recurse.c (do_file_proc): Adjust args to fileproc; passed in
- instead of from globals.
- (do_recursion): Call do_file_proc accordingly. Remove srcfiles
- global variable.
- * update.c (update_fileproc): Renamed from update_file_proc.
- * admin.c, client.c, commit.c, diff.c, edit.c, log.c, patch.c,
- remove.c, rtag.c, status.c, tag.c, update.c, watch.c: Update
- fileprocs to new calling convention.
-
-Fri Feb 9 15:30:32 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
-
- * expand_path.c (expand_variable): Accept a variable name starting
- with '=' as a way to specify an environment variable.
- * sanity.sh (info): New tests, for above behavior.
-
- * Makefile.in (clean): Also remove check.log check.plog.
-
- * import.c (comtable): Remove SYSTEM_COMMENT_TABLE; the table
- should *not* depend on what kind of machine the server happens to
- be. Add "mak", "rc", "dlg", "frm", and "bas" types which were
- formerly included via SYSTEM_COMMENT_TABLE.
-
- * cvs.h, rcs.h, add.c, checkin.c, classify.c, commit.c, diff.c,
- import.c, patch.c, rcs.c, update.c, vers_ts.c: Remove
- DEATH_SUPPORT ifdefs. They were introduced to facilitate merging
- between Cygnus and Berliner variants of CVS, not because it was
- intended to subset CVS this way. And they clutter up the code
- quite a bit.
- * cvs.h, create_adm.c, main.c, update.c: Likewise, remove
- CVSADM_ROOT ifdefs (it is still a #define, of course). I believe
- they had a more-or-less similar motivation.
-
- * sanity.sh: Move setting of HOME from ignore test to the start of
- the tests so it applies to all tests.
- (CVS): Remove -f; the above change takes care of it.
-
- * rcs.h (RCS_MERGE): Removed; unused.
-
- * commit.c (checkaddfile): Fix memory leak.
-
- * admin.c, commit.c, diff.c, log.c, mkmodules.c: Pass -x,v/ to RCS
- commands.
-
- * rcscmds.c, cvs.h (RCS_checkin): New function.
- * checkin.c, commit.c, import.c: Call it, rather than run_*.
- * cvs.h, commit.c: Remove DEATH_STATE define; the behavior
- which used to be the default (DEATH_STATE) is now the only one.
- Failing to define DEATH_STATE has been commented as obsolete at
- least since CVS 1.5. We still can read repositories created with
- such a CVS, however.
- * rcs.h, rcs.c: Adjust comments regarding DEATH_STATE.
- * subr.c (make_message_rcslegal): Add comment, describing
- allocation of returned value.
-
-Fri Feb 9 09:53:44 MET 1996 Norbert Kiesel <nk@col.sw-ley.de>
-
- * sanity.sh: use "${testcvs}" instead of "cvs" in devcom tests
-
- * hash.c: fix "dereferencing a NULL pointer" bug triggered with
- "cvs watch add"
- (findnode): return NULL if key == NULL
- (hashp): assert (key != NULL)
-
-Fri Feb 9 00:46:47 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
-
- * rcs.c (RCS_reparsercsfile): Remove unused variable date.
-
- * myndbm.c (mydbm_load_file): Fix typo ('015' -> '\015').
-
-Thu Feb 8 13:00:00 1996 Jim Kingdon <kingdon@peary.cyclic.com>
-
- * rcs.c (RCS_parse, RCS_parsercsfile, RCS_reparsercsfile),
- fileattr.c (fileattr_read), myndbm.c (myndbm_open):
- Use FOPEN_BINARY_READ.
- * fileattr.c (fileattr_write), myndbm.c (myndbm_close):
- Use FOPEN_BINARY_WRITE.
- * history.c (history_write, read_hrecs): Specify OPEN_BINARY.
- * rcs.c: Remove calls to abort.
- * myndbm.c (myndbm_load_file): Ignore CRs from ends of lines
- if present.
- * myndbm.c, fileattr.c: While I am at it, change \n to \012
- a few places where LF is intended.
- * history.c (history_write): Use getenv ("HOME"), not getpwnam,
- to find home directory. If it isn't set, just keep going; don't
- print a message.
- * rcscmds.c, cvs.h (RCS_checkout): New function.
- * update.c, checkin.c, commit.c, diff.c, import.c, no_diff.c,
- patch.c: Call it instead of run_*.
- * patch.c (patch_fileproc): Clean up inconsistent handling of
- noexec flag.
- * rcscmds.c (RCS_*): Pass -x,v/ to RCS commands; elsewhere in
- CVS it is assumed that ,v is a suffix.
-
-Fri Feb 2 14:07:32 1996 J.T. Conklin <jtc@rtl.cygnus.com>
-
- * rcs.h (struct rcsnode): Remove dates field (list of rcsversnodes
- indexed by date). CVS maintained this list for each RCS file even
- though it was never used. This resulted in higher then necessary
- memory requirements (and run time too). Even if revision info was
- needed, CVS' List data structure is inappropriate because can't
- handle duplicate keys. The above was discovered by tracking down
- a memory leak.
- * rcs.c (RCS_reparsercsfile): Don't build dates list.
- (freercsnode): Don't delete dates list.
- (rcsvers_delproc): Free date field.
- (null_delproc): Removed.
-
-Thu Feb 1 12:28:33 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
-
- * remove.c (cvsremove): Don't tell user the name of the program
- which they use to remove files; we don't have any way of knowing
- that, and besides which they might use a GUI or emacs 'dired' anyway.
- * update.c (update_filesdone_proc, update_dirleave_proc): Call
- unlink_file_dir instead of rm -rf.
- * options.h.in: Remove RM; no longer used.
-
- * sanity.sh: New tests devcom-a* test "cvs watch add",
- "cvs watch remove", and "cvs watchers".
-
- * sanity.sh: New test 171a0 tests for watch.c bug just fixed by kfogel.
-
- * Most .c files: Remove rcsids.
- * cvs.h: Remove USE macro.
-
-Thu Feb 1 13:07:15 1996 J.T. Conklin <jtc@rtl.cygnus.com>
-
- * tag.c, rtag.c: Update various comments to reflect function name
- changes.
-
-Thu Feb 1 14:14:31 1996 Karl Fogel <kfogel@floss.red-bean.com>
+ * sanity.sh (devcom3): Clean up at end of test.
- * recurse.c (do_recursion): comment #endif.
+ * sanity.sh (basicb): Add commented out test basicb-8a0, for
+ whether CVS can print an error on bad numeric revision to diff.
+ Commented out until we get around to fixing CVS.
+ * diff.c (diff_file_nodiff): Add comment about this case.
- * edit.c (notify_check): surround with #ifdef CLIENT_SUPPORT; else
- CVS won't compile if CLIENT_SUPPORT is undefined.
-
- * edit.h (notify_check): surround declaration with #ifdef
- CLIENT_SUPPORT.
-
- * watch.c (watch): if argc <= 1, then just give usage (previously
- was "argc == -1").
-
-Thu Feb 1 12:28:33 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
-
- * README-rm-add: Remove information which is now in cvs.texinfo.
+ * fileattr.c (fileattr_read): If a filename is duplicated,
+ continue to ignore subsequent lines but free the node so that we
+ don't leak memory.
+ * sanity.sh (devcom3): New tests devcom3-8 and devcom3-9 test for
+ behavior on duplicated filenames.
- * sanity.sh: Remove basic0 tests. Move a few to new tests
- basica-1a* (but there is no need to test that *every* command
- gracefully does nothing on an empty directory; exhaustive testing
- is impractical and the generic recursion processor handles this
- anyway).
+ * fileattr.h: Add comment about unrecognized ENT-TYPE and order of
+ lines in fileattr file.
+ * fileattr.c (struct unrecog, unrecog_head): New variables, to
+ record unrecognized lines.
+ (fileattr_startdir): Assert that unrecog_head == NULL.
+ (fileattr_read): Record unrecognized lines in unrecog_head linked
+ list rather than ignoring them.
+ (fileattr_write): Also write out unrecognized lines, if any.
+ * sanity.sh (devcom3): New tests, test for above fix.
- * sanity.sh: New tests 69a* test use of update -p to restore old
- version of dead file.
+ * fileattr.h (fileattr_modify): Fix example in comment.
-Wed Jan 31 18:32:34 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+Sat Feb 22 08:30:27 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
- * ChangeLog-9395: Remove duplicate entries from 1996 which
- accidentally got into this file.
+ * sanity.sh: Add variable username.
+ (basica rdiff multibranch log log2): Use it instead of our own
+ (inconsistent) ways of matching an author name.
- * client.c (read_line, read_from_server): Change "premature end of
- file from server" message to "end of file from server (consult
- above messages if any)" because 99% of the time it means rsh has
- printed an error message and exited.
+ * filesubr.c, root.c, rtag.c, server.c, subr.c, update.c,
+ wrapper.c: Nuke PATH_MAX.
+ * cvs.h, wrapper.c (wrap_fromcvs_process_file): Now returns void
+ (return value had been unused).
+ * cvs.h: Adjust comment to reflect the fact that PATH_MAX is
+ gone, at least from src/*.c (except safe_location, as noted).
-Wed Jan 31 15:09:51 1996 J.T. Conklin <jtc@rtl.cygnus.com>
+22 Feb 1997 patch by Tom Hageman <tom@basil.icce.rug.nl> (4 Jun 1996)
+ updated and commented by Jim Kingdon <kingdon@harvey.cyclic.com>
- * edit.c (ncheck_fileproc): Fix memory leak; free line before
- returning.
+ * update.c (checkout_file): Call unlink_file_dir on backup, not
+ unlink_file.
-Tue Jan 30 18:06:12 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+Fri Feb 21 16:40:03 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
- * recurse.c (do_recursion): Add comment about the fact that we
- don't have locks in place at certain points.
+ * Makefile.in (DISTFILES): Remove NOTES.
-Tue Jan 30 09:43:34 1996 Vince Demarco <vdemarco@bou.shl.com>
+ * NOTES: Removed. bcopy->memcpy is done. "static buffers" I
+ assume refers to what is covered by reentrancy text in HACKING.
+ Obstack idea moved to comment in hash.c (at nodecache). Checking
+ system calls for error returns largely done, and isn't a very
+ helpful suggestion unless you know where the bogus calls are
+ anyway. Sizing limits--we're in the progress of removing them
+ (assuming it meant things like PATH_MAX and earlier, already
+ nuked, limits). Removed various items about changes which were
+ done a long time ago (I realize that the ChangeLog's probably
+ aren't reliable that far back, but I'm not convinced anyone cares
+ anymore). CONFIRM_DIRECTORY_ADDS: I assume this is a
+ reference to the #if 0'd code in add_directory which asks for
+ confirmation--a better way of making it harder to accidentally add
+ directories would be to have to add and commit directories like
+ for files. I don't know what FORCE_MESSAGE_ON_ADD meant.
+
+ * rcs.c (RCS_getrevtime): Fix documentation (in particular, the
+ size of the array that DATE must point to, but many other things
+ too).
+ * patch.c, recurse.c, release.c, remove.c, repos.c: Nuke PATH_MAX.
+ (patch_fileproc): Use MAXDATELEN not hardcoded 50.
+
+Sun Feb 16 12:00:44 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * client.c (client_process_import_file): New variable fullname;
+ pass it to send_modified. This finishes the job of untangling the
+ old short_pathname variable into update_dir vs. fullname.
- * edit.c (notify_proc): have notify_proc call expand_path with
- the name of the filter program. The user may have used a
- cvs environmental variable. (Popen will expand it, but it may not
- use the correct value)
+ * client.c (client_process_import_file): Nuke first_time. If
+ toplevel_repos were ever NULL here, the code would dump core in
+ strncmp a few lines down. And client_import_setup ensures
+ toplevel_repos is not NULL.
+
+Sun Feb 16 08:16:48 1997 Ian Lance Taylor <ian@cygnus.com>
-Tue Jan 30 09:43:34 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+ * client.c (client_process_import_file): Rename short_pathname to
+ update_dir (to reflect its function) and make sure that it doesn't
+ point to uninitialized memory if repository and toplevel_repos
+ contain the same string.
- * ChangeLog: take the pre-1996 changes and put them in a new file
- ChangeLog-9395.
- * ChangeLog-9194: Renamed from ChangeLog.fsf.
- * ChangeLog-9194, ChangeLog-9395, ChangeLog: Add additional text
- explaining the difference between all these logs and pointing to
- older logs.
- * Makefile.in (DISTFILES): Add ChangeLog-9194 and ChangeLog-9395;
- remove ChangeLog.fsf.
+Sun Feb 16 08:16:48 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
- * modules.c (do_module): Don't fall through from 'l' to 'o' case
- of option processing switch statement.
-
-Tue Jan 30 06:50:19 1996 J.T. Conklin <jtc@rtl.cygnus.com>
-
- * client.c (send_repository): Fix memory leak; free adm_name
- before returning.
- * diff.c (diff_file_nodiff): Fix memory leak; free xvers before
- returning.
- * rtag.c (rtag_fileproc): Fix memory leak; if branch_mode is set,
- free rev before returning.
- * status.c (status_fileproc, tag_list_proc): Fix memory leak; free
- return value of RCS_whatbranch.
- * tag.c (tag_fileproc): Fix memory leak; free vers before
- returning.
- (val_fileproc): Fix memory leak; free return value of RCS_gettag.
- * watch.c (watch_modify_watchers): Fix memory leak; free mynewattr
- before returning.
-
-Tue Jan 30 09:43:34 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
-
- * lock.c (readers_exist): If stat gave an error, print an error
- message saying it was from stat, rather than from "reading
- directory". Skip the message completely if it was an
- existence_error.
-
- * sanity.sh (branches): New tests (branches off of branches, etc.).
+ * client.c (start_rsh_server): Nuke comment about weirdnesses with
+ pre-1.5 versions of CVS and .bashrc/.cshrc. The remote protocol
+ is interoperable only back to 1.5, and people who need to know are
+ unlikely to see this comment anyway.
+
+Sun Dec 15 13:12:30 1996 Michael Douglass <mikedoug@texas.net>
+ and Jim Kingdon <kingdon@harvey.cyclic.com>
-Tue Jan 30 11:55:34 MET 1996 Norbert Kiesel <nk@col.sw-ley.de>
+ * main.c (cmds): Added an entry for new logout command.
+ (cmd_usage): Added an entry for new logout command.
+ (lookup_command_attribute): Added 'logout' to list of commands
+ that set need_to_crate_root to 1.
+ * login.c, cvs.h (logout): New command for removing entries from
+ the .cvspass file.
+ (logout_usage): Usage information on the logout command.
- * main.c (main): Add change to run getopt_long twice again.
+Wed Feb 12 11:19:42 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
-Mon Jan 29 15:59:31 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+ * client.c (struct send_data): Fix indentation.
- gcc -Wall lint:
- * client.c: Include edit.h
+Wed Feb 12 08:48:04 1997 Greg A. Woods <woods@most.weird.com>
-Sun Jan 28 09:45:53 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+ * mkmodules.c (loginfo_contents): add missing comma in
+ initializer statement (caused syntax error on SunOS-4).
- * edit.c, edit.h (mark_up_to_date): New function, to remove file
- in CVS/Base.
- * client.c (update_entries): Call it if file is up to date.
- * checkin.c (Checkin): Call it in non-server (local) case.
- * sanity.sh: New test 182.5, tests for above-fixed bug.
+Tue Feb 11 21:14:28 1997 Ian Lance Taylor <ian@cygnus.com>
-Sun Jan 28 01:07:22 1996 Jim Kingdon (kingdon@beezley)
+ * commit.c (find_fileproc): If force_ci is set, set the status to
+ T_MODIFIED even if the file hasn't changed.
+ (commit): Pass force_ci to send_files as new force argument.
+ * client.c (struct send_data): Define.
+ (send_fileproc): The callerdat parameter now points to a send_data
+ struct. If force is set, always call send_modified.
+ (send_dirent_proc): The callerdat parameter now points to a
+ send_data struct.
+ (send_files): Add force parameter. Change all callers. Set up a
+ send_data struct and pass it to start_recursion as callerdat.
+ * client.h (send_files): Update declaration.
+ * sanity.sh (basica): Add a simple test for the above patch.
- * client.c (change_mode): Separate out CHMOD_BROKEN code to parse
- mode_string, rather than going through a mode_t. Cleaner than
- the previous CHMOD_BROKEN code (which also had a typo of && not &).
+Sun Feb 9 12:58:59 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
-Sat Jan 27 23:29:46 1996 Jim Kingdon (kingdon@beezley)
+ * tag.c (cvstag), rtag.c (rtag): Pass -f to server if specified in
+ the client. I haven't tried to come up with a test case because
+ the fix seems obvious.
- * edit.c (edit_fileproc): Check for EACCESS as well as EEXIST.
+ * import.c (add_rcs_file): Change size of altdate1 and altdate2 to
+ MAXDATELEN.
+ * cvs.h (MAXDATELEN): Fix comments; describe what this is for.
-Sat Jan 27 16:26:30 1996 Karl Fogel (kfogel@floss.cyclic.com)
+ * diff.c (diff_usage): Document --ifdef and try to briefly say
+ what "rcsdiff-options" means.
- * client.c (notified_a_file): use rename_file() instead of
- rename() (but temporarily set `noexec' to 0 so it runs
- unconditionally).
- (change_mode): deal with CHMOD_BROKEN.
+ * update.c (update): If update had a nonzero status and we haven't
+ yet tried to fetch unpatchable files, go ahead and try it again.
+ The previous behavior was to quit, which meant that updates would
+ keep failing until you hacked around the problem. Patch and bug
+ report by Ian; comment, ChangeLog entry, and willingness to take
+ the flak if checking it is premature by Jim.
-Fri Jan 26 00:14:00 1996 Karl Fogel <kfogel@floss.red-bean.com>
+ * server.c (alloc_pending): New function.
+ * server.c: Call it. Fixes places where we had neglected to
+ check for NULL return from malloc.
- * server.c: renamed `dirname' to `dir_name', to avoid conflicts
- with system headers.
+ * sanity.sh (binwrap): Add test binwrap-0, tests for import.c fix
+ below.
- * client.c: renamed `dirname' and `last_dirname' to `dir_name' and
- last_dir_name' (see above). Not strictly necessary, but
- consistency is nice -- as long as you do it all the time.
+Sun, 9 Feb 1997 (submitted 19 Jul 1996) John Polstra <jdp@polstra.com>
-Thu Jan 25 00:41:59 1996 Karl Fogel <kfogel@floss.red-bean.com>
+ * import.c (import): Give error if the same tag is specified more
+ than once. The previous behavior was to write an RCS file which
+ had the same tag listed twice, once pointing to each revision,
+ which is not legal.
- * options.h.in (AUTH_SERVER_SUPPORT, AUTH_CLIENT_SUPPORT): change
- comment now that no longer under construction.
+Sun Feb 9 12:37:09 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
-Wed Jan 24 15:25:22 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+ * checkin.c (Checkin): Use cvs_output to print message (should
+ make out of order bugs no worse, as it merely substitues a
+ protocol_pipe vs. stderr_pipe race instead of a stdout_pipe
+ vs. stderr_pipe race). Add comment about stdout vs. stderr.
- * Version 1.7.1.
+Fri Feb 7 08:29:52 1997 Josef Nelissen <josef.nelissen@munich.ixos.de>
- * Version 1.7.
+ * server.c (check_command_legal_p): Don't use ANSI-style definition.
-Sat Jan 20 00:05:08 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+Thu Feb 6 10:55:37 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
- * Version 1.6.87.
+ * patch.c (patch): Give a fatal error for -V option (see comment
+ for rationale).
-Mon Jan 15 18:14:55 1996 Gary Oberbrunner <garyo@avs.com>
- and Jim Kingdon <kingdon@harvey.cyclic.com>
+ * diff.c (diff): Also send "options" to server. Pretty much the
+ patch submitted independently by josef.nelissen@munich.ixos.de and
+ Ronald Khoo <ronald@demon.net>.
- * tag.c (val_direntproc): New function to ignore
- nonexistent dirs when recursing to check tag validity.
- (tag_check_valid): Pass it to start_recursion.
- * sanity.sh (death): New tests 65a0-65a6 cause test 74 to test for
- above-fixed bug.
+Wed Feb 5 18:57:14 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
-Mon Jan 15 12:55:37 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+ * modules.c (do_module): Fix typo in 30 Jan 97 PATH_MAX nuking
+ (free -> free_cwd). Testsuite test 151 gets credit for catching
+ this one.
- * main.c: Revert change to run getopt_long twice. This can go in
- after 1.7.
+Mon Feb 3 16:14:54 1997 Ian Lance Taylor <ian@cygnus.com>
-Mon Jan 15 13:03:28 1996 Norbert Kiesel <nk@col.sw-ley.de>
+ * main.c (lookup_command_attribute): Don't use an ANSI prototype
+ when defining the function.
- * filesubr.c (deep_remove_dir): added test of EEXIST for nonempty
- directory (Posix states that both ENOTEMPTY (BSD) and EEXIST
- (SYSV) are valid)
+Fri Jan 31 12:49:02 1997 Ian Lance Taylor <ian@cygnus.com>
- * main.c (main): run getopt_long twice to allow command-line
- suppression of reading the cvsrc file
+ * modules.c (do_module): Actually goto found if is_found is set
+ (fixes thinko in PATH_MAX nuking of 30 Jan 97).
-Fri Jan 12 10:02:43 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+Fri Jan 31 12:49:02 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
- * Version 1.6.86.
+ * sanity.sh: Add modules3 and big to list of tests to run
+ by default; they were omitted by accident.
-Thu Jan 11 23:28:05 1996 J.T. Conklin <jtc@rtl.cygnus.com>
- and Jim Kingdon <kingdon@harvey.cyclic.com>
+Thu Jan 30 11:46:33 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
- * fileattr.h (fileattr_startdir): Add comment about REPOS == NULL.
- * fileattr.c (fileattr_read, fileattr_write): Assert that
- fileattr_stored_repos != NULL.
- (fileattr_free): If fileattr_stored_repos is NULL, don't free it.
+ * logmsg.c, main.c, mkmodules.c, modules.c, parseinfo.c, patch.c:
+ Nuke more PATH_MAX.
-Thu Jan 11 18:03:21 1996 Karl Fogel <kfogel@floss.red-bean.com>
+ * server.c (server_updated): After we send Created or
+ Update-existing for a file, mark it as unchanged, in case we
+ process it again.
+ * sanity.sh (modules3): New tests, test for above fix.
- * scramble.c (descramble): deal with DIAGNOSTIC better.
+ * logmsg.c (do_verify): Error return from fopen is NULL, not -1.
+ Pass errno to error().
-Thu Jan 11 12:04:42 1996 Norbert Kiesel <nk@col.sw-ley.de>
+ * login.c [_CRAY]: Don't declare getpass.
- * main.c: remove CVS_NOADMIN.
+Mon Jan 27 17:25:27 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
- * options.h.in: remove CVS_NOADMIN
+ * import.c (process_import_file): Fix freeing of rcs (Don't free
+ it before we are done using it, and don't free it twice).
-Thu Jan 11 10:28:44 1996 Karl Fogel <kfogel@floss.red-bean.com>
+ * modules.c (cat_module): Allocate line right before we use
+ it. The previous code was wrong because the length of the
+ s_h->rest changes between the time we allocate line and the time we
+ sprintf s_h->rest into it.
- * scramble.c (descramble): make sure the string returned is safe
- to free().
+Sun Jan 26 21:58:16 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
-Wed Jan 10 01:11:23 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+ * expand_path.c (expand_path): Revise to call expand_string as
+ needed. Nuke PATH_MAX.
+ * find_names.c (find_dirs): Likewise.
+ * import.c, lock.c: Nuke more PATH_MAX.
- * server.c (serve_notify): Cast return value from malloc.
+ * server.c (mkdir_p): Set retval to 0 at start of function.
+ Previously it had been uninitialized for some cases. Thanks are
+ due to nightly testing for catching this one.
- * edit.c (notify_do): Use struct assignment, not struct
- initialization (which SunOS4 /bin/cc doesn't have).
+Sat Jan 25 21:34:19 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
-Tue Jan 9 09:41:29 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+ * subr.c, cvs.h (expand_string): New function.
+ * rcs.c (getrcskey, getrcsrev): Call it. This greatly reduces the
+ number of calls to realloc if there is a very large file in the
+ RCS file. Credit goes to Mike Heath <mike@pswtech.com> for
+ pointing out the problem and the basic solution (MIN_INCR,
+ MAX_INCR); I adapted it into the separate function expand_string.
+ * sanity.sh (big): New test helps insure this hasn't broken
+ anything obvious.
- * Version 1.6.85.
+Wed Jan 22 10:06:13 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
- We use version numbers instead of patchlevels. But there was some
- confusing patchlevel stuff lying around. Nuke it:
- * Makefile.in (HEADERS): Remove patchlevel.h
- * patchlevel.h: Removed.
- * main.c: Don't include patchlevel.h.
- (main): Don't print patch level.
+ * status.c (status_fileproc): Change message which is printed for
+ T_MODIFIED and ts_conflict set, so that it doesn't say "unresolved
+ confict". This message occurs whether the conflict is resolved or
+ not.
+ * sanity.sh (conflicts): Add tests conflicts-status-* to test
+ output of "cvs status" in the context of conflicts. Tests for
+ above fix.
- * server.c (check_repository_password): Check for errors from
- system calls; reindent function.
+ * rtag.c (rtag): Send -n if run_module_prog is NOT true.
-Tue Jan 9 23:15:30 1996 Karl Fogel <kfogel@floss.red-bean.com>
+Thu Jan 16 00:06:00 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
- * expand_path.c: fix comments (explain expand_path()'s behavior
- correctly).
+ * version.c: Change version number to 1.9.3.
-Tue Jan 9 09:41:29 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+ * version.c: Version 1.9.2.
- * edit.c (notify_proc): After copying in string following %s,
- don't clobber it. Instead set up q to end of string.
+Wed Jan 15 09:14:38 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
- * watch.c (watch_modify_watchers), edit.c (editor_set): Fix sense
- of test in trying to decide whether attributes are changed.
+ * client.c (call_in_directory): Take code that creates CVSADM at
+ top level, move it before the CVS_CHDIR (dir_name) call, and do it
+ regardless of whether dir_name is ".". Pass "." not dir_name to
+ Create_Admin (when the code was written they were always the
+ same). Don't add reposdirname to the repository we pass to
+ Create_Admin (when the code was written, I think reposdirname
+ probably would always be "."). Don't create CVSADM if
+ reposdirname_absolute.
+ * sanity.sh (basicb): Enable tests basicb-1a and basicb-9a for
+ remote; tests for above fix.
+ (basic1): Do entire test within a "1" directory to deal with
+ creation of CVS directories at top level. Support --keep.
+ (conflicts): In test conflicts-136, only update first-dir.
+ (basica): Uncomment the part that tests "cvs co -l .". That tests
+ the existing functionality which I might have (but hopefully did not)
+ perturbed with the call_in_directory changes.
- * cvs.h (CVSROOTADM_USERS): New macro.
- * edit.c (notify_do): Look up notifyee in CVSROOTADM_USERS if it
- exists.
+Mon Jan 13 11:04:32 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
-Tue Jan 9 21:39:45 1996 Karl Fogel <kfogel@floss.red-bean.com>
+ * server.c (check_command_legal_p): Do not call error (1, ...)
+ here; that will always cause a protocol violation by shutting down
+ the connection prematurely. Remove croak_on_illegal arg.
+ (do_cvs_command): Move call to check_command_legal_p until after
+ the call to print_pending_error. Print the error message ourself.
- * expand_path.c: don't redundantly #include things that cvs.h
- already #includes (i.e., stdio.h, ctype.h, string[s].h).
+ * mkmodules.c (filelist): Add readers and writers. Add comment
+ about why passwd is not included. Add comment about meaning of
+ NULL contents field.
-Tue Jan 9 09:41:29 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+Fri Jan 10 13:23:09 1997 Norbert Kiesel <nk@col.sw-ley.de>
- * ignore.c (ign_default): Add *.obj.
+ * release.c (release): Initialize delete_flag before reading it
+ (found by running purify)
- * server.c: Put /* */ around #endif comment.
+ * logmsg.c (do_verify): Fix reading unallocated memory (found by
+ running purify)
-Mon Jan 8 20:37:17 1996 Karl Fogel <kfogel@floss.red-bean.com>
+Thu Jan 9 16:32:47 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
- * client.c (connect_to_pserver): check return value of recv().
+ * checkout.c (build_dirs_and_chdir): Partially revert 3 Jan
+ change--move call to Subdir_Register back above the CVS_CHDIR call
+ (we need to register in the old, not the new, directory). Instead
+ of calling CVS_MKDIR and ignoring errors, call mkdir_if_needed;
+ this is an effort to catch errors there rather than catching them
+ in the CVS_CHDIR. This makes test 27-add-add in sanity.sh work
+ again.
+
+ * find_names.c (Find_Directories): Remove code inside
+ #ifdef ATTIC_DIR_SUPPORT and replace it with a comment explaining
+ why we don't look in the attic. ATTIC_DIR_SUPPORT was never defined.
+
+ * find_names.c (find_dirs): Add comment about tmp being unset.
+
+ * commit.c (checkaddfile): Report errors with errno and specific
+ error messages.
+
+ * rcs.c, commit.c, create_adm.c, entries.c, find_names.c,
+ ignore.c, history.c: Nuke PATH_MAX arbitrary limits.
+
+Wed Jan 8 23:07:41 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * add.c (add): Reindent a portion which needed it.
+
+1997-01-08 Jim Kingdon
-Mon Jan 8 11:37:57 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+ * client.c (send_file_names): When looking name up in Entries,
+ call Entries_Open and Entries_Close. This has two effects:
+ (1) we look at Entries.Log, and (2) we don't skip 'D' entries,
+ both of which are needed to make us get the right (command
+ line) name for a directory we are adding.
+
+Wed Jan 8 14:50:47 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * Makefile.in, cvs.h, hash.h, myndbm.h, rcs.h: Remove CVSid; we
+ decided to get rid of these some time ago.
- * client.c (connect_to_pserver): Check for error from connect;
- reindent function.
+Tue Jan 7 12:56:10 1997 Karl Fogel <kfogel@ynu38.ynu.edu.cn>
- * sanity.sh (4.75): Use dotest, so we get a PASS if test passes.
+ * root.c (check_root_consistent): new func, compares below new
+ global var with CVSroot_directory, assuming both set.
+ (set_local_cvsroot): use above new func for security check.
+ (parse_cvsroot): same.
+ But do all of above only #ifdef AUTH_SERVER_SUPPORT.
- * sanity.sh (dotest): New argument OUTPUT2.
- (188a): Use it instead of \|.
+ * server.c: (Pserver_Repos): new global var, init to NULL.
+ (pserver_authenticate_connection): set above new global.
+ (check_repository_password): be a good scout and use
+ CVSROOTADM and CVSROOTADM_PASSWD, now that they are the standard.
+ Make sure all of above is in #ifdef AUTH_SERVER_SUPPORT.
+ (check_command_legal_p): wrap most of body in #ifdef
+ AUTH_SERVER_SUPPORT.
+ Everywhere: wrap all references to CVS_Username in #ifdef
+ AUTH_SERVER_SUPPORT.
- * sanity.sh (import): Avoid using string $ followed by Id followed
- by $ in sanity.sh source, in case sanity.sh itself is under CVS.
- I hate keyword expansion.
+ * cvs.h (Pserver_Repos): new var, used in consistency [security]
+ check. Defined only #ifdef AUTH_SERVER_SUPPORT.
+ (CVSROOTADM_PASSWD): new #define, trying to get with the program.
- * sanity.sh: If expr cannot handle multiline expressions, fail and
- tell the user to get one which can.
+Fri Jan 3 18:10:39 1997 Ian Lance Taylor <ian@cygnus.com>
- * release.c (release_delete): Remove unused variable retcode.
+ * checkout.c (build_dirs_and_chdir): Move call to Subdir_Register
+ until after we know that the directory exists.
+
+Thu Jan 2 13:30:56 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
-Fri Jan 5 13:30:00 1996 Jim Kingdon <kingdon@peary.cyclic.com>
+ * Makefile.in, cvsbug.sh, edit.c, edit.h, error.c, error.h,
+ fileattr.c, fileattr.h, filesubr.c, run.c, update.h, watch.c,
+ watch.h: Remove "675" paragraph; see ../ChangeLog for rationale.
- * release.c (release_delete): Call unlink_file_dir rather
- than "rm -rf".
+Thu Jan 2 12:27:46 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
-Thu Jan 4 09:58:30 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+ * sanity.sh (info): New test info-cleanup-verifymsg gets rid of
+ verifymsg when we are done with it.
- * commit.c (find_fileproc): Print "nothing known about foo" and
- return 1 if the file doesn't exist and isn't in CVS/Entries.
- (commit): If the recursion over find_fileproc returns an error,
- print "correct above errors first!" just like local CVS.
- * sanity.sh (basica): Test for above-fixed bug.
+ * sanity.sh (basicb): Skip tests basicb-1a and basicb-9a for remote.
+ * sanity.sh (modules-155a4): It is OK if a CVS directory exists.
+ * sanity.sh (ignore): Do everything inside a "1" directory. The
+ change to create CVS directories at top-level causes messages such as
+ "? home" otherwise. In test 191, specify -I CVS so that new CVS
+ directory is ignored.
+ * sanity.sh (crerepos): Manually remove CVS directory which had not
+ existed before.
- * release.c (release): If we are the client, only unedit if the
- server supports it.
+Thu Jan 2 09:06:20 1997 Karl Fogel <kfogel@ynu38.ynu.edu.cn>
- * sanity.sh: Remove STARTANCHOR stuff; expr patterns are
- automatically anchored to the start. ENDANCHOR remains.
+ * server.c: Changes for pserver read-only repository access:
+ (check_command_legal_p): new func. Right now, just checks if
+ repository modification is permitted, and that only if pserver is
+ active.
+ (do_cvs_command): take new parameter `cmd_name', a string. All
+ callers changed. Pass it on to new func check_command_legal_p()
+ before executing the command.
+ (CVS_Username): new global, init to NULL. Used by
+ check_command_legal_p(), set in check_password().
+ (check_password): set above new global CVS_Username; reorganized a
+ bit to facilitate this.
+ (check_repository_password): give *host_user_ptr permanent
+ storage iff success.
- * commit.c (commit): Don't start the server until we have
- determined that there is something to commit.
+ * main.c: Changes for pserver read-only repository access:
+ (lookup_command_attribute): new func.
+ (main): use new func lookup_command_attribute() to establish if
+ CVS_CMD_IGNORE_ADMROOT and CVS_CMD_USES_WORK_DIR.
-Thu Jan 4 09:48:33 1996 Ben Laurie <ben@gonzo.ben.algroup.co.uk>
- and Jim Kingdon <kingdon@harvey.cyclic.com>
+ * cvs.h: Changes for pserver read-only repository access:
+ (CVSROOTADM_READERS, CVSROOTADM_WRITERS): new #defines.
+ Prototype lookup_command_attribute().
+ (CVS_CMD_IGNORE_ADMROOT, CVS_CMD_USES_WORK_DIR,
+ CVS_CMD_MODIFIES_REPOSITORY): new #defines for
+ lookup_command_attribute() and its callers.
- * client.c (start_server): dup the file descriptor before
- fdopening it.
+Wed Jan 1 19:50:38 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
-Wed Jan 3 18:25:25 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+ * options.h.in: Reword comment for TMPDIR_DFLT to make it clear
+ that this isn't specific to the pserver server.
- * sanity.sh: Remove tests 5, 5.5, and 5.75. All that stuff is
- tested elsewhere.
+ * modules.c (do_module): Give an error message if one tries to
+ specify -a together with another option.
+ * sanity.sh (modules2): New tests modules2-a* test for above fix.
- * ignore.c (ign_default): Change CVS* to CVS CVS.adm. CVS* is too
- broad, especially in a case-insensitive filesystem.
+ * sanity.sh (devcom): Add tests devcom-a-nonexist and
+ devcom-t-nonexist for "cvs watchers" on nonexistent argument.
- * Makefile.in (cvsbug): version.c is in srcdir.
+1997-01-01 Fred Fish <fnf@ninemoons.com>
-Wed Jan 3 17:30:45 1996 Phi-Long Tran <ptran@autodesk.com>
+ * run.c (piped_child, filter_stream_through_program): Actually
+ install these HAVE_VFORK patches that got missed.
+ (There was a log entry for these changes for 29 Nov 1996 but it
+ seems I accidentally forgot to actually check them in -kingdon).
- * modules.c (do_module): Honor error_use_protocol in printing trace.
- * server.c (server_register): Move check for options NULL to above
- printing of the trace.
+Wed Jan 1 18:32:44 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
-Wed Jan 3 01:19:53 1996 Mark Immel <immel@centerline.com>
- and Jim Kingdon <kingdon@harvey.cyclic.com>
+ * Makefile.in: Add ChangeLog-96.
+ * ChangeLog-96: New file, contains former contents of ChangeLog.
+ * ChangeLog: Now just contains 1997 changes.
- * update.c (checkout_file): Do not resurrect file on join if it
- doesn't contain the revisions we are joining. Probably not a
- perfect test, but should be an improvement.
- * sanity.sh (death): New death-file4-* tests, for bug fixed above.
-
-Wed Jan 3 01:19:53 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
-
- * add.c, admin.c, checkout.c, client.c, commit.c, diff.c, edit.c,
- history.c, import.c, log.c, patch.c, release.c, remove.c, rtag.c,
- status.c, tag.c, update.c, watch.c: In calling send_to_server,
- pass \012 not \n. On the Mac \n is CR, not LF, and we want to
- send LF. I didn't try to deal with whether files in CVSADM should
- contain CR or LF--in fact there is some code in client.c which
- reads \n from CVSADM files and passes it to send_to_server; it
- needs to be cleaned up one way or the other.
-
- * entries.c (Entries_Open): Don't try to close fpin twice.
-
- * client.c (update_entries): Fix typo ("strlen (filename + 10)"
- -> "strlen (filename) + 10").
-
- * commit.c (checkaddfile): Remove arbitrary limit.
-
-Tue Jan 2 11:25:22 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
-
- * commit.c (commit): Only pass files which were modified, added,
- or removed to send_file_names. This has as a side effect a
- semantic change--the up-to-date check is now skipped for other
- files--but probably a good one, or at least not a bad one.
- * sanity.sh (basica): New test; tests for bug fixed above.
- * sanity.sh (187a3): Adjust for new 'cvs commit' output. Set up
- DOTSTAR to match arbitrary text (another GNU expr bug/misfeature,
- sigh).
-
- * sanity.sh: Test that the commit in test 43 actually worked.
- Merge tests basic2 and basic3 and make them independent of basic1.
- (pass,fail): Don't insert spurious space.
- (45.5): Fix typo in directory name.
-
-Tue Jan 2 13:00:00 1996 Jim Kingdon <kingdon@peary.cyclic.com>
-
- Visual C++ lint:
- * myndbm.c: Prototype write_item.
-
-Tue Jan 2 11:25:22 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
-
- gcc -Wall lint:
- * client.c (client_expand_modules): Pass error message not "" to error.
- * client.c (supported_request), server.c (supported_response):
- Return a value (gcc -Wall can't know that error doesn't return).
- * commit.c (copy_ulist): Return a value.
- * history.c (fill_hrec): Don't make assumptions about whether
- time_t is "int" or "long" or what.
- * cvs.h: Declare link_file.
- * server.c: Include fileattr.h.
- * server.c (server_notify): Remove unused variable val.
- * tag.c (val_fileproc): Remove unused variable foundtag.
-
-Mon Jan 1 09:49:16 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
-
- * Version 1.6.5.
-
- * Version 1.6.4.
-
- * filesubr.c (link_file): Add comment about link vs. copy semantics.
-
- * cvs.h (struct vers_ts): Fix comments.
- * commit.c (commit): Before we ask for a log message, figure out
- what is modified and what is not and pass the information to
- do_editor.
- (copy_ulist,find_fileproc): New helper functions for above code.
-
- * client.c (read_line): When writing to from_server_logfile, write
- the \n too.
-
- * client.c (send_files): No longer call send_file_names.
- * client.h: Update comment.
- * add.c, admin.c, commit.c, diff.c, edit.c, log.c, remove.c,
- status.c, tag.c, update.c, watch.c: Call send_file_names before
- send_files.
- * client.c: New variables module_argc, module_argv.
- (client_expand_modules): Set them, to arguments.
- (client_send_expansions): Use them instead of modules_vector to
- send arguments.
- * sanity.sh (modules): Add test of modules -d flag.
-
-
-For older changes see ChangeLog-9395.
+
+For older changes see ChangeLog-96.
diff --git a/contrib/cvs/src/ChangeLog-96 b/contrib/cvs/src/ChangeLog-96
new file mode 100644
index 0000000..6c3a2a1
--- /dev/null
+++ b/contrib/cvs/src/ChangeLog-96
@@ -0,0 +1,4434 @@
+Mon Dec 30 15:43:48 1996 Abe Feldman <feldman@harvey.cyclic.com>
+
+ * checkout.c (build_dirs_and_chdir): Reproduced block containing
+ Create_Admin, placing it before Subdir_Register.
+ * sanity.sh (basicb): Added tests 1a and 9a to test above changes
+ to the checkout command.
+
+Mon Dec 30 13:29:14 1996 uz@wuschel.ibb.schwaben.com (Ullrich von Bassewitz)
+ and Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * cvs.h (CVSEDITPREFIXLEN): New define.
+ * logmsg.c (do_editor): Use CVSEDITPREFIXLEN when deciding whether
+ to strip off CVSEDITPREFIX and when telling the user what we will
+ strip off.
+
+Sun Dec 22 22:06:49 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * logmsg.c (do_verify): If noexec, skip the verification *without*
+ printing a message. Use cvs_output not printf. Skip verification
+ for client_active.
+
+Wed Dec 18 12:27:35 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * repos.c (Name_Repository): Add comment regarding wording of
+ "*PANIC*" error message.
+
+1996-12-18 Jim Kingdon
+
+ * client.c (call_in_directory): If the directory we are about
+ to create is the same as CVSADM as seen by fncmp (for example,
+ it is "cvs" and filenames are case-insensitive), then give a
+ fatal error.
+
+Tue Dec 17 13:14:22 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * options.h.in: Add comments about SETXID security holes.
+
+ * logmsg.c (do_verify): Reindent comments. Check errno if return
+ code from run_exec is -1, not if it is 1.
+ * sanity.sh (info): Move tests info-4 and info-8 to end and rename
+ them. Add verifymsg tests. Instead of forcibly removing loginfo,
+ remove it nicely (test info-11).
+
+Tue Dec 17 12:45:32 1996 Abe Feldman <feldman@cyclic.com>
+
+ * commit.c, import.c: Call do_verify as well as do_editor.
+ * cvs.h (CVSROOTADM_VERIFYMSG): Define.
+ * logmsg.c, cvs.h (do_verify, verifymsg_proc): New functions.
+ (verifymsg_script): New variable.
+ * mkmodules.c (filelist): Add CVSROOTADM_VERIFYMSG.
+
+Mon Dec 16 13:24:47 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * lock.c (remove_locks): New static function, copied from part of
+ Lock_Cleanup.
+ (Lock_Cleanup): Call remove_locks.
+ (Writer_Lock): Call remove_locks rather than Lock_Cleanup when
+ waiting for a lock.
+
+Thu Dec 12 10:36:37 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * login.c (get_cvs_password): If CVS_PASSWORD is set, print a
+ warning (and then proceed to ignore it). It was a documented
+ feature, so we should point people who were using it to the
+ replacement.
+
+Mon Dec 9 12:35:43 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * server.c (server_updated): Change comment to only worry about
+ umask in the rsh case.
+ (server): Create the temporary directory, and change the mode to
+ S_IRWXU.
+ (switch_to_user): Set the umask to 0, not 077.
+
+Mon Dec 9 10:58:28 1996 Jim Blandy <jimb@floss.cyclic.com>
+
+ * login.c (get_cvs_password): Remove code to check for value of
+ CVS_PASSWORD. Keeping cleartext passwords in environment
+ variables is a really bad idea on Unix, since anyone can print
+ out a processes' environment using 'ps' (on BSD variants
+ anyway). Update help message.
+
+Fri Dec 6 15:59:40 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * sanity.sh: When matching "use .cvs commit. to remove this file
+ permanently" messages, change "cvs" to "${PROG}".
+ (rdiff, binfiles): Likewise.
+ This fixes testing a program named something other than "cvs", e.g.
+ $ cp cvs cvs-test
+ $ /bin/sh <srcdir>/sanity.sh `pwd`/cvs-test
+
+1996-12-02 Jim Kingdon
+
+ * client.c: In comment saying that socket buffers don't
+ implement the blocking routine, say they are blocking.
+ * buffer.h (struct buffer): In description of input function,
+ describe blocking, non-blocking, and NEED more fully. Say
+ what happens if we read a nonzero amount less than NEED and
+ then get end of file.
+ * client.c (socket_buffer_input): If NEED == 0, still call
+ recv (once). Handle the case where recv returns 0.
+
+Sat Nov 30 15:10:07 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * subr.c, cvs.h (file_has_markers): New function.
+ * rcs.h (RCS_MERGE_PAT): Now a fixed string not a regexp.
+ * options.h.in (GREP): Removed; no longer used.
+ * update.c (update_fileproc), commit.c (check_fileproc): Call
+ file_has_markers rather than GREP.
+ * rcscmds.c (RCS_merge): Just give a fatal error in the case where
+ we had been calling GREP. I suspect noone is using this code
+ any more.
+ * sanity.sh (conflicts): Rewrite tests 131, 132, and 133 to use
+ dotest; tests that the above changes didn't break anything.
+
+Fri Nov 29 09:06:41 1996 fnf@ninemoons.com (Fred Fish)
+ and Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * checkout.c (safe_location): Only call readlink if HAVE_READLINK.
+
+ * run.c (piped_child, filter_stream_through_program): If
+ HAVE_VFORK, call vfork not fork.
+ * run.c (run_exec): Add comment about why we use vfork.
+
+Mon Nov 25 12:48:31 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * release.c (release): Don't return after processing the first
+ argument; that kind of defeats the purpose of having a loop, eh?
+ For client, close the connection after we've processed them all.
+ * sanity.sh: Remove workaround for modules2-8 test; tests for
+ above fix. Adjust modules2-6 test to answer both questions.
+
+ * login.c: Reindent (all of get_cvs_password, a handful of lines
+ elsewhere).
+
+ Cleanups to release, mostly cosmetic:
+ * release.c (release_server): New function; breaks out server code
+ from the release function.
+ * release.c: Move delete_flag inside the release function.
+ * release.c (release): Reindent. Rewrite comments about how the
+ implementation could be improved. Don't declare variables as
+ "register". Include errno in error message. Don't cast result of
+ printf to void. Remove unused variable srepos.
+ * release.c: Remove comments at top of file about what it does.
+ They were not particularly coherent and they were also out of date
+ (I think). Likewise for comment in release function about "if we
+ are in a repository".
+ * release.c: Change "module" to "directory" in a few messages
+ since that is what is meant.
+ * sanity.sh: In tests ignore-195 and ignore-193, change expected
+ message accordingly.
+
+Sun Nov 24 11:30:55 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * sanity.sh: Clarify a few items in the todo list.
+
+ * log.c (log_parse_date): Use the "end" of the epoch not "next
+ week" as the time which means "no end time".
+ * sanity.sh (rcs): New test, tests dates and importing RCS files.
+
+1996-11-19 Jim Kingdon
+
+ Visual C++ lint:
+ * hash.c: Declare qsort_comp.
+ * update.c: Declare isremoved.
+
+1996-11-19 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * root.c, repos.c, modules.c, create_adm.c: Change all calls to
+ strip_path to strip_trailing_slashes. Basically strip_path is
+ just an unneeded complication (we should keep the pathname the way
+ the user specifies it, and the system can worry about things like
+ consecutive /'s if it wants to). Stripping trailing slashes is
+ potentially dubious for the same reason, but it is a somewhat
+ different case which I won't try to tackle now.
+ * cvs.h (strip_path): Remove declaration.
+
+Tue Nov 19 15:18:13 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ There are a lot of details to this change, but the concept is
+ relatively simple: make it so that for every CVSLCK lock that we
+ might take out, there is a flag which is set iff we have created
+ the CVSLCK directory.
+ * lock.c (struct lock): New structure.
+ * lock.c: Remove static variables repository and cleanup_lckdir.
+ They are replaced by global_readlock.repository and
+ global_readlock.have_lckdir, respectively (except insofar as the
+ rest of these changes change the concept of cleanup_lckdir).
+ New static variable global_readlock.
+ (Reader_Lock, Lock_Cleanup): Use global_readlock in place of
+ repository.
+ (lock_simple_remove, set_lock, clear_lock, write_lock): Take a
+ struct lock * instead of just a repository. Set/clear
+ lock->have_lckdir instead of cleanup_lckdir.
+ (set_writelock_proc, unlock_proc): Pass ->data, not ->key, to
+ write_lock or lock_simple_remove.
+ (lock_filesdoneproc,lock_dir_for_write): Allocate a struct lock,
+ put it in the ->data field, and fill in its fields.
+ (lock_simple_remove): Use lock->have_lckdir as the sole test for
+ whether the CVSLCK directory needs to be removed. Add
+ comments about why readlock and writelock variables don't tell us
+ for sure whether locks exist.
+ (lock_simple_remove, clear_lock): Use SIG_beginCrSect and
+ SIG_endCrSect to ensure that ->have_lckdir is set to 0 iff the
+ CVSLCK directory was really removed.
+ (lock_simple_remove): Check for errors removing CVSLCK directory.
+ (lock_simple_remove, Check_Owner, set_lock): Remove all code which
+ checks userids (including all of Check_Owner and all the AFCVS
+ code). It was bogus if several CVS processes with the same userid
+ were running (common if several users share a userid; a common
+ practice with remote CVS), and with the rest of the changes here
+ should not be needed.
+
+1996-11-16 Paul Eggert <eggert@twinsun.com>
+
+ * rcs.c (RCS_deltas): Fix unintended trigraphs.
+
+Fri Nov 15 13:06:03 1996 Tom Hageman <tom@basil.icce.rug.nl>
+
+ * diff.c (diff_fileproc): In printing error messages, use the
+ correct filename for which the error occurred.
+
+Sun Nov 10 21:13:38 1996 Paul Sanders <p.sanders@dial.pipex.com>
+ and Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * server.c: Use all the right cruft which goes along with
+ including sys/time.h.
+
+ * server.c: Include a "copyright" notice.
+
+ * server.c: If HAVE_WINSOCK_H, include winsock.h.
+
+ * server.c (server): Only set a handler for SIGHUP if it is
+ defined. Likewise for all the other signals.
+
+ * server.c (do_cvs_command): Use DEVNULL not /dev/null.
+
+Fri Nov 08 12:14:20 1996 Jim Kingdon
+
+ IBM ICC (OS/2) lint:
+ * add.c (add): Only declare begin_added_files if
+ SERVER_SUPPORT.
+ * client.c (init_sockaddr): Change port argument from
+ unsigned short to unsigned int. Change hostname
+ argument from const char * to char *.
+
+Sun Nov 3 18:24:28 1996 Noel Cragg <noel@gargle.rain.org>
+
+ * sanity.sh (info): add new tests that check behavior of format
+ string substitution in loginfo file.
+
+Sat Nov 2 09:39:09 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * client.c (do_deferred_progs): Don't access memory once it is
+ freed (we already did it right for checkin_progs; do the same
+ thing for update_progs).
+
+ * update.c, client.c, classify.c, client.h, diff.c, commit.c,
+ create_adm.c: Nuke more PATH_MAX.
+
+Fri Nov 1 18:22:32 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * error.h: Define PROTO if it is not defined.
+
+Wed Oct 30 08:53:20 1996 jalving@ibm.net
+
+ * patch.c (patch_fileproc): Set line1 and line2 to NULL up-front
+ (before the first "goto out") so we don't try to free them.
+
+Wed Oct 30 08:53:20 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * commit.c (remove_file, commit_filesdoneproc), run.c (run_print,
+ run_exec), modules.c (open_module, cat_module, do_module), update.c
+ (update_dirleave_proc), tag.c (tag_fileproc): Call cvs_out* rather
+ than stdio.
+ * server.c (serve_expand_modules): Remove comment about do_module
+ writing to stdout/stderr; above changes should fix this.
+
+Tue Oct 29 17:23:59 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * status.c (tag_list_proc): When printing the tag name, don't
+ truncate it to 25 characters.
+
+Tue Oct 29 12:49:07 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * add.c, checkin.c, checkout.c, filesubr.c: Nuke arbitrary limit
+ of PATH_MAX. Many more such limits surely remain.
+
+ * fileattr.c (fileattr_set): Set attrs_modified *after* we might
+ call fileattr_read, because fileattr_read clears it.
+ * sanity.sh (devcom2): New tests, test for above fix and other
+ behaviors I discovered in the process of looking into it.
+
+Mon Oct 28 08:55:57 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ The following changes are to ensure that SYSTEM_CLEANUP is always
+ called.
+ * error.c, cvs.h, main.c: Remove error_set_cleanup and related
+ machinery. It was for a time when error.c was intended to be
+ shared with other programs, but that is no longer true.
+ * error.c, error.h (error_exit): New function; like error_cleanup
+ from main.c but also calls SYSTEM_CLEANUP and exit (EXIT_FAILURE).
+ * error.c (error, fperror): Call error_exit instead of doing it
+ ourself.
+ * server.c (server, serve_valid_responses, switch_to_user,
+ check_password, pserver_authenticate_connection,
+ kserver_authenticate_connection): Call SYSTEM_CLEANUP before exit.
+ * add.c, client.c, import.c, main.c, mkmodules.c, modules.c,
+ recurse.c, server.c, tag.c, update.c: Call error_exit ()
+ instead of exit (EXIT_FAILURE).
+
+Sun Oct 27 08:34:16 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * sanity.sh (conflicts): New test 128.5 tests "cvs co -p" in an empty
+ directory (like 126.5), but when the file has nonempty contents.
+ * rcs.c (RCS_checkout): If writing to stdout, use cvs_output
+ rather than fwrite.
+ * update.c (checkout_file): Call cvs_stderr not fprintf.
+ These changes should fix some out-of-order bugs which show up in
+ situations like conflicts-126.5 and conflicts-128.5.
+
+ * mkmodules.c (checkout_file): Call RCS_checkout rather than
+ run_exec on RCS_CO.
+
+Sat Oct 26 18:29:46 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * sanity.sh (rdiff): cd out of testimport directory and remove it
+ when done.
+
+ * sanity.sh (info): Adjust tests to reflect fact that loginfo was
+ created by cvs init.
+
+ * sanity.sh (ignore): Change test 187a1 to allow any number of
+ files in CVSROOT, not just modules.
+
+ * sanity.sh (modules): In tests 148a0 and 148a1, don't expect a
+ module which defines CVSROOT to itself, since we don't define one
+ any more. Also change test to rewrite modules rather than append
+ to it (in case any previous tests are changed to do something with
+ modules). Change test 155b to allow any number of files in
+ CVSROOT, not just modules.
+
+ * add.c (add_directory): Set rev_old and rev_new fields of struct
+ logfile_info to NULL (prevents us from trying to free them later).
+ * commit.c (find_fileproc), import.c (import): Likewise.
+
+ * sanity.sh (crerepos): New tests, to test alternate ways of
+ creating a repository and related matters.
+ * sanity.sh: Remove tests 1 through 3 and related cruft; replace
+ them with a new test 1 which merely tests "cvs init". By doing
+ the obscure stuff in crerepos we avoid having to do all this stuff
+ any time we run any single test.
+
+Sat Oct 26 16:19:48 1996 Jim Blandy <jimb@totoro.cyclic.com>
+
+ * main.c (main): If HAVE_TZSET is #defined, call tzset. This is
+ harmless on all systems I know of, and required on some.
+
+Fri Oct 25 13:20:44 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * diff.c (diff_file_nodiff): When setting use_rev1, only return
+ DIFF_SAME if empty_file is DIFF_DIFFERENT and ts_user is not
+ NULL. Don't get confused by a vn_user field of "0" or one
+ starting with '-'.
+ * sanity.sh (death2): Add new death2-diff-{1,2,7,8} tests for
+ above patch. Renumber existing death2-diff tests to make room.
+
+Fri Oct 25 12:38:29 1996 Jim Wilson <wilson@cygnus.com>
+
+ * sanity.sh (death2): In tests death2-diff-{2,4,6,8,10}, allow "_"
+ in temp file names. The system (tmpnam or whatever) generates
+ these names so they vary from system to system.
+
+Fri Oct 25 07:52:44 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * logmsg.c (logfile_write): Give an error for several cases which
+ should not be legal. Adjust comments accordingly.
+ * mkmodules.c (loginfo_contents): Make description of loginfo much
+ more concise. This should be a reminder, not full documentation.
+
+Tue Oct 22 10:37:37 1996 Noel Cragg <noel@gargle.rain.org>
+
+ * commit.c (update_delproc): free structure members rev_old and
+ rev_new if they have been allocated.
+
+ * mkmodules.c: change loginfo_contents to include a description of
+ the new format string.
+
+ * logmsg.c (logfile_write): change syntax of format string.
+
+Sat Oct 19 16:09:55 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ For reference, this takes CVS's text segment from 348348 bytes to
+ 347420 bytes.
+ * server.c (requests): Change Directory to rq_essential
+ per change in doc/cvsclient.texi.
+ * client.c: Remove use_directory and all code which executed if
+ it wasn't set. This includes the get_short_pathname function.
+ * server.c: Likewise, for use_dir_and_repos.
+ (serve_repository): Give a fatal error.
+ * server.c (requests): Remove Lost. Change Unchanged to rq_essential.
+ (serve_lost): Removed.
+ * server.c, server.h, client.c, vers_ts.c: Remove use_unchanged,
+ code to set it, and all code which executed if it wasn't set.
+
+Sat Oct 19 12:44:08 1996 J. Richard Sladkey <jrs@world.std.com>
+ and Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * hash.c (sortlist, new function qsort_comp): Rewrite to use qsort
+ instead of insert sort. Changes algorithm from n^2 to n log n
+ (assuming qsort is implemented with quicksort or similar).
+
+Sat Oct 19 12:44:08 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * sanity.sh (basic2): In test basic2-64, use -x and specify types
+ which exclude E; the test is not built to deal with E (or any
+ other new types).
+
+Sat Oct 19 12:00:00 1996 Mark Mitchell <mmitchell@usa.net>
+ and Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * update.c (isemptydir, new function isremoved): Avoid pruning
+ directories that contain files marked for removal but not
+ comitted.
+ * update.c, update.h (isemptydir): Now extern, not static.
+ * update.c (isemptydir): New parameter might_not_exist handles
+ difference in functionality from old client_isemptydir. Bring
+ over the improved error checking from client_isemptydir.
+ * client.c (client_isemptydir): Removed; isemptydir now suffices.
+ * update.c (update_dirleave_proc), client.c
+ (process_prune_candidates): Update callers.
+ * sanity.sh (deep): Add tests deep-rm* for above fix.
+
+Fri Oct 18 15:53:41 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * sanity.sh (devcom): Add tests devcom-some* to test watching just
+ a single file.
+
+ * root.c (Name_Root): Use isabsolute to test whether a pathname is
+ absolute instead of checking for the first character being '/'.
+ (Reported by Antoine P. Brusseau <brusseau@jprc.com>).
+
+ * commit.c (checkaddfile): Free rev only if it is non-NULL (thanks
+ to cwong@world.std.com (Christopher Wong) for diagnosing this; the
+ death2-15 test in sanity.sh hits it).
+
+Thu Oct 17 15:21:56 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * sanity.sh: Reenable rdiff tests. Delete rdiff-9 test to reflect
+ the fact that the change to add a -K option has not been
+ incorporated. Adjust rdiff-8 test to reflect the fact that the
+ change to change the default keyword expansion for the first
+ revision has not been incorporated.
+ * patch.c (patch_fileproc): Pass the symbolic revision to
+ RCS_checkout so that Name can be expanded correctly. Reinstates
+ one of the 30 Sep 96 changes and fixes a bug which the sanity.sh
+ rdiff test tests for.
+
+ Reinstate change from 30 Sep 96:
+ * patch.c (patch): CLIENT_SUPPORT: send '-f' if NOT force_tag_match
+
+ * client.c (process_prune_candidates): Do not ignore errors from
+ unlink_file_dir.
+
+ * filesubr.c (deep_remove_dir): If rmdir returns an error other
+ than ENOTEMPTY or EEXIST, return -1 not 0. Add workaround for AIX
+ header bug.
+
+Tue Apr 30 08:21:27 1996 Mike Sutton <mike_sutton@dayton.saic.com>
+
+ * checkout.c, history.c: added logging/reporting of cvs export
+ command
+
+Wed Oct 16 10:16:57 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * sanity.sh: Remove tests 4, 4.5, and 4.75; this functionality is
+ already tested by 45, 45.5 and other tests.
+ (ignore): New tests ignore-192, ignore-193, ignore-194, and
+ ignore-195 test output from "cvs release".
+ (modules2): New tests modules2-6, modules2-7, and modules2-8 test
+ ability of cvs release to handle multiple arguments. Since it
+ currently doesn't, the tests are kludged.
+
+ * server.c, cvs.h (cvs_flushout): New function.
+ * recurse.c (do_file_proc): Call it.
+ * server.c (cvs_outerr): Call fflush (stdout) in non-server case.
+ * main.c (main): Don't call setvbuf. The code was incorrectly
+ checking for "patch" (it really is "rdiff"); the concern about
+ slowing down large amounts of output is not specific to rdiff
+ (it applies to "log" for example); and the above changes should
+ meet the need.
+
+Tue Oct 15 10:22:10 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ This is intended to facilitate some future cleanups to the
+ locking, but by itself it is a simple, conversative rearrangement:
+ * tag.c (locked_dir, locked_list): Move from here...
+ * lock.c: ...to here.
+ * lock.c (Lock_Cleanup): If locked_dir is set clean it up too.
+ * tag.c (tag_unlockdir): Removed; with the above change
+ Lock_Cleanup suffices.
+ * tag.c (tag_lockdir): Move from here...
+ * lock.c (lock_dir_for_write): ...to here.
+ * tag.c (tag_fileproc), rtag.c (rtag_fileproc): Update callers.
+ Move comments concerning why we are locking what we are from
+ tag_lockdir to here.
+ * tag.c (tag_filesdoneproc), rtag.c (rtag_filesdoneproc):
+ Update callers.
+ * lock.c (Writer_Lock): Made static.
+ * cvs.h: Update declarations.
+ * server.c (server_notify): Call lock_dir_for_write rather than
+ calling Writer_Lock ourselves.
+
+ This is intended to facilitate some future cleanups to the
+ locking, but by itself it is a simple, conversative rearrangement:
+ * lock.c (Lock_Cleanup): Also dellist (lock_tree_list).
+ * lock.c, cvs.h (lock_tree_cleanup): Removed; with the above change
+ Lock_Cleanup suffices.
+ * commit.c, edit.c, watch.c: Change callers.
+
+Sat Oct 12 21:41:46 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * sanity.sh (deep): Add comment about whether the deep-4b behavior
+ is considered desirable.
+
+Sat Oct 12 20:36:36 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * client.c (client_send_expansions): Add build_dirs parameter.
+ Change all callers.
+ (send_dirent_proc): Get build_dirs from callerdat; if it is
+ zero, don't send a nonexistent directory to the server.
+ (send_files): Add build_dirs parameter. Change all callers.
+ * client.h (send_files): Update prototype.
+ (send_files_contents): Remove prototype for nonexistent function.
+ (client_send_expansions): Update prototype.
+ * sanity.sh (deep): Add deep-4b test for above patch.
+
+Fri Oct 11 14:07:12 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ gcc -Wall lint:
+ * logmsg.c (title_proc): Remove unused variables title and comma.
+
+ * sanity.sh (modules2): Don't be picky about whether we are
+ checking in 1.3 or 1.2 of modules; it depends on whether we are
+ running all the tests or just some.
+
+Thu Oct 10 14:52:06 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * server.c, server.h (server_dir): New variable.
+ (output_dir): If it is set, send it before the directory name.
+ * modules.c (do_module): Set it, in the case of & modules, and
+ restore it when done.
+ * sanity.sh (modules): Don't clean up first-dir before starting;
+ tests now clean up for themselves at the end.
+ (modules2): New tests, for above fix.
+
+Wed Oct 9 15:52:34 1996 Jim Blandy <jimb@totoro.cyclic.com>
+
+ * sanity.sh: Barf immediately if run as root.
+
+ * rcs.c (RCS_getrevtime): When giving a date to get_date, use the full
+ year, not the year - 1900, so that dates after 1999 are parsed
+ correctly. (Change thanks to Paul Eggert.)
+
+Wed Oct 9 10:59:11 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ Clean up gcc -Wmissing-prototypes lint:
+ * cvs.h (admin, add, checkout, commit, diff, history, import,
+ cvslog, login, patch, release, cvsremove, rtag, status, tag):
+ Declare.
+ * server.c, main.c: Don't declare them here. Don't declare update
+ either (which is already declared in cvs.h).
+ * tag.c, cvs.h, main.c, server.c: Rename tag to cvstag to avoid
+ name conflicts.
+ * client.c (init_sockaddr, auth_server_port_number), entries.c
+ (Entnode_Create, Entnode_Destroy), hash.c (nodetypestring),
+ login.c (construct_cvspass_filename), server.c
+ (supported_response), wrapper.c (wrap_matching_entry): Make static;
+ prototype.
+ * hash.c (printlist): Prototype.
+ * myndbm.c (mydbm_load_file): Change declaration to prototype.
+
+Tue Oct 8 22:35:34 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * sanity.sh (log2): Re-add these tests; they were deleted for 1.9
+ (because they were thought to be destabilizing and/or due to
+ confusion/accident), but they can be put back now.
+
+ * sanity.sh (death2): In tests death2-diff-{2,4,6,8,10}, allow "-"
+ or "%" in temp file names. The system (tmpnam or whatever)
+ generates these names so they vary from system to system.
+
+Tue Oct 8 12:37:09 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * options.h.in (HAD_RCS4): Remove; no longer used.
+
+Sun Oct 6 15:58:11 1996 Noel Cragg <noel@gargle.rain.org>
+
+ * The following changes address problem #56 in the GNATS database
+ on harvey.cyclic.com:
+
+ * logmsg.c (str_list_format): new global -- contains the format
+ for items to be placed in str_list.
+ (Update_Logfile): move code that creates the "title" string...
+ (logfile_write): ...to here. Pull apart the filter program and
+ look for a format string, extracting it if there is one.
+ (title_proc): write a given filename/value based on the format
+ string.
+
+ * commit.c (classify_file_internal): new routine, old code (needed
+ to use the code in more than one place). Determines the status
+ and version information about a file.
+ (check_fileproc): use classify_file_internal. Fill in the rev_old
+ field for the struct logfile_info.
+ (commit_fileproc): Fill in the rev_new field.
+
+ * cvs.h (struct logfile_info): add two new fields -- rev_old and
+ rev_new -- that keep track of revision numbers across commits.
+
+Fri Sep 27 15:21:47 1996 Peter Wemm <peter@spinner.dialix.com>
+
+ * logmsg.c (do_editor): Do not use editinfo if running on the client.
+
+Fri Oct 4 15:11:46 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * server.c (server_cleanup): Temporarily clear noexec when calling
+ unlink_file_dir. This is so we clean up the temp directory even
+ when the -n global option is specified.
+
+Wed Oct 2 10:47:33 1996 Norbert Kiesel <nk@col.sw-ley.de>
+
+ * client.c (send_repository): initialize some variables before
+ first usage
+
+Tue Oct 1 13:01:24 1996 Jim Blandy <jimb@floss.cyclic.com>
+
+ Revert some of Greg's changes; they're welcome later, but we're
+ trying to keep CVS stable for pre-release testing at the moment.
+ * checkin.c, commit.c, cvs.h, diff.c, import.c, main.c, no_diff.c,
+ options.h.in, patch.c, rcs.c, rcs.h, rcscmds.c, sanity.sh, update.c:
+ Revert changes of Sep 29 and 30.
+
+Tue Oct 1 13:17:31 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ Make sure the server temporary directory is removed even if
+ Max-dotdot is used.
+ * server.c (orig_server_temp_dir): New static variable.
+ (serve_max_dotdot): Don't free server_temp_dir if it is the same
+ as orig_server_temp_dir.
+ (do_cvs_command): Use orig_server_temp_dir in error message.
+ (server_cleanup): Remove orig_server_temp_dir.
+ (server): Set orig_server_temp_dir. Remove incorrect indentation
+ of error message.
+
+ * import.c (update_rcs_file): Restore new argument to
+ RCS_checkout, removed in last patch.
+
+Tue Oct 1 00:32:55 1996 Jim Blandy <jimb@floss.cyclic.com>
+
+ * import.c: Revert Greg Woods' changes of Sep 30. We may want
+ them later, but not before 1.9.
+
+Mon Sep 30 23:31:01 1996 Jim Blandy <jimb@floss.cyclic.com>
+
+ * log.c (log_fileproc): Now that we might actually find a "desc"
+ node in rcsfile->other, thanks to Ian's change below, we had
+ better deal correctly if we find a null pointer in it.
+
+Mon Sep 30 13:55:03 1996 Greg A. Woods <woods@most.weird.com>
+
+ * main.c (main): don't set need_to_create_root for "cvs init"
+ either, just in case it's run from within a valid working
+ directory.
+
+ * sanity.sh (testcvs): oops, forgot to comment out test version I
+ was using...
+
+ * diff.c (diff_fileproc): use Diffbin instead of DIFF (3).
+ * patch.c (patch_fileproc): use Diffbin instead of DIFF.
+ * commit.c (check_fileproc): use Grepbin instead of GREP.
+ * rcscmds.c (RCS_merge): use Grepbin instead of GREP.
+ * update.c (patch_file): use Diffbin instead of DIFF.
+ (update_fileproc): use Grepbin instead of GREP.
+ * cvs.h (Diffbin): new declaration.
+ (Grepbin): new declaration.
+ (DIFFBIN_ENV): new manifest to name DIFFBIN environ var.
+ (GREPBIN_ENV): new manifest to name GREPBIN environ var.
+ * option.h.in (DIFFBIN_DFLT): renamed from DIFF.
+ (GREPBIN_DFLT): renamed from GREP.
+ * main.c (main): new variables diffbin_update_env and
+ grepbin_update_inv, ala rcsbin_update_env.
+ (main): new options -D diffbin and -g grepbin
+ (usg): describe new options -D diffbin and -g grepbin.
+ (Diffbin): new global variable for DIFF path.
+ (Grepfbin): new global variable for GREP path.
+
+ * options.h.in (RCSBIN_DFLT): mention this needs to be set if
+ your PATH isn't set properly by rshd.
+
+ * sanity.sh (rdiff): re-do Jim's change, but with the original
+ keywords I had intended (should be a bit more like real life), and
+ Jim's better RCS date and user matching form.
+ [I guess that's what I get for checking things in at 3am! ;-)]
+
+Mon Sep 30 17:00:20 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * rcs.c (RCS_reparsercsfile): Store desc field value in main RCS
+ node data, not in version specific data.
+ * sanity.sh: Enable log2 test (for local CVS only).
+
+Mon Sep 30 13:01:45 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * sanity.sh (log2): New test, tests cvs add -m. Not yet enabled
+ in "tests" because CVS currently flunks this test.
+
+ * sanity.sh (rdiff, basic2): Allow "cvs server" as well as "cvs
+ checkout" and friends in messages. In testing output of cvs
+ status, don't require a tab which isn't there for remote. Skip
+ test rdiff-9 for remote. In test basic2-64, add missing slash in
+ the pattern which gets used for remote.
+
+ * sanity.sh (rdiff): Fix strings we were matching against which
+ got keyword-expanded in checking in sanity.sh.
+
+Mon Sep 30 03:21:37 1996 Greg A. Woods <woods@most.weird.com>
+
+ * sanity.sh: change all regexpr literal '.' to '\.'
+ (basic2): why are tests 34 & 42 commented out (because
+ of 'diff -u'?)?
+ add tests 56[abc], 57a, and 58a to test import to the main
+ branch (i.e. branch '1').
+ (rdiff): new test section for rdiff -K, etc.
+ (dotest): remove dotest.ex? before running a new test.
+ (dotest_fail): remove dotest.ex? before running a new test.
+ (dotest_internal): write expected output to dotest.exp, or if $4
+ also used, to dotest.ex1 and dotest.ex2.
+ (patch): renamed this test to 'serverpatch'.
+ (dotest_lit): rename dotest.res to dotest.exp ala dotest().
+ remove dotest.ex? before running a new test.
+ (DOTSTAR): mention the bug exists up to 1.12
+ (ENDANCHOR): mention the bug exists up to 1.12
+ (dotest_all_in_one): new function for debugging.
+ (dotest_line_by_line): new function for debugging.
+ (dotest_internal_debug): new function for debugging.
+ (dotest_internal): stop emulating the ancient tests and don't spew
+ the dotest.tmp contents onto $LOGFILE -- it's just too much
+ meaningless noise. Only do this if the test fails. Many tests
+ don't use dotest() yet, so this isn't quite so helpful as it might
+ otherwise be.
+ (TODO): mention CVS/* files, especially CVS/Root.
+
+ * main.c (main): add a commented out piece of code to suggest that
+ there should be a function lookup_command_attribute() that could
+ tell us various things about internal commands, such as whether
+ they use CVS/Root, or if they're repository-only, or if they need
+ a working directory, etc....
+ (main): don't set need_to_create_root if command doesn't use a
+ local working directory.
+
+ * patch.c (patch): CLIENT_SUPPORT: send '-f' if NOT force_tag_match
+
+ * error.c (fperror): protect declaration for un-defined __STDC__
+
+ * import.c (import): permit imports to a branch with zero dots,
+ i.e. the trunk.
+ (update_rcs_file): don't detect conflicts if importing to the
+ trunk.
+ (import): add hint that we should allow a module name, instead of
+ just a pathname relative to $CVSROOT.
+ (add_rcs_file): if importing to trunk, do it with ci(1).
+
+ * import.c: XXX the following are all #if 0'ed out until a full
+ implementation can be designed....
+ (cbranch): new variable to support conflict detection on another
+ branch set by -c.
+ (import): truncate -b and -c optarg if to fit in static storage.
+ (import_usage): describe -c
+
+ * rcscmds.c (RCS_checkout): add new argument 'rcsver'. If rcsver
+ is set, turn on 'keywords' to force call to RCS_exec_checkout.
+ * rcs.c (RCS_exec_checkout): add new argument 'rcsver'. Pass
+ 'rcsver' to "co" with run_arg().
+ * cvs.h: (RCS_checkout): add new argument 'rcsver' to prototype.
+ (RCS_exec_checkout): add new argument 'rcsver' to prototype.
+ * commit.c (remove_file): supply new argument to RCS_checkout.
+ * checkin.c (Checkin): supply new argument to RCS_checkout.
+ * diff.c (diff_fileproc): supply new argument to RCS_checkout.
+ (diff_file_nodiff): supply new argument to RCS_checkout.
+ * no_diff.c (No_Difference): supply new argument to RCS_checkout.
+ * update.c (checkout_file): supply new argument to RCS_checkout.
+ (patch_file): supply new argument to RCS_checkout.
+ (join_file): supply new argument to RCS_checkout.
+
+ * patch.c: (o_options): new variable for -K
+ (rcsver): new variable for -V.
+ (patch): add -K flag which sets o_options, change -V to set
+ rcsver, send o_options and rcsver if in client mode.
+ (patch_fileproc): use RCS_checkout instead of RCS_fast_checkout in
+ order to ensure $Name is expanded, use o_options if set, or
+ options if set, or by default "-ko" when getting "old" file.
+
+Sun Sep 29 16:43:28 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * rcscmds.c: Replace comment at top of file concerning RCS library
+ with a reworded version based on discussion between me, Ian, Paul
+ Eggert, and JimB.
+
+Sun Sep 29 13:09:45 1996 Noel Cragg <noel@kiva.rain.org>
+
+ * main.c (main): don't create/update CVS/Root when doing the "cvs
+ login" command. Consider: if the user executes "cvs login" with
+ the working directory inside an already checked out module, we'd
+ incorrectly change the CVS/Root file to reflect the CVSROOT of the
+ "cvs login" command.
+
+ * login.c (login): if we're re-logging into a server for which a
+ .cvspass entry already exists, copy the temporary file to its home
+ location rather than renaming. Renaming doesn't work between
+ filesystems. After copying, unlink the temporary file.
+
+Fri Sep 27 05:24:56 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * diff.c: Add comment about --brief option.
+
+ * README-rm-add: Removed; the information which was here is now in
+ cvs.texinfo.
+ * Makefile.in (DISTFILES): Remove README-rm-add.
+
+Wed Sep 25 10:00:00 1996 Larry Jones <larry.jones@sdrc.com>
+
+ * Makefile.in (cvsbug): Add dependency on version.c.
+
+Wed Sep 25 09:01:48 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * filesubr.c (get_homedir), update.c (update): Reindent.
+
+Wed Sep 25 04:44:54 1996 Jim Blandy <jimb@totoro.cyclic.com>
+
+ * version.c (version_string): Bump to 1.8.86.
+
+Wed Sep 25 05:17:50 1996 Jim Blandy <jimb@floss.cyclic.com>
+
+ * update.c (update): Don't neglect to pass the -kmumble options
+ to the server.
+ * sanity.sh (binfiles-sticky): New tests for above.
+
+ * cvsrc.c (read_cvsrc): Deal correctly with lines that specify a
+ command, but no options; don't corrupt argv.
+
+ * sanity.sh: When testing rsh, use the program specified by
+ the CVS_RSH environment variable, if it's set. Move test to top
+ of file, so it runs before all other tests (it's really a
+ meta-test).
+
+ * filesubr.c (get_homedir): Use getpwuid to find the home
+ directory, if the HOME environment variable isn't set.
+ * ignore.c (ign_add_file): Call get_homedir to find the user's
+ home directory; this is more portable than calling getpwuid.
+
+Tue Sep 24 09:08:17 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * log.c (log_tree): When walking through branches, follow the
+ ->prev field rather than following ->next which insures that the
+ loop only executes once and we only see the last branch.
+ * sanity.sh (multibranch): Test "cvs log" too; tests for above fix.
+
+Mon Sep 23 09:55:22 1996 Norbert Kiesel <nk@col.sw-ley.de>
+
+ * options.h.in: Fixed some typos in the comments and reindented
+ them.
+
+Sat Sep 21 02:33:26 1996 Jim Blandy <jimb@totoro.cyclic.com>
+
+ * sanity.sh: If we're testing remote CVS, make sure rsh itself is
+ working before running any tests. It's confusing when basica-1
+ fails just because you don't have the local host in your .rhosts
+ file.
+
+ * version.c (version_string): Bump to 1.8.85.
+
+Thu Sep 19 09:15:41 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * options.h.in: Define SERVER_FLOWCONTROL, SERVER_HI_WATER,
+ SERVER_LO_WATER. Several large sites (FreeBSD, Cygnus) have been
+ pounding on this code without problems, and it doesn't seem to
+ have any significant downsides.
+
+Tue Sep 17 01:13:41 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * status.c (status_fileproc): Instead of a default case, set sstat
+ before the switch. This way gcc -Wall can detect a missed case.
+ Add explicit T_TITLE case.
+
+Tue Sep 17 00:09:44 1996 Assar Westerlund <assar@pdc.kth.se>
+
+ * login.c (login): Print usage if argc < 0.
+
+Tue Sep 17 00:09:44 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * lock.c: In comment, mention one more function of readlocks
+ (fileattr not updated atomically). Note similarity between
+ solutions #2 and #5.
+
+ * checkout.c (safe_location): Do not reject a location merely
+ because it textually starts with hardpath; insist that it be
+ hardpath or a subdirectory thereof.
+
+Mon Sep 16 11:46:36 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * server.c (server_cleanup): Add comment about ignoring errors
+ from unlink_file_dir.
+
+Mon Sep 16 10:31:48 1996 Norbert Kiesel <nk@col.sw-ley.de>
+
+ * main.c: Add support for -T <tmpdir> command line option. This
+ is needed for servers started via inetd.
+ (usg): Added line for -T. Improved -z documentation.
+ (main): Read default for tmpdir from the environment. Test for 'T'
+ in getopt loop. Use '/tmp' as ultimative fallback. Update
+ environment if possible.
+
+ * cvs.h (TMPDIR_ENV): Added for -T <tmpdir> command line option.
+
+ * options.h.in: Add TMPDIR_DFLT
+
+ * import.c (update_rcs_file): Use global variable Tmpdir instead
+ of reading the environment.
+
+ * server.c (server_cleanup): Use global variable Tmpdir instead of
+ reading the environment. Also, replace system("rm -rf") with
+ unlink_file_dir.
+ (server): Use global variable Tmpdir instead of reading the
+ environment.
+
+Thu Sep 12 1996 Jim Kingdon <kingdon@cyclic.com>
+
+ * main.c (main): If ARGV0_NOT_PROGRAM_NAME, then just set
+ program_name to "cvs" rather than argv[0].
+
+Thu Sep 12 12:06:56 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * client.c (update_entries): If we can't write the file, don't
+ make it a fatal error.
+
+Wed Sep 11 12:46:23 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * client.c (start_server): Move START_SERVER_RETURNS_SOCKET code
+ so that it is only run for server_method. It is wrong for
+ pserver_method (in which connect_to_pserver sets server_sock).
+
+ * login.c (construct_cvspass_filename): If NO_SLASH_AFTER_HOME,
+ don't put a '/' between $HOME and .cvspass. Reindent function.
+ * build_src.com: Add zlib.c, login.c, and scramble.c.
+
+ * rcs.c (RCS_deltas): When looking for our branch in ->branches,
+ check the branch number.
+ * sanity.sh (multibranch): New tests test for above fix.
+
+ * commit.c (precommit_list_proc): Fix typo in last change
+ (->status to ->type).
+
+Tue Sep 10 23:05:41 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * Makefile.in (DISTFILES): Add build_src.com.
+ * build_src.com: Add buffer.c, buffer.obj, and zlib.olb.
+
+Tue Sep 10 20:35:23 1996 Juergen Renz <renz@conware.de>
+ and Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * commit.c (precommit_list_proc): Update to reflect Jul 22 change
+ in which p->data was changed from a Ctype to a struct
+ logfile_info *. This means that commitinfo scripts again get
+ passed the file list like they should.
+
+Tue Sep 10 20:35:23 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * client.c (auth_server_port_number): Change name of service from
+ "cvs" to "cvspserver". The latter is what the manual has always
+ recommended, and it is also officially registered with IANA.
+
+Tue Sep 10 11:12:42 1996 Mark A. Solinski <markso@mcs.com>
+ and Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * client.c (socket_buffer_output): Change ifdef VMS to ifdef
+ SEND_NEVER_PARTIAL.
+ (start_server): Change ifdef VMS to ifdef START_SERVER_RETURNS_SOCKET.
+
+Tue Sep 10 17:15:21 1996 Jim Blandy <jimb@totoro.cyclic.com>
+
+ * client.c (auth_server_port_number): Look up "cvs" in the
+ services database, and use the value it returns; fall back to
+ CVS_AUTH_PORT if no entry is present.
+ (connect_to_pserver): Use the correct port number in any error
+ messages.
+
+Tue Sep 10 11:12:42 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * sanity.sh (newb): New test newb-123j0 tests for another "cvs
+ status" case.
+
+Sun Sep 8 15:20:37 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * rcs.c (RCS_checkout): Clarify handling of options parameter.
+
+ * rcs.c (RCS_checkout): Free buffer allocated by RCS_deltas.
+
+Sat Sep 7 21:28:27 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * main.c (struct cmd): Add comment concerning recognizing unique
+ abbreviations.
+
+Fri Sep 6 22:31:52 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * rcs.c (RCS_checkout): Fix indentation.
+
+Fri Sep 6 11:48:08 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * rcs.c (RCS_checkout): Replace tag parameter with rev and nametag
+ parameters. Change all callers.
+ * rcs.h (RCS_checkout): Update declaration.
+
+ * rcs.c (RCS_getversion): Replace return_both parameter with
+ simple_tag. Change all callers.
+ (RCS_gettag): Likewise.
+ * rcs.h (RCS_getversion, RCS_gettag): Update declarations.
+ * vers_ts.c (Version_TS): Simplify vn_tag initialization using new
+ simple_tag rather than old return_both.
+ * cvs.h (struct vers_ts): Clarify vn_tag comment a bit.
+
+ * main.c (usg): Only mention -x if ENCRYPTION is defined.
+ (main): Mention ENCRYPTION define in comment for -x.
+ * client.h (krb_encrypt_buffer_initialize): Only declare if
+ ENCRYPTION is defined.
+ * client.c (start_server): Only encrypt if ENCRYPTION is defined.
+ * server.c (serve_kerberos_encrypt): Only define if ENCRYPTION is
+ defined.
+ (requests): Only include Kerberos-encrypt is ENCRYPTION is
+ defined.
+ (krb_encrypt_*): Only define if ENCRYPTION is defined.
+
+Thu Sep 5 17:32:39 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * sanity.sh: When testing remote, use :ext: instead of :server: to
+ match change made earlier today.
+
+Thu Sep 5 13:57:47 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * client.c (start_tcp_server): Don't allow :kserver: to mean
+ "direct tcp" (root.c already takes care of this, but I want to
+ make it clear what is intended, and not intended, here).
+ (start_server): Handle ext_method (external rsh program) and
+ server_method (internal rsh client) separately.
+ * client.c: Take rsh_pid and start_rsh_server out of
+ RSH_NOT_TRANSPARENT ifdefs. It is useful for things like SSH on NT.
+ * cvs.h (CVSmethod), root.c (method_names): Add ext_method.
+ * root.c (parse_cvsroot): Recognize "ext" access method.
+ If access method is not specified and CVSROOT contains a colon,
+ use either ext_method or server_method depending on
+ RSH_NOT_TRANSPARENT.
+
+Thu Sep 5 00:09:49 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * rcs.c (RCS_checkout): Remove flags parameter, which was not
+ serving any useful purpose. Change all callers.
+ * rcscmds.c (RCS_exec_checkout): Likewise.
+
+ * rcscmds.c (RCS_exec_checkout): Rename from RCS_checkout. Change
+ all callers.
+ * rcs.c (RCS_checkout): Rename from RCS_fast_checkout. Change all
+ callers.
+
+Wed Sep 4 14:42:28 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * rcs.c (RCS_fast_checkout): If tracing, output a message. If
+ noexec, and workfile is not NULL, just return immediately. Assert
+ that sout is RUN_TTY or workfile is NULL, rather than using it as
+ a conditional. Replace found variable with two variables--gothead
+ and keywords--reflecting what it actually means.
+
+ * rcs.c (RCS_fast_checkout): Don't handle the case of workfile set
+ to "".
+ * rcscmds.c (RCS_checkout): Likewise.
+ * checkin.c (Checkin): Pass explicit file name, not "", to
+ RCS_fast_checkout.
+ * update.c (join_file): Likewise.
+ * commit.c (remove_file): Pass explicit file name to
+ RCS_fast_checkout and RCS_checkin.
+
+ * rcs.c (RCS_reparsercsfile): Always continue after seeing
+ RCSSYMBOLS, even if the value is NULL. Clear the NODELTA flag
+ after setting delta_pos.
+ (free_rcsnode_contents): New static function.
+ (freercsnode): Call free_rcsnode_contents.
+ (RCS_fast_checkout): If NODELTA is set, reparse the RCS file.
+ (RCS_settag): New function. Change all callers to old function.
+ (RCS_deltag, RCS_setbranch): Likewise.
+ (RCS_lock, RCS_unlock): Likewise.
+ (RCS_deltas): If NODELTA is set, reparse the RCS file.
+ * rcs.h (NODELTA): Define.
+ (RCS_settag, RCS_deltag, RCS_setbranch): Declare.
+ (RCS_lock, RCS_unlock): Declare.
+ * rcscmds.c (RCS_exec_settag): Rename from RCS_settag. Don't
+ check tag against BASE or HEAD (now done in new RCS_settag).
+ (RCS_exec_deltag): Rename from RCS_deltag.
+ (RCS_exec_setbranch): Rename from RCS_setbranch.
+ (RCS_exec_lock): Rename from RCS_lock.
+ (RCS_exec_unlock): Rename from RCS_unlock.
+ * cvs.h: Update declarations of renamed functions.
+ * checkin.c (Checkin): Remove rcscopy variable (no longer needed
+ because of change in RCS_unlock call).
+ * commit.c: Include <assert.h>.
+ (remove_file): Update RCSNode path if the file is renamed.
+ (unblockrcs): Change rcs parameter to RCSNode. Change all
+ callers.
+ (fixbranch): Likewise.
+ (lock_RCS): Likewise. Don't call RCS_parsercsfile.
+ (checkaddfile): Update RCSNode path if the file is renamed. After
+ creating a new file, call RCS_parse. When stubbing a branch, use
+ the passed in RCSNode if there is one, rather than calling
+ RCS_Parse. Don't call RCS_Parse again after calling RCS_settag.
+ Free head and magicrev even if RCS_settag fails.
+ * import.c (add_rev): Change rcs parameter to RCSNode. Change all
+ callers.
+ (add_tag): Likewise.
+
+ * rcs.c (RCS_fast_checkout): Amend last patch: if workfile is
+ NULL, but sout is not NULL, use sout in error message.
+
+Wed Sep 4 13:35:09 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * version.c: Increment version number to 1.8.8.
+
+ * Version 1.8.7.
+
+Wed Sep 4 1996 Jim Kingdon <kingdon@cyclic.com>
+
+ * client.c (send_file_names): Look for the name to send in
+ Entries even if the file doesn't exist; we should send the
+ name as it appears in Entries in the "rm foo; cvs update FOO"
+ case.
+
+Tue Sep 3 20:50:11 1996 William A. Hoffman <hoffman@albirio.crd.ge.com>
+
+ * rcs.c (RCS_fast_checkout): If workfile is NULL, don't try to
+ include it in error message.
+
+Mon Aug 26 12:27:38 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * mkmodules.c (mkdir_if_needed): Move from here ...
+ * filesubr.c, cvs.h (mkdir_if_needed): ... to here. Have it
+ return a value saying whether the directory was created.
+ * client.c (call_in_directory), edit.c (edit_fileproc): Call it.
+
+Fri Aug 23 19:19:44 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * checkin.c (Checkin): Copy rcs parameter in case it is freed when
+ finfo->rcs is freed.
+
+Fri Aug 23 14:55:41 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * remove.c (remove_fileproc): Revert change of 23 Aug to print
+ getwd and finfo->file in message. The latter is redundant with
+ fullname and the former is redundant with fullname and the working
+ directory when CVS was invoked. The implementation was also
+ lacking as the getwd call could overflow the buffer.
+
+Fri Aug 23 18:40:35 1996 Norbert Kiesel <nk@col.sw-ley.de>
+
+ * remove.c (cvsremove): fix remove -f for client/server
+
+Fri Aug 23 11:28:27 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * wrapper.c, cvs.h: Remove conflictHook field of WrapperEntry,
+ WRAP_CONFLICT in WrapMergeHas, and 'c' option in wrap_add; they
+ are never used.
+
+Fri Aug 23 11:41:46 1996 Norbert Kiesel <nk@col.sw-ley.de>
+
+ * server.c (switch_to_user): use #ifdef SETXID_SUPPORT instead of
+ #if SETXID_SUPPORT
+
+Thu Aug 22 14:18:43 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * checkin.c (Checkin): Remove local variable xfinfo. Reparse the
+ RCS file after the checkin. Call RCS_fast_checkout rather than
+ RCS_checkout.
+
+ * cvs.h (RCS_FLAGS_LOCK): Don't define.
+ (RCS_FLAGS_*): Adjust values to fill in hole left by removal of
+ RCS_FLAGS_LOCK.
+ * rcs.c (RCS_fast_checkout): Don't check for RCS_FLAGS_LOCK.
+ * rcscmds.c (RCS_checkout): Likewise.
+ * commit.c (commit_fileproc): Remove rcs local variable. If
+ status is T_MODIFIED, require that finfo->rcs be set, call
+ Lock_RCS directly, and don't call locate_rcs. If adding to a tag,
+ require that finfo->rcs be set, and don't call locate_rcs.
+ (remove_file): Remove rcs local variable. Require that finfo->rcs
+ be set. Don't call locate_rcs. Don't pass RCS_FLAGS_LOCK to
+ RCS_checkout; use RCS_lock instead. Call RCS_fast_checkout rather
+ than RCS_checkout.
+ (unlockrcs): Use a single rcs parameter rather than two parameters
+ for file and repository. Change all callers. Don't call
+ locate_rcs.
+ (fixbranch): Likewise.
+ (lockrcsfile): Remove; no more callers.
+
+Tue Aug 20 10:13:59 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * buffer.c, rcs.c: Don't use inline. It wasn't being used in a
+ loop or any such place where it would matter for performance, and
+ it was a (minor) portability hassle.
+
+ * server.c (server): Change "Dummy argument 0" to "cvs server" and
+ add comment explaining why.
+
+ * rcs.c (linevector_add): Add comment regarding changing \n to \0.
+
+Tue Aug 20 09:19:19 1996 Norbert Kiesel <nk@col.sw-ley.de>
+
+ * checkout.c (checkout_proc): Call RCS_parse to get the default
+ options from the RCS file.
+
+ * sanity.sh (binfiles): Add tests 5.5b0 and 5.5b1 for the above fix
+
+Mon Aug 19 18:13:32 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * rcs.c (linevector_init): Make inline. Set lines_alloced to 0,
+ not 10. Set vector to NULL.
+ (linevector_add): Remove assertion that lines_alloced is greater
+ than zero. Initialize lines_alloced if necessary.
+ (linevector_copy): Initialize lines_alloced if necessary.
+ (linevector_free): Only free vector if it is not NULL.
+ (RCS_deltas): Always call linevector_init and linevector_free on
+ curlines, headlines, and trunklines.
+ (RCS_fast_checkout): Remove #if 0 around code that calls
+ RCS_deltas.
+
+Fri Aug 16 17:52:54 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * rcs.c (linevector_add): Handle zero length correctly.
+ (RCS_deltas): In RCS_FETCH case, the data is in headlines, not
+ curlines.
+ (RCS_fast_checkout): Update comment about RCS_deltas: the
+ testsuite now passes.
+
+ * rcs.c (RCS_fully_parse): Use the length of the value, rather
+ than assuming that there are no embedded zero bytes.
+ (struct line): Add len field.
+ (linevector_add): Add len parameter. Change all callers. Use
+ len, rather than assuming that there are no embedded zero bytes.
+ Set the len field in new lines.
+ (RCS_deltas): Use the length of the value, rather than assuming
+ that there are no embedded zero bytes. Use the line length when
+ outputting it and when copying it.
+ (RCS_fast_checkout): Update comment about RCS_deltas to remove
+ note about supporting zero bytes correctly.
+
+Thu Aug 15 23:38:48 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * commit.c, import.c: Revise comments regarding the fact that we
+ call start_server before do_editor.
+
+Thu Aug 15 11:30:55 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * server.c: Include <sys/socket.h> if AUTH_SERVER_SUPPORT.
+ (pserver_authenticate_connection): Set SO_KEEPALIVE on
+ STDIN_FILENO.
+ (kserver_authenticate_connection): Likewise.
+
+Thu Aug 15 10:26:41 1996 Norbert Kiesel <nk@col.sw-ley.de>
+
+ * server.c (switch_to_user): Fix previous patch to compile it for
+ both HAVE_KERBEROS and AUTH_SERVER_SUPPORT
+
+Wed Aug 14 14:02:00 1996 Norbert Kiesel <nk@col.sw-ley.de>
+
+ * server.c (check_password): if available use getspnam instead of
+ getpwnam when reading system passwords. This allows cvs pserver
+ to run on systems with shadow passwords.
+ (switch_to_user): new static function. Contains the extracted
+ common tail of kserver_authenticate_connection and
+ pserver_authenticate_connection. If compiled with SETXID_SUPPORT,
+ honor the setgid bit if it is set.
+ (check_repository_password): turn into a static function
+ (check_password): ditto
+ (pserver_authenticate_connection): little code cleanup
+
+Wed Aug 14 01:07:10 1996 Greg A. Woods <woods@most.weird.com>
+
+ * history.c (history): apply fix posted by Steven Meyer
+ <steve@blacksmith.com> to info-cvs to correct handling of '-D'
+ argument. Message-Id: <9608122335.AA01385@nijel.blacksmith.com>
+
+Tue Aug 13 13:42:36 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * log.c (cvslog): Remove comment about calling rlog.
+ * rcs.c (translate_symtag): Correct typo in comment (l ist ->
+ list).
+ * server.c (server_write_entries): Add omitted word (lists) in
+ comment.
+
+Tue Aug 13 14:01:49 1996 Norbert Kiesel <nk@col.sw-ley.de>
+
+ * wrapper.c (wrap_rcsoption): fix memory access error
+
+ * rcs.c (RCS_fast_checkout): fix memory access error (triggered
+ by an empty option string)
+
+Mon Aug 12 17:45:15 1996 Jim Kingdon (unknown@beezley)
+
+ * buffer.c, zlib.c: If EIO is not defined, try to define it.
+
+Mon Aug 12 10:33:27 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * import.c (comtable): Add comment concerning applicability with
+ RCS 5.7.
+
+ * server.c (server): If TMPDIR is not an absolute pathname, give
+ an error.
+
+Mon Aug 12 10:34:43 1996 Norbert Kiesel <nk@col.sw-ley.de>
+
+ * main.c: add synonym "ann" for "annotate" again
+
+Sun Aug 11 17:54:11 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * rcs.h (RCS_RLOG): Removed; no longer used.
+
+Fri Aug 9 20:16:20 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * server.c (dirswitch): Open the Entries file with mode "a" rather
+ than "w+".
+ (server_write_entries): Open the Entries file with mode "a" rather
+ than "w".
+ * sanity.sh (modules): Add topfiles module and 155cN tests for
+ above patch.
+
+Fri Aug 9 12:11:25 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * main.c (cmd): Add comment regarding synonyms.
+
+Thu Aug 8 14:40:10 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * main.c: Remove synonyms for "cvs annotate". Synonyms create
+ user confusion.
+
+Thu Aug 8 10:24:04 1996 Norbert Kiesel <nk@col.sw-ley.de>
+
+ * main.c: Revert (undocumented) change to rename the cvs history
+ alias "his" to "hist"
+
+Wed Aug 7 18:26:25 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * server.c (cvs_output): Change str parameter to const char *.
+ Correct loop to print from p, not str.
+ (cvs_outerr): Likewise.
+ * cvs.h (cvs_output, cvs_outerr): Update declarations.
+
+ * server.c (receive_partial_file): Read and discard remaining file
+ data on a write error.
+ (serve_modified): Discard data while size > 0, not >=.
+
+Wed Aug 7 15:11:40 1996 Norbert Kiesel <nk@col.sw-ley.de>
+
+ * main.c (cmds): Add some aliases for "annotate".
+ (usg): Improve usage message text
+ (cmd_synonyms): New function to print the command synonym list
+ (main): Add new option --help-synonyms
+
+Wed Aug 7 00:07:31 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ Keep track of subdirectories in the Entries file.
+ * cvs.h (enum ent_type): Define.
+ (struct entnode): Add type field.
+ (struct stickydirtag): Add subdirs field.
+ (Subdirs_Known, Subdir_Register, Subdir_Deregister): Declare.
+ (ignore_files): Update declaration for new parameter.
+ (FILESDONEPROC): Add entries parameter.
+ (DIRENTPROC, DIRLEAVEPROC): Likewise.
+ * entries.c (Entnode_Create): Add type parameter. Change all
+ callers.
+ (write_ent_proc): If closure is not NULL, treat it as a pointer to
+ an int, and set it to 1 if a node is seen which is not ENT_FILE.
+ (write_entries): If subdirectory information is known, but no
+ subdirectories were written, write an unadorned D to the file.
+ (Scratch_Entry): Write an R command to Entries.Log. Don't rewrite
+ the Entries file.
+ (Register): Set entfilename. Write an A command rather than an
+ unadorned entries line.
+ (fgetentent): Add cmd and sawdir parameters. Change all callers.
+ If CMD is not NULL, expect and return a single character command.
+ Handle an initial D by setting the type to ENT_SUBDIR.
+ (fputentent): Output an initial D for an ENT_SUBDIR entry.
+ (Entries_Open): Handle removal commands in Entries.Log. Record
+ whether subdirectory information is known in the list private
+ data.
+ (Subdirs_Known): New function.
+ (subdir_record): New static function.
+ (Subdir_Register, Subdir_Deregister): New functions.
+ * find_names.c (add_entries_proc): Skip entries that are not
+ ENT_FILE.
+ (add_subdir_proc): New static function.
+ (register_subdir_proc): New static function.
+ (Find_Directories): If the Entries file has subdirectory
+ information, get the directories out of it. Otherwise, call
+ find_dirs, and add the information to the Entries file.
+ * recurse.c (struct frame_and_entries): Define.
+ (do_recursion): Don't call Entries_Close until after processing
+ dirlist. Pass entries to filesdoneproc. Pass a frame_and_entries
+ structure to do_dir_proc via walklist.
+ (do_dir_proc): Expect a frame_and_entries structure in closure,
+ not a recursion_frame. Pass entries to direntproc and
+ dirleaveproc.
+ * ignore.c (ignore_files): Add entries parameter. Change all
+ callers. If we have subdirectory information, check for
+ directories in entries.
+ * add.c (add): If client_active, call Subdir_Register on each new
+ directory.
+ (add_directory): Add entries parameter. Change caller. Call
+ Subdir_Register.
+ * checkout.c (build_dirs_and_chdir): Call Subdir_Register.
+ * client.c (call_in_directory): Call Subdir_Register for newly
+ created directories. Call Subdirs_Known or Find_Directories after
+ calling Entries_Open.
+ (process_prune_candidates): Call Subdir_Deregister.
+ * commit.c (findmaxrev): Skip entries that are not ENT_FILE.
+ * server.c (dirswitch): Call Subdir_Register.
+ * update.c (update_dirent_proc): Call Subdir_Register.
+ (update_dirleave_proc): Call Subdir_Deregister.
+ * Several files: Change direntproc, dirleaveproc, and
+ filesdoneproc routines to expect an entries argument.
+
+ * rcs.c (translate_symtag): New static function.
+ (RCS_gettag): Use translate_symtag rather than RCS_symbols.
+ (RCS_nodeisbranch, RCS_whatbranch): Likewise.
+
+Tue Aug 6 15:36:09 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ Finish the conversion of cvs log so that it never invokes rlog.
+ * log.c (struct log_data): Remove dorlog field. Add nameonly,
+ header, long_header, statelist, and authorlist fields.
+ (log_usage): Remove rlog-options. Add -R, -h, -t, -b, -s, -w.
+ (cvslog): Don't clear opterr. Handle -h, -R, -s, -t, -w. If an
+ unrecognized option is seen, call usage.
+ (log_parse_list): New static function.
+ (log_fileproc): Remove code that called rlog. Check nameonly,
+ header, and long_header fields in log_data.
+ (log_version_requested): Check statelist and authorlist.
+
+ * log.c (struct datelist): Define.
+ (struct log_data): Add datelist and singledatelist fields.
+ (log_usage): Add -d.
+ (cvslog): Handle -d.
+ (log_parse_date): New static function.
+ (log_fileproc): Do special single date handling.
+ (log_version_requested): Check datelist and singledatelist.
+ (log_fix_singledate): New static function.
+
+Mon Aug 5 23:48:16 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * log.c (struct option_revlist): Define.
+ (struct revlist): Define.
+ (struct log_data): Add default_branch and revlist fields.
+ (struct log_data_and_rcs): Define.
+ (log_usage): Add -N and -r.
+ (cvslog): Handle -N and -r.
+ (log_parse_revlist): New static function.
+ (log_fileproc): Call log_expand_revlist and log_free_revlist.
+ Pass log_data_and_rcs structure to log_count_print via walklist.
+ (log_expand_revlist, log_free_revlist): New static functions.
+ (log_version_requested): New static function.
+ (log_count_print): New static function.
+ (log_tree): Add log_data and revlist parameter. Change all
+ callers.
+ (log_abranch): Likewise.
+ (log_version): Likewise. Call log_version_requested.
+ (version_compare): New static function.
+ * sanity.sh (log): New tests for -r, -b, and -N options to log.
+
+Sun Aug 4 11:19:30 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ Handle simple cases of cvs log without invoking rlog.
+ * log.c (struct log_data): Define.
+ (cvslog): Use getopt to parse options. Set up a log_data
+ structure, and pass it to start_recursion.
+ (log_fileproc): Get arguments form callerdat rather than static
+ variables. In simple cases, print the log information directly,
+ rather than invoking rlog.
+ (log_symbol, log_count, log_tree): New static functions.
+ (log_abranch, log_version, log_branch): New static functions.
+ * rcs.h (struct rcsnode): Add other field.
+ (struct rcsversnode): Add other field.
+ (RCS_fully_parse): Declare.
+ * rcs.c (getrcsrev): Move declaration to start of file.
+ (RCS_reparsercsfile): Add all parameter. Change all callers.
+ (RCS_fully_parse): New function.
+ (freercsnode): Free other list.
+ (rcsvers_delproc): Free other list.
+ * hash.h (enum ntype): Add RCSFIELD.
+ * hash.c (nodetypestring): Handle RCSFIELD.
+
+Sat Aug 3 19:39:54 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * log.c (cvslog): Correct position of CLIENT_SUPPORT #endif.
+
+Thu Jul 25 12:06:45 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * update.c (join_file): If merging a branch, and the branch
+ revision does not exist, just return without doing anything.
+ * sanity.sh (join): Add cases file7 and file8 to test above
+ patch.
+
+ * server.c (cvsencrypt): Rename from encrypt, to avoid conflict
+ with NetBSD unistd.h. Rename all uses.
+
+ * server.c (krb_encrypt_buffer_output): Fix typo in comment (reply
+ -> replay).
+
+Thu Jul 25 10:37:32 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * server.c (krb_encrypt_buffer_output): Fix typo in comment
+ (krb_recv_auth -> krb_recvauth).
+
+Wed Jul 24 09:28:33 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * lock.c (set_lock): Adjust comment regarding why we call stat.
+
+Wed Jul 24 15:06:08 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ Add encryption support over a Kerberos connection.
+ * main.c (usg): Mention -x if CLIENT_SUPPORT.
+ (main): Handle -x.
+ * client.h (encrypt): Declare.
+ (krb_encrypt_buffer_initialize): Declare.
+ * client.c (kblock, sched): New static variables if
+ HAVE_KERBEROS.
+ (start_tcp_server): Remove sched local variable. Copy
+ cred.session into kblock.
+ (start_server): Turn on encryption if requested.
+ * server.c (kblock, sched): New static variables if
+ HAVE_KERBEROS.
+ (serve_kerberos_encrypt): New static function.
+ (requests): Add "Kerberos-encrypt" if HAVE_KERBEROS.
+ (kserver_authenticate_connection): Remove sched local variable.
+ Copy auth.session into kblock.
+ (encrypt): New global variable.
+ (struct krb_encrypt_buffer): Define.
+ (krb_encrypt_buffer_initialize): New function.
+ (krb_encrypt_buffer_input): New static function.
+ (krb_encrypt_buffer_output): New static function.
+ (krb_encrypt_buffer_flush): New static function.
+ (krb_encrypt_buffer_block): New static function.
+ (krb_encrypt_buffer_shutdown): New static function.
+
+Wed Jul 24 09:28:33 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * recurse.c (do_recursion): Add comment about calling
+ Name_Repository in !(which & W_LOCAL) case.
+
+ * expand_path.c (expand_variable): Fix typo (varaible -> variable).
+
+Tue Jul 23 15:05:01 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * update.c (update_fileproc): In T_REMOVE_ENTRY case, only call
+ server_scratch_entry_only if ts_user is NULL.
+ * sanity.sh (death2): Add death2-20 test for above patch.
+
+ * diff.c (diff_fileproc): If a file is not in the working
+ directory, check that the tag is present before warning that no
+ comparison is possible.
+ * sanity.sh (death2): Add death2-diff-9 and death2-diff-10 tests
+ for above patch.
+
+Tue Jul 23 12:05:42 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * tag.c (tag_check_valid): Fix indentation.
+
+ * client.c (handle_e): Flush stdout before writing to stderr.
+ (handle_m): Flush stderr before writing to stdout.
+
+Fri Jul 19 16:02:11 1996 Mike Ladwig <mike@twinpeaks.prc.com>
+
+ * client.c: Added NO_CLIENT_GZIP_PROCESS to deal with the MacOS
+ client where Gzip-stream is supported, but "gzip-file-contents" is
+ not.
+
+Fri Jul 19 16:02:11 1996 Mike Ladwig <mike@twinpeaks.prc.com>
+
+ * repos.c: Fixed recent patch which added plain fopen rather than
+ CVS_FOPEN
+
+Mon Jul 22 22:25:53 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * logmsg.c (tag): New static variable.
+ (setup_tmpfile): Don't print the prefix before calling fmt_proc.
+ Free tag if it is set.
+ (find_type): Get type from logfile_info struct.
+ (fmt_proc): Likewise. Print tag information. Handle all prefix
+ printing.
+ (revision): Remove static variable.
+ (Update_Logfile): Remove xrevision parameter. Change all
+ callers.
+ (title_proc): Get type from logfile_info struct.
+ (logfile_write): Remove revision parameter. Change all callers.
+ * cvs.h (struct logfile_info): Define.
+ (Update_Logfile): Update prototype.
+ * commit.c (find_fileproc): Set logfile_info information.
+ (check_fileproc): Likewise.
+ (commit_filesdoneproc): Don't call ParseTag.
+ (update_delproc): Free logfile_info information.
+ * add.c (add_directory): Set logfile_info information.
+ * import.c (import): Likewise.
+
+ * tag.c (tag_check_valid): The special BASE and HEAD tags are
+ always valid.
+ * sanity.sh (basica): Add basica-6.3 test for above patch.
+
+Mon Jul 22 14:41:20 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * update.c (merge_file): Pass 0 not NULL to checkout_file (20 Jul
+ 96 change changed other calls to checkout_file but missed this one).
+
+Sat Jul 20 00:21:54 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * update.c (join_file): Check whether the target of the merge is
+ the same as the working file revision before checking whether the
+ file was added during the merge.
+
+ * update.c (scratch_file): Remove existing parameters, and add a
+ single parameter of type struct file_info. Change all callers.
+ Warn if unlink_file fails.
+ (checkout_file): Remove resurrecting_out parameter. Add adding
+ parameter. Change all callers. Remove joining code.
+ (join_file): Remove resurrecting parameter. Rewrite to handle
+ joining dead or added revisions.
+ * classify.c (Classify_File): If there is no user file, and the
+ RCS file is dead, return T_UPTODATE rather than T_CHECKOUT.
+ * checkout.c (checkout_proc): Set W_ATTIC if there is a join tag.
+ * sanity.sh (join): New set of tests for above patches.
+ (death): Adjust tests 86, 89, 89a, 92.1c, 95 for above patches.
+ (import): Adjust test 113 for above patches.
+
+Thu Jul 18 19:24:08 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * lock.c: Add comment explaining what locks are for. Also discuss
+ various changes to locking which get proposed from time to time.
+
+ * sanity.sh (death2): Change a number of test names from death-*
+ to death2-*.
+
+ * wrapper.c (wrap_setup): Don't look in repository if client_active.
+ * wrapper.c, cvs.h (wrap_send): New function.
+ * update.c (update), import.c (import): Call it.
+ * sanity.sh (binwrap): Do binwrap tests for remote as well as
+ local; tests for above fixes.
+
+ * wrapper.c: Add a few FIXME comments.
+
+Thu Jul 18 18:43:50 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * sanity.sh (patch): Fix names of a couple of tests to say patch
+ rather than death2.
+
+Thu Jul 18 16:19:21 1996 Bill Bumgarner <bbum@friday.com>
+ and Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * add.c (add), import.c (add_rcs_file): Check for options from
+ wrappers and use them if specified.
+ * cvs.h (WrapMergeHas): Add WRAP_RCSOPTION.
+ * wrapper.c (WrapperEntry): Add rcsOption field.
+ (wrap_add): Allow a single character argument to an option.
+ (wrap_add): Handle -k option.
+ (wrap_add_entry): Handle rcsOption field.
+ (wrap_name_has): Handle WRAP_RCSOPTION.
+ * wrapper.c, cvs.h (wrap_rcsoption): New function.
+ * add.c, import.c, wrapper.c: Minor beautification (mostly
+ removing trailing spaces).
+ * sanity.sh (binwrap): New tests test for this feature.
+
+Wed Jul 17 10:14:20 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * checkout.c (checkout): Remove extraneous else accidentally
+ inserted in last checkin.
+
+Tue Jul 16 11:37:41 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * sanity.sh (import): Use quoting to avoid expansion of RCS ID
+ strings.
+
+ * sanity.sh (import): Use dotest to examine the output of test
+ 113, and the actual contents of the file in test 116.
+
+ * update.c (join_file): Always skip rcsmerge if the two revisions
+ are the same (the old code always did the rcsmerge when two -j
+ options were specified).
+
+ * checkout.c (history_name): New static variable.
+ (checkout): Permit both tag and date to be specified. Set
+ history_name.
+ (checkout_proc): Use history_name when calling history_write.
+ * rcs.c (RCS_getversion): If both tag and date are set, use
+ RCS_whatbranch to get the branch revision number of a symbolic
+ tag.
+ (RCS_getdatebranch): If the branch revision itself is early
+ enough, then use it if the first branch is not early enough. Add
+ comment for invalid RCS file. Don't bother to check for NULL
+ before calling xstrdup, since xstrdup checks anyhow.
+
+ * client.h (file_gzip_level): Declare.
+ * client.c (file_gzip_level): Define.
+ (start_server): Don't set gzip_level to zero after sending
+ Gzip-stream command. Set file_gzip_level after sending
+ gzip-file-contents command.
+ (send_modified): Use file_gzip_level rather than gzip_level.
+ * server.c (server_updated): Likewise.
+ (serve_gzip_contents): Likewise.
+
+ * sanity.sh (patch): New tests. Test remote CVS handling of
+ unpatchable files.
+
+ * sanity.sh (death2): Accept a '.' in the temporary file name
+ printed by diff.
+
+ * rcscmds.c (RCS_checkin): Remove noerr parameter. Change all
+ callers.
+ * cvs.h (RCS_checkin): Update declaration.
+ * commit.c (remove_file): Pass RCS_FLAGS_QUIET to RCS_checkin.
+
+ * history.c (history): Cast sizeof to int to use correct type in
+ error printf string.
+ (report_hrecs): Cast strlen result to int to use correct type in
+ printf string.
+
+ * server.c (cvs_flusherr): Correct typo in comment.
+
+ * rcs.c (getrcskey): Hoist three constant strcmp calls out of the
+ value reading loop.
+
+ * fileattr.c (fileattr_get): Change parameter types from char * to
+ const char *.
+ (fileattr_get0, fileattr_modify, fileattr_set): Likewise.
+ (fileattr_newfile): Likewise.
+ * fileattr.h (fileattr_get): Update declaration.
+ (fileattr_get0, fileattr_modify, fileattr_set): Likewise.
+ (fileattr_newfile): Likewise.
+
+Thu May 16 11:12:18 1996 Mark P. Immel <immel@radix.net>
+ and Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * client.h, client.c, checkout.c (client_send_expansions):
+ Pass an additional parameter indicating where the checkout is
+ to occur, to avoid passing the wrong information to send_files().
+ * sanity.sh (basicb): New test basicb-cod-1 tests for above fix.
+
+Mon Jul 15 18:26:56 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * recurse.c (do_recursion): Require a repository before calling
+ Find_Names.
+ * repos.c (Name_Repository): Remove sanity checks which spend time
+ examining the filesystem.
+
+Mon Jul 15 1996 Jim Kingdon <kingdon@cyclic.com>
+
+ * client.c (send_file_names): Send file names as they appear
+ in CVS/Entries, rather than as specified (in cases where they
+ might differ in case).
+ (send_fileproc): Use file name from CVS/Entries (vers->entdata->user)
+ rather than file name as specified (finfo->file) when available.
+
+Sun Jul 14 15:39:44 1996 Mark Eichin <eichin@cygnus.com>
+ and Ian Lance Taylor <ian@cygnus.com>
+
+ Improve diff -N handling of nonexistent tags and removed files.
+ * diff.c (enum diff_file): New definition for whole file, moving
+ unnamed enum out of diff_fileproc, renaming DIFF_NEITHER to
+ DIFF_DIFFERENT, and adding DIFF_SAME.
+ (diff): Look through the repository even if only one revision is
+ given.
+ (diff_fileproc): Change empty_file to be enum diff_file. If there
+ is no user revision, but there is a repository file, treat it as a
+ removed file. Pass empty_file to diff_file_nodiff, and set it
+ from the return value.
+ (diff_file_nodiff): Change return type to enum diff_file. Replace
+ just_set_rev parameter with enum diff_file empty_file parameter.
+ Change handling of a missing tag to return an enum diff_file value
+ if empty_files is set, rather than reporting an error. Free tmp
+ if xcmp returns 0.
+ * sanity.sh (death2): Add tests for above patches.
+
+Sat Jul 13 19:11:32 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * rcs.c (annotate): In sending options to server, reverse sense of
+ test so that we send -f iff -f was specified, rather than iff -f was
+ not specified.
+
+Fri Jul 12 20:23:54 1996 Greg A. Woods <woods@most.weird.com>
+
+ * zlib.c (compress_buffer_input): add a couple of casts for
+ uses of z_stream's next_in and next_out
+
+Fri Jul 12 18:55:26 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * zlib.c: New file.
+ * client.c (log_buffer_block): Call set_block and set_nonblock,
+ rather than lb->buf->block.
+ (log_buffer_shutdown): New static function.
+ (get_responses_and_close): Call buf_shutdown on to_server and
+ from_server.
+ (start_server): If "Gzip-stream" is supported, use it rather than
+ "gzip-file-contents".
+ * server.c (print_error): Call buf_flush rather than
+ buf_send_output.
+ (print_pending_error, serve_valid_responses): Likewise.
+ (serve_expand_modules, serve_valid_requests): Likewise.
+ (do_cvs_command): Call buf_flush rather than buf_send_output
+ before the fork, and in the parent after the child has completed.
+ In the child, set buf_to_net and buf_from_net to NULL.
+ (serve_gzip_stream): New static function.
+ (requests): Add "Gzip-stream".
+ (server_cleanup): Don't do anything with buf_to_net if it is
+ NULL. Call buf_flush rather than buf_send_output. Call
+ buf_shutdown on buf_to_net and buf_from_net. Call error for an
+ malloc failure rather than buf_output to buf_to_net.
+ * buffer.h (struct buffer): Add shutdown field.
+ (buf_initialize): Update declaration for new shutdown parameter.
+ (compress_buffer_initialize): Declare.
+ (buf_shutdown): Declare.
+ * buffer.c (buf_initialize): Add shutdown parameter. Change all
+ callers.
+ (buf_shutdown): New function.
+ * Makefile.in (SOURCES): Add zlib.c
+ (OBJECTS): Add zlib.o.
+ ($(PROGS)): Depend upon ../zlib/libz.a.
+ (cvs): Link against ../zlib/libz.a.
+ (zlib.o): New target.
+
+Fri Jul 12 1996 Jim Kingdon <kingdon@cyclic.com>
+
+ * client.c (log_buffer_input, log_buffer_output): Use size_t
+ to avoid Visual C++ signed/unsigned warnings.
+
+Thu Jul 11 22:01:37 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * client.c (handle_f): Reindent.
+
+ * client.c (mode_to_string, handle_m, handle_e,
+ auth_server_port_number, get_responses_and_close), server.c
+ (pserver_authenticate_connection, serve_modified,
+ serve_enable_unchanged, wait_sig, server_cleanup): Reindent.
+ * server.c: Remove #if 0'd block of code above
+ check_repository_password; it was yanked out of some unknown
+ context and didn't seem to be very useful.
+
+Thu Jul 11 20:10:21 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * server.c (do_cvs_command): Pass new special parameter to
+ buf_copy_counted. If it gets set to -1, send an 'F' response if
+ the client supports it, and call cvs_flusherr.
+ (cvs_flusherr): New function.
+ * cvs.h (cvs_flusherr): Declare.
+ * client.c (handle_f): New static function.
+ (responses): Add "F".
+ * buffer.c (buf_send_special_count): New function.
+ (buf_copy_counted): Add special parameter. Handle negative counts
+ specially.
+ * buffer.h (buf_send_sepcial_count): Declare.
+ (buf_copy_counted): Update declaration.
+ * lock.c (lock_wait, lock_obtained): Call cvs_flusherr.
+
+ Change the client to use the buffer data structure.
+ * client.c: Include "buffer.h".
+ (to_server): Change to be struct buffer *.
+ (to_server_fp): New static variable.
+ (from_server): Change to be struct buffer *.
+ (from_server_fp): New static variable.
+ (from_server_logfile, to_server_logfile): Remove.
+ (buf_memory_error): New static function.
+ (struct log_buffer): Define.
+ (log_buffer_initialize, log_buffer_input): New static functions.
+ (log_buffer_output, log_buffer_flush): New static functions.
+ (log_buffer_block): New static function.
+ (struct socket_buffer): Define if NO_SOCKET_TO_FD.
+ (socket_buffer_initialize): New static function if
+ NO_SOCKET_TO_FD.
+ (socket_buffer_input, socket_buffer_output): Likewise.
+ (socket_buffer_flush): Likewise.
+ (read_line): Rewrite to use buf_read_line. Remove eof_ok
+ parameter (it was always passed as 0); change all callers.
+ (send_to_server): Rewrite to use buf_output.
+ (try_read_from_server): Rewrite to use buf_read_data.
+ (get_responses_and_close): Use from_server_fp and to_server_fp for
+ the streams. Check buf_empty_p when checking for dying gasps.
+ (start_server): Don't set from_server_logfile and
+ to_server_logfile; instead, call log_buffer_initialize. If
+ NO_SOCKET_TO_FD and use_socket_style, call
+ socket_buffer_initialize; otherwise, call
+ stdio_buffer_initialize.
+ * buffer.c: Compile if CLIENT_SUPPORT is defined.
+ (buf_flush): Fix comment to describe return value.
+ (buf_read_line): Add lenp parameter. Change all callers. Look
+ for a line terminated by \012 rather than \n.
+ * buffer.h: Compile if CLIENT_SUPPORT is defined.
+ (buf_read_line): Update declaration.
+
+ * server.c (server): Initialize buf_to_net, buf_from_net,
+ saved_output, and saved_outerr before setting error_use_protocol.
+ (pserver_authenticate_connection): Don't set error_use_protocol.
+ Errors before the authentication is complete aren't handled
+ cleanly anyhow. Change error call after authentication to use
+ printf.
+
+Thu Jul 11 1996 Jim Kingdon <kingdon@cyclic.com>
+
+ * client.c (start_server): Open logfiles in binary, not text, mode.
+
+Wed Jul 10 19:24:22 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * server.c (print_pending_error, print_error): Remove comments
+ about deadlocks; they don't apply here. Add comments saying
+ that these functions must only be called when it is OK to
+ send output (which is why the deadlock concern doesn't apply). The
+ comments remain for server_cleanup and serve_valid_responses,
+ where they are an example of the "print a message and exit"
+ behavior which is noted in cvsclient.texi and which also exists
+ places like kserver_authenticate_connection.
+
+Wed Jul 10 18:24:46 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * server.c (print_error): Add comment warning about potential
+ deadlock.
+ (print_pending_error, serve_valid_responses): Likewise.
+ (server_cleanup): Likewise.
+ (serve_directory): Don't call buf_send_output.
+ (serve_modified, serve_notify, server, cvs_outerr): Likewise.
+ (serve_expand_modules): Call buf_send_output.
+ (serve_valid_requests): Likewise.
+
+Wed Jul 10 15:51:29 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * main.c (main): Print a warning for rlog command.
+
+Wed Jul 10 15:00:55 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ Abstract the buffer data structure away from the underlying
+ communication medium.
+ * buffer.h (struct buffer): Remove fd and output fields. Add
+ input, output, flush, block, and closure fields.
+ (buf_initialize, buf_nonio_initialize): Declare.
+ (stdio_buffer_initialize, buf_flush): Declare.
+ (buf_read_line, buf_read_data): Declare.
+ * buffer.c: Include <assert.h>. Don't include <fcntl.h>.
+ (O_NONBLOCK, blocking_error): Don't define.
+ (buf_initialize, buf_nonio_initialize): New functions.
+ (buf_send_output): Use output function, rather than write.
+ (buf_flush): New function.
+ (set_nonblock, set_block): Use block function, rather than calling
+ fcntl.
+ (buf_send_counted): Don't check output.
+ (buf_input_data): Call input function, rather than read.
+ (buf_read_line, buf_read_data): New functions.
+ (buf_copy_lines, buf_copy_counted): Don't check output.
+ (stdio_buffer_initialize): New function.
+ (stdio_buffer_input, stdio_buffer_output): New static functions.
+ (stdio_bufer_flush): New static function.
+ * server.c: Include "getline.h".
+ (buf_to_net): Change to be a pointer. Change all uses.
+ (protocol, saved_output, saved_outerr): Likewise.
+ (buf_from_net): New static variable.
+ (no_mem_error, NO_MEM_ERROR, read_line): Remove.
+ (struct fd_buffer): Define.
+ (fd_buffer_initialize, fd_buffer_input): New static functions.
+ (fd_buffer_output, fd_buffer_flush): New static functions.
+ (fd_buffer_block): New static function.
+ (serve_directory): Call buf_read_line rather than read_line.
+ (serve_notify, server): Likewise.
+ (receive_partial_file): Call buf_read_data rather than fread.
+ (serve_modified): Call buf_read_line rather than read_line. Call
+ buf_read_data rather than fread.
+ (do_cvs_command): Initialize buffers with fd_buffer_initialize.
+ Change stdoutbuf, stderrbuf, and protocol_inbuf to be pointers.
+ (server): Initialize buffers using fd_buffer_initialize,
+ stdio_buffer_initialize, and buf_nonio_initialize.
+ (check_repository_password): Call getline rather than read_line.
+
+Wed Jul 10 15:51:29 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * commit.c (find_fileproc): Add comments describing a few cases
+ that we aren't handling.
+
+Tue Jul 9 04:33:03 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * rcs.c (RCS_deltas): New function, created from guts of old
+ annotate_fileproc.
+ (annotate_fileproc): Call RCS_deltas.
+ (RCS_fast_checkout): Call it (commented out for now; see comment
+ for reasons).
+
+ * cvs.h, recurse.c (start_recursion): Add callerdat argument.
+ * cvs.h: Add callerdat argument to recursion processor callbacks.
+ * recurse.c: add it to struct recursion_frame and pass it to all
+ the callbacks.
+ * admin.c, client.c, commit.c, diff.c, edit.c, lock.c, log.c,
+ patch.c, rcs.c, remove.c, rtag.c, status.c, tag.c, update.c,
+ watch.c: Update all the functions used as callbacks. Update calls
+ to start_recursion.
+ * commit.c (find_filesdoneproc, find_fileproc, find_dirent_proc,
+ commit), tag.c (val_fileproc, tag_check_valid): Use callerdat
+ instead of a static variable.
+
+ * recurse.c (do_recursion): Make static and move declaration to here...
+ * cvs.h: ...from here.
+ * recurse.c (do_recursion): Replace plethora of arguments with
+ single struct recursion_frame *. Change callers.
+ * recurse.c: New structure frame_and_file. Use it and existing
+ struct recursion_frame structures to pass info to do_file_proc and
+ do_dir_proc. Remove globals fileproc, filesdoneproc, direntproc,
+ dirleaveproc, which, flags, aflag, readlock, and dosrcs.
+
+Tue Jul 9 11:13:29 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * modules.c (do_module): Call cvs_outerr rather than fprintf.
+
+Mon Jul 8 1996 Jim Kingdon <kingdon@cyclic.com>
+
+ * rcs.c (RCS_fast_checkout): If -kb is not in use, open the
+ working file in text, not binary, mode.
+
+Sun Jul 7 10:36:16 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * rcscmds.c (RCS_settag): Add comment regarding moving check for
+ reserved tag names to RCS_check_tag.
+
+ * rcscmds.c: Add comment regarding librarifying RCS and related
+ issues. This is a lightly edited version of a message I sent to
+ the CVS developers and didn't get flamed for, so it would appear
+ to be relatively uncontroversial.
+
+ * rcs.c (annotate): Remove comment suggesting -r option and
+ related functionality; it is done.
+
+Fri Jul 5 17:19:57 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * client.c (last_entries): Make file static, rather than function
+ static within call_in_directory.
+ (get_responses_and_close): If last_entries is not NULL, pass it to
+ Entries_Close.
+
+ * server.c (server_pause_check): Check for errors when reading
+ from flowcontrol_pipe.
+
+ * client.c (call_in_directory): If dir_name is ".", call
+ Create_Admin if there is no CVS directory.
+ (send_dirent_proc): If there is no CVS subdirectory, pretend that
+ the directory does not exist (i.e., don't try to send any files in
+ the directory).
+ * server.c (dirswitch): If dir is "." in the top level repository,
+ add "/." after the Repository entry.
+ * sanity.sh (modules): Add test 155b for above patches.
+
+Thu Jul 4 15:57:34 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * server.c (buf_to_net): Move definition near top of file.
+ (read_line): Call buf_send_output rather than fflush.
+ (print_error): Output information to buf_to_net buffer rather than
+ stdout.
+ (print_pending_error, serve_valid_responses): Likewise.
+ (server_notify, do_cvs_command, server_co): Likewise.
+ (expand_proc, serve_expand_modules, server_prog): Likewise.
+ (serve_valid_requests, server_cleanup, server): Likewise.
+ (server_notify): Don't call fflush on stdout.
+ (do_cvs_command): Flush saved_output and saved_outerr to
+ buf_to_net before fork. Flush buf_to_net before fork. In child,
+ just initialize memory_error field of saved_output and
+ saved_outerr.
+ (server_cleanup): Flush buf_to_net.
+ (server): Initialize saved_output and saved_outerr.
+ (cvs_output): Add support for error_use_protocol case.
+ (cvs_outerr): Likewise.
+ * error.c (error): In HAVE_VPRINTF case, just call cvs_outerr.
+
+ * buffer.c: New file; buffer support functions taken from
+ server.c.
+ * buffer.h: New file; declarations for buffer.c.
+ * server.c: Move buffer support functions into buffer.c and
+ buffer.h. Include "buffer.h".
+ * Makefile.in (SOURCES): Add buffer.c.
+ (OBJECTS): Add buffer.o.
+ (HEADERS): Add buffer.h.
+
+Thu Jul 4 00:12:45 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * version.c: Increment version number to 1.8.6.
+
+Wed Jul 3 22:31:16 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * version.c: Version 1.8.5.
+
+Wed Jul 3 21:51:23 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * server.c (blocking_error): Define macro.
+ (buf_send_output, buf_input_data): Use blocking_error rather than
+ #ifdef EWOULDBLOCK.
+
+Tue Jul 2 20:38:41 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * add.c (add): Change message which said "version 1.2 of foo.c
+ will be resurrected"; the message was confusing because it made
+ people think that the old contents of the file would come back
+ instead of the contents in the working directory.
+
+Mon Jul 1 01:38:57 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * find_names.c (find_dirs): Add comment explaining why we bother
+ with the entries stuff.
+
+Sat Jun 29 20:23:50 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * find_names.c (Find_Directories): Add entries parameter, and pass
+ it to find_dirs.
+ (find_dirs): Add entries parameter, and skip all files it names.
+ * cvs.h (Find_Directories): Update declaration.
+ * recurse.c (start_recursion): Pass NULL to Find_Directories.
+ (do_recursion): Pass entries to Find_Directories.
+
+ * client.c (send_modified): Add trace output.
+
+ * diff.c (diff_fileproc): Always call diff_file_nodiff. Handle
+ dead versions correctly. Handle diffs between a specified
+ revision to a dead file correctly.
+ (diff_file_nodiff): Add just_set_rev parameter. Change caller.
+ * patch.c (patch_fileproc): Check for dead versions.
+ * sanity.sh (death2): Add tests for above patches.
+
+Fri Jun 28 20:30:48 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ For reference, this takes CVS's text segment from 271136 bytes to
+ 270352 bytes, a saving of 784. Not as good as I had hoped (oh well,
+ the source *seems* simpler at least).
+ * checkin.c (Checkin), commit.c (finaladd, remove_file), update.c
+ (join_file, checkout_file, patch_file), no_diff.c
+ (No_Differences), server.c (server_updated), classify.c
+ (Classify_File), vers_ts.c (Version_TS), diff.c (diff_file_nodiff):
+ Use a single struct file_info * argument instead of a bunch of
+ separate arguments for each of its fields. Remove local fullname
+ emulations. Use fullname in error messages where file had
+ erroneously been used.
+ * cvs.h: Update declarations of above functions and move them to
+ after the struct file_info declaration.
+ * server.h: Update declarations.
+ * add.c, admin.c, checkin.c, checkout.c, classify.c, client.c,
+ commit.c, diff.c, history.c, import.c, update.c, status.c,
+ remove.c, rtag.c, tag.c: Change callers.
+
+ * diff.c (diff): Remove -q and -Q command options. This somehow
+ slipped through the cracks of the general removal of -q and -Q
+ command options on Jul 21 1995. Note that there is no need to
+ accept and ignore these options in server mode, like there is for
+ some of the commands, because the client has never sent -q and -Q
+ command options for "cvs diff".
+
+Fri Jun 28 16:50:18 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * add.c (add): Pass force_tag_match as 1 when calling Version_TS.
+ * sanity.sh (death2): Add test for above patch. Also add
+ commented out test for adding a file on a nonbranch tag, which CVS
+ currently, mistakenly, permits.
+
+Thu Jun 27 23:20:49 1996 Ian Lance Taylor <ian@cygnus.com>
+ and Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * diff.c (longopts): New static array.
+ (diff): Handle long options and new short options in diff 2.7.
+ Fix arbitrary limit associated with the tmp variable.
+ * client.c (send_option_string): Parse options as space separated,
+ rather than requiring all options to be single characters.
+ * diff.c, options.h.in: Remove CVS_DIFFDATE; the need for it is gone
+ now that we have --ifdef (the new behavior is the behavior which
+ was the default, which is that -D specifies a date).
+
+Wed Jun 26 22:36:29 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * commit.c (check_fileproc): If there is a tag, permit adding a
+ file even if the RCS file already exists.
+ (checkaddfile): If there is a tag, use the file in the regular
+ repository, rather than the Attic, if it exists.
+ * sanity.sh (death2): New set of tests for above patch.
+
+Tue Jun 25 23:34:13 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * update.c (checkout_file): Add comments about two cases which
+ seem fishy.
+
+ * sanity.sh (basic2, death): Add comments encouraging people to
+ stop making these sections bigger and more complex. I'm not (yet
+ at least) trying to figure out the ideal size for a section (my
+ current best estimate is 10-20 tests), but surely these
+ two sections are pushing the limit, whatever it is.
+
+Tue Jun 25 19:52:02 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * update.c (checkout_file): Rewrite handling of dead files when
+ joining. Avoid space leaks. Avoid unnecessary file
+ resurrections.
+ (join_file): Add checks to skip merging a dead revision onto a
+ dead revision, and to skip merging a common ancestor onto a dead
+ revision. Move check for non-existent working file after new
+ checks.
+ * sanity.sh (death): Use dotest for tests 86 and 95, and add test
+ death-file2-1, to test above changes.
+
+Mon Jun 24 11:27:37 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * update.c (merge_file): Replace file, repository, entries, and
+ update_dir arguments with finfo argument. Use fullname field
+ instead of locally emulating it.
+ (update_fileproc): Update caller.
+ (merge_file): If -kb is in effect, call it a conflict, leave
+ the two versions in the file and the backup file, and tell the
+ user to deal with it. The previous behavior was that the merge
+ would fail and then there was no way to do a checkin even once you
+ resolved the conflict (short of kludges like moving the file
+ aside, updating, and then moving it back).
+ * sanity.sh (binfiles): New tests binfiles-con* test for above
+ behavior. Adjust remaining tests to reflect changes in revision
+ numbers.
+
+Mon Jun 17 15:11:09 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * sanity.sh (import): Remove sleep. Requiring it was a bug, and
+ it is fixed in the current sources.
+
+Mon Jun 17 1996 Ian Lance Taylor <ian@cygnus.com>
+ and Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * sanity.sh (TMPPWD): Set to real name of /tmp directory.
+ (basic2-64, conflicts-126.5): Use ${TMPPWD}.
+
+Mon Jun 17 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * rcscmds.c (RCS_checkout): Remove noerr parameter. Change all
+ callers.
+ * rcs.c (RCS_fast_checkout): Likewise.
+
+Mon Jun 17 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ Cleaner implementation of tag locking code added Jun 13 1996:
+ * cvs.h (tag_lockdir, tag_unlockdir): Declare.
+ * rtag.c (locked_dir, locked_list): Remove.
+ (rtag_fileproc): Don't lock here; just call tag_lockdir.
+ (rtag_filesdoneproc): Don't unlock here; just call tag_unlockdir.
+ * tag.c (locked_dir, locked_list): Move farther down in file.
+ (tag_fileproc): Don't lock here; just call tag_lockdir.
+ (tag_filesdoneproc): Don't unlock here; just call tag_unlockdir.
+ (tag_lockdir, tag_unlockdir): New functions.
+
+Wed Jun 15 07:52:22 1996 Mike Ladwig <mike@twinpeaks.prc.com>
+
+ * client.c (send_modified, update_entries): Fixed bug which didn't
+ handle binary file transfers in BROKEN_READWRITE_CONVERSION.
+
+Thu Jun 13 1996 Ian Lance Taylor <ian@cygnus.com>
+ and Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * update.c (checkout_file): Call server_scratch_entry_only when a
+ non-pertinent file is found that does not exist.
+ * sanity.sh (newb): Add test case for above patch.
+
+Thu Jun 13 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * update.c (update_fileproc): Call server_scratch_entry_only when
+ handling T_REMOVE_ENTRY on the server.
+ * sanity.sh (conflicts2): Remove special case for remote server
+ bug fixed by above patch.
+
+Thu Jun 13 21:16:26 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * sanity.sh (basica-9): Update to reflect change to "sufficient
+ access" message.
+
+Thu Jun 13 20:13:55 1996 Ian Lance Taylor <ian@cygnus.com>
+ and Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * recurse.c, cvs.h (start_recursion): Remove wd_is_repos argument;
+ add comment about meaning of which argument. Use !(which &
+ W_LOCAL) instead of wd_is_repos.
+ * admin.c, client.c, commit.c, diff.c, edit.c, lock.c, log.c,
+ patch.c, rcs.c, remove.c, rtag.c, status.c, tag.c, update.c,
+ watch.c: Change callers. This is a semantic change in only two
+ cases: (1) tag_check_valid, where repository was not "", and (2)
+ the pipeout case in checkout_proc. In both of those cases the
+ previous setting of wd_is_repos did not reflect whether we
+ actually were cd'd into the repository.
+ * recurse.c (start_recursion): Only check for the CVS subdirectory
+ if which & W_LOCAL.
+ * sanity.sh (devcom): Add test case fixed by above patch.
+
+Thu Jun 13 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * ignore.c (ignore_files): Skip based on the file name before
+ calling lstat.
+
+ * client.c (last_register_time): New static variable.
+ (update_entries): Set last_register_time when calling Register.
+ (get_responses_and_close): If the current time is the same as
+ last_register_time, sleep for a section to avoid timestamp races.
+
+Thu Jun 13 17:24:38 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * client.c (supported_request): Reindent.
+
+Thu Jun 13 1996 Mark H. Wilkinson <mhw@minster.york.ac.uk>
+
+ * options.h.in, mkmodules.c: Corrections to allow compilation of
+ non-client-server version.
+
+Thu Jun 13 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * tag.c (tag_check_valid_join): New function.
+ * cvs.h (tag_check_valid_join): Declare.
+ * checkout.c (join_tags_validated): New static variable.
+ (checkout_proc): Check validity of join tags.
+ * update.c (update): Likewise.
+
+ * tag.c (tag_check_valid): Correct sizeof CVSROOTADM_HISTORY to
+ use CVSROOTADM_VALTAGS.
+
+ * lock.c (Writer_Lock): If we called lock_wait to wait for a lock,
+ then call lock_obtained when we get it.
+ (set_lock): Likewise.
+ (lock_obtained): New static function.
+
+Thu Jun 13 13:55:38 1996 Ian Lance Taylor <ian@cygnus.com>
+ and Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * main.c (main): If we can't read cvs root, don't say "you don't
+ have sufficient access"; just print the message from errno. It
+ might be "No such file or directory" or something else for which
+ "you don't have sufficient access" doesn't make any sense.
+
+Thu Jun 13 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * commit.c (remove_file): Pass noerr as 0 to RCS_checkout.
+
+Thu Jun 13 12:55:56 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * patch.c: Initialize rev1_validated and rev2_validated to 0, not 1.
+
+Thu Jun 13 12:55:56 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * rtag.c (locked_dir): Revise comments regarding locking; the rtag
+ and tag situations are different (changing from readlocking one
+ directory at a time to writelocking one directory at a time does
+ not do everything we might want, but it does fix simultaneous tags
+ and it doesn't make anything worse).
+
+Thu Jun 13 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ Prevent simultaneous tag operations from interfering with each
+ other.
+ * rtag.c (rtag_proc): Pass rtag_filesdoneproc to start_recursion,
+ and pass readlock as 0.
+ (locked_dir, locked_list): New static variables.
+ (rtag_fileproc): Write lock the repository if it is not already
+ locked.
+ (rtag_filesdoneproc): New static function to unlock the
+ repository.
+ * tag.c (tag): Pass tag_filesdoneproc to start_recursion, and pass
+ readlock as 0.
+ (locked_dir, locked_list): New static variables.
+ (tag_fileproc): Write lock the repository if it is not already
+ locked.
+ (tag_filesdoneproc): New static function.
+
+Thu Jun 13 11:42:25 1996 Mike Sutton <mws115@llcoolj.dayton.saic.com>
+
+ * sanity.sh: Allow digits in usernames.
+
+Wed Jun 12 16:23:03 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * client.c (send_modified, update_entries): Reindent and add
+ comments to BROKEN_READWRITE_CONVERSION code.
+
+Wed Jun 12 16:23:03 1996 Mike Ladwig <mike@twinpeaks.prc.com>
+
+ * client.c (send_modified, update_entries): Add
+ BROKEN_READWRITE_CONVERSION code.
+
+Mon Jun 10 20:03:16 1996 J.T. Conklin <jtc@cygnus.com>
+
+ * rcs.c (RCS_gettag): No longer set p to NULL if rcs is also NULL.
+ rcs will never be null, thanks to the assertion at top of function.
+
+Mon Jun 10 16:28:14 1996 Ian Lance Taylor <ian@cygnus.com>
+ and Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * main.c (main): Ignore CVS/Root file when doing an import.
+
+Fri Jun 7 18:20:01 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * status.c (status_fileproc, tag_list_proc): Use cvs_output rather
+ than writing to stdout directly.
+
+Wed Jun 5 13:54:57 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * rcs.c (force_tag_match, tag, date): New static variables.
+ (annotate_fileproc): Redo the loop to look for the version
+ specified by tag/date/force_tag_match, and handle branches
+ correctly.
+ (annotate_usage): Mention -f, -r, and -D.
+ (annotate): Handle -f, -r, and -D.
+
+Tue Jun 4 13:38:17 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * rcs.c (annotate_fileproc): Skip unrelated branch deltas.
+
+Fri Jun 7 13:04:01 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * main.c (main): Change INITIALIZE_SOCKET_SUBSYSTEM to
+ SYSTEM_INITIALIZE and pass it pointers to argc and argv. Rename
+ CLEANUP_SOCKET_SUBSYSTEM to SYSTEM_CLEANUP.
+
+Wed Jun 05 10:07:29 1996 Mike Ladwig <mike@twinpeaks.prc.com>
+
+ * import.c (add_rcs_file): make buf char[] not unsigned char[]
+
+Wed Jun 05 10:07:29 1996 Mike Ladwig <mike@twinpeaks.prc.com>
+ and Jim Kingdon <kingdon@cyclic.com>
+
+ * main.c (main): Add CLEANUP_SOCKET_SUBSYSTEM hook at end. Revise
+ comments regarding INITIALIZE_SOCKET_SUBSYSTEM.
+
+Wed Jun 05 10:07:29 1996 Mike Ladwig <mike@twinpeaks.prc.com>
+ and Jim Kingdon <kingdon@cyclic.com>
+
+ * main.c (main): Don't mess with signals if DONT_USE_SIGNALS is
+ defined.
+
+Thu Jun 6 15:32:41 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * modules.c (cat_module): Always format for 80 columns rather than
+ trying to determine how wide the screen is. The code we had for
+ the latter didn't cover all cases, was a portability headache, and
+ didn't work client/server.
+
+Wed Jun 05 10:07:29 1996 Mike Ladwig <mike@twinpeaks.prc.com>
+
+ * error.c: Don't declare strerror if it is #defined.
+
+Wed Jun 05 10:07:29 1996 Mike Ladwig <mike@twinpeaks.prc.com>
+ and Jim Kingdon <kingdon@cyclic.com>
+
+ * cvs.h: If ENUMS_CAN_BE_TROUBLE, typedef Dtype to int not an enum.
+
+Wed Jun 05 10:07:29 1996 Mike Ladwig <mike@twinpeaks.prc.com>
+ and Jim Kingdon <kingdon@cyclic.com>
+
+ * update.c (update): If DONT_USE_PATCH, don't request patches.
+ Also call supported_request rather than reimplementing it.
+
+Wed Jun 05 10:07:29 1996 Mike Ladwig <mike@twinpeaks.prc.com>
+
+ * client.c (read_line): Changed an occurence of '\n' to '\012'.
+
+Wed Jun 5 17:18:46 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * add.c (add_directory): Don't create the directory if noexec.
+ * sanity.sh (basica): New tests basica-1a10, basica-1a11 test for
+ above fix.
+ * sanity.sh (basicb): New tests basicb-2a10, basicb-2a11,
+ basicb-3a1 test for analogous situation with files rather than
+ directories.
+
+Tue Jun 4 13:38:17 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * sanity.sh: When doing a remote check, use :server: in CVSROOT.
+
+Wed Jun 5 13:32:40 1996 Larry Jones <larry.jones@sdrc.com>
+ and Jim Kingdon <kingdon@cyclic.com>
+
+ * ignore.c: Set ign_hold to -1 when not holding instead of 0 so
+ that holding an empty list works correctly.
+ * sanity.sh (ignore): New tests 190 & 191 for above fix.
+
+Wed Jun 5 1996 Jim Kingdon <kingdon@cyclic.com>
+
+ Visual C++ lint:
+ * client.c (update_entries): Copy the size to an unsigned variable
+ before comparing it with unsigned variables.
+ (handle_created, handle_update_existing): Prototype.
+
+Tue Jun 4 10:02:44 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * client.c (responses): Add Created and Update-existing responses.
+ * server.c (server_updated): If they are supported, use them
+ instead of Updated.
+ * client.c (struct update_entries_data): Add existp field.
+ (handle_checked_in, handle_updated, handle_new_entry,
+ handle_merged, handle_patched): Set it.
+ (handle_update_existing, handle_created): New functions,
+ for new responses.
+ (update_entries): Based on existp, check for
+ existence/nonexistence of file.
+ (try_read_from_server): Expand comment.
+ * server.c, server.h (server_updated): New argument vers.
+ * checkin.c (Checkin), commit.c (commit_fileproc), update.c
+ (update_fileproc, merge_file, join_file): Pass it.
+ * cvs.h: Move include of server.h after Vers_TS declaration.
+ * sanity.sh (conflicts2): New tests conflicts2-142d* test for
+ above fix.
+
+ * sanity.sh (ignore): Fix typo in comment.
+
+ * tag.c (tag_check_valid): Add comment clarifying when val-tags
+ entries are created.
+
+Mon Jun 3 07:26:35 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * version.c: Increment version number to 1.8.4.
+
+Mon Jun 3 02:20:30 1996 Noel Cragg <noel@gargle.rain.org>
+
+ * version.c: version 1.8.3.
+
+Thu May 30 10:07:24 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * main.c (cmds): Fix typo ("bdif" -> "dif") which was accidentally
+ introduced 24 May 96.
+
+ * main.c (main_cleanup): Add comment stating default case will
+ never be reached.
+
+Wed May 29 21:43:43 1996 noel <noel@BOAT_ANCHOR>
+
+ * main.c (main_cleanup): check to see if SIGHUP, SIGINT, SIGQUIT,
+ SIGPIPE, and SIGTERM are defined before using them. Also add a
+ default case to print out those errors numerically which are not
+ found.
+
+Wed May 29 18:43:45 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * expand_path.c (expand_path): Document LINE == 0 and allocation
+ of return value.
+ * modules.c (do_module): Pass 0, not -1, to indicate line number
+ not known. Free value returned from expand_path. Deal with NULL
+ return from expand_path.
+
+Wed May 29 15:56:47 1996 Greg A. Woods <woods@most.weird.com>
+
+ * modules.c (do_module): call expand_path() on the program name
+ specfied by one of '-o', '-t', or '-e' in the modules file before
+ passing it to run_setup(). This makes it possible to use $CVSROOT
+ (or indeed ~user or any other user-specified variable) to specify
+ pathnames for programs not installed in the normal execution path.
+
+Sun May 26 21:57:09 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * client.c (start_server): Don't include %s in error message;
+ there is no argument to go with it. Do include "internal error"
+ in error message since that might not be clear to the user otherwise.
+
+Sun May 26 11:58:13 1996 Greg A. Woods <woods@most.weird.com>
+
+ * root.c (set_local_cvsroot): enforce a wee bit of portability
+ (parse_cvsroot): same....
+ (DEBUG main): same, plus style guidelines
+ (DEBUG error): deleted -- not necessary here (use fprintf instead)
+
+ * mkmodules.c (modules_contents): updated notes about what must be
+ done if you change any of the options for a module.
+ (loginfo_contents): fixed grammar, re-pargraphed, and added 'echo
+ %s;' to the example.
+ (editinfo_contents): minor grammar fix.
+
+Sun May 26 17:51:18 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * vers_ts.c (Version_TS): Remove case where we get options from
+ sdtp->options. Whatever case that was intended to handle is
+ probably lost in the mists of time, but sdtp->options isn't set
+ anywhere, and I think that has been true for a long time.
+ * cvs.h (struct stickydirtag): remove options field.
+ * entries.c (freesdt): Don't free ->options.
+ * sanity.sh (binfiles): New tests binfiles-13a* test for above fix.
+
+ * tag.c (check_fileproc): Use fullname not file in error message.
+ Say "locally modified" not "up-to-date"; the file need not match
+ the head revision it only need match some revision.
+
+Sun May 26 16:57:02 1996 Norbert Kiesel <nk@col.sw-ley.de>
+
+ * tag.c: added support for new option -c to make sure all tagged
+ files are up-to-date
+ (tag): check for option and set check_uptodate
+ (check_fileproc): check status of file if check_uptodate is set
+
+Sat May 25 15:22:26 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * main.c (main): Revert change to look for a -H command option;
+ command option parsing should be up to each subcommand and the -H
+ global option works fine.
+
+Mon May 23 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * client.c (process_prune_candidates): Set prune_candidates to
+ NULL at the end of the function.
+
+Mon May 23 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * checkout.c (checkout): In code to handle multiple arguments,
+ pass preload_update_dir, not where, to Create_Admin.
+ (checkout_proc): Pass preload_update_dir, not where, to
+ Create_Admin.
+
+Thu May 23 19:14:35 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * server.c (server_set_sticky): Assert that update_dir != NULL.
+ * sanity.sh (basicb): New test; tests for Ian's fix to checkout.c
+ above.
+
+Thu May 23 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * patch.c (patch_fileproc): Don't ignore a file just because it is
+ in the Attic directory.
+
+Thu May 23 10:40:24 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * sanity.sh (death): New tests death-{72a,76a0,76a1} test for bug
+ fixed by Ian's patch_fileproc change above.
+
+ * sanity.sh (death): Remove "temporary hack" in test 89.
+
+ * rcs.c (RCS_fast_checkout): If error closing file, and workfile
+ is NULL, use sout in error message instead of workfile.
+
+Thu May 23 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * rcs.c (RCS_fast_checkout): Do a fast checkout in the case where
+ workfile is NULL and sout is a file name.
+
+Wed May 22 19:06:23 1996 Mark Immel <immel@centerline.com>
+
+ * update.c (checkout_file): New arg resurrecting_out, to provide
+ resurrecting flag to caller.
+ (join_file): New arg resurrecting. Register with "0" if we are
+ the server and are resurrecting.
+ (update_fileproc): Pass the flag from checkout_file to join_file.
+
+Wed May 22 19:06:23 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * sanity.sh (death): Test for above fix, in test 89 and new test 89a.
+
+Tue May 21 09:49:04 1996 Greg A. Woods <woods@most.weird.com>
+
+ * update.c (update_usage): oops -- fix my spelling typo.
+
+Mon May 20 10:53:14 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * commit.c (find_fileproc): Call freevers_ts.
+
+ * commit.c (find_*): Keep an ignlist, like update.c and client.c do.
+ * commit.c (commit): Process the files from the ignlists, once we
+ are connected to the server.
+ * sanity.sh (ignore): New tests 189e and 189f test for new
+ commit.c behavior (and client.c behavior, which is unchanged).
+ * sanity.sh (conflicts): Remove dir1 and sdir in parts of the test
+ where we aren't prepared for "? dir1" and similar output.
+
+Mon May 20 13:23:36 1996 Greg A. Woods <woods@most.weird.com>
+
+ * main.c (cmd_usage): minor corrections to descriptions of status,
+ rtag, tag, and rdiff. Sort alphabetically by command name.
+
+Mon May 20 10:36:07 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * client.c (call_in_directory): Move the call to Entries_Close
+ before the call to chdir, since Entries_Close examines files in
+ the current directory.
+
+Fri May 17 12:13:09 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * client.c (start_tcp_server, start_server, start_rsh_server,
+ read_line, filter_through_gzip, filter_through_gunzip,
+ call_in_directory): Reindent as needed.
+
+ * main.c (main): Add missing #endif. Use indentation to indicate
+ nesting.
+
+Thu May 16 17:15:01 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * main.c (cmd_usage): Add "init" command.
+
+Thu May 16 16:45:51 1996 Noel Cragg <noel@gargle.rain.org>
+
+ * client.c (start_tcp_server): Error message modified to tell the
+ user to use ":server:" instead of setting CVS_CLIENT_PORT to a
+ negative number.
+
+ * main.c (main): Add #ifdefs for turning off buffering of
+ stdio/stderr, so we don't get it by default.
+
+Thu May 16 01:29:47 1996 noel <noel@BOAT_ANCHOR>
+
+ * commit.c (commit_filesdoneproc): Print the repository and root
+ directories as part of the error message.
+
+ * main.c (main): Don't buffer stdout or stderr. It's inefficient,
+ but it then produces the right output for sanity.sh.
+
+Thu May 16 09:44:47 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * fileattr.c (fileattr_set): In the case where we are about to
+ call delproc, don't free ->data; delproc does that.
+ * sanity.sh (devcom): New tests devcom-b* test for this fix.
+
+ * sanity.sh (conflicts): Remove redundant clean up from previous
+ tests at the beginning of the test. Use dotest a few more places.
+ (conflicts2): New test, tests for Ian's fix to Classify_File.
+
+ * client.c (remove_entry_and_file): Add comment about
+ existence_error's.
+
+Sat May 16 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * update.c (update_dirleave_proc): Don't try to chdir .. and check
+ for an empty directory if there is a slash in the directory name.
+
+Thu May 16 09:02:59 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * sanity.sh (deep): New tests deep-4a* test for Ian's fix to
+ update_dirleave_proc.
+
+Sat May 16 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * main.c (main_cleanup): Report signal name before dying.
+
+Wed May 15 23:47:59 1996 Noel Cragg <noel@gargle.rain.org>
+
+ * main.c (usg): revert usage strings for `-H' flag change.
+
+Sat May 15 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * server.c (serve_static_directory): Return immediately if there
+ is a pending error.
+ (serve_sticky): Likewise.
+ (serve_modified): Read the file data even if there is a pending
+ error.
+
+Wed May 15 14:26:32 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * main.c (main): If -d and CVS/Root both specified, after writing
+ the value from -d into CVS/Root, use the value from -d, not the
+ old value from CVS/Root. Don't write CVS/Root with value from -d
+ until we have verified that it works.
+ * sanity.sh: Reenable test basica-9 and adjust for new behavior.
+
+Tue May 14 1996 Jim Kingdon <kingdon@cyclic.com>
+
+ * logmsg.c (do_editor): If user aborts the commit, still remove the
+ temporary file.
+
+Tue May 14 11:45:41 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * filesubr.c, cvs.h (cvs_temp_name): New function. Move L_tmpnam
+ define from cvs.h to filesubr.c.
+ * client.c, diff.c, import.c, login.c, logmsg.c, no_diff.c,
+ patch.c, wrapper.c: Call cvs_temp_name not tmpnam.
+ * login.c (login): Reindent function.
+
+Tue May 14 10:56:56 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * rcs.c (RCS_fast_checkout): If workfile is NULL, don't call chmod.
+
+Mon May 13 10:52:10 1996 Greg A. Woods <woods@most.weird.com>
+
+ * checkout.c (export_usage): note which options cause a sticky
+ version to be set, and which option avoids this.
+ * update.c (update_usage): likewise
+
+Sat May 11 18:57:07 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * sanity.sh: Comment out test basica-9 until I get around to
+ actually fixing it (the -d vs. CVS/Root change broke it).
+
+Fri May 10 09:39:49 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * main.c (main): -d now overrides CVS/Root.
+
+Thu May 9 19:45:24 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * main.c: Remove comment listing commands at beginning. It was
+ out of date and redundant with the help.
+
+Thu May 9 09:33:55 1996 Greg A. Woods <woods@most.weird.com>
+
+ * main.c: add 'init' to opening comment listing commands
+
+ * mkmodules.c (init): fix to recognize argc==-1 as hint to call
+ usage() [should make "cvs init -H" work as expected]
+
+Wed May 8 15:02:49 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * sanity.sh: Set EXPR in the case that the expr in the path is the
+ one that we want.
+
+Wed May 8 14:06:24 1996 Greg A. Woods <woods@most.weird.com>
+
+ * sanity.sh (test): - convert all '[' to test ala GCD
+
+Wed May 8 13:46:56 1996 Greg A. Woods <woods@most.weird.com>
+
+ * sanity.sh (expr): - make a valiant attempt to find GNU expr
+ - Patch from Larry Jones:
+ sanity test deep-4 failed with "expr: arg list too long"
+ sanity test 56 failed because the stderr and stdout output was not
+ interleaved as expected.
+ sanity test modules-155a4 failed with "ls: illegal option -- 1"
+
+ * main.c (main): - Patch from Larry Jones for SysV setvbuf
+
+Tue May 7 16:41:16 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * version.c: Increment version number to 1.8.2 to work around fact
+ that CVS 1.8 (confusingly) calls itself 1.8.1 not 1.8.
+
+Tue May 7 10:44:20 MET DST 1996 Norbert Kiesel <nk@col.sw-ley.de>
+
+ * rcs.c (rcsvers_delproc): fix memory leak by freeing author
+ field.
+
+Mon May 6 10:40:05 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * sanity.sh (conflicts): New test conflicts-126.5 tests for bug
+ which Ian fixed May 5 in update.c
+
+Mon May 6 06:00:10 1996 Benjamin J. Lee <benjamin@cyclic.com>
+
+ * Version 1.8.1
+
+Sun May 5 21:39:02 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * vers_ts.c (Version_TS): If sdtp is NULL, go ahead and check
+ RCS_getexpand for options. Fixes binaries and non-unix clients.
+ * sanity.sh: Fix binfiles-5.5 to test for the correct behavior
+ rather than the buggy behavior which existed when the binfiles-5.5
+ test was written.
+ (binfiles-14c,binfiles-14f): Likewise.
+
+Sun May 5 17:38:21 1996 Benjamin J. Lee <benjamin@cyclic.com>
+
+ Integrated changes submitted by Ian Taylor <ian@cygnus.com>
+
+ * update.c (update_dirent_proc): cvs co -p doesn't print
+ anything when run from an empty directory.
+
+ * import.c (import_descend_dir): Check for a file in the
+ repository which will be checked out to the same name as the
+ directory.
+
+Sat May 4 12:33:02 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ Extract the head revision directly from the RCS file when
+ possible, rather than execing co.
+ * rcs.c (RCS_reparsercsfile): Set delta_pos field.
+ (getrcskey): Add lenp parameter. Change all callers.
+ (RCS_fast_checkout): New function.
+ (annotate_fileproc): If PARTIAL is not set, just fseek to
+ delta_pos.
+ * rcs.h (struct rcsnode): Add delta_pos field.
+ (RCS_fast_checkout): Declare.
+ * diff.c (diff_file_nodiff): Call RCS_fast_checkout rather than
+ RCS_checkout.
+ * import.c (update_rcs_file): Likewise.
+ * no_diff.c (No_Difference): Likewise.
+ * patch.c (patch_fileproc): Likewise.
+ * update.c (checkout_file): Likewise.
+ (patch_file): Likewise.
+ (join_file): Likewise.
+
+Sat May 4 12:33:02 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * classify.c (Classify_File): Don't report a conflict for a
+ pending remove if somebody else has already removed the file.
+
+Thu May 2 13:34:37 1996 Benjamin J. Lee <benjamin@cyclic.com>
+
+ * Version 1.7.88
+
+Thu May 2 01:40:55 1996 Benjamin J. Lee <benjamin@cyclic.com>
+
+ * server.c (HAVE_INITGROUPS): Use initgroups() only if
+ located by configure, in the event a system has crypt(), but
+ no initgroups()
+
+Wed May 01 21:08:21 1996 noel <noel@BOAT_ANCHOR>
+
+ * client.c (filter_through_gunzip): use "gzip -d" instead of
+ "gunzip," since there's no good reason (on NT at least) to have an
+ extra copy of gzip.exe copied to gunzip.exe (Arrrrgh! No symbolic
+ links!).
+
+ * mkmodules.c (init): check to see that we have the correct number
+ of arguments or print out the usage message (used to be argc > 1,
+ should be argc != 1, because help forces argc == -1 as a special
+ case).
+
+Wed May 1 18:05:02 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * sanity.sh (basica): When testing rejection of reserved tag name,
+ use BASE instead of RESERVED.
+
+Wed May 1 15:15:11 1996 Tom Jarmolowski <tjj@booklink.com>
+
+ * rcs.c (linevector_delete): Only copy up to vec->nlines - nlines,
+ not to vec->nlines.
+
+Wed May 1 15:43:21 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * rcscmds.c (RCS_settag): Instead of reserving all tag names
+ containing only uppercase letters, reserve only BASE and HEAD.
+ * sanity.sh (mflag): Revert 26 Mar change; use all-uppercase tag
+ name again.
+
+Wed May 1 15:15:11 1996 Tom Jarmolowski <tjj@booklink.com>
+
+ * rcs.c (linevector_add): Move increment of i out of larger
+ statement, to avoid assumptions about evaluation order.
+
+Tue Apr 30 15:46:03 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * Version 1.7.87.
+
+ * server.c (check_password): Don't use ANSI string concatenation.
+ Reindent function.
+
+Mon Apr 29 10:48:38 1996 Noel Cragg <noel@gargle>
+
+ * root.c (parse_cvsroot): removed "rsh" as an alias to "server" in
+ the method section.
+
+ * main.c (main): new variable help so we can support the `cvs -H
+ cmd' convention. Reverts change of 26 Apr 96 which removed this
+ feature.
+
+Sun Apr 28 14:57:38 1996 Noel Cragg <noel@gargle>
+
+ * main.c (main): update error message if parse_cvsroot fails.
+ * server.c (serve_root): same.
+ (serve_init): same.
+
+ * client.c (start_tcp_server): get rid of the "fall through"
+ stuff, now that we have access methods.
+ (start_server): switch off the access method to choose routine
+ that starts the server.
+ (start_tcp_server): tofd wasn't getting set to -1 early enough,
+ because a call to error for bind or gethostbyname might fail and
+ the subsequent error check to see if the connection had been made
+ would fail.
+
+ * root.c: new variable method_names for error reporting purposes.
+
+Sun Apr 28 17:22:15 1996 Noel Cragg <noel@occs.cs.oberlin.edu>
+
+ * server.c: moved kerberos #includes from main.c for the
+ kserver_authenticate_connection routine.
+
+Fri Apr 26 07:59:44 1996 Noel Cragg <noel@gargle>
+
+ * server.c (serve_init): use the new return value from
+ parse_cvsroot.
+ (serve_root): same.
+ * main.c (main): same.
+
+ * root.c (parse_cvsroot): fix indentation, add a return value
+ which tells whether the command succeeded or failed.
+
+ * main.c (main): move the setting of the UMASK environment
+ variable inside the stuff that gets done if the user is NOT asking
+ for help, so we don't signal any errors prematurely (don't want to
+ give an error because we can't parse an environment variable
+ correctly if the user asks for help). Similar mods for the code
+ that tries to get the working directory.
+
+ Also make CVSADM_Root a local variable instead of a global, since
+ its scope is only about 20 lines here!
+
+ * server.c (kserver_authenticate_connection): moved code from
+ main.c to clean up MAIN. Makes sense, since we already have a
+ pserver_authenticate_connection.
+ (pserver_authenticate_connection): rename from
+ authenticate_connection.
+
+ * main.c (main): reorganized the routine to eliminate variables
+ help, help_commands, and version_flag. Now the routine is much
+ clearer, since we don't have to be checking to see if these
+ variables are set. One behavior that was a bug/feature which is
+ now gone is an invocation like "cvs -H rtag" -- previously this
+ would give usage for rtag, but now gives usage for cvs itself.
+ The first behavior didn't make sense, especially since we say in
+ the docs that command-line flags are position-specific. *Reverted
+ Above*
+
+Thu Apr 25 20:05:10 1996 Noel Cragg <noel@gargle>
+
+ * main.c (main): make sure we have a valid command name before we
+ do anything else (moved the thing that looks for a command in CMDS
+ to right after the GETOPT loop). Added `kserver' and `pserver' to
+ the table so they will be recognized; set their functions to
+ SERVER so that help will be given when asked for.
+
+ * expand_path.c (expand_variable): return CVSroot_original rather
+ than CVSroot_directory.
+
+ * main.c (main): save CVSroot in the env rather than
+ CVSroot_original, since we might not have called PARSE_CVSROOT
+ (this can happen if we use the -H option to a command).
+
+ * root.c (parse_cvsroot): the parsing method was bogus for
+ guessing when we had hostnames vs. directories specified. Any
+ ambiguity should be removed by having the user specify the access
+ method. If the access method isn't specified, choose
+ server_method if the string contains a colon or local_method
+ otherwise.
+
+ * Changed CVSroot_remote back to client_active since the code
+ reads better.
+
+Wed Apr 24 17:27:53 1996 Norbert Kiesel <nk@col.sw-ley.de>
+
+ * vers_ts.c (Version_TS): xmalloc enough space (1 more
+ byte). Thanks to purify!
+
+Mon Apr 22 00:38:08 1996 Noel Cragg <noel@gargle>
+
+ * create_adm.c (Create_Admin): pass CVSroot_original instead of
+ CVSroot_directory (oops!).
+ * update.c (update_filesdone_proc): same.
+
+ * server.c (serve_root): modify to use parse_cvsroot rather than
+ goofing around with other variables. Will need to fix
+ parse_cvsroot to have a return value so we can return an error and
+ quit gracefully if in server mode.
+ (serve_init): same.
+
+ * main.c: modify command table to remove client_* routines, since
+ they no longer exist.
+ (main): don't try to switch off non-existent field in command
+ table! ;-)
+
+ * client.h (client_*): removed prototypes for now non-existent
+ functions.
+
+ * client.c: remove proto for get_cvs_password, since it is now in
+ cvs.h. Modify routines to use new globals that describe CVSROOT
+ rather than client_active, server_host, server_user, and
+ server_cvsroot.
+ (parse_cvsroot): removed function, since a more generic version
+ now lives in root.c.
+ (connect_to_pserver): remove call to parse_cvsroot, since main.c
+ has already done it for us.
+ (client_*): removed all of these routines, since they only call
+ parse_cvsroot and then their respective operation functions.
+ Since main.c has already called parse_cvsroot, we shouldn't bother
+ with the extra function call, since client-server diffs are
+ already handled in the core routines themselves.
+
+ * main.c: remove CVSroot as a global variable. Remove
+ use_authenticating_server variable since we have a new
+ `CVSroot_method' variable instead.
+ (main): add `CVSroot' as a local variable. Call parse_cvsroot
+ after we're sure we have the right setting for `CVSroot.'
+
+ * login.c (login): update to use new global variables. Instead of
+ old behavior which let the user type in user@host when prompted,
+ it makes them do it in CVSROOT proper. The routine still lets the
+ user type the password, however.
+ (get_cvs_password): make sure that CVSROOT is fully qualified
+ before trying to find the entry in the .cvspass file.
+ * cvs.h: add prototype for get_cvs_password.
+
+ * add.c: use new globals that describe CVSROOT.
+ * admin.c: same.
+ * checkout.c: same.
+ * commit.c: same.
+ * create_adm.c: same.
+ * diff.c: same.
+ * edit.c: same.
+ * expand_path.c: same.
+ * history.c: same.
+ * ignore.c: same.
+ * import.c: same.
+ * log.c: same.
+ * mkmodules.c: same.
+ * modules.c: same.
+ * parseinfo.c: same.
+ * patch.c: same.
+ * rcs.c: same.
+ * recurse.c: same.
+ * release.c: same.
+ * remove.c: same.
+ * repos.c: same.
+ * rtag.c: same.
+ * status.c: same.
+ * tag.c: same.
+ * update.c: same.
+ * watch.c: same.
+ * wrapper.c: same.
+
+ * root.c (Name_Root): remove error message that reports missing
+ CVSROOT, since new code in main.c will catch it and also print out
+ an error.
+ (parse_cvsroot): new function -- takes a CVSROOT string and breaks
+ it up into its component parts -- method, hostname, username, and
+ repository directory. Sets new global variables that describe the
+ repository location more precisely: CVSroot_original,
+ CVSroot_remote, CVSroot_method, CVSroot_username,
+ CVSroot_hostname, CVSroot_directory for use by all other
+ functions. Checks for obvious errors in format of string.
+ (main): a short routine to test parse_cvsroot from the command
+ line.
+ * cvs.h: add prototype for parse_cvsroot and extern definitions
+ for new globals.
+
+ * cvs.h: removed CVSroot variable, since we don't want other
+ routines using the raw CVSROOT (also helped to find all of the
+ refs to the variable!).
+
+Fri Apr 19 11:22:35 1996 Benjamin J. Lee <benjamin@cyclic.com>
+
+ * Version 1.7.86
+
+Thu Apr 18 1996 Jim Kingdon <kingdon@cyclic.com>
+
+ * client.c (try_read_from_server): Compare return value from fwrite
+ with a size_t not an int (Visual C++ lint).
+
+Wed Apr 17 11:56:32 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * client.c (try_read_from_server): New function.
+ (read_from_server): Use it.
+ (read_counted_file): New function.
+ * client.c, server.c: Add Template response.
+ * cvs.h (CVSADM_TEMPLATE): Added.
+ * logmsg.c (do_editor): If repository is NULL, use CVSADM_TEMPLATE
+ file in place of rcsinfo.
+ * server.c, server.h (server_template): New function.
+ * create_adm.c (Create_Admin): Call it.
+
+Tue Apr 16 13:56:06 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * repos.c (Name_Repository): Fix comments.
+ * create_adm.c (Create_Admin): Fix indentation.
+
+Wed Apr 10 16:46:54 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * options.h.in: Include relevant information here rather than
+ citing (former) FAQ.
+
+ * ChangeLog-9395: Fix typo in introductory paragraph.
+
+Wed Apr 10 14:55:10 1996 code by Mike Spengler mks@msc.edu
+ comments by Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * filesubr.c (unlink_file_dir,deep_remove_dir): Don't call unlink
+ on something which might be a directory; check using isdir instead.
+
+Wed Apr 10 14:55:10 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * checkout.c (build_dirs_and_chdir): Pass path, not cp, to
+ Create_Admin. The former is the correct update dir.
+ * sanity.sh (modules): New tests modules-155* test, for above fix.
+
+Mon Apr 8 13:53:27 1996 Samuel Tardieu <sam@inf.enst.fr>
+
+ * rcs.c (annotate_fileproc): If the file is not under CVS control,
+ return instead of dumping a core. Don't bug on files with an empty
+ first revision.
+
+Fri Mar 29 16:08:28 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * rcs.c (annotate_fileproc): If last line of add-chunk is not
+ newline terminated, end the loop when we find that out.
+
+Fri Mar 29 16:59:34 1996 Norbert Kiesel <nk@col.sw-ley.de>
+
+ * rcs.c (annotate_fileproc): allow last line of add-chunk not to
+ be newline terminated
+
+Thu Mar 28 10:56:36 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ Add more diff tests:
+ * sanity.sh (basic2): Use dotest for test 61.
+ (basica): Add test basica-6.2.
+ (branches): Add tests branches-14.4 and branches-14.5.
+ (basic1): Remove tests 19, 20, 25, and 26. The only thing this
+ might miss out on is diff's interaction with added and removed
+ files, but those tests didn't test that very well anyway.
+
+ * rcs.c (RCS_getrevtime): Add comment regarding years after 1999.
+
+ * rcs.c: Add "cvs annotate" command and related code.
+ (getrcskey): Move special handling of RCSDESC from here to
+ callers. Handle those keys (desc, log, text) which do not
+ end in a semicolon.
+ * rcs.h (RCSVers): Add author field.
+ * rcs.c (RCS_reparsercsfile): Set it.
+ * cvs.h (annotate), main.c (cmd_usage, cmds), client.h client.c
+ (client_annotate), server.c (serve_annotate, requests): Usual
+ machinery to add a new command.
+ * sanity.sh (basica): Test cvs annotate.
+
+ * sanity.sh (branches): More tests, of things like adding files on
+ the trunk after a branch has been made.
+
+Tue Mar 26 09:48:49 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * expand_path.c: Don't declare free and xmalloc; cvs.h already
+ takes care of that.
+
+ * sanity.sh (mflag): Don't use tag name reserved to CVS.
+
+ NT local changes plus miscellaneous things noticed in the process:
+ * import.c (add_rcs_file): Use binary mode to write RCS file. Use
+ \012 where linefeed is intended. Copy data a small block at a
+ time, until we hit EOF, rather than trying to read the whole file
+ into memory at once.
+ * client.c (send_modified): Add comments regarding st_size.
+ * commit.c (commit): Add comments regarding binary mode and read().
+ * logmsg.c (do_editor): Add comments regarding st_size.
+ * server.c (server_updated): Use binary mode to read file we are
+ sending.
+
+ * rcscmds.c (RCS_settag): Complain if user tries to add a tag name
+ reserved to CVS.
+ * sanity.sh (basica): Test for this behavior.
+
+ * sanity.sh (binfiles): New tests test ability to change keyword
+ expansion.
+
+Mon Mar 25 1996 Jim Kingdon <kingdon@cyclic.com>
+
+ * cvs.h, filesubr.c (expand_wild): New function.
+ * recurse.c (start_recursion): Call expand_wild at beginning and
+ free its results at the end.
+ * cvs.h, subr.c (xrealloc): Make argument and return value void *.
+ * client.h, client.c (send_file_names): Add flags argument. If
+ SEND_EXPAND_WILD flag is passed, call expand_wild at beginning and
+ free its results at the end.
+ * admin.c, add.c, log.c, tag.c, status.c, edit.c, watch.c,
+ update.c, commit.c, remove.c, client.c, diff.c: Update callers.
+
+Fri Mar 22 10:09:55 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * error.c (error, fperror): Exit with status EXIT_FAILURE rather
+ than STATUS. We had been neglecting to check for 256, and the
+ value of providing a count of errors is probably minimal anyway.
+ * add.c, modules.c, mkmodules.c, tag.c, server.c, main.c,
+ import.c, client.c, scramble.c, recurse.c: Exit with status
+ EXIT_FAILURE rather than 1. On VMS, 1 is success, not failure.
+ * main.c (main): Return EXIT_FAILURE or 0. The value of providing
+ a count of errors is minimal.
+
+ * client.c (init_sockaddr): Exit with status 1 rather than
+ EXIT_FAILURE. The latter apparently doesn't exist on SunOS4.
+ Reindent function.
+
+Mon Mar 18 14:28:00 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * cvs.h, ignore.c: New variable ign_case.
+ * ignore.c (ign_name): If it is set, match in a case-insensitive
+ fashion.
+ * server.c (serve_case): New function.
+ (requests): Add Case request.
+ * client.c (start_server): If FILENAMES_CASE_INSENSITIVE is
+ defined, send Case request.
+
+Sat Mar 16 08:20:01 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ For reference, this change takes cvs's text segment from 315392
+ bytes to 311296 bytes (one 4096 byte page).
+ * cvs.h (struct file_info): Add fullname field.
+ * recurse.c (do_file_proc): Set it.
+ * commit.c (find_fileproc), client.c (send_fileproc), commit.c
+ (check_fileproc), diff.c (diff_fileproc), edit.c
+ (unedit_fileproc), patch.c (patch_fileproc), remove.c
+ (remove_fileproc), rtag.c (rtag_fileproc), tag.c (tag_fileproc),
+ update.c (update_fileproc), watch.c (watchers_fileproc): Use it
+ instead of computing it each time.
+ * diff.c (diff_fileproc), remove.c (remove_fileproc): Use fullname
+ where we had been (bogusly) omitting the directory from user
+ messages.
+ * edit.c (unedit_fileproc, edit_fileproc): If we cannot close
+ CVSADM_NOTIFY, mention CVSADM_NOTIFY rather than finfo->file in
+ error message.
+ * rtag.c (rtag_fileproc), tag.c (tag_fileproc): Reindent.
+
+Fri Mar 15 15:12:11 1996 Norbert Kiesel <nk@col.sw-ley.de>
+
+ * server.h: fix prototype of server_pause_check (was
+ server_check_pause)
+
+Thu Mar 14 1996 Jim Kingdon <kingdon@cyclic.com>
+
+ * vers_ts.c (Version_TS), entries.c (Scratch_Entry, AddEntryNode):
+ Change findnode to findnode_fn.
+
+ * main.c: Depending on HAVE_WINSOCK_H, include winsock.h or
+ declare gethostname.
+ * cvs.h: Don't declare it here.
+
+Thu Mar 14 07:06:59 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * commit.c (find_fileproc): If vn_user is NULL and ts_user is not,
+ print an error rather than silently succeeding.
+ * sanity.sh (basica-notadded): New test, for above fix.
+ (dotest_internal): New function.
+ (dotest,dotest_fail): Call it instead of duplicating code between
+ these two functions.
+
+ * sanity.sh: Skip tests binfiles-9 through binfiles-13 for remote.
+
+ * options.h.in: Adjust comment to reflect kfogel change.
+
+Thu Mar 14 01:38:30 1996 Karl Fogel <kfogel@floss.red-bean.com>
+
+ * options.h.in (AUTH_CLIENT_SUPPORT): turn on by default.
+
+Wed Mar 13 09:25:56 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * vers_ts.c (Version_TS): Don't try to override options from rcs
+ file if there isn't an rcs file (e.g. called from send_fileproc).
+ This fixes a bug detected by test 59 in "make remotecheck".
+
+ * rcs.c (RCS_reparsercsfile, RCS_getexpand): Assert that argument
+ is not NULL.
+
+ Fix a gcc -Wall warning:
+ * rcs.c, rcs.h (RCS_getexpand): New function.
+ * vers_ts.c (Version_TS): Call it.
+ * rcs.c (RCS_reparsercsfile): Make static.
+
+ Add a "cvs init" command. This is needed because cvsinit.sh
+ invoked mkmodules which doesn't exist any more.
+ * mkmodules.c: Break filelist out of mkmodules function, rename
+ struct _checkout_file to struct admin_file (for namespace
+ correctness), and add contents field.
+ (init,mkdir_if_needed): New functions.
+ * cvs.h (init): Declare.
+ * main.c (cmds): Add init.
+ (main): If command is init, don't require cvsroot to exist.
+ * client.c, client.h (client_init, send_init_command): New functions.
+ * client.c (start_server): Don't send Root request if command is init.
+ * server.c (serve_init): New function.
+ (requests): Add "init".
+
+Wed Mar 13 09:51:03 MET 1996 Norbert Kiesel <nk@col.sw-ley.de>
+
+ * vers_ts.c (Version_TS): set options to default option if the
+ file if no -k option but -A was given. This avoids the (wrong)
+ update message for binary files which are up-to-date when
+ running 'cvs -A'.
+
+ * update.c (checkout_file): remove test of -k option stored in the
+ file itself because it was moved to vers_ts.c
+
+ * sanity.sh: added tests for the above fix.
+
+Tue Mar 12 13:47:09 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * hash.c (findnode): Adjust comment regarding errors.
+
+ * hash.c (findnode, findnode_fn): Assert that key != NULL. This
+ way the check still happens even if the function is later
+ rewritten to not start out by calling hashp.
+
+Mon Mar 11 10:21:05 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * sanity.sh: If expr accepts multi-line patterns but is too
+ liberal in matching them, print a warning but keep going.
+
+ * sanity.sh: Add QUESTION variable, analogous to PLUS. Use it
+ instead of \? to match a question mark.
+
+ * cvs.h (CVSMODULE_OPTS, CVSMODULE_SPEC): Move from here...
+ * modules.c: ...to here. They are only used here and the code to
+ handle the syntax of modules files should not be scattered all over.
+ * modules.c (CVSMODULE_OPTS): Add "+" as first character.
+ * sanity.sh (modules): New tests 148a0 and 148a1 test for
+ above-fixed bug.
+
+Mon Mar 11 13:11:04 1996 Samuel Tardieu <sam@inf.enst.fr>
+
+ * modules.c (cat_module): set optind to 0 to force getopt() to
+ reinitialize its internal nextchar
+
+Mon Mar 11 00:09:14 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * hash.c (findnode, findnode_fn): Revert changes of 7-8 Mar 1996.
+ The correct style is to assert() that key != NULL (see HACKING),
+ which is already done in the hashp function.
+ * fileattr.c (fileattr_delproc): Likewise, assert() that
+ node->data != NULL rather than trying to deal with it being NULL.
+
+Fri Mar 8 01:31:04 1996 Greg A. Woods <woods@most.weird.com>
+
+ * hash.c (findnode_fn): one more place to avoid calling hashp()
+ with a NULL key
+
+Thu Mar 7 17:30:01 1996 Greg A. Woods <woods@most.weird.com>
+
+ * hash.c (findnode): also return NULL if key is not set
+ [[ reported by Chris_Eich@optilink.optilink.dsccc.com, and
+ supposedly in a PR that should be marked "fixed"..... ]]
+
+ * fileattr.c (fileattr_set): set node->data to NULL after freeing
+ it to prevent subsequent accesses
+ (fileattr_delproc): don't free node->data if it's NULL, and set it
+ to NULL after freeing
+ [[ reported by Chris_Eich@optilink.optilink.dsccc.com, and
+ supposedly in a PR that should be marked "fixed"..... ]]
+
+Fri Mar 1 14:56:08 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * sanity.sh (basica): New test basica-4a tests for bug fixed by
+ sam@inf.enst.fr on 1 Mar 96.
+
+Fri Mar 1 18:10:49 1996 Samuel Tardieu <sam@inf.enst.fr>
+
+ * tag.c (check_fileproc): Check for file existence before trying
+ to tag it.
+
+Fri Mar 1 07:51:29 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * client.c (update_entries): If command is export, set options to
+ NULL.
+
+Thu Feb 29 16:54:14 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * lock.c (write_lock, Reader_Lock): Remove
+ BOGUS_UNLESS_PROVEN_OTHERWISE code. It was pretty bogus, and has
+ been ifdeffed out for a long time.
+ * cvs.h (CVSTFL): Removed; no longer used.
+
+ * cvsrc.c, cvs.h (read_cvsrc): Pass in command name rather than
+ using global variable command_name.
+ * main.c (command_name): Initialize to "", not "cvs" so that error
+ messages don't say "cvs cvs". Update calls to read_cvsrc to pass
+ in command_name or "cvs" as appropriate.
+ * sanity.sh (basica): New test basica-9 tests for above-fixed bug.
+
+ * lock.c: Rename unlock to lock_simple_remove to avoid conflict
+ with builtin function on QNX.
+
+Thu Feb 29 17:02:22 1996 Samuel Tardieu <sam@inf.enst.fr>
+
+ * fileattr.c (fileattr_get): Removed NULL pointer dereference
+ which occurred in the absence of default attribute.
+
+Thu Feb 29 07:36:57 1996 J.T. Conklin <jtc@rtl.cygnus.com>
+
+ * rcs.c (RCS_isbranch, RCS_whatbranch): Remove no longer used file
+ argument, swap order of remaining two arguments to be like other
+ RCS_* functions.
+ (RCS_nodeisbranch): swap order of arguments to be like other RCS_*
+ functions.
+ * rcs.h (RCS_isbranch, RCS_whatbranch, RCS_nodeisbranch): Update
+ prototypes for above changes.
+ * commit.c, rtag.c, status.c, tag.c: Update for above calling
+ convention changes.
+
+Thu Feb 29 08:39:03 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * client.c (start_server): Revert changes which claimed to fall
+ back to a different way of connecting. Add comments explaining
+ why. (I don't think the changes did what they claimed, anyway).
+ Use indentation rather than comments to line up #if, #else, and
+ #endif.
+
+ * patch.c (patch, patch_fileproc): Revert change to add optional
+ arguments to -c and -u. Optional arguments are evil and in
+ violation of the POSIX argument syntax guidelines. The correct
+ way to do this is -C and -U. Also change DIFF back to "diff" in
+ output (see comments).
+
+ gcc -Wall lint:
+ * client.c (copy_a_file): Declare p inside the #ifdef in which is
+ it used.
+ * commit.c (remove_file): Remove unused variable p.
+ * commit.c (checkaddfile): Remove unused variables p.
+ * rcs.c (RCS_isbranch): Remove unused variable p.
+ * rcs.c: Remove unused declarations and definitions of
+ parse_rcs_proc, rcsnode_delproc, rcslist, and repository.
+ * rtag.c (rtag_fileproc): Remove unused variable p.
+ * patch.c (patch_fileproc): Remove unused variable p.
+ * tag.c (val_fileproc): Remove unused variable node.
+ * client.c, import.c, lock.c, server.c: Cast pid_t to long before
+ passing it to %ld.
+
+ * cvs.h: Don't prototype gethostname; merely declare it (on linux,
+ second argument is size_t not int).
+
+Thu Feb 29 10:29:25 MET 1996 Norbert Kiesel (nk) <nk@col.sw-ley.de>
+
+ * sanity.sh: added "cat > /dev/null" to loginfo entry to avoid the
+ SIGPIPE signal
+
+Thu Feb 29 10:28:25 MET 1996 Norbert Kiesel (nk) <nk@col.sw-ley.de>
+
+ * patch.c: added new variable diff_opt
+ (patch): allow optional parameter to -c and -u option, send it to
+ server
+ (patch_fileproc): cleaned up the code which prints the current
+ filename. For "-s" option, print the pathname relative to CVSROOT
+ instead of just the filename.
+
+ * filesubr.c (xchmod): added cast to shut up gcc
+
+ * cvs.h: added prototype for gethostname
+
+Thu Feb 29 10:27:25 MET 1996 Norbert Kiesel (nk) <nk@col.sw-ley.de>
+
+ * lock.c (write_lock), (Reader_Lock), import.c (update_rcs_file),
+ client.c (update_entries), (send_modified), server.c (server),
+ (receive_file), (server_updated): use %ld for printing pid_t
+ variables
+
+Thu Feb 29 02:22:12 1996 Benjamin J. Lee <benjamin@cyclic.com>
+
+ * run.c (run_exec): Added VMS return status support.
+
+Thu Feb 29 01:07:43 1996 Benjamin J. Lee <benjamin@cyclic.com>
+
+ * client.c (send_to_server): wrtn wasn't being declared under
+ VMS for some reason.
+
+Wed Feb 28 23:27:04 1996 Benjamin J. Lee <benjamin@cyclic.com>
+
+ * client.c: Changed #ifdef VMS && NO_SOCKET_TO_FD to
+ #if defined(VMS) && defined(NO_SOCKET_TO_FD)
+
+Wed Feb 28 22:28:43 1996 Benjamin J. Lee <benjamin@cyclic.com>
+
+ * build_src.com: Added DCL command procedure to build
+ and link CVS client for VMS.
+
+Wed Feb 28 22:07:20 1996 Benjamin J. Lee <benjamin@cyclic.com>
+
+ * client.c: VMS CVS client specific changes.
+
+ Added USE_DIRECT_TCP to allow CVS_PORT to be used to specify
+ a TCP connection port (no Kerberos). Changed
+ start_kerberos_server() to start_tcp_server().
+
+ In copy_a_file(): transform a backup file to have a
+ VMS-friendly name.
+
+ Added HAVE_CONFIG_H to include "config.h".
+
+ start_server() will starts the first successful of any
+ mutually exclusive methods of starting the CVS server
+ which might be enabled.
+
+ Initialized use_socket_style and server_sock for VMS in
+ start_server().
+
+Wed Feb 28 21:49:48 1996 Benjamin J. Lee <benjamin@cyclic.com>
+
+ * find_names.c, recurse.c, cvs.h: Changed Find_Dirs() to
+ Find_Directories().
+ * cvs.h: Added VMS filenames enabled through USE_VMS_FILENAMES
+ VMS POSIX will require to use the regular CVS filenames
+ while VMS is #define'd.
+
+Wed Feb 28 21:26:22 1996 Benjamin J. Lee <benjamin@cyclic.com>
+
+ * ignore.c: Added the patterns *.olb *.exe _$* *$ to default
+ ignore list for VMS.
+
+Wed Feb 28 13:32:28 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * logmsg.c (do_editor): Fix indentation.
+
+Wed Feb 28 12:56:49 1996 Benjamin J. Lee <benjamin@cyclic.com>
+
+ * logmsg.c (do_editor): If no editor is defined, exit and print
+ a message.
+
+Wed Feb 28 10:40:25 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * vers_ts.c (time_stamp, time_stamp_server): Reindent and revise
+ comments.
+
+Tue Feb 27 23:57:55 1996 Benjamin J. Lee <benjamin@cyclic.com>
+
+ * vers_ts.c: gmtime() returns NULL on some systems (VMS)
+ revert to local time via ctime() if GMT is not avaiable.
+
+Tue Feb 27 13:07:45 1996 J.T. Conklin <jtc@rtl.cygnus.com>
+
+ The changes listed below cause cvs to parse each rcs file (and
+ free the associated rcsnode after the file has been processed)
+ sequentially. cvs used to parse all files in a directory, an
+ approach that does not scale to huge repositories with lots
+ of revisions/branches/tags/etc.
+
+ * cvs.h (struct file_info): Removed srcfiles field. Added rcs
+ (node) field.
+ * recurse.c (do_recursion): Removed code that pre-parsed all
+ rcs files in the directory.
+ (do_file_proc): Parse current rcs file.
+ * rcs.c (RCS_parsefiles, parse_rcs_proc, RCS_addnode): Removed.
+ (RCS_isbranch, RCS_whatbranch): Changed srcfiles argument to
+ rcs (node).
+ * rcs.h (RCS_parsefiles, RCS_addnode): Removed prototypes.
+ (RCS_isbranch, RCS_whatbranch): Updated prototypes.
+ * add.c, admin.c, checkin.c, checkout.c, classify.c, client.c,
+ commit.c, diff.c, history.c, import.c, log.c, patch.c, remove.c,
+ rtag.c, status.c, tag.c, update.c, vers_ts: Updated for above
+ calling convention / data structure changes.
+
+Mon Feb 26 16:07:56 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * Version 1.7.3.
+
+ * Version 1.7.2.
+
+Mon Feb 26 1996 Jim Kingdon <kingdon@cyclic.com>
+
+ * recurse.c (start_recursion): Use last_component rather than
+ checking for '/' directly.
+ (do_dir_proc): Likewise.
+
+ Visual C++ lint:
+ * client.c (send_to_server): Change wrtn to size_t.
+ (connect_to_pserver): Put tofd and fromfd declarations inside
+ #ifndef NO_SOCKET_TO_FD.
+ * scramble.c (shifts): Change from array of char to array of
+ unsigned char.
+
+Mon Feb 26 13:31:25 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * server.c (check_repository_password): Remove unused variables
+ linelen, ch.
+
+ * client.c (send_file_names): Translate ISDIRSEP characters to '/'.
+
+Sat Feb 24 21:25:46 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * checkout.c (safe_location): Re-indent one line.
+
+Sat Feb 24 10:50:42 1996 Karl Fogel <kfogel@floss.red-bean.com>
+
+ * checkout.c (safe_location): put assignment to hardpath[x] in an
+ `else'-clause, so we don't do it when x == -1.
+
+Sat Feb 24 01:40:28 1996 Marcus Daniels <marcus@sayre.sysc.pdx.edu>
+ via Karl Fogel <kfogel@floss.red-bean.com>
+
+ * server.c (check_repository_password): Return by reference an
+ optional username, the `host_user', from the passwd file. The
+ host_user will be the user-id under which the cvs repository is
+ run.
+ (check_repository_password): Use `read_line' instead of fgets to
+ allow for passwords larger than 32 characters, as well as the
+ optional host user argument.
+ (check_password): Modify to use host_user.
+ (authenticate_connection): Modify to use host_user.
+
+Sat Feb 24 01:05:21 1996 Karl Fogel <kfogel@floss.red-bean.com>
+
+ * scramble.c (descramble): just shift descrambled string to get
+ rid of tag char, instead of allocating a whole new copy.
+ (scramble): cast return value of xmalloc to avoid unsightly
+ compiler warnings.
+
+ * options.h.in (RCSBIN_DFLT): don't refer to AUTH_SERVER_SUPPORT
+ in comment anymore, now that it's not defined in this file.
+
+Fri Feb 23 1996 Jim Kingdon <kingdon@cyclic.com>
+
+ * client.c: Ifdef HAVE_WINSOCK_H, include winsock.h
+ instead of sys/socket.h and friends.
+ * login.c: Don't include sys/socket.h and friends.
+ * login.c (login): Only fclose fp in the case where it was
+ successfully fopen'd.
+ * login.c: Declare getpass.
+ * filesubr.c, cvs.h (get_homedir): New function.
+ * cvsrc.c, expand_path.c, history.c, login.c: Call it instead
+ of getenv ("HOME").
+
+Fri Feb 23 09:23:20 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * client.c (connect_to_pserver): Remove unused variable host.
+ * login.c: Include getline.h.
+ (login): Remove unused variables i and username.
+ (get_cvs_password): Move free of linebuf to where it actually will
+ be called. Add a "return NULL" at the end of the function to shut
+ up gcc -Wall.
+
+ * options.h.in: Remove AUTH_SERVER_SUPPORT.
+ * client.h (authenticate_connection): Declare.
+ * scramble.c (scramble): Cast char to unsigned char before using
+ it to look up in table (char might be signed).
+ * server.c [AUTH_SERVER_SUPPORT]: Include grp.h
+ (authenticate_connection): Remove unused variables len and
+ server_user.
+
+ * sanity.sh (basica): Add comments regarding creating a top-level
+ directory.
+ (basic1): Don't try to remove first-dir and
+ ${CVSROOT_DIRNAME}/first-dir at start of test; tests are now
+ responsible for cleaning up at the end.
+ (PLUS,DOTSTAR,ENDANCHOR): Add comments regarding fixed GNU expr.
+
+Thu Feb 22 22:34:11 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * cvs.h: Remove alloca cruft.
+
+Wed Feb 21 07:30:16 1996 J.T. Conklin <jtc@rtl.cygnus.com>
+
+ * modules.c (do_module): call free_cwd before exiting.
+
+ * recurse.c: Removed entries global variable.
+ (do_recursion): Declare entries. Moved call to Entries_Close so
+ entries list is closed on all code paths.
+ (start_recursion): Removed call to Entries_Close, entries list has
+ been moved to do_recursion only.
+
+Tue Feb 20 22:10:05 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * update.c (update_dirent_proc): If dir lacks a CVS subdirectory,
+ don't recurse into it.
+ * sanity.sh (conflicts): Test for above-fixed bug.
+
+ * update.c (merge_file): Use write_letter not printf.
+
+Tue Feb 20 12:34:07 EST 1996: Gary Oberbrunner <garyo@avs.com>
+ and Jim Kingdon <kingdon@cyclic.com>
+
+ * history.c (history_write): Change username to char * and call
+ getcaller() to set it. Setting username accidentally got deleted
+ 8 Feb 96.
+ * sanity.sh: Revise test 64 to test for above-fixed bug.
+ * sanity.sh (PLUS): New variable, work around yet another GNU expr
+ bug.
+
+Tue Feb 20 14:07:50 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * sanity.sh: Merge test rtags into test basic2. They never were
+ capable of running separately of each other.
+
+ * sanity.sh (deep): New test, to test ability to operate in deeply
+ nested directories (more quickly than basic2 test did).
+ (basic2,rtags): Remove directories dir3 and dir4. Remove file8,
+ file10, file12, file9, file11, file13, file15, file16, file17.
+ These additional files slowed down the tests considerably without
+ significantly increasing coverage.
+
+ * sanity.sh (PROG): New variable. Use it instead of "cvs"
+ to match the name cvs prints out for itself.
+
+Mon Feb 19 09:00:29 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ This fixes a bug whereby old default attributes would get
+ clobbered instead of added to on "cvs watch add".
+ * hash.c (findnode): Don't check for key == NULL; let the
+ assertion in hashp take care of it.
+ * fileattr.h, fileattr.c (fileattr_get): If filename is NULL,
+ return default attributes.
+
+ * client.c (send_repository): Fix indentation.
+
+Mon Feb 19 01:10:01 1996 Karl Fogel <kfogel@floss.red-bean.com>
+
+ * login.c (login): print out full repos so user knows which server
+ she's logging into.
+
+ * client.c (send_repository): die if `repos' is NULL. This is a
+ lame solution; see comments in code.
+
+Thu Feb 15 15:04:01 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * error.c (error): Free entire and mess when done with them.
+
+ * sanity.sh (info): Correct syntax of .cvsrc file.
+
+ * cvs.h, expand_path.c, edit.c, parseinfo.c, wrapper.c:
+ expand_path now takes arguments containing file and line for error
+ message, and it prints the error message itself.
+ * sanity.sh (info-6a): Test printing of error message.
+
+ * expand_path.c (expand_variable): Add USER internal variable.
+ * sanity.sh (info): Test USER and CVSROOT internal variables too.
+
+Wed Feb 14 19:11:08 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * main.c (usg): Add -s option.
+
+Tue Feb 13 20:26:06 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ gcc -Wall lint:
+ * mkmodules.c (mkmodules_usage): Remove declaration of
+ non-existent function.
+ * cvs.h (mkmodules): Declare.
+
+Mon Feb 12 12:20:04 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * mkmodules.c: Rename main to mkmodules and remove various pieces
+ of scaffolding which it used to emulate non-existent parts of CVS.
+ Change calling convention to just take a char * not argc,argv.
+ Save and restore working directory.
+ * commit.c (commit_filesdoneproc): Call it if checking files into
+ CVSROOT.
+ * Makefile.in (SOURCES): Add mkmodules.c.
+ (OBJECTS): Add mkmodules.o.
+ (MSOURCES,MOBJECTS): Removed.
+ (COMMON_OBJECTS): Removed; move former contents into OBJECTS.
+ Update other rules accordingly.
+ * sanity.sh: Adjust to reflect nonexistence of mkmodules.
+
+ These changes introduce functions cvs_output and cvs_outerr;
+ eventually all server output will go through them rather than
+ stdio directly.
+ * server.c (saved_output, saved_outerr): New variables.
+ (do_cvs_command): Initialize them.
+ (buf_output): Don't require that buf->output be set; saved_* use
+ this to shove some data in a buffer which buf_copy_lines will
+ later want to get data from.
+ * server.c, cvs.h (cvs_output, cvs_outerr): New functions.
+ * mkmodules.c (cvs_outerr): New function, so error() works.
+ * error.c: Reindent. Don't declare program_name and command_name;
+ cvs.h declares them.
+ (error): Use vasprintf and cvs_outerr (or fputs in the
+ error_use_protocol case) rather than stdio directly.
+ * import.c (import_descend_dir): Remove kludge which had prevented
+ messages from error() from being out of order with respect to
+ messages from printf; cvs_output and cvs_outerr are a cleaner
+ solution to the problem.
+ (add_log, import): Use cvs_output not printf.
+ * update.c (write_letter): Use cvs_output not printf.
+ (checkout_file): Use write_letter not printf.
+ * sanity.sh: Use dotest for test 56 (test that output is actually
+ correct). In theory should test that the import.c bug is fixed,
+ but I was unable to reproduce the bug (it is timing dependent).
+
+Mon Feb 12 16:07:45 1996 Norbert Kiesel <nk@col.sw-ley.de>
+
+ * commit.c: define last_register_time
+ (commit): make sure cvs doesn't exit in the same second it wrote
+ the last timestamp
+ (commit_fileproc): set last_register_time
+ (finaladd): set last_register_time
+
+ * run.c, cvs.h: Changed more Popen() to run_popen()
+
+Mon Feb 12 03:06:50 1996 Benjamin J. Lee <benjamin@cyclic.com>
+
+ * release.c, rtag.c, tag.c: changed 'delete' to 'delete_flag'
+ to avoid symbol collision with DEC C RTL function delete()
+
+Mon Feb 12 03:01:48 1996 Benjamin J. Lee <benjamin@cyclic.com>
+
+ * mkmodules.c: changed 'void Lock_Cleanup()' to 'void static
+ Lock_Cleanup() to avoid conflict with more substantial
+ Lock_Cleanup() in lock.c
+
+Mon Feb 12 02:50:19 1996 Benjamin J. Lee <benjamin@cyclic.com>
+
+ * edit.c, logmsg.c, release.c, run.c: Changed Popen() to
+ run_popen(). VMS' linker is not case sensitive and considered
+ popen() and Popen() to be identical symbols.
+
+Sun Feb 11 10:51:14 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * main.c (main) [!CLIENT_SUPPORT]: Silently ignore gzip level
+ rather than printing usage message.
+
+ * cvs.h, expand_path.c (variable_list): New variable.
+ (variable_set): New function.
+ * hash.h (enum ntype), hash.c (nodetypestring): Add VARIABLE.
+ * expand_path.c (expand_path, expand_variable): Reindent.
+ (expand_variable): Use user variables not environment variables
+ for ${=VAR} syntax. The environment variables didn't work
+ client/server.
+ * main.c (main): Process new -s global option.
+ * client.c (send_variable_proc): New function.
+ (start_server): Call it, to send user variables.
+ * server.c (serve_set): New function.
+ (requests): Add Set request.
+ * sanity.sh: Revise info test to use user variables rather than
+ environment variables.
+
+Sat Feb 10 16:55:37 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ By itself this is only a small cleanup, but in the long run it
+ will be way cool (for reference, it takes CVS's text segment from
+ 290816 bytes to 294912, which I expect will be made up by future
+ changes which this enables):
+ * cvs.h (struct file_info): Added.
+ (FILEPROC): Replace 5 args with single struct file_info *.
+ * recurse.c (do_file_proc): Adjust args to fileproc; passed in
+ instead of from globals.
+ (do_recursion): Call do_file_proc accordingly. Remove srcfiles
+ global variable.
+ * update.c (update_fileproc): Renamed from update_file_proc.
+ * admin.c, client.c, commit.c, diff.c, edit.c, log.c, patch.c,
+ remove.c, rtag.c, status.c, tag.c, update.c, watch.c: Update
+ fileprocs to new calling convention.
+
+Fri Feb 9 15:30:32 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * expand_path.c (expand_variable): Accept a variable name starting
+ with '=' as a way to specify an environment variable.
+ * sanity.sh (info): New tests, for above behavior.
+
+ * Makefile.in (clean): Also remove check.log check.plog.
+
+ * import.c (comtable): Remove SYSTEM_COMMENT_TABLE; the table
+ should *not* depend on what kind of machine the server happens to
+ be. Add "mak", "rc", "dlg", "frm", and "bas" types which were
+ formerly included via SYSTEM_COMMENT_TABLE.
+
+ * cvs.h, rcs.h, add.c, checkin.c, classify.c, commit.c, diff.c,
+ import.c, patch.c, rcs.c, update.c, vers_ts.c: Remove
+ DEATH_SUPPORT ifdefs. They were introduced to facilitate merging
+ between Cygnus and Berliner variants of CVS, not because it was
+ intended to subset CVS this way. And they clutter up the code
+ quite a bit.
+ * cvs.h, create_adm.c, main.c, update.c: Likewise, remove
+ CVSADM_ROOT ifdefs (it is still a #define, of course). I believe
+ they had a more-or-less similar motivation.
+
+ * sanity.sh: Move setting of HOME from ignore test to the start of
+ the tests so it applies to all tests.
+ (CVS): Remove -f; the above change takes care of it.
+
+ * rcs.h (RCS_MERGE): Removed; unused.
+
+ * commit.c (checkaddfile): Fix memory leak.
+
+ * admin.c, commit.c, diff.c, log.c, mkmodules.c: Pass -x,v/ to RCS
+ commands.
+
+ * rcscmds.c, cvs.h (RCS_checkin): New function.
+ * checkin.c, commit.c, import.c: Call it, rather than run_*.
+ * cvs.h, commit.c: Remove DEATH_STATE define; the behavior
+ which used to be the default (DEATH_STATE) is now the only one.
+ Failing to define DEATH_STATE has been commented as obsolete at
+ least since CVS 1.5. We still can read repositories created with
+ such a CVS, however.
+ * rcs.h, rcs.c: Adjust comments regarding DEATH_STATE.
+ * subr.c (make_message_rcslegal): Add comment, describing
+ allocation of returned value.
+
+Fri Feb 9 09:53:44 MET 1996 Norbert Kiesel <nk@col.sw-ley.de>
+
+ * sanity.sh: use "${testcvs}" instead of "cvs" in devcom tests
+
+ * hash.c: fix "dereferencing a NULL pointer" bug triggered with
+ "cvs watch add"
+ (findnode): return NULL if key == NULL
+ (hashp): assert (key != NULL)
+
+Fri Feb 9 00:46:47 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * rcs.c (RCS_reparsercsfile): Remove unused variable date.
+
+ * myndbm.c (mydbm_load_file): Fix typo ('015' -> '\015').
+
+Thu Feb 8 13:00:00 1996 Jim Kingdon <kingdon@peary.cyclic.com>
+
+ * rcs.c (RCS_parse, RCS_parsercsfile, RCS_reparsercsfile),
+ fileattr.c (fileattr_read), myndbm.c (myndbm_open):
+ Use FOPEN_BINARY_READ.
+ * fileattr.c (fileattr_write), myndbm.c (myndbm_close):
+ Use FOPEN_BINARY_WRITE.
+ * history.c (history_write, read_hrecs): Specify OPEN_BINARY.
+ * rcs.c: Remove calls to abort.
+ * myndbm.c (myndbm_load_file): Ignore CRs from ends of lines
+ if present.
+ * myndbm.c, fileattr.c: While I am at it, change \n to \012
+ a few places where LF is intended.
+ * history.c (history_write): Use getenv ("HOME"), not getpwnam,
+ to find home directory. If it isn't set, just keep going; don't
+ print a message.
+ * rcscmds.c, cvs.h (RCS_checkout): New function.
+ * update.c, checkin.c, commit.c, diff.c, import.c, no_diff.c,
+ patch.c: Call it instead of run_*.
+ * patch.c (patch_fileproc): Clean up inconsistent handling of
+ noexec flag.
+ * rcscmds.c (RCS_*): Pass -x,v/ to RCS commands; elsewhere in
+ CVS it is assumed that ,v is a suffix.
+
+Fri Feb 2 14:07:32 1996 J.T. Conklin <jtc@rtl.cygnus.com>
+
+ * rcs.h (struct rcsnode): Remove dates field (list of rcsversnodes
+ indexed by date). CVS maintained this list for each RCS file even
+ though it was never used. This resulted in higher then necessary
+ memory requirements (and run time too). Even if revision info was
+ needed, CVS' List data structure is inappropriate because can't
+ handle duplicate keys. The above was discovered by tracking down
+ a memory leak.
+ * rcs.c (RCS_reparsercsfile): Don't build dates list.
+ (freercsnode): Don't delete dates list.
+ (rcsvers_delproc): Free date field.
+ (null_delproc): Removed.
+
+Thu Feb 1 12:28:33 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * remove.c (cvsremove): Don't tell user the name of the program
+ which they use to remove files; we don't have any way of knowing
+ that, and besides which they might use a GUI or emacs 'dired' anyway.
+ * update.c (update_filesdone_proc, update_dirleave_proc): Call
+ unlink_file_dir instead of rm -rf.
+ * options.h.in: Remove RM; no longer used.
+
+ * sanity.sh: New tests devcom-a* test "cvs watch add",
+ "cvs watch remove", and "cvs watchers".
+
+ * sanity.sh: New test 171a0 tests for watch.c bug just fixed by kfogel.
+
+ * Most .c files: Remove rcsids.
+ * cvs.h: Remove USE macro.
+
+Thu Feb 1 13:07:15 1996 J.T. Conklin <jtc@rtl.cygnus.com>
+
+ * tag.c, rtag.c: Update various comments to reflect function name
+ changes.
+
+Thu Feb 1 14:14:31 1996 Karl Fogel <kfogel@floss.red-bean.com>
+
+ * recurse.c (do_recursion): comment #endif.
+
+ * edit.c (notify_check): surround with #ifdef CLIENT_SUPPORT; else
+ CVS won't compile if CLIENT_SUPPORT is undefined.
+
+ * edit.h (notify_check): surround declaration with #ifdef
+ CLIENT_SUPPORT.
+
+ * watch.c (watch): if argc <= 1, then just give usage (previously
+ was "argc == -1").
+
+Thu Feb 1 12:28:33 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * README-rm-add: Remove information which is now in cvs.texinfo.
+
+ * sanity.sh: Remove basic0 tests. Move a few to new tests
+ basica-1a* (but there is no need to test that *every* command
+ gracefully does nothing on an empty directory; exhaustive testing
+ is impractical and the generic recursion processor handles this
+ anyway).
+
+ * sanity.sh: New tests 69a* test use of update -p to restore old
+ version of dead file.
+
+Wed Jan 31 18:32:34 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * ChangeLog-9395: Remove duplicate entries from 1996 which
+ accidentally got into this file.
+
+ * client.c (read_line, read_from_server): Change "premature end of
+ file from server" message to "end of file from server (consult
+ above messages if any)" because 99% of the time it means rsh has
+ printed an error message and exited.
+
+Wed Jan 31 15:09:51 1996 J.T. Conklin <jtc@rtl.cygnus.com>
+
+ * edit.c (ncheck_fileproc): Fix memory leak; free line before
+ returning.
+
+Tue Jan 30 18:06:12 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * recurse.c (do_recursion): Add comment about the fact that we
+ don't have locks in place at certain points.
+
+Tue Jan 30 09:43:34 1996 Vince Demarco <vdemarco@bou.shl.com>
+
+ * edit.c (notify_proc): have notify_proc call expand_path with
+ the name of the filter program. The user may have used a
+ cvs environmental variable. (Popen will expand it, but it may not
+ use the correct value)
+
+Tue Jan 30 09:43:34 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * ChangeLog: take the pre-1996 changes and put them in a new file
+ ChangeLog-9395.
+ * ChangeLog-9194: Renamed from ChangeLog.fsf.
+ * ChangeLog-9194, ChangeLog-9395, ChangeLog: Add additional text
+ explaining the difference between all these logs and pointing to
+ older logs.
+ * Makefile.in (DISTFILES): Add ChangeLog-9194 and ChangeLog-9395;
+ remove ChangeLog.fsf.
+
+ * modules.c (do_module): Don't fall through from 'l' to 'o' case
+ of option processing switch statement.
+
+Tue Jan 30 06:50:19 1996 J.T. Conklin <jtc@rtl.cygnus.com>
+
+ * client.c (send_repository): Fix memory leak; free adm_name
+ before returning.
+ * diff.c (diff_file_nodiff): Fix memory leak; free xvers before
+ returning.
+ * rtag.c (rtag_fileproc): Fix memory leak; if branch_mode is set,
+ free rev before returning.
+ * status.c (status_fileproc, tag_list_proc): Fix memory leak; free
+ return value of RCS_whatbranch.
+ * tag.c (tag_fileproc): Fix memory leak; free vers before
+ returning.
+ (val_fileproc): Fix memory leak; free return value of RCS_gettag.
+ * watch.c (watch_modify_watchers): Fix memory leak; free mynewattr
+ before returning.
+
+Tue Jan 30 09:43:34 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * lock.c (readers_exist): If stat gave an error, print an error
+ message saying it was from stat, rather than from "reading
+ directory". Skip the message completely if it was an
+ existence_error.
+
+ * sanity.sh (branches): New tests (branches off of branches, etc.).
+
+Tue Jan 30 11:55:34 MET 1996 Norbert Kiesel <nk@col.sw-ley.de>
+
+ * main.c (main): Add change to run getopt_long twice again.
+
+Mon Jan 29 15:59:31 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ gcc -Wall lint:
+ * client.c: Include edit.h
+
+Sun Jan 28 09:45:53 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * edit.c, edit.h (mark_up_to_date): New function, to remove file
+ in CVS/Base.
+ * client.c (update_entries): Call it if file is up to date.
+ * checkin.c (Checkin): Call it in non-server (local) case.
+ * sanity.sh: New test 182.5, tests for above-fixed bug.
+
+Sun Jan 28 01:07:22 1996 Jim Kingdon (kingdon@beezley)
+
+ * client.c (change_mode): Separate out CHMOD_BROKEN code to parse
+ mode_string, rather than going through a mode_t. Cleaner than
+ the previous CHMOD_BROKEN code (which also had a typo of && not &).
+
+Sat Jan 27 23:29:46 1996 Jim Kingdon (kingdon@beezley)
+
+ * edit.c (edit_fileproc): Check for EACCESS as well as EEXIST.
+
+Sat Jan 27 16:26:30 1996 Karl Fogel (kfogel@floss.cyclic.com)
+
+ * client.c (notified_a_file): use rename_file() instead of
+ rename() (but temporarily set `noexec' to 0 so it runs
+ unconditionally).
+ (change_mode): deal with CHMOD_BROKEN.
+
+Fri Jan 26 00:14:00 1996 Karl Fogel <kfogel@floss.red-bean.com>
+
+ * server.c: renamed `dirname' to `dir_name', to avoid conflicts
+ with system headers.
+
+ * client.c: renamed `dirname' and `last_dirname' to `dir_name' and
+ last_dir_name' (see above). Not strictly necessary, but
+ consistency is nice -- as long as you do it all the time.
+
+Thu Jan 25 00:41:59 1996 Karl Fogel <kfogel@floss.red-bean.com>
+
+ * options.h.in (AUTH_SERVER_SUPPORT, AUTH_CLIENT_SUPPORT): change
+ comment now that no longer under construction.
+
+Wed Jan 24 15:25:22 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * Version 1.7.1.
+
+ * Version 1.7.
+
+Sat Jan 20 00:05:08 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * Version 1.6.87.
+
+Mon Jan 15 18:14:55 1996 Gary Oberbrunner <garyo@avs.com>
+ and Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * tag.c (val_direntproc): New function to ignore
+ nonexistent dirs when recursing to check tag validity.
+ (tag_check_valid): Pass it to start_recursion.
+ * sanity.sh (death): New tests 65a0-65a6 cause test 74 to test for
+ above-fixed bug.
+
+Mon Jan 15 12:55:37 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * main.c: Revert change to run getopt_long twice. This can go in
+ after 1.7.
+
+Mon Jan 15 13:03:28 1996 Norbert Kiesel <nk@col.sw-ley.de>
+
+ * filesubr.c (deep_remove_dir): added test of EEXIST for nonempty
+ directory (Posix states that both ENOTEMPTY (BSD) and EEXIST
+ (SYSV) are valid)
+
+ * main.c (main): run getopt_long twice to allow command-line
+ suppression of reading the cvsrc file
+
+Fri Jan 12 10:02:43 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * Version 1.6.86.
+
+Thu Jan 11 23:28:05 1996 J.T. Conklin <jtc@rtl.cygnus.com>
+ and Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * fileattr.h (fileattr_startdir): Add comment about REPOS == NULL.
+ * fileattr.c (fileattr_read, fileattr_write): Assert that
+ fileattr_stored_repos != NULL.
+ (fileattr_free): If fileattr_stored_repos is NULL, don't free it.
+
+Thu Jan 11 18:03:21 1996 Karl Fogel <kfogel@floss.red-bean.com>
+
+ * scramble.c (descramble): deal with DIAGNOSTIC better.
+
+Thu Jan 11 12:04:42 1996 Norbert Kiesel <nk@col.sw-ley.de>
+
+ * main.c: remove CVS_NOADMIN.
+
+ * options.h.in: remove CVS_NOADMIN
+
+Thu Jan 11 10:28:44 1996 Karl Fogel <kfogel@floss.red-bean.com>
+
+ * scramble.c (descramble): make sure the string returned is safe
+ to free().
+
+Wed Jan 10 01:11:23 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * server.c (serve_notify): Cast return value from malloc.
+
+ * edit.c (notify_do): Use struct assignment, not struct
+ initialization (which SunOS4 /bin/cc doesn't have).
+
+Tue Jan 9 09:41:29 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * Version 1.6.85.
+
+ We use version numbers instead of patchlevels. But there was some
+ confusing patchlevel stuff lying around. Nuke it:
+ * Makefile.in (HEADERS): Remove patchlevel.h
+ * patchlevel.h: Removed.
+ * main.c: Don't include patchlevel.h.
+ (main): Don't print patch level.
+
+ * server.c (check_repository_password): Check for errors from
+ system calls; reindent function.
+
+Tue Jan 9 23:15:30 1996 Karl Fogel <kfogel@floss.red-bean.com>
+
+ * expand_path.c: fix comments (explain expand_path()'s behavior
+ correctly).
+
+Tue Jan 9 09:41:29 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * edit.c (notify_proc): After copying in string following %s,
+ don't clobber it. Instead set up q to end of string.
+
+ * watch.c (watch_modify_watchers), edit.c (editor_set): Fix sense
+ of test in trying to decide whether attributes are changed.
+
+ * cvs.h (CVSROOTADM_USERS): New macro.
+ * edit.c (notify_do): Look up notifyee in CVSROOTADM_USERS if it
+ exists.
+
+Tue Jan 9 21:39:45 1996 Karl Fogel <kfogel@floss.red-bean.com>
+
+ * expand_path.c: don't redundantly #include things that cvs.h
+ already #includes (i.e., stdio.h, ctype.h, string[s].h).
+
+Tue Jan 9 09:41:29 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * ignore.c (ign_default): Add *.obj.
+
+ * server.c: Put /* */ around #endif comment.
+
+Mon Jan 8 20:37:17 1996 Karl Fogel <kfogel@floss.red-bean.com>
+
+ * client.c (connect_to_pserver): check return value of recv().
+
+Mon Jan 8 11:37:57 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * client.c (connect_to_pserver): Check for error from connect;
+ reindent function.
+
+ * sanity.sh (4.75): Use dotest, so we get a PASS if test passes.
+
+ * sanity.sh (dotest): New argument OUTPUT2.
+ (188a): Use it instead of \|.
+
+ * sanity.sh (import): Avoid using string $ followed by Id followed
+ by $ in sanity.sh source, in case sanity.sh itself is under CVS.
+ I hate keyword expansion.
+
+ * sanity.sh: If expr cannot handle multiline expressions, fail and
+ tell the user to get one which can.
+
+ * release.c (release_delete): Remove unused variable retcode.
+
+Fri Jan 5 13:30:00 1996 Jim Kingdon <kingdon@peary.cyclic.com>
+
+ * release.c (release_delete): Call unlink_file_dir rather
+ than "rm -rf".
+
+Thu Jan 4 09:58:30 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * commit.c (find_fileproc): Print "nothing known about foo" and
+ return 1 if the file doesn't exist and isn't in CVS/Entries.
+ (commit): If the recursion over find_fileproc returns an error,
+ print "correct above errors first!" just like local CVS.
+ * sanity.sh (basica): Test for above-fixed bug.
+
+ * release.c (release): If we are the client, only unedit if the
+ server supports it.
+
+ * sanity.sh: Remove STARTANCHOR stuff; expr patterns are
+ automatically anchored to the start. ENDANCHOR remains.
+
+ * commit.c (commit): Don't start the server until we have
+ determined that there is something to commit.
+
+Thu Jan 4 09:48:33 1996 Ben Laurie <ben@gonzo.ben.algroup.co.uk>
+ and Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * client.c (start_server): dup the file descriptor before
+ fdopening it.
+
+Wed Jan 3 18:25:25 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * sanity.sh: Remove tests 5, 5.5, and 5.75. All that stuff is
+ tested elsewhere.
+
+ * ignore.c (ign_default): Change CVS* to CVS CVS.adm. CVS* is too
+ broad, especially in a case-insensitive filesystem.
+
+ * Makefile.in (cvsbug): version.c is in srcdir.
+
+Wed Jan 3 17:30:45 1996 Phi-Long Tran <ptran@autodesk.com>
+
+ * modules.c (do_module): Honor error_use_protocol in printing trace.
+ * server.c (server_register): Move check for options NULL to above
+ printing of the trace.
+
+Wed Jan 3 01:19:53 1996 Mark Immel <immel@centerline.com>
+ and Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * update.c (checkout_file): Do not resurrect file on join if it
+ doesn't contain the revisions we are joining. Probably not a
+ perfect test, but should be an improvement.
+ * sanity.sh (death): New death-file4-* tests, for bug fixed above.
+
+Wed Jan 3 01:19:53 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * add.c, admin.c, checkout.c, client.c, commit.c, diff.c, edit.c,
+ history.c, import.c, log.c, patch.c, release.c, remove.c, rtag.c,
+ status.c, tag.c, update.c, watch.c: In calling send_to_server,
+ pass \012 not \n. On the Mac \n is CR, not LF, and we want to
+ send LF. I didn't try to deal with whether files in CVSADM should
+ contain CR or LF--in fact there is some code in client.c which
+ reads \n from CVSADM files and passes it to send_to_server; it
+ needs to be cleaned up one way or the other.
+
+ * entries.c (Entries_Open): Don't try to close fpin twice.
+
+ * client.c (update_entries): Fix typo ("strlen (filename + 10)"
+ -> "strlen (filename) + 10").
+
+ * commit.c (checkaddfile): Remove arbitrary limit.
+
+Tue Jan 2 11:25:22 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * commit.c (commit): Only pass files which were modified, added,
+ or removed to send_file_names. This has as a side effect a
+ semantic change--the up-to-date check is now skipped for other
+ files--but probably a good one, or at least not a bad one.
+ * sanity.sh (basica): New test; tests for bug fixed above.
+ * sanity.sh (187a3): Adjust for new 'cvs commit' output. Set up
+ DOTSTAR to match arbitrary text (another GNU expr bug/misfeature,
+ sigh).
+
+ * sanity.sh: Test that the commit in test 43 actually worked.
+ Merge tests basic2 and basic3 and make them independent of basic1.
+ (pass,fail): Don't insert spurious space.
+ (45.5): Fix typo in directory name.
+
+Tue Jan 2 13:00:00 1996 Jim Kingdon <kingdon@peary.cyclic.com>
+
+ Visual C++ lint:
+ * myndbm.c: Prototype write_item.
+
+Tue Jan 2 11:25:22 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ gcc -Wall lint:
+ * client.c (client_expand_modules): Pass error message not "" to error.
+ * client.c (supported_request), server.c (supported_response):
+ Return a value (gcc -Wall can't know that error doesn't return).
+ * commit.c (copy_ulist): Return a value.
+ * history.c (fill_hrec): Don't make assumptions about whether
+ time_t is "int" or "long" or what.
+ * cvs.h: Declare link_file.
+ * server.c: Include fileattr.h.
+ * server.c (server_notify): Remove unused variable val.
+ * tag.c (val_fileproc): Remove unused variable foundtag.
+
+Mon Jan 1 09:49:16 1996 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * Version 1.6.5.
+
+ * Version 1.6.4.
+
+ * filesubr.c (link_file): Add comment about link vs. copy semantics.
+
+ * cvs.h (struct vers_ts): Fix comments.
+ * commit.c (commit): Before we ask for a log message, figure out
+ what is modified and what is not and pass the information to
+ do_editor.
+ (copy_ulist,find_fileproc): New helper functions for above code.
+
+ * client.c (read_line): When writing to from_server_logfile, write
+ the \n too.
+
+ * client.c (send_files): No longer call send_file_names.
+ * client.h: Update comment.
+ * add.c, admin.c, commit.c, diff.c, edit.c, log.c, remove.c,
+ status.c, tag.c, update.c, watch.c: Call send_file_names before
+ send_files.
+ * client.c: New variables module_argc, module_argv.
+ (client_expand_modules): Set them, to arguments.
+ (client_send_expansions): Use them instead of modules_vector to
+ send arguments.
+ * sanity.sh (modules): Add test of modules -d flag.
+
+
+For older changes see ChangeLog-9395.
diff --git a/contrib/cvs/src/Makefile.in b/contrib/cvs/src/Makefile.in
index acb3343..f02edf2 100644
--- a/contrib/cvs/src/Makefile.in
+++ b/contrib/cvs/src/Makefile.in
@@ -12,12 +12,6 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-# $CVSid: @(#)Makefile.in 1.19 94/09/29 $
-
SHELL = /bin/sh
srcdir = @srcdir@
@@ -43,31 +37,31 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
LIBS = @LIBS@
-SOURCES = add.c admin.c checkin.c checkout.c classify.c client.c commit.c \
-create_adm.c cvsrc.c diff.c edit.c entries.c error.c expand_path.c \
+SOURCES = add.c admin.c buffer.c checkin.c checkout.c classify.c client.c \
+commit.c create_adm.c cvsrc.c diff.c edit.c entries.c error.c expand_path.c \
fileattr.c find_names.c hash.c history.c ignore.c import.c \
lock.c log.c login.c logmsg.c main.c mkmodules.c modules.c myndbm.c no_diff.c \
parseinfo.c patch.c rcs.c rcscmds.c recurse.c release.c remove.c repos.c \
root.c rtag.c scramble.c server.c status.c subr.c filesubr.c run.c \
-tag.c update.c watch.c wrapper.c vers_ts.c version.c
+tag.c update.c watch.c wrapper.c vers_ts.c version.c zlib.c
-OBJECTS = add.o admin.o checkin.o checkout.o classify.o client.o commit.o \
-create_adm.o cvsrc.o diff.o edit.o entries.o expand_path.o \
+OBJECTS = add.o admin.o buffer.o checkin.o checkout.o classify.o client.o \
+commit.o create_adm.o cvsrc.o diff.o edit.o entries.o expand_path.o \
fileattr.o find_names.o hash.o history.o ignore.o import.o \
lock.o log.o login.o logmsg.o main.o mkmodules.o modules.o myndbm.o no_diff.o \
parseinfo.o patch.o rcs.o rcscmds.o recurse.o release.o remove.o repos.o \
root.o rtag.o scramble.o server.o status.o tag.o update.o \
watch.o wrapper.o vers_ts.o \
-subr.o filesubr.o run.o version.o error.o
+subr.o filesubr.o run.o version.o error.o zlib.o
-HEADERS = cvs.h rcs.h hash.h myndbm.h \
+HEADERS = buffer.h cvs.h rcs.h hash.h myndbm.h \
update.h server.h client.h error.h fileattr.h edit.h watch.h
TAGFILES = $(HEADERS) options.h.in $(SOURCES)
-DISTFILES = .cvsignore Makefile.in ChangeLog ChangeLog-9395 ChangeLog-9194 \
- NOTES README-rm-add \
- sanity.sh cvsbug.sh $(TAGFILES)
+DISTFILES = .cvsignore Makefile.in \
+ ChangeLog ChangeLog-96 ChangeLog-9395 ChangeLog-9194 \
+ sanity.sh cvsbug.sh $(TAGFILES) build_src.com
PROGS = cvs cvsbug
@@ -91,8 +85,7 @@ saber_cvs:
lint:
@cd ..; $(MAKE) lint SUBDIRS=src
-# CYGNUS LOCAL: Do not depend upon installdirs
-install:
+install: installdirs
@for prog in $(PROGS); do \
echo Installing $$prog in $(bindir); \
$(INSTALL) $$prog $(bindir)/$$prog ; \
@@ -151,10 +144,10 @@ dist-dir:
# Linking rules.
-$(PROGS): ../lib/libcvs.a
+$(PROGS): ../lib/libcvs.a ../zlib/libz.a
cvs: $(OBJECTS)
- $(CC) $(OBJECTS) ../lib/libcvs.a $(LIBS) $(LDFLAGS) -o $@
+ $(CC) $(OBJECTS) ../lib/libcvs.a ../zlib/libz.a $(LIBS) $(LDFLAGS) -o $@
xlint: $(SOURCES)
files= ; \
@@ -168,7 +161,7 @@ saber: $(SOURCES)
# load $(CFLAGS) $(SOURCES)
# load ../lib/libcvs.a $(LIBS)
-cvsbug: cvsbug.sh
+cvsbug: cvsbug.sh $(srcdir)/version.c
echo > .fname \
cvs-`sed < $(srcdir)/version.c \
-e '/version_string/!d' \
@@ -184,6 +177,9 @@ cvsbug: cvsbug.sh
$(OBJECTS): $(HEADERS) options.h
+zlib.o: zlib.c
+ $(CC) $(CPPFLAGS) $(INCLUDES) -I$(top_srcdir)/zlib $(DEFS) $(CFLAGS) -c $(srcdir)/zlib.c
+
subdir = src
Makefile: ../config.status Makefile.in
cd .. && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= ./config.status
diff --git a/contrib/cvs/src/add.c b/contrib/cvs/src/add.c
index 82efefe..b7d5e5d 100644
--- a/contrib/cvs/src/add.c
+++ b/contrib/cvs/src/add.c
@@ -27,7 +27,7 @@
#include "cvs.h"
#include "savecwd.h"
-static int add_directory PROTO((char *repository, char *dir));
+static int add_directory PROTO((char *repository, List *, char *dir));
static int build_entry PROTO((char *repository, char *user, char *options,
char *message, List * entries, char *tag));
@@ -39,6 +39,47 @@ static const char *const add_usage[] =
NULL
};
+static char *combine_dir PROTO ((char *, char *));
+
+/* Given a directory DIR and a subdirectory within it, SUBDIR, combine
+ the two into a new directory name. Returns a newly malloc'd string.
+ For now this is a fairly simple affair, but perhaps it will want
+ to have grander ambitions in the context of VMS or others (or perhaps
+ not, perhaps that should all be hidden inside CVS_FOPEN and libc and so
+ on, and CVS should just see foo/bar/baz style pathnames). */
+static char *
+combine_dir (dir, subdir)
+ char *dir;
+ char *subdir;
+{
+ char *retval;
+ size_t dir_len;
+
+ dir_len = strlen (dir);
+ retval = xmalloc (dir_len + strlen (subdir) + 10);
+ if (dir_len >= 2
+ && dir[dir_len - 1] == '.'
+ && ISDIRSEP (dir[dir_len - 2]))
+ {
+ /* The dir name has an extraneous "." at the end.
+ I'm not completely sure that this is the best place
+ to strip it off--it is possible that Name_Repository
+ should do so, or it shouldn't be in the CVS/Repository
+ file in the first place. Fixing it here seems like
+ a safe, small change, but I'm not sure it catches
+ all the cases. */
+ strncpy (retval, dir, dir_len - 2);
+ retval[dir_len - 2] = '\0';
+ }
+ else
+ {
+ strcpy (retval, dir);
+ }
+ strcat (retval, "/");
+ strcat (retval, subdir);
+ return retval;
+}
+
int
add (argc, argv)
int argc;
@@ -62,7 +103,7 @@ add (argc, argv)
/* parse args */
optind = 1;
- while ((c = getopt (argc, argv, "k:m:")) != -1)
+ while ((c = getopt (argc, argv, "+k:m:")) != -1)
{
switch (c)
{
@@ -92,42 +133,61 @@ add (argc, argv)
#ifdef CLIENT_SUPPORT
if (client_active)
- {
+ {
int i;
start_server ();
ign_setup ();
if (options) send_arg(options);
option_with_arg ("-m", message);
for (i = 0; i < argc; ++i)
- /* FIXME: Does this erroneously call Create_Admin in error
- conditions which are only detected once the server gets its
- hands on things? */
- if (isdir (argv[i]))
+ /* FIXME: Does this erroneously call Create_Admin in error
+ conditions which are only detected once the server gets its
+ hands on things? */
+ if (isdir (argv[i]))
{
- char *tag;
- char *date;
- char *rcsdir = xmalloc (strlen (repository)
- + strlen (argv[i]) + 10);
+ char *tag;
+ char *date;
+ int nonbranch;
+ char *rcsdir;
- /* before we do anything else, see if we have any
- per-directory tags */
- ParseTag (&tag, &date);
+ /* before we do anything else, see if we have any
+ per-directory tags */
+ ParseTag (&tag, &date, &nonbranch);
- sprintf (rcsdir, "%s/%s", repository, argv[i]);
+ rcsdir = combine_dir (repository, argv[i]);
- Create_Admin (argv[i], argv[i], rcsdir, tag, date);
+ strip_trailing_slashes (argv[i]);
- if (tag)
- free (tag);
- if (date)
- free (date);
- free (rcsdir);
+ Create_Admin (argv[i], argv[i], rcsdir, tag, date, nonbranch);
+
+ if (tag)
+ free (tag);
+ if (date)
+ free (date);
+ free (rcsdir);
+
+ if (strchr (argv[i], '/') == NULL)
+ Subdir_Register ((List *) NULL, (char *) NULL, argv[i]);
+ else
+ {
+ char *cp, *b;
+
+ cp = xstrdup (argv[i]);
+ b = strrchr (cp, '/');
+ *b++ = '\0';
+ Subdir_Register ((List *) NULL, cp, b);
+ free (cp);
+ }
}
send_file_names (argc, argv, SEND_EXPAND_WILD);
- send_files (argc, argv, 0, 0);
+ /* FIXME: should be able to pass SEND_NO_CONTENTS, I think. */
+ send_files (argc, argv, 0, 0, SEND_BUILD_DIRS);
send_to_server ("add\012", 0);
+ if (message)
+ free (message);
+ free (repository);
return get_responses_and_close ();
- }
+ }
#endif
entries = Entries_Open (0);
@@ -136,7 +196,10 @@ add (argc, argv)
for (i = 0; i < argc; i++)
{
int begin_err = err;
+#ifdef SERVER_SUPPORT
int begin_added_files = added_files;
+#endif
+ struct file_info finfo;
user = argv[i];
strip_trailing_slashes (user);
@@ -148,8 +211,19 @@ add (argc, argv)
continue;
}
- vers = Version_TS (repository, options, (char *) NULL, (char *) NULL,
- user, 0, 0, entries, (RCSNode *) NULL);
+ memset (&finfo, 0, sizeof finfo);
+ finfo.file = user;
+ finfo.update_dir = "";
+ finfo.fullname = user;
+ finfo.repository = repository;
+ finfo.entries = entries;
+ finfo.rcs = NULL;
+
+ /* We pass force_tag_match as 1. If the directory has a
+ sticky branch tag, and there is already an RCS file which
+ does not have that tag, then the head revision is
+ meaningless to us. */
+ vers = Version_TS (&finfo, options, NULL, NULL, 1, 0);
if (vers->vn_user == NULL)
{
/* No entry available, ts_rcs is invalid */
@@ -168,7 +242,8 @@ add (argc, argv)
* See if a directory exists in the repository with
* the same name. If so, blow this request off.
*/
- char dname[PATH_MAX];
+ char *dname = xmalloc (strlen (repository) + strlen (user)
+ + 10);
(void) sprintf (dname, "%s/%s", repository, user);
if (isdir (dname))
{
@@ -179,29 +254,55 @@ add (argc, argv)
dname);
error (1, 0, "illegal filename overlap");
}
+ free (dname);
- /* There is a user file, so build the entry for it */
- if (build_entry (repository, user, vers->options,
- message, entries, vers->tag) != 0)
- err++;
- else
+ if (vers->options == NULL || *vers->options == '\0')
{
- added_files++;
- if (!quiet)
+ /* No options specified on command line (or in
+ rcs file if it existed, e.g. the file exists
+ on another branch). Check for a value from
+ the wrapper stuff. */
+ if (wrap_name_has (user, WRAP_RCSOPTION))
{
- if (vers->tag)
- error (0, 0, "\
+ if (vers->options)
+ free (vers->options);
+ vers->options = wrap_rcsoption (user, 1);
+ }
+ }
+
+ if (vers->nonbranch)
+ {
+ error (0, 0,
+ "cannot add file on non-branch tag %s",
+ vers->tag);
+ ++err;
+ }
+ else
+ {
+ /* There is a user file, so build the entry for it */
+ if (build_entry (repository, user, vers->options,
+ message, entries, vers->tag) != 0)
+ err++;
+ else
+ {
+ added_files++;
+ if (!quiet)
+ {
+ if (vers->tag)
+ error (0, 0, "\
scheduling %s `%s' for addition on branch `%s'",
- (wrap_name_has (user, WRAP_TOCVS)
- ? "wrapper"
- : "file"),
- user, vers->tag);
- else
- error (0, 0, "scheduling %s `%s' for addition",
- (wrap_name_has (user, WRAP_TOCVS)
- ? "wrapper"
- : "file"),
- user);
+ (wrap_name_has (user, WRAP_TOCVS)
+ ? "wrapper"
+ : "file"),
+ user, vers->tag);
+ else
+ error (0, 0,
+ "scheduling %s `%s' for addition",
+ (wrap_name_has (user, WRAP_TOCVS)
+ ? "wrapper"
+ : "file"),
+ user);
+ }
}
}
}
@@ -210,20 +311,38 @@ scheduling %s `%s' for addition on branch `%s'",
{
if (isdir (user) && !wrap_name_has (user, WRAP_TOCVS))
{
- error (0, 0, "the directory `%s' cannot be added because a file of the", user);
- error (1, 0, "same name already exists in the repository.");
+ error (0, 0, "\
+the directory `%s' cannot be added because a file of the", user);
+ error (1, 0, "\
+same name already exists in the repository.");
}
else
{
- if (vers->tag)
- error (0, 0, "file `%s' will be added on branch `%s' from version %s",
- user, vers->tag, vers->vn_rcs);
+ if (vers->nonbranch)
+ {
+ error (0, 0,
+ "cannot add file on non-branch tag %s",
+ vers->tag);
+ ++err;
+ }
else
- error (0, 0, "version %s of `%s' will be resurrected",
- vers->vn_rcs, user);
- Register (entries, user, "0", vers->ts_user, NULL,
- vers->tag, NULL, NULL);
- ++added_files;
+ {
+ if (vers->tag)
+ error (0, 0, "\
+file `%s' will be added on branch `%s' from version %s",
+ user, vers->tag, vers->vn_rcs);
+ else
+ /* I'm not sure that mentioning
+ vers->vn_rcs makes any sense here; I
+ can't think of a way to word the
+ message which is not confusing. */
+ error (0, 0, "\
+re-adding file %s (in place of dead revision %s)",
+ user, vers->vn_rcs);
+ Register (entries, user, "0", vers->ts_user, NULL,
+ vers->tag, NULL, NULL);
+ ++added_files;
+ }
}
}
else
@@ -259,8 +378,8 @@ scheduling %s `%s' for addition on branch `%s'",
* There is no RCS file, so somebody else must've removed
* it from under us
*/
- error (0, 0,
- "cannot resurrect %s; RCS file removed by second party", user);
+ error (0, 0, "\
+cannot resurrect %s; RCS file removed by second party", user);
err++;
}
else
@@ -298,7 +417,8 @@ scheduling %s `%s' for addition on branch `%s'",
else
{
/* The user file shouldn't be there */
- error (0, 0, "%s should be removed and is still there (or is back again)", user);
+ error (0, 0, "\
+%s should be removed and is still there (or is back again)", user);
err++;
}
}
@@ -316,7 +436,7 @@ scheduling %s `%s' for addition on branch `%s'",
&& isdir (user)
&& !wrap_name_has (user, WRAP_TOCVS))
{
- err += add_directory (repository, user);
+ err += add_directory (repository, entries, user);
continue;
}
#ifdef SERVER_SUPPORT
@@ -332,6 +452,7 @@ scheduling %s `%s' for addition on branch `%s'",
if (message)
free (message);
+ free (repository);
return (err);
}
@@ -344,14 +465,16 @@ scheduling %s `%s' for addition on branch `%s'",
* Returns 1 on failure, 0 on success.
*/
static int
-add_directory (repository, dir)
+add_directory (repository, entries, dir)
char *repository;
+ List *entries;
char *dir;
{
- char rcsdir[PATH_MAX];
+ char *rcsdir = NULL;
struct saved_cwd cwd;
- char message[PATH_MAX + 100];
+ char *message = NULL;
char *tag, *date;
+ int nonbranch;
if (strchr (dir, '/') != NULL)
{
@@ -366,12 +489,12 @@ add_directory (repository, dir)
}
/* before we do anything else, see if we have any per-directory tags */
- ParseTag (&tag, &date);
+ ParseTag (&tag, &date, &nonbranch);
/* now, remember where we were, so we can get back */
if (save_cwd (&cwd))
return (1);
- if (chdir (dir) < 0)
+ if ( CVS_CHDIR (dir) < 0)
{
error (0, errno, "cannot chdir to %s", dir);
return (1);
@@ -386,7 +509,7 @@ add_directory (repository, dir)
goto out;
}
- (void) sprintf (rcsdir, "%s/%s", repository, dir);
+ rcsdir = combine_dir (repository, dir);
if (isfile (rcsdir) && !isdir (rcsdir))
{
error (0, 0, "%s is not a directory; %s not added", rcsdir, dir);
@@ -394,6 +517,7 @@ add_directory (repository, dir)
}
/* setup the log message */
+ message = xmalloc (strlen (rcsdir) + 80);
(void) sprintf (message, "Directory %s added to the repository\n", rcsdir);
if (tag)
{
@@ -413,30 +537,27 @@ add_directory (repository, dir)
mode_t omask;
Node *p;
List *ulist;
+ struct logfile_info *li;
-#if 0
- char line[MAXLINELEN];
-
- (void) printf ("Add directory %s to the repository (y/n) [n] ? ",
- rcsdir);
- (void) fflush (stdout);
- clearerr (stdin);
- if (fgets (line, sizeof (line), stdin) == NULL ||
- (line[0] != 'y' && line[0] != 'Y'))
- {
- error (0, 0, "directory %s not added", rcsdir);
- goto out;
- }
-#endif
+ /* There used to be some code here which would prompt for
+ whether to add the directory. The details of that code had
+ bitrotted, but more to the point it can't work
+ client/server, doesn't ask in the right way for GUIs, etc.
+ A better way of making it harder to accidentally add
+ directories would be to have to add and commit directories
+ like for files. The code was #if 0'd at least since CVS 1.5. */
- omask = umask (cvsumask);
- if (CVS_MKDIR (rcsdir, 0777) < 0)
+ if (!noexec)
{
- error (0, errno, "cannot mkdir %s", rcsdir);
+ omask = umask (cvsumask);
+ if (CVS_MKDIR (rcsdir, 0777) < 0)
+ {
+ error (0, errno, "cannot mkdir %s", rcsdir);
+ (void) umask (omask);
+ goto out;
+ }
(void) umask (omask);
- goto out;
}
- (void) umask (omask);
/*
* Set up an update list with a single title node for Update_Logfile
@@ -446,28 +567,45 @@ add_directory (repository, dir)
p->type = UPDATE;
p->delproc = update_delproc;
p->key = xstrdup ("- New directory");
- p->data = (char *) T_TITLE;
+ li = (struct logfile_info *) xmalloc (sizeof (struct logfile_info));
+ li->type = T_TITLE;
+ li->tag = xstrdup (tag);
+ li->rev_old = li->rev_new = NULL;
+ p->data = (char *) li;
(void) addnode (ulist, p);
- Update_Logfile (rcsdir, message, (char *) NULL, (FILE *) NULL, ulist);
+ Update_Logfile (rcsdir, message, (FILE *) NULL, ulist);
dellist (&ulist);
}
#ifdef SERVER_SUPPORT
if (!server_active)
- Create_Admin (".", dir, rcsdir, tag, date);
+ Create_Admin (".", dir, rcsdir, tag, date, nonbranch);
#else
- Create_Admin (".", dir, rcsdir, tag, date);
+ Create_Admin (".", dir, rcsdir, tag, date, nonbranch);
#endif
if (tag)
free (tag);
if (date)
free (date);
+ if (restore_cwd (&cwd, NULL))
+ error_exit ();
+ free_cwd (&cwd);
+
+ Subdir_Register (entries, (char *) NULL, dir);
+
(void) printf ("%s", message);
+ free (rcsdir);
+ free (message);
+
+ return (0);
+
out:
if (restore_cwd (&cwd, NULL))
- exit (EXIT_FAILURE);
+ error_exit ();
free_cwd (&cwd);
+ if (rcsdir != NULL)
+ free (rcsdir);
return (0);
}
@@ -484,8 +622,8 @@ build_entry (repository, user, options, message, entries, tag)
List *entries;
char *tag;
{
- char fname[PATH_MAX];
- char line[MAXLINELEN];
+ char *fname;
+ char *line;
FILE *fp;
if (noexec)
@@ -496,19 +634,23 @@ build_entry (repository, user, options, message, entries, tag)
* file user,t. If the "message" argument is set, use it as the
* initial creation log (which typically describes the file).
*/
+ fname = xmalloc (strlen (user) + 80);
(void) sprintf (fname, "%s/%s%s", CVSADM, user, CVSEXT_LOG);
fp = open_file (fname, "w+");
if (message && fputs (message, fp) == EOF)
error (1, errno, "cannot write to %s", fname);
if (fclose(fp) == EOF)
error(1, errno, "cannot close %s", fname);
+ free (fname);
/*
* Create the entry now, since this allows the user to interrupt us above
* without needing to clean anything up (well, we could clean up the
* ,t file, but who cares).
*/
+ line = xmalloc (strlen (user) + 20);
(void) sprintf (line, "Initial %s", user);
Register (entries, user, "0", line, options, tag, (char *) 0, (char *) 0);
+ free (line);
return (0);
}
diff --git a/contrib/cvs/src/admin.c b/contrib/cvs/src/admin.c
index 214318a..d1401f4 100644
--- a/contrib/cvs/src/admin.c
+++ b/contrib/cvs/src/admin.c
@@ -16,8 +16,10 @@
#include <grp.h>
#endif
-static Dtype admin_dirproc PROTO((char *dir, char *repos, char *update_dir));
-static int admin_fileproc PROTO((struct file_info *finfo));
+static Dtype admin_dirproc PROTO ((void *callerdat, char *dir,
+ char *repos, char *update_dir,
+ List *entries));
+static int admin_fileproc PROTO ((void *callerdat, struct file_info *finfo));
static const char *const admin_usage[] =
{
@@ -36,6 +38,7 @@ admin (argc, argv)
int err;
#ifdef CVS_ADMIN_GROUP
struct group *grp;
+ struct group *getgrnam();
#endif
if (argc <= 1)
usage (admin_usage);
@@ -75,8 +78,6 @@ admin (argc, argv)
av = argv + 1;
argv += ac;
ac--;
- if (ac == 0 || argc == 0)
- usage (admin_usage);
#ifdef CLIENT_SUPPORT
if (client_active)
@@ -88,14 +89,11 @@ admin (argc, argv)
ign_setup ();
- for (i = 0; i <= ac; ++i) /* XXX send -ko too with i = 0 */
+ for (i = 0; i < ac; ++i) /* XXX send -ko too with i = 0 */
send_arg (av[i]);
send_file_names (argc, argv, SEND_EXPAND_WILD);
- /* FIXME: We shouldn't have to send current files, but I'm not sure
- whether it works. So send the files --
- it's slower but it works. */
- send_files (argc, argv, 0, 0);
+ send_files (argc, argv, 0, 0, SEND_NO_CONTENTS);
send_to_server ("admin\012", 0);
return get_responses_and_close ();
}
@@ -103,8 +101,8 @@ admin (argc, argv)
/* start the recursion processor */
err = start_recursion (admin_fileproc, (FILESDONEPROC) NULL, admin_dirproc,
- (DIRLEAVEPROC) NULL, argc, argv, 0,
- W_LOCAL, 0, 1, (char *) NULL, 1, 0);
+ (DIRLEAVEPROC) NULL, NULL, argc, argv, 0,
+ W_LOCAL, 0, 1, (char *) NULL, 1);
return (err);
}
@@ -113,7 +111,8 @@ admin (argc, argv)
*/
/* ARGSUSED */
static int
-admin_fileproc (finfo)
+admin_fileproc (callerdat, finfo)
+ void *callerdat;
struct file_info *finfo;
{
Vers_TS *vers;
@@ -123,8 +122,7 @@ admin_fileproc (finfo)
int retcode = 0;
int status = 0;
- vers = Version_TS (finfo->repository, (char *) NULL, (char *) NULL, (char *) NULL,
- finfo->file, 0, 0, finfo->entries, finfo->rcs);
+ vers = Version_TS (finfo, NULL, NULL, NULL, 0, 0);
version = vers->vn_user;
if (version == NULL)
@@ -157,10 +155,12 @@ admin_fileproc (finfo)
*/
/* ARGSUSED */
static Dtype
-admin_dirproc (dir, repos, update_dir)
+admin_dirproc (callerdat, dir, repos, update_dir, entries)
+ void *callerdat;
char *dir;
char *repos;
char *update_dir;
+ List *entries;
{
if (!quiet)
error (0, 0, "Administrating %s", update_dir);
diff --git a/contrib/cvs/src/buffer.c b/contrib/cvs/src/buffer.c
new file mode 100644
index 0000000..d6ea895
--- /dev/null
+++ b/contrib/cvs/src/buffer.c
@@ -0,0 +1,1294 @@
+/* Code for the buffer data structure. */
+
+#include <assert.h>
+#include "cvs.h"
+#include "buffer.h"
+
+#if defined (SERVER_SUPPORT) || defined (CLIENT_SUPPORT)
+
+/* OS/2 doesn't have EIO. FIXME: this whole notion of turning
+ a different error into EIO strikes me as pretty dubious. */
+#if !defined (EIO)
+#define EIO EBADPOS
+#endif
+
+/* Linked list of available buffer_data structures. */
+static struct buffer_data *free_buffer_data;
+
+/* Local functions. */
+static void allocate_buffer_datas PROTO((void));
+static struct buffer_data *get_buffer_data PROTO((void));
+
+/* Initialize a buffer structure. */
+
+struct buffer *
+buf_initialize (input, output, flush, block, shutdown, memory, closure)
+ int (*input) PROTO((void *, char *, int, int, int *));
+ int (*output) PROTO((void *, const char *, int, int *));
+ int (*flush) PROTO((void *));
+ int (*block) PROTO((void *, int));
+ int (*shutdown) PROTO((void *));
+ void (*memory) PROTO((struct buffer *));
+ void *closure;
+{
+ struct buffer *buf;
+
+ buf = (struct buffer *) xmalloc (sizeof (struct buffer));
+ buf->data = NULL;
+ buf->last = NULL;
+ buf->nonblocking = 0;
+ buf->input = input;
+ buf->output = output;
+ buf->flush = flush;
+ buf->block = block;
+ buf->shutdown = shutdown;
+ buf->memory_error = memory;
+ buf->closure = closure;
+ return buf;
+}
+
+/* Initialize a buffer structure which is not to be used for I/O. */
+
+struct buffer *
+buf_nonio_initialize (memory)
+ void (*memory) PROTO((struct buffer *));
+{
+ return (buf_initialize
+ ((int (*) PROTO((void *, char *, int, int, int *))) NULL,
+ (int (*) PROTO((void *, const char *, int, int *))) NULL,
+ (int (*) PROTO((void *))) NULL,
+ (int (*) PROTO((void *, int))) NULL,
+ (int (*) PROTO((void *))) NULL,
+ memory,
+ (void *) NULL));
+}
+
+/* Allocate more buffer_data structures. */
+
+static void
+allocate_buffer_datas ()
+{
+ struct buffer_data *alc;
+ char *space;
+ int i;
+
+ /* Allocate buffer_data structures in blocks of 16. */
+#define ALLOC_COUNT (16)
+
+ alc = ((struct buffer_data *)
+ malloc (ALLOC_COUNT * sizeof (struct buffer_data)));
+ space = (char *) valloc (ALLOC_COUNT * BUFFER_DATA_SIZE);
+ if (alc == NULL || space == NULL)
+ return;
+ for (i = 0; i < ALLOC_COUNT; i++, alc++, space += BUFFER_DATA_SIZE)
+ {
+ alc->next = free_buffer_data;
+ free_buffer_data = alc;
+ alc->text = space;
+ }
+}
+
+/* Get a new buffer_data structure. */
+
+static struct buffer_data *
+get_buffer_data ()
+{
+ struct buffer_data *ret;
+
+ if (free_buffer_data == NULL)
+ {
+ allocate_buffer_datas ();
+ if (free_buffer_data == NULL)
+ return NULL;
+ }
+
+ ret = free_buffer_data;
+ free_buffer_data = ret->next;
+ return ret;
+}
+
+/* See whether a buffer is empty. */
+
+int
+buf_empty_p (buf)
+ struct buffer *buf;
+{
+ struct buffer_data *data;
+
+ for (data = buf->data; data != NULL; data = data->next)
+ if (data->size > 0)
+ return 0;
+ return 1;
+}
+
+#ifdef SERVER_FLOWCONTROL
+/*
+ * Count how much data is stored in the buffer..
+ * Note that each buffer is a malloc'ed chunk BUFFER_DATA_SIZE.
+ */
+
+int
+buf_count_mem (buf)
+ struct buffer *buf;
+{
+ struct buffer_data *data;
+ int mem = 0;
+
+ for (data = buf->data; data != NULL; data = data->next)
+ mem += BUFFER_DATA_SIZE;
+
+ return mem;
+}
+#endif /* SERVER_FLOWCONTROL */
+
+/* Add data DATA of length LEN to BUF. */
+
+void
+buf_output (buf, data, len)
+ struct buffer *buf;
+ const char *data;
+ int len;
+{
+ if (buf->data != NULL
+ && (((buf->last->text + BUFFER_DATA_SIZE)
+ - (buf->last->bufp + buf->last->size))
+ >= len))
+ {
+ memcpy (buf->last->bufp + buf->last->size, data, len);
+ buf->last->size += len;
+ return;
+ }
+
+ while (1)
+ {
+ struct buffer_data *newdata;
+
+ newdata = get_buffer_data ();
+ if (newdata == NULL)
+ {
+ (*buf->memory_error) (buf);
+ return;
+ }
+
+ if (buf->data == NULL)
+ buf->data = newdata;
+ else
+ buf->last->next = newdata;
+ newdata->next = NULL;
+ buf->last = newdata;
+
+ newdata->bufp = newdata->text;
+
+ if (len <= BUFFER_DATA_SIZE)
+ {
+ newdata->size = len;
+ memcpy (newdata->text, data, len);
+ return;
+ }
+
+ newdata->size = BUFFER_DATA_SIZE;
+ memcpy (newdata->text, data, BUFFER_DATA_SIZE);
+
+ data += BUFFER_DATA_SIZE;
+ len -= BUFFER_DATA_SIZE;
+ }
+
+ /*NOTREACHED*/
+}
+
+/* Add a '\0' terminated string to BUF. */
+
+void
+buf_output0 (buf, string)
+ struct buffer *buf;
+ const char *string;
+{
+ buf_output (buf, string, strlen (string));
+}
+
+/* Add a single character to BUF. */
+
+void
+buf_append_char (buf, ch)
+ struct buffer *buf;
+ int ch;
+{
+ if (buf->data != NULL
+ && (buf->last->text + BUFFER_DATA_SIZE
+ != buf->last->bufp + buf->last->size))
+ {
+ *(buf->last->bufp + buf->last->size) = ch;
+ ++buf->last->size;
+ }
+ else
+ {
+ char b;
+
+ b = ch;
+ buf_output (buf, &b, 1);
+ }
+}
+
+/*
+ * Send all the output we've been saving up. Returns 0 for success or
+ * errno code. If the buffer has been set to be nonblocking, this
+ * will just write until the write would block.
+ */
+
+int
+buf_send_output (buf)
+ struct buffer *buf;
+{
+ if (buf->output == NULL)
+ abort ();
+
+ while (buf->data != NULL)
+ {
+ struct buffer_data *data;
+
+ data = buf->data;
+
+ if (data->size > 0)
+ {
+ int status, nbytes;
+
+ status = (*buf->output) (buf->closure, data->bufp, data->size,
+ &nbytes);
+ if (status != 0)
+ {
+ /* Some sort of error. Discard the data, and return. */
+
+ buf->last->next = free_buffer_data;
+ free_buffer_data = buf->data;
+ buf->data = NULL;
+ buf->last = NULL;
+
+ return status;
+ }
+
+ if (nbytes != data->size)
+ {
+ /* Not all the data was written out. This is only
+ permitted in nonblocking mode. Adjust the buffer,
+ and return. */
+
+ assert (buf->nonblocking);
+
+ data->size -= nbytes;
+ data->bufp += nbytes;
+
+ return 0;
+ }
+ }
+
+ buf->data = data->next;
+ data->next = free_buffer_data;
+ free_buffer_data = data;
+ }
+
+ buf->last = NULL;
+
+ return 0;
+}
+
+/*
+ * Flush any data queued up in the buffer. If BLOCK is nonzero, then
+ * if the buffer is in nonblocking mode, put it into blocking mode for
+ * the duration of the flush. This returns 0 on success, or an error
+ * code.
+ */
+
+int
+buf_flush (buf, block)
+ struct buffer *buf;
+ int block;
+{
+ int nonblocking;
+ int status;
+
+ if (buf->flush == NULL)
+ abort ();
+
+ nonblocking = buf->nonblocking;
+ if (nonblocking && block)
+ {
+ status = set_block (buf);
+ if (status != 0)
+ return status;
+ }
+
+ status = buf_send_output (buf);
+ if (status == 0)
+ status = (*buf->flush) (buf->closure);
+
+ if (nonblocking && block)
+ {
+ int blockstat;
+
+ blockstat = set_nonblock (buf);
+ if (status == 0)
+ status = blockstat;
+ }
+
+ return status;
+}
+
+/*
+ * Set buffer BUF to nonblocking I/O. Returns 0 for success or errno
+ * code.
+ */
+
+int
+set_nonblock (buf)
+ struct buffer *buf;
+{
+ int status;
+
+ if (buf->nonblocking)
+ return 0;
+ if (buf->block == NULL)
+ abort ();
+ status = (*buf->block) (buf->closure, 0);
+ if (status != 0)
+ return status;
+ buf->nonblocking = 1;
+ return 0;
+}
+
+/*
+ * Set buffer BUF to blocking I/O. Returns 0 for success or errno
+ * code.
+ */
+
+int
+set_block (buf)
+ struct buffer *buf;
+{
+ int status;
+
+ if (! buf->nonblocking)
+ return 0;
+ if (buf->block == NULL)
+ abort ();
+ status = (*buf->block) (buf->closure, 1);
+ if (status != 0)
+ return status;
+ buf->nonblocking = 0;
+ return 0;
+}
+
+/*
+ * Send a character count and some output. Returns errno code or 0 for
+ * success.
+ *
+ * Sending the count in binary is OK since this is only used on a pipe
+ * within the same system.
+ */
+
+int
+buf_send_counted (buf)
+ struct buffer *buf;
+{
+ int size;
+ struct buffer_data *data;
+
+ size = 0;
+ for (data = buf->data; data != NULL; data = data->next)
+ size += data->size;
+
+ data = get_buffer_data ();
+ if (data == NULL)
+ {
+ (*buf->memory_error) (buf);
+ return ENOMEM;
+ }
+
+ data->next = buf->data;
+ buf->data = data;
+ if (buf->last == NULL)
+ buf->last = data;
+
+ data->bufp = data->text;
+ data->size = sizeof (int);
+
+ *((int *) data->text) = size;
+
+ return buf_send_output (buf);
+}
+
+/*
+ * Send a special count. COUNT should be negative. It will be
+ * handled speciallyi by buf_copy_counted. This function returns 0 or
+ * an errno code.
+ *
+ * Sending the count in binary is OK since this is only used on a pipe
+ * within the same system.
+ */
+
+int
+buf_send_special_count (buf, count)
+ struct buffer *buf;
+ int count;
+{
+ struct buffer_data *data;
+
+ data = get_buffer_data ();
+ if (data == NULL)
+ {
+ (*buf->memory_error) (buf);
+ return ENOMEM;
+ }
+
+ data->next = buf->data;
+ buf->data = data;
+ if (buf->last == NULL)
+ buf->last = data;
+
+ data->bufp = data->text;
+ data->size = sizeof (int);
+
+ *((int *) data->text) = count;
+
+ return buf_send_output (buf);
+}
+
+/* Append a list of buffer_data structures to an buffer. */
+
+void
+buf_append_data (buf, data, last)
+ struct buffer *buf;
+ struct buffer_data *data;
+ struct buffer_data *last;
+{
+ if (data != NULL)
+ {
+ if (buf->data == NULL)
+ buf->data = data;
+ else
+ buf->last->next = data;
+ buf->last = last;
+ }
+}
+
+/*
+ * Copy the contents of file F into buffer_data structures. We can't
+ * copy directly into an buffer, because we want to handle failure and
+ * succeess differently. Returns 0 on success, or -2 if out of
+ * memory, or a status code on error. Since the caller happens to
+ * know the size of the file, it is passed in as SIZE. On success,
+ * this function sets *RETP and *LASTP, which may be passed to
+ * buf_append_data.
+ */
+
+int
+buf_read_file (f, size, retp, lastp)
+ FILE *f;
+ long size;
+ struct buffer_data **retp;
+ struct buffer_data **lastp;
+{
+ int status;
+
+ *retp = NULL;
+ *lastp = NULL;
+
+ while (size > 0)
+ {
+ struct buffer_data *data;
+ int get;
+
+ data = get_buffer_data ();
+ if (data == NULL)
+ {
+ status = -2;
+ goto error_return;
+ }
+
+ if (*retp == NULL)
+ *retp = data;
+ else
+ (*lastp)->next = data;
+ data->next = NULL;
+ *lastp = data;
+
+ data->bufp = data->text;
+ data->size = 0;
+
+ if (size > BUFFER_DATA_SIZE)
+ get = BUFFER_DATA_SIZE;
+ else
+ get = size;
+
+ errno = EIO;
+ if (fread (data->text, get, 1, f) != 1)
+ {
+ status = errno;
+ goto error_return;
+ }
+
+ data->size += get;
+ size -= get;
+ }
+
+ return 0;
+
+ error_return:
+ if (*retp != NULL)
+ {
+ (*lastp)->next = free_buffer_data;
+ free_buffer_data = *retp;
+ }
+ return status;
+}
+
+/*
+ * Copy the contents of file F into buffer_data structures. We can't
+ * copy directly into an buffer, because we want to handle failure and
+ * succeess differently. Returns 0 on success, or -2 if out of
+ * memory, or a status code on error. On success, this function sets
+ * *RETP and *LASTP, which may be passed to buf_append_data.
+ */
+
+int
+buf_read_file_to_eof (f, retp, lastp)
+ FILE *f;
+ struct buffer_data **retp;
+ struct buffer_data **lastp;
+{
+ int status;
+
+ *retp = NULL;
+ *lastp = NULL;
+
+ while (!feof (f))
+ {
+ struct buffer_data *data;
+ int get, nread;
+
+ data = get_buffer_data ();
+ if (data == NULL)
+ {
+ status = -2;
+ goto error_return;
+ }
+
+ if (*retp == NULL)
+ *retp = data;
+ else
+ (*lastp)->next = data;
+ data->next = NULL;
+ *lastp = data;
+
+ data->bufp = data->text;
+ data->size = 0;
+
+ get = BUFFER_DATA_SIZE;
+
+ errno = EIO;
+ nread = fread (data->text, 1, get, f);
+ if (nread == 0 && !feof (f))
+ {
+ status = errno;
+ goto error_return;
+ }
+
+ data->size = nread;
+ }
+
+ return 0;
+
+ error_return:
+ if (*retp != NULL)
+ {
+ (*lastp)->next = free_buffer_data;
+ free_buffer_data = *retp;
+ }
+ return status;
+}
+
+/* Return the number of bytes in a chain of buffer_data structures. */
+
+int
+buf_chain_length (buf)
+ struct buffer_data *buf;
+{
+ int size = 0;
+ while (buf)
+ {
+ size += buf->size;
+ buf = buf->next;
+ }
+ return size;
+}
+
+/*
+ * Read an arbitrary amount of data into an input buffer. The buffer
+ * will be in nonblocking mode, and we just grab what we can. Return
+ * 0 on success, or -1 on end of file, or -2 if out of memory, or an
+ * error code. If COUNTP is not NULL, *COUNTP is set to the number of
+ * bytes read.
+ */
+
+int
+buf_input_data (buf, countp)
+ struct buffer *buf;
+ int *countp;
+{
+ if (buf->input == NULL)
+ abort ();
+
+ if (countp != NULL)
+ *countp = 0;
+
+ while (1)
+ {
+ int get;
+ int status, nbytes;
+
+ if (buf->data == NULL
+ || (buf->last->bufp + buf->last->size
+ == buf->last->text + BUFFER_DATA_SIZE))
+ {
+ struct buffer_data *data;
+
+ data = get_buffer_data ();
+ if (data == NULL)
+ {
+ (*buf->memory_error) (buf);
+ return -2;
+ }
+
+ if (buf->data == NULL)
+ buf->data = data;
+ else
+ buf->last->next = data;
+ data->next = NULL;
+ buf->last = data;
+
+ data->bufp = data->text;
+ data->size = 0;
+ }
+
+ get = ((buf->last->text + BUFFER_DATA_SIZE)
+ - (buf->last->bufp + buf->last->size));
+
+ status = (*buf->input) (buf->closure,
+ buf->last->bufp + buf->last->size,
+ 0, get, &nbytes);
+ if (status != 0)
+ return status;
+
+ buf->last->size += nbytes;
+ if (countp != NULL)
+ *countp += nbytes;
+
+ if (nbytes < get)
+ {
+ /* If we did not fill the buffer, then presumably we read
+ all the available data. */
+ return 0;
+ }
+ }
+
+ /*NOTREACHED*/
+}
+
+/*
+ * Read a line (characters up to a \012) from an input buffer. (We
+ * use \012 rather than \n for the benefit of non Unix clients for
+ * which \n means something else). This returns 0 on success, or -1
+ * on end of file, or -2 if out of memory, or an error code. If it
+ * succeeds, it sets *LINE to an allocated buffer holding the contents
+ * of the line. The trailing \012 is not included in the buffer. If
+ * LENP is not NULL, then *LENP is set to the number of bytes read;
+ * strlen may not work, because there may be embedded null bytes.
+ */
+
+int
+buf_read_line (buf, line, lenp)
+ struct buffer *buf;
+ char **line;
+ int *lenp;
+{
+ if (buf->input == NULL)
+ abort ();
+
+ *line = NULL;
+
+ while (1)
+ {
+ int len, finallen = 0;
+ struct buffer_data *data;
+ char *nl;
+
+ /* See if there is a newline in BUF. */
+ len = 0;
+ for (data = buf->data; data != NULL; data = data->next)
+ {
+ nl = memchr (data->bufp, '\012', data->size);
+ if (nl != NULL)
+ {
+ finallen = nl - data->bufp;
+ len += finallen;
+ break;
+ }
+ len += data->size;
+ }
+
+ /* If we found a newline, copy the line into a memory buffer,
+ and remove it from BUF. */
+ if (data != NULL)
+ {
+ char *p;
+ struct buffer_data *nldata;
+
+ p = malloc (len + 1);
+ if (p == NULL)
+ return -2;
+ *line = p;
+
+ nldata = data;
+ data = buf->data;
+ while (data != nldata)
+ {
+ struct buffer_data *next;
+
+ memcpy (p, data->bufp, data->size);
+ p += data->size;
+ next = data->next;
+ data->next = free_buffer_data;
+ free_buffer_data = data;
+ data = next;
+ }
+
+ memcpy (p, data->bufp, finallen);
+ p[finallen] = '\0';
+
+ data->size -= finallen + 1;
+ data->bufp = nl + 1;
+ buf->data = data;
+
+ if (lenp != NULL)
+ *lenp = len;
+
+ return 0;
+ }
+
+ /* Read more data until we get a newline. */
+ while (1)
+ {
+ int size, status, nbytes;
+ char *mem;
+
+ if (buf->data == NULL
+ || (buf->last->bufp + buf->last->size
+ == buf->last->text + BUFFER_DATA_SIZE))
+ {
+ data = get_buffer_data ();
+ if (data == NULL)
+ {
+ (*buf->memory_error) (buf);
+ return -2;
+ }
+
+ if (buf->data == NULL)
+ buf->data = data;
+ else
+ buf->last->next = data;
+ data->next = NULL;
+ buf->last = data;
+
+ data->bufp = data->text;
+ data->size = 0;
+ }
+
+ mem = buf->last->bufp + buf->last->size;
+ size = (buf->last->text + BUFFER_DATA_SIZE) - mem;
+
+ /* We need to read at least 1 byte. We can handle up to
+ SIZE bytes. This will only be efficient if the
+ underlying communication stream does its own buffering,
+ or is clever about getting more than 1 byte at a time. */
+ status = (*buf->input) (buf->closure, mem, 1, size, &nbytes);
+ if (status != 0)
+ return status;
+
+ buf->last->size += nbytes;
+
+ /* Optimize slightly to avoid an unnecessary call to
+ memchr. */
+ if (nbytes == 1)
+ {
+ if (*mem == '\012')
+ break;
+ }
+ else
+ {
+ if (memchr (mem, '\012', nbytes) != NULL)
+ break;
+ }
+ }
+ }
+}
+
+/*
+ * Extract data from the input buffer BUF. This will read up to WANT
+ * bytes from the buffer. It will set *RETDATA to point at the bytes,
+ * and set *GOT to the number of bytes to be found there. Any buffer
+ * call which uses BUF may change the contents of the buffer at *DATA,
+ * so the data should be fully processed before any further calls are
+ * made. This returns 0 on success, or -1 on end of file, or -2 if
+ * out of memory, or an error code.
+ */
+
+int
+buf_read_data (buf, want, retdata, got)
+ struct buffer *buf;
+ int want;
+ char **retdata;
+ int *got;
+{
+ if (buf->input == NULL)
+ abort ();
+
+ while (buf->data != NULL && buf->data->size == 0)
+ {
+ struct buffer_data *next;
+
+ next = buf->data->next;
+ buf->data->next = free_buffer_data;
+ free_buffer_data = buf->data;
+ buf->data = next;
+ if (next == NULL)
+ buf->last = NULL;
+ }
+
+ if (buf->data == NULL)
+ {
+ struct buffer_data *data;
+ int get, status, nbytes;
+
+ data = get_buffer_data ();
+ if (data == NULL)
+ {
+ (*buf->memory_error) (buf);
+ return -2;
+ }
+
+ buf->data = data;
+ buf->last = data;
+ data->next = NULL;
+ data->bufp = data->text;
+ data->size = 0;
+
+ if (want < BUFFER_DATA_SIZE)
+ get = want;
+ else
+ get = BUFFER_DATA_SIZE;
+ status = (*buf->input) (buf->closure, data->bufp, get,
+ BUFFER_DATA_SIZE, &nbytes);
+ if (status != 0)
+ return status;
+
+ data->size = nbytes;
+ }
+
+ *retdata = buf->data->bufp;
+ if (want < buf->data->size)
+ {
+ *got = want;
+ buf->data->size -= want;
+ buf->data->bufp += want;
+ }
+ else
+ {
+ *got = buf->data->size;
+ buf->data->size = 0;
+ }
+
+ return 0;
+}
+
+/*
+ * Copy lines from an input buffer to an output buffer. This copies
+ * all complete lines (characters up to a newline) from INBUF to
+ * OUTBUF. Each line in OUTBUF is preceded by the character COMMAND
+ * and a space.
+ */
+
+void
+buf_copy_lines (outbuf, inbuf, command)
+ struct buffer *outbuf;
+ struct buffer *inbuf;
+ int command;
+{
+ while (1)
+ {
+ struct buffer_data *data;
+ struct buffer_data *nldata;
+ char *nl;
+ int len;
+
+ /* See if there is a newline in INBUF. */
+ nldata = NULL;
+ nl = NULL;
+ for (data = inbuf->data; data != NULL; data = data->next)
+ {
+ nl = memchr (data->bufp, '\n', data->size);
+ if (nl != NULL)
+ {
+ nldata = data;
+ break;
+ }
+ }
+
+ if (nldata == NULL)
+ {
+ /* There are no more lines in INBUF. */
+ return;
+ }
+
+ /* Put in the command. */
+ buf_append_char (outbuf, command);
+ buf_append_char (outbuf, ' ');
+
+ if (inbuf->data != nldata)
+ {
+ /*
+ * Simply move over all the buffers up to the one containing
+ * the newline.
+ */
+ for (data = inbuf->data; data->next != nldata; data = data->next)
+ ;
+ data->next = NULL;
+ buf_append_data (outbuf, inbuf->data, data);
+ inbuf->data = nldata;
+ }
+
+ /*
+ * If the newline is at the very end of the buffer, just move
+ * the buffer onto OUTBUF. Otherwise we must copy the data.
+ */
+ len = nl + 1 - nldata->bufp;
+ if (len == nldata->size)
+ {
+ inbuf->data = nldata->next;
+ if (inbuf->data == NULL)
+ inbuf->last = NULL;
+
+ nldata->next = NULL;
+ buf_append_data (outbuf, nldata, nldata);
+ }
+ else
+ {
+ buf_output (outbuf, nldata->bufp, len);
+ nldata->bufp += len;
+ nldata->size -= len;
+ }
+ }
+}
+
+/*
+ * Copy counted data from one buffer to another. The count is an
+ * integer, host size, host byte order (it is only used across a
+ * pipe). If there is enough data, it should be moved over. If there
+ * is not enough data, it should remain on the original buffer. A
+ * negative count is a special case. if one is seen, *SPECIAL is set
+ * to the (negative) count value and no additional data is gathered
+ * from the buffer; normally *SPECIAL is set to 0. This function
+ * returns the number of bytes it needs to see in order to actually
+ * copy something over.
+ */
+
+int
+buf_copy_counted (outbuf, inbuf, special)
+ struct buffer *outbuf;
+ struct buffer *inbuf;
+ int *special;
+{
+ *special = 0;
+
+ while (1)
+ {
+ struct buffer_data *data;
+ int need;
+ union
+ {
+ char intbuf[sizeof (int)];
+ int i;
+ } u;
+ char *intp;
+ int count;
+ struct buffer_data *start;
+ int startoff;
+ struct buffer_data *stop;
+ int stopwant;
+
+ /* See if we have enough bytes to figure out the count. */
+ need = sizeof (int);
+ intp = u.intbuf;
+ for (data = inbuf->data; data != NULL; data = data->next)
+ {
+ if (data->size >= need)
+ {
+ memcpy (intp, data->bufp, need);
+ break;
+ }
+ memcpy (intp, data->bufp, data->size);
+ intp += data->size;
+ need -= data->size;
+ }
+ if (data == NULL)
+ {
+ /* We don't have enough bytes to form an integer. */
+ return need;
+ }
+
+ count = u.i;
+ start = data;
+ startoff = need;
+
+ if (count < 0)
+ {
+ /* A negative COUNT is a special case meaning that we
+ don't need any further information. */
+ stop = start;
+ stopwant = 0;
+ }
+ else
+ {
+ /*
+ * We have an integer in COUNT. We have gotten all the
+ * data from INBUF in all buffers before START, and we
+ * have gotten STARTOFF bytes from START. See if we have
+ * enough bytes remaining in INBUF.
+ */
+ need = count - (start->size - startoff);
+ if (need <= 0)
+ {
+ stop = start;
+ stopwant = count;
+ }
+ else
+ {
+ for (data = start->next; data != NULL; data = data->next)
+ {
+ if (need <= data->size)
+ break;
+ need -= data->size;
+ }
+ if (data == NULL)
+ {
+ /* We don't have enough bytes. */
+ return need;
+ }
+ stop = data;
+ stopwant = need;
+ }
+ }
+
+ /*
+ * We have enough bytes. Free any buffers in INBUF before
+ * START, and remove STARTOFF bytes from START, so that we can
+ * forget about STARTOFF.
+ */
+ start->bufp += startoff;
+ start->size -= startoff;
+
+ if (start->size == 0)
+ start = start->next;
+
+ if (stop->size == stopwant)
+ {
+ stop = stop->next;
+ stopwant = 0;
+ }
+
+ while (inbuf->data != start)
+ {
+ data = inbuf->data;
+ inbuf->data = data->next;
+ data->next = free_buffer_data;
+ free_buffer_data = data;
+ }
+
+ /* If COUNT is negative, set *SPECIAL and get out now. */
+ if (count < 0)
+ {
+ *special = count;
+ return 0;
+ }
+
+ /*
+ * We want to copy over the bytes from START through STOP. We
+ * only want STOPWANT bytes from STOP.
+ */
+
+ if (start != stop)
+ {
+ /* Attach the buffers from START through STOP to OUTBUF. */
+ for (data = start; data->next != stop; data = data->next)
+ ;
+ inbuf->data = stop;
+ data->next = NULL;
+ buf_append_data (outbuf, start, data);
+ }
+
+ if (stopwant > 0)
+ {
+ buf_output (outbuf, stop->bufp, stopwant);
+ stop->bufp += stopwant;
+ stop->size -= stopwant;
+ }
+ }
+
+ /*NOTREACHED*/
+}
+
+/* Shut down a buffer. This returns 0 on success, or an errno code. */
+
+int
+buf_shutdown (buf)
+ struct buffer *buf;
+{
+ if (buf->shutdown)
+ return (*buf->shutdown) (buf->closure);
+ return 0;
+}
+
+/* The simplest type of buffer is one built on top of a stdio FILE.
+ For simplicity, and because it is all that is required, we do not
+ implement setting this type of buffer into nonblocking mode. The
+ closure field is just a FILE *. */
+
+static int stdio_buffer_input PROTO((void *, char *, int, int, int *));
+static int stdio_buffer_output PROTO((void *, const char *, int, int *));
+static int stdio_buffer_flush PROTO((void *));
+
+/* Initialize a buffer built on a stdio FILE. */
+
+struct buffer
+*stdio_buffer_initialize (fp, input, memory)
+ FILE *fp;
+ int input;
+ void (*memory) PROTO((struct buffer *));
+{
+ return buf_initialize (input ? stdio_buffer_input : NULL,
+ input ? NULL : stdio_buffer_output,
+ input ? NULL : stdio_buffer_flush,
+ (int (*) PROTO((void *, int))) NULL,
+ (int (*) PROTO((void *))) NULL,
+ memory,
+ (void *) fp);
+}
+
+/* The buffer input function for a buffer built on a stdio FILE. */
+
+static int
+stdio_buffer_input (closure, data, need, size, got)
+ void *closure;
+ char *data;
+ int need;
+ int size;
+ int *got;
+{
+ FILE *fp = (FILE *) closure;
+ int nbytes;
+
+ /* Since stdio does its own buffering, we don't worry about
+ getting more bytes than we need. */
+
+ if (need == 0 || need == 1)
+ {
+ int ch;
+
+ ch = getc (fp);
+
+ if (ch == EOF)
+ {
+ if (feof (fp))
+ return -1;
+ else if (errno == 0)
+ return EIO;
+ else
+ return errno;
+ }
+
+ *data = ch;
+ *got = 1;
+ return 0;
+ }
+
+ nbytes = fread (data, 1, need, fp);
+
+ if (nbytes == 0)
+ {
+ *got = 0;
+ if (feof (fp))
+ return -1;
+ else if (errno == 0)
+ return EIO;
+ else
+ return errno;
+ }
+
+ *got = nbytes;
+
+ return 0;
+}
+
+/* The buffer output function for a buffer built on a stdio FILE. */
+
+static int
+stdio_buffer_output (closure, data, have, wrote)
+ void *closure;
+ const char *data;
+ int have;
+ int *wrote;
+{
+ FILE *fp = (FILE *) closure;
+
+ *wrote = 0;
+
+ while (have > 0)
+ {
+ int nbytes;
+
+ nbytes = fwrite (data, 1, have, fp);
+
+ if (nbytes != have)
+ {
+ if (errno == 0)
+ return EIO;
+ else
+ return errno;
+ }
+
+ *wrote += nbytes;
+ have -= nbytes;
+ data += nbytes;
+ }
+
+ return 0;
+}
+
+/* The buffer flush function for a buffer built on a stdio FILE. */
+
+static int
+stdio_buffer_flush (closure)
+ void *closure;
+{
+ FILE *fp = (FILE *) closure;
+
+ if (fflush (fp) != 0)
+ {
+ if (errno == 0)
+ return EIO;
+ else
+ return errno;
+ }
+
+ return 0;
+}
+
+#endif /* defined (SERVER_SUPPORT) || defined (CLIENT_SUPPORT) */
diff --git a/contrib/cvs/src/buffer.h b/contrib/cvs/src/buffer.h
new file mode 100644
index 0000000..b62456c
--- /dev/null
+++ b/contrib/cvs/src/buffer.h
@@ -0,0 +1,142 @@
+/* Declarations concerning the buffer data structure. */
+
+#if defined (SERVER_SUPPORT) || defined (CLIENT_SUPPORT)
+
+/*
+ * We must read data from a child process and send it across the
+ * network. We do not want to block on writing to the network, so we
+ * store the data from the child process in memory. A BUFFER
+ * structure holds the status of one communication, and uses a linked
+ * list of buffer_data structures to hold data.
+ */
+
+struct buffer
+{
+ /* Data. */
+ struct buffer_data *data;
+
+ /* Last buffer on data chain. */
+ struct buffer_data *last;
+
+ /* Nonzero if the buffer is in nonblocking mode. */
+ int nonblocking;
+
+ /* Functions must be provided to transfer data in and out of the
+ buffer. Either the input or output field must be set, but not
+ both. */
+
+ /* Read data into the buffer DATA. There is room for up to SIZE
+ bytes. In blocking mode, wait until some input, at least NEED
+ bytes, is available (NEED may be 0 but that is the same as NEED
+ == 1). In non-blocking mode return immediately no matter how
+ much input is available; NEED is ignored. Return 0 on success,
+ or -1 on end of file, or an errno code. Set the number of
+ bytes read in *GOT.
+
+ If there are a nonzero number of bytes available, less than NEED,
+ followed by end of file, just read those bytes and return 0. */
+ int (*input) PROTO((void *closure, char *data, int need, int size,
+ int *got));
+
+ /* Write data. This should write up to HAVE bytes from DATA.
+ This should return 0 on success, or an errno code. It should
+ set the number of bytes written in *WROTE. */
+ int (*output) PROTO((void *closure, const char *data, int have,
+ int *wrote));
+
+ /* Flush any data which may be buffered up after previous calls to
+ OUTPUT. This should return 0 on success, or an errno code. */
+ int (*flush) PROTO((void *closure));
+
+ /* Change the blocking mode of the underlying communication
+ stream. If BLOCK is non-zero, it should be placed into
+ blocking mode. Otherwise, it should be placed into
+ non-blocking mode. This should return 0 on success, or an
+ errno code. */
+ int (*block) PROTO ((void *closure, int block));
+
+ /* Shut down the communication stream. This does not mean that it
+ should be closed. It merely means that no more data will be
+ read or written, and that any final processing that is
+ appropriate should be done at this point. This may be NULL.
+ It should return 0 on success, or an errno code. This entry
+ point exists for the compression code. */
+ int (*shutdown) PROTO((void *closure));
+
+ /* This field is passed to the INPUT, OUTPUT, and BLOCK functions. */
+ void *closure;
+
+ /* Function to call if we can't allocate memory. */
+ void (*memory_error) PROTO((struct buffer *));
+};
+
+/* Data is stored in lists of these structures. */
+
+struct buffer_data
+{
+ /* Next buffer in linked list. */
+ struct buffer_data *next;
+
+ /*
+ * A pointer into the data area pointed to by the text field. This
+ * is where to find data that has not yet been written out.
+ */
+ char *bufp;
+
+ /* The number of data bytes found at BUFP. */
+ int size;
+
+ /*
+ * Actual buffer. This never changes after the structure is
+ * allocated. The buffer is BUFFER_DATA_SIZE bytes.
+ */
+ char *text;
+};
+
+/* The size we allocate for each buffer_data structure. */
+#define BUFFER_DATA_SIZE (4096)
+
+extern struct buffer *buf_initialize PROTO((int (*) (void *, char *, int,
+ int, int *),
+ int (*) (void *, const char *,
+ int, int *),
+ int (*) (void *),
+ int (*) (void *, int),
+ int (*) (void *),
+ void (*) (struct buffer *),
+ void *));
+extern struct buffer *buf_nonio_initialize PROTO((void (*) (struct buffer *)));
+extern struct buffer *stdio_buffer_initialize
+ PROTO((FILE *, int, void (*) (struct buffer *)));
+extern struct buffer *compress_buffer_initialize
+ PROTO((struct buffer *, int, int, void (*) (struct buffer *)));
+extern int buf_empty_p PROTO((struct buffer *));
+extern void buf_output PROTO((struct buffer *, const char *, int));
+extern void buf_output0 PROTO((struct buffer *, const char *));
+extern void buf_append_char PROTO((struct buffer *, int));
+extern int buf_send_output PROTO((struct buffer *));
+extern int buf_flush PROTO((struct buffer *, int));
+extern int set_nonblock PROTO((struct buffer *));
+extern int set_block PROTO((struct buffer *));
+extern int buf_send_counted PROTO((struct buffer *));
+extern int buf_send_special_count PROTO((struct buffer *, int));
+extern void buf_append_data PROTO((struct buffer *,
+ struct buffer_data *,
+ struct buffer_data *));
+extern int buf_read_file PROTO((FILE *, long, struct buffer_data **,
+ struct buffer_data **));
+extern int buf_read_file_to_eof PROTO((FILE *, struct buffer_data **,
+ struct buffer_data **));
+extern int buf_input_data PROTO((struct buffer *, int *));
+extern int buf_read_line PROTO((struct buffer *, char **, int *));
+extern int buf_read_data PROTO((struct buffer *, int, char **, int *));
+extern void buf_copy_lines PROTO((struct buffer *, struct buffer *, int));
+extern int buf_copy_counted PROTO((struct buffer *, struct buffer *, int *));
+extern int buf_chain_length PROTO((struct buffer_data *));
+extern int buf_shutdown PROTO((struct buffer *));
+
+#ifdef SERVER_FLOWCONTROL
+extern int buf_count_mem PROTO((struct buffer *));
+#endif /* SERVER_FLOWCONTROL */
+
+#endif /* defined (SERVER_SUPPORT) || defined (CLIENT_SUPPORT) */
diff --git a/contrib/cvs/src/checkin.c b/contrib/cvs/src/checkin.c
index e1ce9cb..0da220c 100644
--- a/contrib/cvs/src/checkin.c
+++ b/contrib/cvs/src/checkin.c
@@ -20,34 +20,30 @@
#include "edit.h"
int
-Checkin (type, file, update_dir, repository,
- rcs, rev, tag, options, message, entries)
+Checkin (type, finfo, rcs, rev, tag, options, message)
int type;
- char *file;
- char *update_dir;
- char *repository;
+ struct file_info *finfo;
char *rcs;
char *rev;
char *tag;
char *options;
char *message;
- List *entries;
{
- char fname[PATH_MAX];
+ char *fname;
Vers_TS *vers;
int set_time;
- char *fullname;
-
char *tocvsPath = NULL;
- fullname = xmalloc (strlen (update_dir) + strlen (file) + 10);
- if (update_dir[0] == '\0')
- strcpy (fullname, file);
- else
- sprintf (fullname, "%s/%s", update_dir, file);
+ /* Hmm. This message goes to stdout and the "foo,v <-- foo"
+ message from "ci" goes to stderr. This doesn't make a whole
+ lot of sense, but making everything go to stdout can only be
+ gracefully achieved once RCS_checkin is librarified. */
+ cvs_output ("Checking in ", 0);
+ cvs_output (finfo->fullname, 0);
+ cvs_output (";\n", 0);
- (void) printf ("Checking in %s;\n", fullname);
- (void) sprintf (fname, "%s/%s%s", CVSADM, CVSPREFIX, file);
+ fname = xmalloc (strlen (finfo->file) + 80);
+ (void) sprintf (fname, "%s/%s%s", CVSADM, CVSPREFIX, finfo->file);
/*
* Move the user file to a backup file, so as to preserve its
@@ -55,25 +51,25 @@ Checkin (type, file, update_dir, repository,
* for the checkin and checkout.
*/
- tocvsPath = wrap_tocvs_process_file (fullname);
+ tocvsPath = wrap_tocvs_process_file (finfo->file);
if (!noexec)
{
if (tocvsPath)
{
copy_file (tocvsPath, fname);
- if (unlink_file_dir (file) < 0)
+ if (unlink_file_dir (finfo->file) < 0)
if (! existence_error (errno))
- error (1, errno, "cannot remove %s", file);
- copy_file (tocvsPath, file);
+ error (1, errno, "cannot remove %s", finfo->fullname);
+ copy_file (tocvsPath, finfo->file);
}
else
{
- copy_file (file, fname);
+ copy_file (finfo->file, fname);
}
}
- switch (RCS_checkin (rcs, NULL, message, rev, 0, 0))
+ switch (RCS_checkin (rcs, NULL, message, rev, 0))
{
case 0: /* everything normal */
@@ -89,13 +85,21 @@ Checkin (type, file, update_dir, repository,
if (strcmp (options, "-V4") == 0) /* upgrade to V5 now */
options[0] = '\0';
+ /* Reparse the RCS file, so that we can safely call
+ RCS_checkout. FIXME: We could probably calculate
+ all the changes. */
+ freercsnode (&finfo->rcs);
+ finfo->rcs = RCS_parse (finfo->file, finfo->repository);
+
/* FIXME: should be checking for errors. */
- (void) RCS_checkout (rcs, "", rev, options, RUN_TTY, 0, 0);
+ (void) RCS_checkout (finfo->rcs, finfo->file, rev,
+ (char *) NULL, options, RUN_TTY,
+ (RCSCHECKOUTPROC) NULL, (void *) NULL);
- xchmod (file, 1);
- if (xcmp (file, fname) == 0)
+ xchmod (finfo->file, 1);
+ if (xcmp (finfo->file, fname) == 0)
{
- rename_file (fname, file);
+ rename_file (fname, finfo->file);
/* the time was correct, so leave it alone */
set_time = 0;
}
@@ -107,24 +111,23 @@ Checkin (type, file, update_dir, repository,
set_time = 1;
}
- wrap_fromcvs_process_file (file);
+ wrap_fromcvs_process_file (finfo->file);
/*
* If we want read-only files, muck the permissions here, before
* getting the file time-stamp.
*/
- if (cvswrite == FALSE || fileattr_get (file, "_watched"))
- xchmod (file, 0);
+ if (cvswrite == FALSE || fileattr_get (finfo->file, "_watched"))
+ xchmod (finfo->file, 0);
- /* re-register with the new data */
- vers = Version_TS (repository, (char *) NULL, tag, (char *) NULL,
- file, 1, set_time, entries, (RCSNode *) NULL);
+ /* Re-register with the new data. */
+ vers = Version_TS (finfo, NULL, tag, NULL, 1, set_time);
if (strcmp (vers->options, "-V4") == 0)
vers->options[0] = '\0';
- Register (entries, file, vers->vn_rcs, vers->ts_user,
+ Register (finfo->entries, finfo->file, vers->vn_rcs, vers->ts_user,
vers->options, vers->tag, vers->date, (char *) 0);
- history_write (type, (char *) 0, vers->vn_rcs, file, repository);
- freevers_ts (&vers);
+ history_write (type, NULL, vers->vn_rcs,
+ finfo->file, finfo->repository);
if (tocvsPath)
if (unlink_file_dir (tocvsPath) < 0)
@@ -139,7 +142,8 @@ Checkin (type, file, update_dir, repository,
if (!noexec)
error (1, errno, "could not check in %s -- fork failed",
- fullname);
+ finfo->fullname);
+ free (fname);
return (1);
default: /* ci failed */
@@ -154,9 +158,10 @@ Checkin (type, file, update_dir, repository,
if (!noexec)
{
- rename_file (fname, file);
- error (0, 0, "could not check in %s", fullname);
+ rename_file (fname, finfo->file);
+ error (0, 0, "could not check in %s", finfo->fullname);
}
+ free (fname);
return (1);
}
@@ -167,7 +172,7 @@ Checkin (type, file, update_dir, repository,
*/
if (rev)
{
- (void) RCS_unlock (rcs, NULL, 1);
+ (void) RCS_unlock (finfo->rcs, NULL, 1);
}
#ifdef SERVER_SUPPORT
@@ -175,14 +180,16 @@ Checkin (type, file, update_dir, repository,
{
if (set_time)
/* Need to update the checked out file on the client side. */
- server_updated (file, update_dir, repository, SERVER_UPDATED,
+ server_updated (finfo, vers, SERVER_UPDATED,
NULL, NULL);
else
- server_checked_in (file, update_dir, repository);
+ server_checked_in (finfo->file, finfo->update_dir, finfo->repository);
}
else
#endif
- mark_up_to_date (file);
+ mark_up_to_date (finfo->file);
+ freevers_ts (&vers);
+ free (fname);
return (0);
}
diff --git a/contrib/cvs/src/checkout.c b/contrib/cvs/src/checkout.c
index 64aa10e..5074fe4 100644
--- a/contrib/cvs/src/checkout.c
+++ b/contrib/cvs/src/checkout.c
@@ -36,8 +36,6 @@
#include "cvs.h"
static char *findslash PROTO((char *start, char *p));
-static int build_dirs_and_chdir PROTO((char *dir, char *prepath, char *realdir,
- int sticky));
static int checkout_proc PROTO((int *pargc, char **argv, char *where,
char *mwhere, char *mfile, int shorten,
int local_specified, char *omodule,
@@ -46,18 +44,20 @@ static int safe_location PROTO((void));
static const char *const checkout_usage[] =
{
- "Usage:\n %s %s [-ANPcflnps] [-r rev | -D date] [-d dir] [-k kopt] modules...\n",
+ "Usage:\n %s %s [-ANPRcflnps] [-r rev | -D date] [-d dir]\n",
+ " [-j rev1] [-j rev2] [-k kopt] modules...\n",
"\t-A\tReset any sticky tags/date/kopts.\n",
"\t-N\tDon't shorten module paths if -d specified.\n",
"\t-P\tPrune empty directories.\n",
+ "\t-R\tProcess directories recursively.\n",
"\t-c\t\"cat\" the module database.\n",
"\t-f\tForce a head revision match if tag/date not found.\n",
"\t-l\tLocal directory only, not recursive\n",
"\t-n\tDo not run module program (if any).\n",
- "\t-p\tCheck out files to standard output.\n",
+ "\t-p\tCheck out files to standard output (avoids stickiness).\n",
"\t-s\tLike -c, but include module status.\n",
- "\t-r rev\tCheck out revision or tag. (implies -P)\n",
- "\t-D date\tCheck out revisions as of date. (implies -P)\n",
+ "\t-r rev\tCheck out revision or tag. (implies -P) (is sticky)\n",
+ "\t-D date\tCheck out revisions as of date. (implies -P) (is sticky)\n",
"\t-d dir\tCheck out into dir instead of module name.\n",
"\t-k kopt\tUse RCS kopt -k option on checkout.\n",
"\t-j rev\tMerge in changes made between current revision and rev.\n",
@@ -66,14 +66,15 @@ static const char *const checkout_usage[] =
static const char *const export_usage[] =
{
- "Usage: %s %s [-NPfln] [-r rev | -D date] [-d dir] [-k kopt] module...\n",
+ "Usage: %s %s [-NRfln] [-r rev | -D date] [-d dir] [-k kopt] module...\n",
"\t-N\tDon't shorten module paths if -d specified.\n",
"\t-f\tForce a head revision match if tag/date not found.\n",
"\t-l\tLocal directory only, not recursive\n",
+ "\t-R\tProcess directories recursively (default).\n",
"\t-n\tDo not run module program (if any).\n",
- "\t-r rev\tCheck out revision or tag.\n",
- "\t-D date\tCheck out revisions as of date.\n",
- "\t-d dir\tCheck out into dir instead of module name.\n",
+ "\t-r rev\tExport revision or tag.\n",
+ "\t-D date\tExport revisions as of date.\n",
+ "\t-d dir\tExport into dir instead of module name.\n",
"\t-k kopt\tUse RCS kopt -k option on checkout.\n",
NULL
};
@@ -88,7 +89,9 @@ static int tag_validated = 0;
static char *date = NULL;
static char *join_rev1 = NULL;
static char *join_rev2 = NULL;
+static int join_tags_validated = 0;
static char *preload_update_dir = NULL;
+static char *history_name = NULL;
int
checkout (argc, argv)
@@ -116,13 +119,13 @@ checkout (argc, argv)
if (strcmp (command_name, "export") == 0)
{
m_type = EXPORT;
- valid_options = "Nnk:d:flRQqr:D:";
+ valid_options = "+Nnk:d:flRQqr:D:";
valid_usage = export_usage;
}
else
{
m_type = CHECKOUT;
- valid_options = "ANnk:d:flRpQqcsr:D:j:P";
+ valid_options = "+ANnk:d:flRpQqcsr:D:j:P";
valid_usage = checkout_usage;
}
@@ -218,8 +221,7 @@ checkout (argc, argv)
if (shorten == -1)
shorten = 0;
- if ((!(cat + status) && argc == 0) || ((cat + status) && argc != 0)
- || (tag && date))
+ if ((!(cat + status) && argc == 0) || ((cat + status) && argc != 0))
usage (valid_usage);
if (where && pipeout)
@@ -269,13 +271,13 @@ checkout (argc, argv)
&& supported_request ("expand-modules"));
if (expand_modules)
- {
+ {
/* This is done here because we need to read responses
from the server before we send the command checkout or
export files. */
client_expand_modules (argc, argv, local);
- }
+ }
if (!run_module_prog) send_arg ("-n");
if (local) send_arg ("-l");
@@ -296,6 +298,8 @@ checkout (argc, argv)
}
if (status)
send_arg("-s");
+ /* Why not send -k for export? This would appear to make
+ remote export differ from local export. FIXME. */
if (strcmp (command_name, "export") != 0
&& options != NULL
&& options[0] != '\0')
@@ -309,16 +313,16 @@ checkout (argc, argv)
option_with_arg ("-j", join_rev2);
if (expand_modules)
- {
- client_send_expansions (local);
- }
+ {
+ client_send_expansions (local, where, 1);
+ }
else
- {
+ {
int i;
for (i = 0; i < argc; ++i)
- send_arg (argv[i]);
+ send_arg (argv[i]);
client_nonexpanded_setup ();
- }
+ }
send_to_server (strcmp (command_name, "export") == 0 ?
"export\012" : "co\012",
@@ -342,17 +346,18 @@ checkout (argc, argv)
*/
if (argc > 1 && where != NULL)
{
- char repository[PATH_MAX];
-
(void) CVS_MKDIR (where, 0777);
- if (chdir (where) < 0)
+ if ( CVS_CHDIR (where) < 0)
error (1, errno, "cannot chdir to %s", where);
preload_update_dir = xstrdup (where);
where = (char *) NULL;
if (!isfile (CVSADM))
{
- (void) sprintf (repository, "%s/%s/%s", CVSroot, CVSROOTADM,
- CVSNULLREPOS);
+ char *repository;
+
+ repository = xmalloc (strlen (CVSroot_directory) + 80);
+ (void) sprintf (repository, "%s/%s/%s", CVSroot_directory,
+ CVSROOTADM, CVSNULLREPOS);
if (!isfile (repository))
{
mode_t omask;
@@ -365,8 +370,8 @@ checkout (argc, argv)
if (!isdir (repository))
error (1, 0, "there is no repository %s", repository);
- Create_Admin (".", where, repository,
- (char *) NULL, (char *) NULL);
+ Create_Admin (".", preload_update_dir, repository,
+ (char *) NULL, (char *) NULL, 0);
if (!noexec)
{
FILE *fp;
@@ -379,9 +384,25 @@ checkout (argc, argv)
server_set_entstat (preload_update_dir, repository);
#endif
}
+ free (repository);
}
}
+ /* If we will be calling history_write, work out the name to pass
+ it. */
+ if (strcmp (command_name, "export") != 0 && !pipeout)
+ {
+ if (tag && date)
+ {
+ history_name = xmalloc (strlen (tag) + strlen (date) + 2);
+ sprintf (history_name, "%s:%s", tag, date);
+ }
+ else if (tag)
+ history_name = tag;
+ else
+ history_name = date;
+ }
+
/*
* if where was specified (-d) and we have not taken care of it already
* with the multiple arg stuff, and it was not a simple directory name
@@ -396,7 +417,7 @@ checkout (argc, argv)
slash = strrchr (where, '/');
*slash = '\0';
- if (chdir (where) < 0)
+ if ( CVS_CHDIR (where) < 0)
error (1, errno, "cannot chdir to %s", where);
preload_update_dir = xstrdup (where);
@@ -417,25 +438,102 @@ checkout (argc, argv)
static int
safe_location ()
{
- char current[PATH_MAX];
+ char *current;
char hardpath[PATH_MAX+5];
+ size_t hardpath_len;
int x;
-
- x = readlink(CVSroot, hardpath, sizeof hardpath - 1);
+ int retval;
+
+#ifdef HAVE_READLINK
+ /* FIXME-arbitrary limit: should be retrying this like xgetwd.
+ But how does readlink let us know that the buffer was too small?
+ (by returning sizeof hardpath - 1?). */
+ x = readlink(CVSroot_directory, hardpath, sizeof hardpath - 1);
+#else
+ x = -1;
+#endif
if (x == -1)
{
- strcpy(hardpath, CVSroot);
+ strcpy(hardpath, CVSroot_directory);
}
else
{
hardpath[x] = '\0';
}
- getwd (current);
- if (strncmp(current, hardpath, strlen(hardpath)) == 0)
+ current = xgetwd ();
+ hardpath_len = strlen (hardpath);
+ if (strlen (current) >= hardpath_len
+ && strncmp (current, hardpath, hardpath_len) == 0)
{
- return (0);
+ if (/* Current is a subdirectory of hardpath. */
+ current[hardpath_len] == '/'
+
+ /* Current is hardpath itself. */
+ || current[hardpath_len] == '\0')
+ retval = 0;
+ else
+ /* It isn't a problem. For example, current is
+ "/foo/cvsroot-bar" and hardpath is "/foo/cvsroot". */
+ retval = 1;
+ }
+ else
+ retval = 1;
+ free (current);
+ return retval;
+}
+
+struct dir_to_build
+{
+ /* What to put in CVS/Repository. */
+ char *repository;
+ /* The path to the directory. */
+ char *dirpath;
+
+ struct dir_to_build *next;
+};
+
+static int build_dirs_and_chdir PROTO ((struct dir_to_build *list,
+ int sticky));
+
+static void build_one_dir PROTO ((char *, char *, int));
+
+static void
+build_one_dir (repository, dirpath, sticky)
+ char *repository;
+ char *dirpath;
+ int sticky;
+{
+ FILE *fp;
+
+ if (!isfile (CVSADM) && strcmp (command_name, "export") != 0)
+ {
+ /* I suspect that this check could be omitted. */
+ if (!isdir (repository))
+ error (1, 0, "there is no repository %s", repository);
+
+ Create_Admin (".", dirpath, repository,
+ sticky ? (char *) NULL : tag,
+ sticky ? (char *) NULL : date,
+
+ /* FIXME? This is a guess. If it is important
+ for nonbranch to be set correctly here I
+ think we need to write it one way now and
+ then rewrite it later via WriteTag, once
+ we've had a chance to call RCS_nodeisbranch
+ on each file. */
+ 0);
+
+ if (!noexec)
+ {
+ fp = open_file (CVSADM_ENTSTAT, "w+");
+ if (fclose (fp) == EOF)
+ error (1, errno, "cannot close %s", CVSADM_ENTSTAT);
+#ifdef SERVER_SUPPORT
+ if (server_active)
+ server_set_entstat (dirpath, repository);
+#endif
+ }
}
- return (1);
}
/*
@@ -459,11 +557,10 @@ checkout_proc (pargc, argv, where, mwhere, mfile, shorten,
int which;
char *cp;
char *cp2;
- char repository[PATH_MAX];
- char xwhere[PATH_MAX];
+ char *repository;
+ char *xwhere = NULL;
char *oldupdate = NULL;
char *prepath;
- char *realdirs;
/*
* OK, so we're doing the checkout! Our args are as follows:
@@ -476,7 +573,8 @@ checkout_proc (pargc, argv, where, mwhere, mfile, shorten,
*/
/* set up the repository (maybe) for the bottom directory */
- (void) sprintf (repository, "%s/%s", CVSroot, argv[0]);
+ repository = xmalloc (strlen (CVSroot_directory) + strlen (argv[0]) + 5);
+ (void) sprintf (repository, "%s/%s", CVSroot_directory, argv[0]);
/* save the original value of preload_update_dir */
if (preload_update_dir != NULL)
@@ -485,12 +583,14 @@ checkout_proc (pargc, argv, where, mwhere, mfile, shorten,
/* fix up argv[] for the case of partial modules */
if (mfile != NULL)
{
- char file[PATH_MAX];
+ char *file;
/* if mfile is really a path, straighten it out first */
if ((cp = strrchr (mfile, '/')) != NULL)
{
*cp = 0;
+ repository = xrealloc (repository,
+ strlen (repository) + strlen (mfile) + 10);
(void) strcat (repository, "/");
(void) strcat (repository, mfile);
@@ -507,9 +607,15 @@ checkout_proc (pargc, argv, where, mwhere, mfile, shorten,
if (!shorten)
{
if (where != NULL)
+ {
+ xwhere = xmalloc (strlen (where) + strlen (mfile) + 5);
(void) sprintf (xwhere, "%s/%s", where, mfile);
+ }
else
+ {
+ xwhere = xmalloc (strlen (mwhere) + strlen (mfile) + 5);
(void) sprintf (xwhere, "%s/%s", mwhere, mfile);
+ }
where = xwhere;
}
else
@@ -524,6 +630,7 @@ checkout_proc (pargc, argv, where, mwhere, mfile, shorten,
mfile = cp + 1;
}
+ file = xmalloc (strlen (repository) + strlen (mfile) + 5);
(void) sprintf (file, "%s/%s", repository, mfile);
if (isdir (file))
{
@@ -532,7 +639,8 @@ checkout_proc (pargc, argv, where, mwhere, mfile, shorten,
* The portion of a module was a directory, so kludge up where to
* be the subdir, and fix up repository
*/
- (void) strcpy (repository, file);
+ free (repository);
+ repository = xstrdup (file);
/*
* At this point, if shorten is not enabled, we make where either
@@ -545,9 +653,15 @@ checkout_proc (pargc, argv, where, mwhere, mfile, shorten,
if (!shorten)
{
if (where != NULL)
+ {
+ xwhere = xmalloc (strlen (where) + strlen (mfile) + 5);
(void) sprintf (xwhere, "%s/%s", where, mfile);
+ }
else
+ {
+ xwhere = xmalloc (strlen (mwhere) + strlen (mfile) + 5);
(void) sprintf (xwhere, "%s/%s", mwhere, mfile);
+ }
where = xwhere;
}
else if (where == NULL)
@@ -563,6 +677,10 @@ checkout_proc (pargc, argv, where, mwhere, mfile, shorten,
*/
for (i = 1; i < *pargc; i++)/* free the old ones */
free (argv[i]);
+ /* FIXME: Normally one has to realloc argv to make sure
+ argv[1] exists. But this argv does not points to the
+ beginning of an allocated block. For now we allocate
+ at least 4 entries for argv (in line2argv). */
argv[1] = xstrdup (mfile); /* set up the new one */
*pargc = 2;
@@ -570,6 +688,7 @@ checkout_proc (pargc, argv, where, mwhere, mfile, shorten,
if (where == NULL)
where = mwhere;
}
+ free (file);
}
/*
@@ -580,7 +699,7 @@ checkout_proc (pargc, argv, where, mwhere, mfile, shorten,
{
if ((cp = strrchr (argv[0], '/')) != NULL)
{
- (void) strcpy (xwhere, cp + 1);
+ xwhere = xstrdup (cp + 1);
where = xwhere;
}
}
@@ -592,18 +711,18 @@ checkout_proc (pargc, argv, where, mwhere, mfile, shorten,
where = mwhere;
else
{
- (void) strcpy (xwhere, argv[0]);
+ xwhere = xstrdup (argv[0]);
where = xwhere;
}
}
if (preload_update_dir != NULL)
{
- char tmp[PATH_MAX];
-
- (void) sprintf (tmp, "%s/%s", preload_update_dir, where);
- free (preload_update_dir);
- preload_update_dir = xstrdup (tmp);
+ preload_update_dir =
+ xrealloc (preload_update_dir,
+ strlen (preload_update_dir) + strlen (where) + 5);
+ strcat (preload_update_dir, "/");
+ strcat (preload_update_dir, where);
}
else
preload_update_dir = xstrdup (where);
@@ -619,24 +738,80 @@ checkout_proc (pargc, argv, where, mwhere, mfile, shorten,
*/
if (!pipeout)
{
-
- /*
- * We need to tell build_dirs not only the path we want it to build,
- * but also the repositories we want it to populate the path with. To
- * accomplish this, we pass build_dirs a ``real path'' with valid
- * repositories and a string to pre-pend based on how many path
- * elements exist in where. Big Black Magic
- */
+ size_t root_len;
+ struct dir_to_build *head;
+
+ /* We need to tell build_dirs not only the path we want it to
+ build, but also the repositories we want it to populate the
+ path with. To accomplish this, we walk the path backwards,
+ one pathname component at a time, constucting a linked
+ list of struct dir_to_build. */
prepath = xstrdup (repository);
+
+ /* We don't want to start stripping elements off prepath after we
+ get to CVSROOT. */
+ root_len = strlen (CVSroot_directory);
+ if (strncmp (repository, CVSroot_directory, root_len) != 0)
+ error (1, 0, "\
+internal error: %s doesn't start with %s in checkout_proc",
+ repository, CVSroot_directory);
+
+ /* We always create at least one directory, which corresponds to
+ the entire strings for WHERE and REPOSITORY. */
+ head = (struct dir_to_build *) xmalloc (sizeof (struct dir_to_build));
+ /* Special marker to indicate that we don't want build_dirs_and_chdir
+ to create the CVSADM directory for us. */
+ head->repository = NULL;
+ head->dirpath = xstrdup (where);
+ head->next = NULL;
+
cp = strrchr (where, '/');
cp2 = strrchr (prepath, '/');
+
while (cp != NULL)
{
+ struct dir_to_build *new;
+ new = (struct dir_to_build *)
+ xmalloc (sizeof (struct dir_to_build));
+ new->dirpath = xmalloc (strlen (where));
+ strncpy (new->dirpath, where, cp - where);
+ new->dirpath[cp - where] = '\0';
+ if (cp2 == NULL || cp2 < prepath + root_len)
+ {
+ /* Don't walk up past CVSROOT; instead put in CVSNULLREPOS. */
+ new->repository =
+ xmalloc (strlen (CVSroot_directory) + 80);
+ (void) sprintf (new->repository, "%s/%s/%s",
+ CVSroot_directory,
+ CVSROOTADM, CVSNULLREPOS);
+ if (!isfile (new->repository))
+ {
+ mode_t omask;
+ omask = umask (cvsumask);
+ if (CVS_MKDIR (new->repository, 0777) < 0)
+ error (0, errno, "cannot create %s",
+ new->repository);
+ (void) umask (omask);
+ }
+ }
+ else
+ {
+ new->repository = xmalloc (strlen (prepath));
+ strncpy (new->repository, prepath, cp2 - prepath);
+ new->repository[cp2 - prepath] = '\0';
+ }
+ new->next = head;
+ head = new;
+
cp = findslash (where, cp - 1);
cp2 = findslash (prepath, cp2 - 1);
}
- *cp2 = '\0';
- realdirs = cp2 + 1;
+
+ /* First build the top-level CVSADM directory. The value we
+ pass in here for repository is probably wrong; see modules3-7f
+ in the testsuite. */
+ build_one_dir (head->repository != NULL ? head->repository : prepath,
+ ".", *pargc <= 1);
/*
* build dirs on the path if necessary and leave us in the bottom
@@ -644,13 +819,12 @@ checkout_proc (pargc, argv, where, mwhere, mfile, shorten,
* subdir yet, but all the others contain CVS and Entries.Static
* files
*/
- if (build_dirs_and_chdir (where, prepath, realdirs, *pargc <= 1) != 0)
+ if (build_dirs_and_chdir (head, *pargc <= 1) != 0)
{
error (0, 0, "ignoring module %s", omodule);
free (prepath);
- free (preload_update_dir);
- preload_update_dir = oldupdate;
- return (1);
+ err = 1;
+ goto out;
}
/* clean up */
@@ -667,8 +841,8 @@ checkout_proc (pargc, argv, where, mwhere, mfile, shorten,
if (!isdir (repository))
error (1, 0, "there is no repository %s", repository);
- Create_Admin (".", where, repository,
- (char *) NULL, (char *) NULL);
+ Create_Admin (".", preload_update_dir, repository,
+ (char *) NULL, (char *) NULL, 0);
fp = open_file (CVSADM_ENTSTAT, "w+");
if (fclose(fp) == EOF)
error(1, errno, "cannot close %s", CVSADM_ENTSTAT);
@@ -683,7 +857,15 @@ checkout_proc (pargc, argv, where, mwhere, mfile, shorten,
if (!isdir (repository))
error (1, 0, "there is no repository %s", repository);
- Create_Admin (".", where, repository, tag, date);
+ Create_Admin (".", preload_update_dir, repository, tag, date,
+
+ /* FIXME? This is a guess. If it is important
+ for nonbranch to be set correctly here I
+ think we need to write it one way now and
+ then rewrite it later via WriteTag, once
+ we've had a chance to call RCS_nodeisbranch
+ on each file. */
+ 0);
}
}
else
@@ -698,9 +880,8 @@ checkout_proc (pargc, argv, where, mwhere, mfile, shorten,
repos, repository);
error (0, 0, "ignoring module %s", omodule);
free (repos);
- free (preload_update_dir);
- preload_update_dir = oldupdate;
- return (1);
+ err = 1;
+ goto out;
}
free (repos);
}
@@ -713,12 +894,11 @@ checkout_proc (pargc, argv, where, mwhere, mfile, shorten,
*/
if (pipeout)
{
- if (chdir (repository) < 0)
+ if ( CVS_CHDIR (repository) < 0)
{
error (0, errno, "cannot chdir to %s", repository);
- free (preload_update_dir);
- preload_update_dir = oldupdate;
- return (1);
+ err = 1;
+ goto out;
}
which = W_REPOS;
if (tag != NULL && !tag_validated)
@@ -738,11 +918,19 @@ checkout_proc (pargc, argv, where, mwhere, mfile, shorten,
}
}
- if (tag != NULL || date != NULL)
+ if (tag != NULL || date != NULL || join_rev1 != NULL)
which |= W_ATTIC;
- /* FIXME: We don't call tag_check_valid on join_rev1 and join_rev2
- yet (make sure to handle ':' correctly if we do, though). */
+ if (! join_tags_validated)
+ {
+ if (join_rev1 != NULL)
+ tag_check_valid_join (join_rev1, *pargc - 1, argv + 1, 0, aflag,
+ repository);
+ if (join_rev2 != NULL)
+ tag_check_valid_join (join_rev2, *pargc - 1, argv + 1, 0, aflag,
+ repository);
+ join_tags_validated = 1;
+ }
/*
* if we are going to be recursive (building dirs), go ahead and call the
@@ -752,16 +940,17 @@ checkout_proc (pargc, argv, where, mwhere, mfile, shorten,
if (!(local_specified || *pargc > 1))
{
if (strcmp (command_name, "export") != 0 && !pipeout)
- history_write ('O', preload_update_dir, tag ? tag : date, where,
+ history_write ('O', preload_update_dir, history_name, where,
+ repository);
+ else if (strcmp (command_name, "export") == 0 && !pipeout)
+ history_write ('E', preload_update_dir, tag ? tag : date, where,
repository);
err += do_update (0, (char **) NULL, options, tag, date,
force_tag_match, 0 /* !local */ ,
1 /* update -d */ , aflag, checkout_prune_dirs,
pipeout, which, join_rev1, join_rev2,
preload_update_dir);
- free (preload_update_dir);
- preload_update_dir = oldupdate;
- return (err);
+ goto out;
}
if (!pipeout)
@@ -774,22 +963,34 @@ checkout_proc (pargc, argv, where, mwhere, mfile, shorten,
for (i = 1; i < *pargc; i++)
{
char *line;
- char *user;
Vers_TS *vers;
-
- user = argv[i];
- vers = Version_TS (repository, options, tag, date, user,
- force_tag_match, 0, entries, (RCSNode *) NULL);
+ struct file_info finfo;
+
+ memset (&finfo, 0, sizeof finfo);
+ finfo.file = argv[i];
+ /* Shouldn't be used, so set to arbitrary value. */
+ finfo.update_dir = NULL;
+ finfo.fullname = argv[i];
+ finfo.repository = repository;
+ finfo.entries = entries;
+ /* The rcs slot is needed to get the options from the RCS
+ file */
+ finfo.rcs = RCS_parse (finfo.file, repository);
+
+ vers = Version_TS (&finfo, options, tag, date,
+ force_tag_match, 0);
if (vers->ts_user == NULL)
{
- line = xmalloc (strlen (user) + 15);
- (void) sprintf (line, "Initial %s", user);
- Register (entries, user, vers->vn_rcs ? vers->vn_rcs : "0",
+ line = xmalloc (strlen (finfo.file) + 15);
+ (void) sprintf (line, "Initial %s", finfo.file);
+ Register (entries, finfo.file,
+ vers->vn_rcs ? vers->vn_rcs : "0",
line, vers->options, vers->tag,
vers->date, (char *) 0);
free (line);
}
freevers_ts (&vers);
+ freercsnode (&finfo.rcs);
}
Entries_Close (entries);
@@ -797,7 +998,7 @@ checkout_proc (pargc, argv, where, mwhere, mfile, shorten,
/* Don't log "export", just regular "checkouts" */
if (strcmp (command_name, "export") != 0 && !pipeout)
- history_write ('O', preload_update_dir, (tag ? tag : date), where,
+ history_write ('O', preload_update_dir, history_name, where,
repository);
/* go ahead and call update now that everything is set */
@@ -805,8 +1006,12 @@ checkout_proc (pargc, argv, where, mwhere, mfile, shorten,
force_tag_match, local_specified, 1 /* update -d */,
aflag, checkout_prune_dirs, pipeout, which, join_rev1,
join_rev2, preload_update_dir);
+out:
free (preload_update_dir);
preload_update_dir = oldupdate;
+ if (xwhere != NULL)
+ free (xwhere);
+ free (repository);
return (err);
}
@@ -817,73 +1022,49 @@ findslash (start, p)
{
while (p >= start && *p != '/')
p--;
+ /* FIXME: indexing off the start of the array like this is *NOT*
+ OK according to ANSI, and will break some of the time on certain
+ segmented architectures. */
if (p < start)
return (NULL);
else
return (p);
}
-/*
- * build all the dirs along the path to dir with CVS subdirs with appropriate
- * repositories and Entries.Static files
- */
+/* Build all the dirs along the path to DIRS with CVS subdirs with appropriate
+ repositories. If ->repository is NULL, do not create a CVSADM directory
+ for that subdirectory; just CVS_CHDIR into it. */
static int
-build_dirs_and_chdir (dir, prepath, realdir, sticky)
- char *dir;
- char *prepath;
- char *realdir;
+build_dirs_and_chdir (dirs, sticky)
+ struct dir_to_build *dirs;
int sticky;
{
- FILE *fp;
- char repository[PATH_MAX];
- char path[PATH_MAX];
- char path2[PATH_MAX];
- char *slash;
- char *slash2;
- char *cp;
- char *cp2;
+ int retval = 0;
+ struct dir_to_build *nextdir;
- (void) strcpy (path, dir);
- (void) strcpy (path2, realdir);
- for (cp = path, cp2 = path2;
- (slash = strchr (cp, '/')) != NULL && (slash2 = strchr (cp2, '/')) != NULL;
- cp = slash + 1, cp2 = slash2 + 1)
+ while (dirs != NULL)
{
- *slash = '\0';
- *slash2 = '\0';
- (void) CVS_MKDIR (cp, 0777);
- if (chdir (cp) < 0)
+ char *dir = last_component (dirs->dirpath);
+
+ mkdir_if_needed (dir);
+ Subdir_Register (NULL, NULL, dir);
+ if (CVS_CHDIR (dir) < 0)
{
- error (0, errno, "cannot chdir to %s", cp);
- return (1);
+ error (0, errno, "cannot chdir to %s", dir);
+ retval = 1;
+ goto out;
}
- if (!isfile (CVSADM) && strcmp (command_name, "export") != 0)
+ if (dirs->repository != NULL)
{
- (void) sprintf (repository, "%s/%s", prepath, path2);
- /* I'm not sure whether this check is redundant. */
- if (!isdir (repository))
- error (1, 0, "there is no repository %s", repository);
- Create_Admin (".", path, repository, sticky ? (char *) NULL : tag,
- sticky ? (char *) NULL : date);
- if (!noexec)
- {
- fp = open_file (CVSADM_ENTSTAT, "w+");
- if (fclose(fp) == EOF)
- error(1, errno, "cannot close %s", CVSADM_ENTSTAT);
-#ifdef SERVER_SUPPORT
- if (server_active)
- server_set_entstat (path, repository);
-#endif
- }
+ build_one_dir (dirs->repository, dirs->dirpath, sticky);
+ free (dirs->repository);
}
- *slash = '/';
- *slash2 = '/';
+ nextdir = dirs->next;
+ free (dirs->dirpath);
+ free (dirs);
+ dirs = nextdir;
}
- (void) CVS_MKDIR (cp, 0777);
- if (chdir (cp) < 0)
- {
- error (0, errno, "cannot chdir to %s", cp);
- return (1);
- }
- return (0);
+
+ out:
+ return retval;
}
diff --git a/contrib/cvs/src/classify.c b/contrib/cvs/src/classify.c
index 924314b..55851f7 100644
--- a/contrib/cvs/src/classify.c
+++ b/contrib/cvs/src/classify.c
@@ -21,34 +21,23 @@ static void sticky_ck PROTO((char *file, int aflag, Vers_TS * vers, List * entri
* Classify the state of a file
*/
Ctype
-Classify_File (file, tag, date, options, force_tag_match, aflag, repository,
- entries, rcsnode, versp, update_dir, pipeout)
- char *file;
+Classify_File (finfo, tag, date, options, force_tag_match, aflag, versp,
+ pipeout)
+ struct file_info *finfo;
char *tag;
char *date;
char *options;
int force_tag_match;
int aflag;
- char *repository;
- List *entries;
- RCSNode *rcsnode;
Vers_TS **versp;
- char *update_dir;
int pipeout;
{
Vers_TS *vers;
Ctype ret;
- char *fullname;
-
- fullname = xmalloc (strlen (update_dir) + strlen (file) + 10);
- if (update_dir[0] == '\0')
- strcpy (fullname, file);
- else
- sprintf (fullname, "%s/%s", update_dir, file);
/* get all kinds of good data about the file */
- vers = Version_TS (repository, options, tag, date, file,
- force_tag_match, 0, entries, rcsnode);
+ vers = Version_TS (finfo, options, tag, date,
+ force_tag_match, 0);
if (vers->vn_user == NULL)
{
@@ -59,35 +48,39 @@ Classify_File (file, tag, date, options, force_tag_match, aflag, repository,
if (vers->ts_user == NULL)
{
/* there is no user file */
+ /* FIXME: Why do we skip this message if vers->tag or
+ vers->date is set? It causes "cvs update -r tag98 foo"
+ to silently do nothing, which is seriously confusing
+ behavior. "cvs update foo" gives this message, which
+ is what I would expect. */
if (!force_tag_match || !(vers->tag || vers->date))
if (!really_quiet)
- error (0, 0, "nothing known about %s", fullname);
+ error (0, 0, "nothing known about %s", finfo->fullname);
ret = T_UNKNOWN;
}
else
{
/* there is a user file */
+ /* FIXME: Why do we skip this message if vers->tag or
+ vers->date is set? It causes "cvs update -r tag98 foo"
+ to silently do nothing, which is seriously confusing
+ behavior. "cvs update foo" gives this message, which
+ is what I would expect. */
if (!force_tag_match || !(vers->tag || vers->date))
if (!really_quiet)
error (0, 0, "use `cvs add' to create an entry for %s",
- fullname);
+ finfo->fullname);
ret = T_UNKNOWN;
}
}
else if (RCS_isdead (vers->srcfile, vers->vn_rcs))
{
if (vers->ts_user == NULL)
- /*
- * Logically seems to me this should be T_UPTODATE.
- * But the joining code in update.c seems to expect
- * T_CHECKOUT, and that is what has traditionally been
- * returned for this case.
- */
- ret = T_CHECKOUT;
+ ret = T_UPTODATE;
else
{
error (0, 0, "use `cvs add' to create an entry for %s",
- fullname);
+ finfo->fullname);
ret = T_UNKNOWN;
}
}
@@ -115,13 +108,12 @@ Classify_File (file, tag, date, options, force_tag_match, aflag, repository,
* conflict list, only if it is indeed different from what we
* plan to extract
*/
- else if (No_Difference (file, vers, entries,
- repository, update_dir))
+ else if (No_Difference (finfo, vers))
{
/* the files were different so it is a conflict */
if (!really_quiet)
error (0, 0, "move away %s; it is in the way",
- fullname);
+ finfo->fullname);
ret = T_CONFLICT;
}
else
@@ -141,7 +133,7 @@ Classify_File (file, tag, date, options, force_tag_match, aflag, repository,
* entry
*/
if (!really_quiet)
- error (0, 0, "warning: new-born %s has disappeared", fullname);
+ error (0, 0, "warning: new-born %s has disappeared", finfo->fullname);
ret = T_REMOVE_ENTRY;
}
else
@@ -166,7 +158,7 @@ Classify_File (file, tag, date, options, force_tag_match, aflag, repository,
error (0, 0,
"\
conflict: %s has been added, but already exists",
- fullname);
+ finfo->fullname);
}
else
{
@@ -178,7 +170,7 @@ conflict: %s has been added, but already exists",
error (0, 0,
"\
conflict: %s created independently by second party",
- fullname);
+ finfo->fullname);
}
ret = T_CONFLICT;
}
@@ -190,13 +182,10 @@ conflict: %s created independently by second party",
if (vers->ts_user == NULL)
{
- char tmp[PATH_MAX];
-
/* There is no user file (as it should be) */
- (void) sprintf (tmp, "-%s", vers->vn_rcs ? vers->vn_rcs : "");
-
- if (vers->vn_rcs == NULL)
+ if (vers->vn_rcs == NULL
+ || RCS_isdead (vers->srcfile, vers->vn_rcs))
{
/*
@@ -205,8 +194,9 @@ conflict: %s created independently by second party",
*/
ret = T_REMOVE_ENTRY;
}
- else if (strcmp (tmp, vers->vn_user) == 0)
-
+ else if (vers->vn_rcs == NULL
+ ? vers->vn_user[1] == '\0'
+ : strcmp (vers->vn_rcs, vers->vn_user + 1) == 0)
/*
* The RCS file is the same version as the user file was, and
* that's OK; remove it
@@ -222,7 +212,7 @@ conflict: %s created independently by second party",
if (!really_quiet)
error (0, 0,
"conflict: removed %s was modified by second party",
- fullname);
+ finfo->fullname);
ret = T_CONFLICT;
}
}
@@ -231,7 +221,7 @@ conflict: %s created independently by second party",
/* The user file shouldn't be there */
if (!really_quiet)
error (0, 0, "%s should be removed and is still there",
- fullname);
+ finfo->fullname);
ret = T_REMOVED;
}
}
@@ -247,7 +237,7 @@ conflict: %s created independently by second party",
/* There is no user file, so just remove the entry */
if (!really_quiet)
error (0, 0, "warning: %s is not (any longer) pertinent",
- fullname);
+ finfo->fullname);
ret = T_REMOVE_ENTRY;
}
else if (strcmp (vers->ts_user, vers->ts_rcs) == 0)
@@ -259,7 +249,7 @@ conflict: %s created independently by second party",
*/
if (!really_quiet)
error (0, 0, "%s is no longer in the repository",
- fullname);
+ finfo->fullname);
ret = T_REMOVE_ENTRY;
}
else
@@ -268,14 +258,13 @@ conflict: %s created independently by second party",
* The user file has been modified and since it is no longer
* in the repository, a conflict is raised
*/
- if (No_Difference (file, vers, entries,
- repository, update_dir))
+ if (No_Difference (finfo, vers))
{
/* they are different -> conflict */
if (!really_quiet)
error (0, 0,
"conflict: %s is modified but no longer in the repository",
- fullname);
+ finfo->fullname);
ret = T_CONFLICT;
}
else
@@ -284,7 +273,7 @@ conflict: %s created independently by second party",
if (!really_quiet)
error (0, 0,
"warning: %s is not (any longer) pertinent",
- fullname);
+ finfo->fullname);
ret = T_REMOVE_ENTRY;
}
}
@@ -302,7 +291,7 @@ conflict: %s created independently by second party",
*/
if (strcmp (command_name, "update") == 0)
if (!really_quiet)
- error (0, 0, "warning: %s was lost", fullname);
+ error (0, 0, "warning: %s was lost", finfo->fullname);
ret = T_CHECKOUT;
}
else if (strcmp (vers->ts_user, vers->ts_rcs) == 0)
@@ -320,10 +309,10 @@ conflict: %s created independently by second party",
else
{
#ifdef SERVER_SUPPORT
- sticky_ck (file, aflag, vers, entries,
- repository, update_dir);
+ sticky_ck (finfo->file, aflag, vers, finfo->entries,
+ finfo->repository, finfo->update_dir);
#else
- sticky_ck (file, aflag, vers, entries);
+ sticky_ck (finfo->file, aflag, vers, finfo->entries);
#endif
ret = T_UPTODATE;
}
@@ -335,8 +324,7 @@ conflict: %s created independently by second party",
* The user file appears to have been modified, but we call
* No_Difference to verify that it really has been modified
*/
- if (No_Difference (file, vers, entries,
- repository, update_dir))
+ if (No_Difference (finfo, vers))
{
/*
@@ -352,10 +340,10 @@ conflict: %s created independently by second party",
#else
ret = T_MODIFIED;
#ifdef SERVER_SUPPORT
- sticky_ck (file, aflag, vers, entries,
- repository, update_dir);
+ sticky_ck (finfo->file, aflag, vers, finfo->entries,
+ finfo->repository, finfo->update_dir);
#else
- sticky_ck (file, aflag, vers, entries);
+ sticky_ck (finfo->file, aflag, vers, finfo->entries);
#endif /* SERVER_SUPPORT */
#endif
}
@@ -390,7 +378,7 @@ conflict: %s created independently by second party",
if (strcmp (command_name, "update") == 0)
if (!really_quiet)
- error (0, 0, "warning: %s was lost", fullname);
+ error (0, 0, "warning: %s was lost", finfo->fullname);
ret = T_CHECKOUT;
}
else if (strcmp (vers->ts_user, vers->ts_rcs) == 0)
@@ -413,8 +401,7 @@ conflict: %s created independently by second party",
}
else
{
- if (No_Difference (file, vers, entries,
- repository, update_dir))
+ if (No_Difference (finfo, vers))
/* really modified, needs to merge */
ret = T_NEEDS_MERGE;
#ifdef SERVER_SUPPORT
@@ -442,8 +429,6 @@ conflict: %s created independently by second party",
else
freevers_ts (&vers);
- free (fullname);
-
/* return the status of the file */
return (ret);
}
diff --git a/contrib/cvs/src/client.c b/contrib/cvs/src/client.c
index c0557ce..49f7ac8 100644
--- a/contrib/cvs/src/client.c
+++ b/contrib/cvs/src/client.c
@@ -4,15 +4,17 @@
#include "config.h"
#endif /* HAVE_CONFIG_H */
+#include <assert.h>
#include "cvs.h"
#include "getline.h"
#include "edit.h"
+#include "buffer.h"
#ifdef CLIENT_SUPPORT
#include "md5.h"
-#if defined(AUTH_CLIENT_SUPPORT) || HAVE_KERBEROS || USE_DIRECT_TCP
+#if defined(AUTH_CLIENT_SUPPORT) || HAVE_KERBEROS || defined(SOCK_ERRNO) || defined(SOCK_STRERROR)
# ifdef HAVE_WINSOCK_H
# include <winsock.h>
# else /* No winsock.h */
@@ -20,13 +22,32 @@
# include <netinet/in.h>
# include <netdb.h>
# endif /* No winsock.h */
-#endif /* defined(AUTH_CLIENT_SUPPORT) || HAVE_KERBEROS || USE_DIRECT_TCP */
+#endif
-#ifdef AUTH_CLIENT_SUPPORT
-char *get_cvs_password PROTO((char *user, char *host, char *cvsrooot));
-#endif /* AUTH_CLIENT_SUPPORT */
+/* If SOCK_ERRNO is defined, then send()/recv() and other socket calls
+ do not set errno, but that this macro should be used to obtain an
+ error code. This probably doesn't make sense unless
+ NO_SOCKET_TO_FD is also defined. */
+#ifndef SOCK_ERRNO
+#define SOCK_ERRNO errno
+#endif
-#if HAVE_KERBEROS || USE_DIRECT_TCP
+/* If SOCK_STRERROR is defined, then the error codes returned by
+ socket operations are not known to strerror, and this macro must be
+ used instead to convert those error codes to strings. */
+#ifndef SOCK_STRERROR
+# define SOCK_STRERROR strerror
+
+# if STDC_HEADERS
+# include <string.h>
+# endif
+
+# ifndef strerror
+extern char *strerror ();
+# endif
+#endif /* ! SOCK_STRERROR */
+
+#if HAVE_KERBEROS
#define CVS_PORT 1999
#if HAVE_KERBEROS
@@ -36,9 +57,14 @@ extern char *krb_realmofhost ();
#ifndef HAVE_KRB_GET_ERR_TEXT
#define krb_get_err_text(status) krb_err_txt[status]
#endif /* HAVE_KRB_GET_ERR_TEXT */
+
+/* Information we need if we are going to use Kerberos encryption. */
+static C_Block kblock;
+static Key_schedule sched;
+
#endif /* HAVE_KERBEROS */
-#endif /* HAVE_KERBEROS || USE_DIRECT_TCP */
+#endif /* HAVE_KERBEROS */
static void add_prune_candidate PROTO((char *));
@@ -70,6 +96,7 @@ static void handle_copy_file PROTO((char *, int));
static void handle_updated PROTO((char *, int));
static void handle_merged PROTO((char *, int));
static void handle_patched PROTO((char *, int));
+static void handle_rcs_diff PROTO((char *, int));
static void handle_removed PROTO((char *, int));
static void handle_remove_entry PROTO((char *, int));
static void handle_set_static_directory PROTO((char *, int));
@@ -81,8 +108,10 @@ static void handle_set_update_prog PROTO((char *, int));
static void handle_module_expansion PROTO((char *, int));
static void handle_m PROTO((char *, int));
static void handle_e PROTO((char *, int));
+static void handle_f PROTO((char *, int));
static void handle_notified PROTO((char *, int));
+static void buf_memory_error PROTO((struct buffer *));
static size_t try_read_from_server PROTO ((char *, size_t));
#endif /* CLIENT_SUPPORT */
@@ -102,29 +131,29 @@ mode_to_string (mode)
mode_t mode;
#endif /* __STDC__ */
{
- char buf[18], u[4], g[4], o[4];
- int i;
+ char buf[18], u[4], g[4], o[4];
+ int i;
- i = 0;
- if (mode & S_IRUSR) u[i++] = 'r';
- if (mode & S_IWUSR) u[i++] = 'w';
- if (mode & S_IXUSR) u[i++] = 'x';
- u[i] = '\0';
-
- i = 0;
- if (mode & S_IRGRP) g[i++] = 'r';
- if (mode & S_IWGRP) g[i++] = 'w';
- if (mode & S_IXGRP) g[i++] = 'x';
- g[i] = '\0';
-
- i = 0;
- if (mode & S_IROTH) o[i++] = 'r';
- if (mode & S_IWOTH) o[i++] = 'w';
- if (mode & S_IXOTH) o[i++] = 'x';
- o[i] = '\0';
-
- sprintf(buf, "u=%s,g=%s,o=%s", u, g, o);
- return xstrdup(buf);
+ i = 0;
+ if (mode & S_IRUSR) u[i++] = 'r';
+ if (mode & S_IWUSR) u[i++] = 'w';
+ if (mode & S_IXUSR) u[i++] = 'x';
+ u[i] = '\0';
+
+ i = 0;
+ if (mode & S_IRGRP) g[i++] = 'r';
+ if (mode & S_IWGRP) g[i++] = 'w';
+ if (mode & S_IXGRP) g[i++] = 'x';
+ g[i] = '\0';
+
+ i = 0;
+ if (mode & S_IROTH) o[i++] = 'r';
+ if (mode & S_IWOTH) o[i++] = 'w';
+ if (mode & S_IXOTH) o[i++] = 'x';
+ o[i] = '\0';
+
+ sprintf(buf, "u=%s,g=%s,o=%s", u, g, o);
+ return xstrdup(buf);
}
/*
@@ -235,214 +264,379 @@ change_mode (filename, mode_string)
#ifdef CLIENT_SUPPORT
-/* The host part of CVSROOT. */
-static char *server_host;
-/* The user part of CVSROOT */
-static char *server_user;
-/* The repository part of CVSROOT. */
-static char *server_cvsroot;
+int client_prune_dirs;
-int client_active;
+static List *ignlist = (List *) NULL;
-int client_prune_dirs;
+/* Buffer to write to the server. */
+static struct buffer *to_server;
+/* The stream underlying to_server, if we are using a stream. */
+static FILE *to_server_fp;
-static int cvsroot_parsed = 0;
+/* Buffer used to read from the server. */
+static struct buffer *from_server;
+/* The stream underlying from_server, if we are using a stream. */
+static FILE *from_server_fp;
-static List *ignlist = (List *) NULL;
+/* Process ID of rsh subprocess. */
+static int rsh_pid = -1;
+
+
+/* This routine is called when one of the buffer routines runs out of
+ memory. */
-/* Set server_host and server_cvsroot. */
static void
-parse_cvsroot ()
+buf_memory_error (buf)
+ struct buffer *buf;
{
- char *p;
-#ifdef AUTH_CLIENT_SUPPORT
- static char *access_method;
-#endif /* AUTH_CLIENT_SUPPORT */
+ error (1, 0, "out of memory");
+}
+
+/* We want to be able to log data sent between us and the server. We
+ do it using log buffers. Each log buffer has another buffer which
+ handles the actual I/O, and a file to log information to.
- /* Don't go through the trouble twice. */
- if (cvsroot_parsed)
- return;
+ This structure is the closure field of a log buffer. */
- server_host = xstrdup (CVSroot);
+struct log_buffer
+{
+ /* The underlying buffer. */
+ struct buffer *buf;
+ /* The file to log information to. */
+ FILE *log;
+};
-#ifdef AUTH_CLIENT_SUPPORT
- if ((server_host[0] == ':'))
- {
- /* Access method specified, as in
- * "cvs -d :pserver:user@host:/path".
- * We need to get past that part of CVSroot before parsing the
- * rest of it.
- */
- access_method = p = &(server_host[1]);
+static struct buffer *log_buffer_initialize
+ PROTO((struct buffer *, FILE *, int, void (*) (struct buffer *)));
+static int log_buffer_input PROTO((void *, char *, int, int, int *));
+static int log_buffer_output PROTO((void *, const char *, int, int *));
+static int log_buffer_flush PROTO((void *));
+static int log_buffer_block PROTO((void *, int));
+static int log_buffer_shutdown PROTO((void *));
+
+/* Create a log buffer. */
+
+static struct buffer *
+log_buffer_initialize (buf, fp, input, memory)
+ struct buffer *buf;
+ FILE *fp;
+ int input;
+ void (*memory) PROTO((struct buffer *));
+{
+ struct log_buffer *n;
+
+ n = (struct log_buffer *) xmalloc (sizeof *n);
+ n->buf = buf;
+ n->log = fp;
+ return buf_initialize (input ? log_buffer_input : NULL,
+ input ? NULL : log_buffer_output,
+ input ? NULL : log_buffer_flush,
+ log_buffer_block,
+ log_buffer_shutdown,
+ memory,
+ n);
+}
- if (! *access_method)
- error (1, 0, "bad CVSroot: %s", CVSroot);
+/* The input function for a log buffer. */
- if (! *(p = strchr (access_method, ':')))
- error (1, 0, "bad CVSroot: %s", CVSroot);
-
- *p = '\0';
- p++;
+static int
+log_buffer_input (closure, data, need, size, got)
+ void *closure;
+ char *data;
+ int need;
+ int size;
+ int *got;
+{
+ struct log_buffer *lb = (struct log_buffer *) closure;
+ int status;
+ size_t n_to_write;
- server_host = p;
-
- if (! *server_host)
- error (1, 0, "bad CVSroot: %s", CVSroot);
+ if (lb->buf->input == NULL)
+ abort ();
- if (strcmp (access_method, "pserver") == 0)
- use_authenticating_server = 1;
- else
- error (1, 0, "unknown access method: %s", access_method);
- }
-#endif /* AUTH_CLIENT_SUPPORT */
-
- /* First get just the pathname. */
- server_cvsroot = strchr (server_host, ':');
- *server_cvsroot = '\0';
- ++server_cvsroot;
-
- /* Then deal with host and possible user. */
- if ( (p = strchr (server_host, '@')) == NULL)
+ status = (*lb->buf->input) (lb->buf->closure, data, need, size, got);
+ if (status != 0)
+ return status;
+
+ if (*got > 0)
{
- server_user = NULL;
+ n_to_write = *got;
+ if (fwrite (data, 1, n_to_write, lb->log) != n_to_write)
+ error (0, errno, "writing to log file");
}
- else
+
+ return 0;
+}
+
+/* The output function for a log buffer. */
+
+static int
+log_buffer_output (closure, data, have, wrote)
+ void *closure;
+ const char *data;
+ int have;
+ int *wrote;
+{
+ struct log_buffer *lb = (struct log_buffer *) closure;
+ int status;
+ size_t n_to_write;
+
+ if (lb->buf->output == NULL)
+ abort ();
+
+ status = (*lb->buf->output) (lb->buf->closure, data, have, wrote);
+ if (status != 0)
+ return status;
+
+ if (*wrote > 0)
{
- server_user = server_host;
- server_host = p;
- ++server_host;
- *p = '\0';
+ n_to_write = *wrote;
+ if (fwrite (data, 1, n_to_write, lb->log) != n_to_write)
+ error (0, errno, "writing to log file");
}
-
- client_active = 1;
- cvsroot_parsed = 1;
+
+ return 0;
+}
+
+/* The flush function for a log buffer. */
+
+static int
+log_buffer_flush (closure)
+ void *closure;
+{
+ struct log_buffer *lb = (struct log_buffer *) closure;
+
+ if (lb->buf->flush == NULL)
+ abort ();
+
+ /* We don't really have to flush the log file here, but doing it
+ will let tail -f on the log file show what is sent to the
+ network as it is sent. */
+ if (fflush (lb->log) != 0)
+ error (0, errno, "flushing log file");
+
+ return (*lb->buf->flush) (lb->buf->closure);
+}
+
+/* The block function for a log buffer. */
+
+static int
+log_buffer_block (closure, block)
+ void *closure;
+ int block;
+{
+ struct log_buffer *lb = (struct log_buffer *) closure;
+
+ if (block)
+ return set_block (lb->buf);
+ else
+ return set_nonblock (lb->buf);
+}
+
+/* The shutdown function for a log buffer. */
+
+static int
+log_buffer_shutdown (closure)
+ void *closure;
+{
+ struct log_buffer *lb = (struct log_buffer *) closure;
+
+ return buf_shutdown (lb->buf);
}
#ifdef NO_SOCKET_TO_FD
+
/* Under certain circumstances, we must communicate with the server
via a socket using send() and recv(). This is because under some
operating systems (OS/2 and Windows 95 come to mind), a socket
cannot be converted to a file descriptor -- it must be treated as a
- socket and nothing else. */
+ socket and nothing else.
+
+ We may also need to deal with socket routine error codes differently
+ in these cases. This is handled through the SOCK_ERRNO and
+ SOCK_STRERROR macros. */
+
static int use_socket_style = 0;
static int server_sock;
-#endif /* NO_SOCKET_TO_FD */
-/* Stream to write to the server. */
-static FILE *to_server;
-/* Stream to read from the server. */
-static FILE *from_server;
+/* These routines implement a buffer structure which uses send and
+ recv. The buffer is always in blocking mode so we don't implement
+ the block routine. */
-/* We might want to log client/server traffic. */
-static FILE *from_server_logfile;
-static FILE *to_server_logfile;
+/* Note that it is important that these routines always handle errors
+ internally and never return a positive errno code, since it would in
+ general be impossible for the caller to know in general whether any
+ error code came from a socket routine (to decide whether to use
+ SOCK_STRERROR or simply strerror to print an error message). */
-#if ! RSH_NOT_TRANSPARENT
-/* Process ID of rsh subprocess. */
-static int rsh_pid = -1;
-#endif /* ! RSH_NOT_TRANSPARENT */
+/* We use an instance of this structure as the closure field. */
-
-/*
- * Read a line from the server. Result does not include the terminating \n.
- *
- * Space for the result is malloc'd and should be freed by the caller.
- *
- * Returns number of bytes read. If EOF_OK, then return 0 on end of file,
- * else end of file is an error.
- */
-static int
-read_line (resultp, eof_ok)
- char **resultp;
- int eof_ok;
+struct socket_buffer
{
- int c;
- char *result;
- size_t input_index = 0;
- size_t result_size = 80;
+ /* The socket number. */
+ int socket;
+};
-#ifdef NO_SOCKET_TO_FD
- if (! use_socket_style)
-#endif /* NO_SOCKET_TO_FD */
- fflush (to_server);
+static struct buffer *socket_buffer_initialize
+ PROTO ((int, int, void (*) (struct buffer *)));
+static int socket_buffer_input PROTO((void *, char *, int, int, int *));
+static int socket_buffer_output PROTO((void *, const char *, int, int *));
+static int socket_buffer_flush PROTO((void *));
- result = (char *) xmalloc (result_size);
+/* Create a buffer based on a socket. */
- while (1)
- {
+static struct buffer *
+socket_buffer_initialize (socket, input, memory)
+ int socket;
+ int input;
+ void (*memory) PROTO((struct buffer *));
+{
+ struct socket_buffer *n;
+
+ n = (struct socket_buffer *) xmalloc (sizeof *n);
+ n->socket = socket;
+ return buf_initialize (input ? socket_buffer_input : NULL,
+ input ? NULL : socket_buffer_output,
+ input ? NULL : socket_buffer_flush,
+ (int (*) PROTO((void *, int))) NULL,
+ (int (*) PROTO((void *))) NULL,
+ memory,
+ n);
+}
-#ifdef NO_SOCKET_TO_FD
- if (use_socket_style)
- {
- char ch;
- /* Yes, this sucks performance-wise. Short of implementing
- our own buffering, I'm not sure how to effect a big
- improvement. We could at least avoid calling
- read_from_server() for each character if we were willing
- to duplicate a lot of its code, but I'm not sure that's
- worth it. */
- read_from_server (&ch, 1);
- c = ch;
- }
- else
-#endif /* NO_SOCKET_TO_FD */
- c = getc (from_server);
+/* The buffer input function for a buffer built on a socket. */
- if (c == EOF)
- {
- free (result);
+static int
+socket_buffer_input (closure, data, need, size, got)
+ void *closure;
+ char *data;
+ int need;
+ int size;
+ int *got;
+{
+ struct socket_buffer *sb = (struct socket_buffer *) closure;
+ int nbytes;
-#ifdef NO_SOCKET_TO_FD
- if (! use_socket_style)
-#endif /* NO_SOCKET_TO_FD */
- if (ferror (from_server))
- error (1, errno, "reading from server");
-
- /* It's end of file. */
- if (eof_ok)
- return 0;
- else
- error (1, 0, "end of file from server (consult above messages if any)");
- }
+ /* I believe that the recv function gives us exactly the semantics
+ we want. If there is a message, it returns immediately with
+ whatever it could get. If there is no message, it waits until
+ one comes in. In other words, it is not like read, which in
+ blocking mode normally waits until all the requested data is
+ available. */
- if (c == '\n')
- break;
-
- result[input_index++] = c;
- while (input_index + 1 >= result_size)
+ *got = 0;
+
+ do
+ {
+ nbytes = recv (sb->socket, data, size, 0);
+ if (nbytes < 0)
+ error (1, 0, "reading from server: %s", SOCK_STRERROR (SOCK_ERRNO));
+ if (nbytes == 0)
{
- result_size *= 2;
- result = (char *) xrealloc (result, result_size);
+ /* End of file (for example, the server has closed
+ the connection). If we've already read something, we
+ just tell the caller about the data, not about the end of
+ file. If we've read nothing, we return end of file. */
+ if (*got == 0)
+ return -1;
+ else
+ return 0;
}
+ need -= nbytes;
+ size -= nbytes;
+ data += nbytes;
+ *got += nbytes;
}
+ while (need > 0);
- if (resultp)
- *resultp = result;
+ return 0;
+}
- /* Terminate it just for kicks, but we *can* deal with embedded NULs. */
- result[input_index] = '\0';
+/* The buffer output function for a buffer built on a socket. */
+
+static int
+socket_buffer_output (closure, data, have, wrote)
+ void *closure;
+ const char *data;
+ int have;
+ int *wrote;
+{
+ struct socket_buffer *sb = (struct socket_buffer *) closure;
+
+ *wrote = have;
+
+#ifdef SEND_NEVER_PARTIAL
+ /* If send() never will produce a partial write, then just do it. This
+ is needed for systems where its return value is something other than
+ the number of bytes written. */
+ if (send (sb->socket, data, have, 0) < 0)
+ error (1, 0, "writing to server socket: %s", SOCK_STRERROR (SOCK_ERRNO));
+#else
+ while (have > 0)
+ {
+ int nbytes;
+
+ nbytes = send (sb->socket, data, have, 0);
+ if (nbytes < 0)
+ error (1, 0, "writing to server socket: %s", SOCK_STRERROR (SOCK_ERRNO));
+
+ have -= nbytes;
+ data += nbytes;
+ }
+#endif
+
+ return 0;
+}
+
+/* The buffer flush function for a buffer built on a socket. */
+
+/*ARGSUSED*/
+static int
+socket_buffer_flush (closure)
+ void *closure;
+{
+ /* Nothing to do. Sockets are always flushed. */
+ return 0;
+}
-#ifdef NO_SOCKET_TO_FD
- if (! use_socket_style)
#endif /* NO_SOCKET_TO_FD */
+
+/*
+ * Read a line from the server. Result does not include the terminating \n.
+ *
+ * Space for the result is malloc'd and should be freed by the caller.
+ *
+ * Returns number of bytes read.
+ */
+static int
+read_line (resultp)
+ char **resultp;
+{
+ int status;
+ char *result;
+ int len;
+
+ status = buf_flush (to_server, 1);
+ if (status != 0)
+ error (1, status, "writing to server");
+
+ status = buf_read_line (from_server, &result, &len);
+ if (status != 0)
{
- /*
- * If we're using socket style, then everything has already
- * been logged because read_from_server() was used to get the
- * individual chars, and read_from_server() logs already.
- */
- if (from_server_logfile)
- {
- if (fwrite (result, 1, input_index, from_server_logfile)
- < input_index)
- error (0, errno, "writing to from-server logfile");
- putc ('\n', from_server_logfile);
- }
+ if (status == -1)
+ error (1, 0, "end of file from server (consult above messages if any)");
+ else if (status == -2)
+ error (1, 0, "out of memory");
+ else
+ error (1, status, "reading from server");
}
-
- if (resultp == NULL)
+
+ if (resultp != NULL)
+ *resultp = result;
+ else
free (result);
- return input_index;
+
+ return len;
}
#endif /* CLIENT_SUPPORT */
@@ -456,23 +650,28 @@ read_line (resultp, eof_ok)
*/
int gzip_level;
+/*
+ * Level of compression to use when running gzip on a single file.
+ */
+int file_gzip_level;
+
int filter_through_gzip (fd, dir, level, pidp)
- int fd, dir, level;
- pid_t *pidp;
+ int fd, dir, level;
+ pid_t *pidp;
{
- static char buf[5] = "-";
- static char *gzip_argv[3] = { "gzip", buf };
+ static char buf[5] = "-";
+ static char *gzip_argv[3] = { "gzip", buf };
- sprintf (buf+1, "%d", level);
- return filter_stream_through_program (fd, dir, &gzip_argv[0], pidp);
+ sprintf (buf+1, "%d", level);
+ return filter_stream_through_program (fd, dir, &gzip_argv[0], pidp);
}
int filter_through_gunzip (fd, dir, pidp)
- int fd, dir;
- pid_t *pidp;
+ int fd, dir;
+ pid_t *pidp;
{
- static char *gunzip_argv[3] = { "gunzip", "-d" };
- return filter_stream_through_program (fd, dir, &gunzip_argv[0], pidp);
+ static char *gunzip_argv[3] = { "gzip", "-d" };
+ return filter_stream_through_program (fd, dir, &gunzip_argv[0], pidp);
}
#endif /* CLIENT_SUPPORT or SERVER_SUPPORT */
@@ -485,8 +684,10 @@ int filter_through_gunzip (fd, dir, pidp)
*/
static char *toplevel_repos;
-/* Working directory when we first started. */
-char toplevel_wd[PATH_MAX];
+/* Working directory when we first started. Note: we could speed things
+ up on some systems by using savecwd.h here instead of just always
+ storing a name. */
+char *toplevel_wd;
static void
handle_ok (args, len)
@@ -559,9 +760,6 @@ handle_valid_requests (args, len)
*/
send_to_server (rq->name, 0);
send_to_server ("\012", 0);
-
- if (!strcmp("UseUnchanged",rq->name))
- use_unchanged = 1;
}
else
rq->status = rq_supported;
@@ -577,26 +775,10 @@ handle_valid_requests (args, len)
}
}
-static int use_directory = -1;
-
-static char *get_short_pathname PROTO((const char *));
-
-static char *
-get_short_pathname (name)
- const char *name;
-{
- const char *retval;
- if (use_directory)
- return (char *) name;
- if (strncmp (name, toplevel_repos, strlen (toplevel_repos)) != 0)
- error (1, 0, "server bug: name `%s' doesn't specify file in `%s'",
- name, toplevel_repos);
- retval = name + strlen (toplevel_repos) + 1;
- if (retval[-1] != '/')
- error (1, 0, "server bug: name `%s' doesn't specify file in `%s'",
- name, toplevel_repos);
- return (char *) retval;
-}
+/* This variable holds the result of Entries_Open, so that we can
+ close Entries_Close on it when we move on to a new directory, or
+ when we finish. */
+static List *last_entries;
/*
* Do all the processing for PATHNAME, where pathname consists of the
@@ -618,12 +800,15 @@ call_in_directory (pathname, func, data)
char *filename));
char *data;
{
- static List *last_entries;
-
char *dir_name;
char *filename;
- /* Just the part of pathname relative to toplevel_repos. */
- char *short_pathname = get_short_pathname (pathname);
+ /* This is what we get when we hook up the directory (working directory
+ name) from PATHNAME with the filename from REPOSNAME. For example:
+ pathname: ccvs/src/
+ reposname: /u/src/master/ccvs/foo/ChangeLog
+ short_pathname: ccvs/src/ChangeLog
+ */
+ char *short_pathname;
char *p;
/*
@@ -646,30 +831,23 @@ call_in_directory (pathname, func, data)
int reposdirname_absolute;
reposname = NULL;
- if (use_directory)
- read_line (&reposname, 0);
+ read_line (&reposname);
+ assert (reposname != NULL);
reposdirname_absolute = 0;
- if (reposname != NULL)
+ if (strncmp (reposname, toplevel_repos, strlen (toplevel_repos)) != 0)
+ {
+ reposdirname_absolute = 1;
+ short_repos = reposname;
+ }
+ else
{
- if (strncmp (reposname, toplevel_repos, strlen (toplevel_repos)) != 0)
+ short_repos = reposname + strlen (toplevel_repos) + 1;
+ if (short_repos[-1] != '/')
{
reposdirname_absolute = 1;
short_repos = reposname;
}
- else
- {
- short_repos = reposname + strlen (toplevel_repos) + 1;
- if (short_repos[-1] != '/')
- {
- reposdirname_absolute = 1;
- short_repos = reposname;
- }
- }
- }
- else
- {
- short_repos = short_pathname;
}
reposdirname = xstrdup (short_repos);
p = strrchr (reposdirname, '/');
@@ -681,7 +859,7 @@ call_in_directory (pathname, func, data)
else
*p = '\0';
- dir_name = xstrdup (short_pathname);
+ dir_name = xstrdup (pathname);
p = strrchr (dir_name, '/');
if (p == NULL)
{
@@ -699,30 +877,66 @@ call_in_directory (pathname, func, data)
else
++filename;
- if (reposname != NULL)
- {
- /* This is the use_directory case. */
-
- short_pathname = xmalloc (strlen (pathname) + strlen (filename) + 5);
- strcpy (short_pathname, pathname);
- strcat (short_pathname, filename);
- }
+ short_pathname = xmalloc (strlen (pathname) + strlen (filename) + 5);
+ strcpy (short_pathname, pathname);
+ strcat (short_pathname, filename);
if (last_dir_name == NULL
|| strcmp (last_dir_name, dir_name) != 0)
{
+ int newdir;
+
+ if (strcmp (command_name, "export") != 0)
+ if (last_entries)
+ Entries_Close (last_entries);
+
if (last_dir_name)
free (last_dir_name);
last_dir_name = dir_name;
- if (toplevel_wd[0] == '\0')
- if (getwd (toplevel_wd) == NULL)
- error (1, 0,
- "could not get working directory: %s", toplevel_wd);
+ if (toplevel_wd == NULL)
+ {
+ toplevel_wd = xgetwd ();
+ if (toplevel_wd == NULL)
+ error (1, errno, "could not get working directory");
+ }
- if (chdir (toplevel_wd) < 0)
+ if (CVS_CHDIR (toplevel_wd) < 0)
error (1, errno, "could not chdir to %s", toplevel_wd);
- if (chdir (dir_name) < 0)
+ newdir = 0;
+
+ /* Create the CVS directory at the top level if needed.
+ The isdir seems like an unneeded system call, but it *does*
+ need to be called both if the CVS_CHDIR below succeeds (e.g.
+ "cvs co .") or if it fails (e.g. basicb-1a in testsuite). */
+ if (/* I think the reposdirname_absolute case has to do with
+ things like "cvs update /foo/bar". In any event, the
+ code below which tries to put toplevel_repos into
+ CVS/Repository is almost surely unsuited to
+ the reposdirname_absolute case. */
+ !reposdirname_absolute
+
+ && ! isdir (CVSADM))
+ {
+ char *repo;
+ char *r;
+
+ newdir = 1;
+
+ repo = xmalloc (strlen (toplevel_repos)
+ + 10);
+ strcpy (repo, toplevel_repos);
+ r = repo + strlen (repo);
+ if (r[-1] != '.' || r[-2] != '/')
+ strcpy (r, "/.");
+
+ Create_Admin (".", ".", repo, (char *) NULL,
+ (char *) NULL, 0);
+
+ free (repo);
+ }
+
+ if ( CVS_CHDIR (dir_name) < 0)
{
char *dir;
char *dirp;
@@ -731,6 +945,13 @@ call_in_directory (pathname, func, data)
error (1, errno, "could not chdir to %s", dir_name);
/* Directory does not exist, we need to create it. */
+ newdir = 1;
+
+ /* Provided we are willing to assume that directories get
+ created one at a time, we could simplify this a lot.
+ Do note that one aspect still would need to walk the
+ dir_name path: the checking for "fncmp (dir, CVSADM)". */
+
dir = xmalloc (strlen (dir_name) + 1);
dirp = dir_name;
rdirp = reposdirname;
@@ -759,19 +980,21 @@ call_in_directory (pathname, func, data)
{
dirp = strchr (dirp, '/');
if (dirp)
- {
+ {
strncpy (dir, dir_name, dirp - dir_name);
dir[dirp - dir_name] = '\0';
/* Skip the slash. */
++dirp;
if (rdirp == NULL)
- error (0, 0,
- "internal error: repository string too short.");
+ /* This just means that the repository string has
+ fewer components than the dir_name string. But
+ that is OK (e.g. see modules3-8 in testsuite). */
+ ;
else
- rdirp = strchr (rdirp, '/');
- }
+ rdirp = strchr (rdirp, '/');
+ }
else
- {
+ {
/* If there are no more slashes in the dir name,
we're down to the most nested directory -OR- to
the name of a module. In the first case, we
@@ -789,35 +1012,19 @@ call_in_directory (pathname, func, data)
rdirp = NULL;
strcpy (dir, dir_name);
- }
+ }
+
+ if (fncmp (dir, CVSADM) == 0)
+ {
+ error (0, 0, "cannot create a directory named %s", dir);
+ error (0, 0, "because CVS uses \"%s\" for its own uses",
+ CVSADM);
+ error (1, 0, "rename the directory and try again");
+ }
- if (CVS_MKDIR (dir, 0777) < 0)
+ if (mkdir_if_needed (dir))
{
- /* Now, let me get this straight. In IBM C/C++
- * under OS/2, the error string for EEXIST is:
- *
- * "The file already exists",
- *
- * and the error string for EACCESS is:
- *
- * "The file or directory specified is read-only".
- *
- * Nonetheless, mkdir() will set EACCESS if the
- * directory *exists*, according both to the
- * documentation and its actual behavior.
- *
- * I'm sure that this made sense, to someone,
- * somewhere, sometime. Just not me, here, now.
- */
-#ifdef EACCESS
- if ((errno != EACCESS) && (errno != EEXIST))
- error (1, errno, "cannot make directory %s", dir);
-#else /* ! defined(EACCESS) */
- if ((errno != EEXIST))
- error (1, errno, "cannot make directory %s", dir);
-#endif /* defined(EACCESS) */
-
- /* It already existed, fine. Just keep going. */
+ /* It already existed, fine. Just keep going. */
}
else if (strcmp (command_name, "export") == 0)
/* Don't create CVSADM directories if this is export. */
@@ -831,7 +1038,7 @@ call_in_directory (pathname, func, data)
* relative to cvsroot.
*/
char *repo;
- char *r;
+ char *r, *b;
repo = xmalloc (strlen (reposdirname)
+ strlen (toplevel_repos)
@@ -847,6 +1054,13 @@ call_in_directory (pathname, func, data)
if (rdirp)
{
+ /* See comment near start of function; the only
+ way that the server can put the right thing
+ in each CVS/Repository file is to create the
+ directories one at a time. I think that the
+ CVS server has been doing this all along. */
+ error (0, 0, "\
+warning: server is not creating directories one at a time");
strncpy (r, reposdirname, rdirp - reposdirname);
r[rdirp - reposdirname] = '\0';
}
@@ -854,8 +1068,18 @@ call_in_directory (pathname, func, data)
strcpy (r, reposdirname);
Create_Admin (dir, dir, repo,
- (char *)NULL, (char *)NULL);
+ (char *)NULL, (char *)NULL, 0);
free (repo);
+
+ b = strrchr (dir, '/');
+ if (b == NULL)
+ Subdir_Register ((List *) NULL, (char *) NULL, dir);
+ else
+ {
+ *b = '\0';
+ Subdir_Register ((List *) NULL, dir, b + 1);
+ *b = '/';
+ }
}
if (rdirp != NULL)
@@ -867,26 +1091,42 @@ call_in_directory (pathname, func, data)
} while (dirp != NULL);
free (dir);
/* Now it better work. */
- if (chdir (dir_name) < 0)
+ if ( CVS_CHDIR (dir_name) < 0)
error (1, errno, "could not chdir to %s", dir_name);
}
if (strcmp (command_name, "export") != 0)
{
- if (last_entries)
- Entries_Close (last_entries);
last_entries = Entries_Open (0);
+
+ /* If this is a newly created directory, we will record
+ all subdirectory information, so call Subdirs_Known in
+ case there are no subdirectories. If this is not a
+ newly created directory, it may be an old working
+ directory from before we recorded subdirectory
+ information in the Entries file. We force a search for
+ all subdirectories now, to make sure our subdirectory
+ information is up to date. If the Entries file does
+ record subdirectory information, then this call only
+ does list manipulation. */
+ if (newdir)
+ Subdirs_Known (last_entries);
+ else
+ {
+ List *dirlist;
+
+ dirlist = Find_Directories ((char *) NULL, W_LOCAL,
+ last_entries);
+ dellist (&dirlist);
+ }
}
}
else
free (dir_name);
free (reposdirname);
(*func) (data, last_entries, short_pathname, filename);
- if (reposname != NULL)
- {
- free (short_pathname);
- free (reposname);
- }
+ free (short_pathname);
+ free (reposname);
}
static void
@@ -901,7 +1141,7 @@ copy_a_file (data, ent_list, short_pathname, filename)
char *p;
#endif
- read_line (&newname, 0);
+ read_line (&newname);
#ifdef USE_VMS_FILENAMES
/* Mogrify the filename so VMS is happy with it. */
@@ -949,7 +1189,7 @@ read_counted_file (filename, fullname)
FILE *fp;
- read_line (&size_string, 0);
+ read_line (&size_string);
if (size_string[0] == 'z')
error (1, 0, "\
protocol error: compressed files not supported for that operation");
@@ -968,7 +1208,7 @@ protocol error: compressed files not supported for that operation");
is binary or not. I haven't carefully looked into whether
CVS/Template files should use local text file conventions or
not. */
- fp = fopen (filename, "wb");
+ fp = CVS_FOPEN (filename, "wb");
if (fp == NULL)
error (1, errno, "cannot write %s", fullname);
nread = size;
@@ -1002,6 +1242,11 @@ protocol error: compressed files not supported for that operation");
}
/*
+ * The time stamp of the last file we registered.
+ */
+static time_t last_register_time;
+
+/*
* The Checksum response gives the checksum for the file transferred
* over by the next Updated, Merged or Patch response. We just store
* it here, and then check it in update_entries.
@@ -1082,9 +1327,23 @@ struct update_entries_data
* We are getting a patch against the existing local file, not
* an entire new file.
*/
- UPDATE_ENTRIES_PATCH
+ UPDATE_ENTRIES_PATCH,
+ /*
+ * We are getting an RCS change text (diff -n output) against
+ * the existing local file, not an entire new file.
+ */
+ UPDATE_ENTRIES_RCS_DIFF
} contents;
+ enum {
+ /* We are replacing an existing file. */
+ UPDATE_ENTRIES_EXISTING,
+ /* We are creating a new file. */
+ UPDATE_ENTRIES_NEW,
+ /* We don't know whether it is existing or new. */
+ UPDATE_ENTRIES_EXISTING_OR_NEW
+ } existp;
+
/*
* String to put in the timestamp field or NULL to use the timestamp
* of the file.
@@ -1109,13 +1368,13 @@ update_entries (data_arg, ent_list, short_pathname, filename)
/* Timestamp field. Always empty according to the protocol. */
char *ts;
char *options;
- char *tag;
- char *date;
+ char *tag = NULL;
+ char *date = NULL;
char *tag_or_date;
- char *scratch_entries;
+ char *scratch_entries = NULL;
int bin;
- read_line (&entries_line, 0);
+ read_line (&entries_line);
/*
* Parse the entries line.
@@ -1149,8 +1408,6 @@ update_entries (data_arg, ent_list, short_pathname, filename)
cp = strchr (tag_or_date, '/');
if (cp != NULL)
*cp = '\0';
- tag = (char *) NULL;
- date = (char *) NULL;
if (*tag_or_date == 'T')
tag = tag_or_date + 1;
else if (*tag_or_date == 'D')
@@ -1167,20 +1424,20 @@ update_entries (data_arg, ent_list, short_pathname, filename)
options = NULL;
if (data->contents == UPDATE_ENTRIES_UPDATE
- || data->contents == UPDATE_ENTRIES_PATCH)
+ || data->contents == UPDATE_ENTRIES_PATCH
+ || data->contents == UPDATE_ENTRIES_RCS_DIFF)
{
char *size_string;
char *mode_string;
int size;
- int fd;
char *buf;
char *temp_filename;
- int use_gzip, gzip_status;
- pid_t gzip_pid = 0;
+ int use_gzip;
+ int patch_failed;
- read_line (&mode_string, 0);
+ read_line (&mode_string);
- read_line (&size_string, 0);
+ read_line (&size_string);
if (size_string[0] == 'z')
{
use_gzip = 1;
@@ -1193,6 +1450,74 @@ update_entries (data_arg, ent_list, short_pathname, filename)
}
free (size_string);
+ /* Note that checking this separately from writing the file is
+ a race condition: if the existing or lack thereof of the
+ file changes between now and the actually calls which
+ operate on it, we lose. However (a) there are so many
+ cases, I'm reluctant to try to fix them all, (b) in some
+ cases the system might not even have a system call which
+ does the right thing, and (c) it isn't clear this needs to
+ work. */
+ if (data->existp == UPDATE_ENTRIES_EXISTING
+ && !isfile (filename))
+ /* Emit a warning and update the file anyway. */
+ error (0, 0, "warning: %s unexpectedly disappeared",
+ short_pathname);
+
+ if (data->existp == UPDATE_ENTRIES_NEW
+ && isfile (filename))
+ {
+ /* Emit a warning and refuse to update the file; we don't want
+ to clobber a user's file. */
+ size_t nread;
+ size_t toread;
+
+ /* size should be unsigned, but until we get around to fixing
+ that, work around it. */
+ size_t usize;
+
+ char buf[8192];
+
+ /* This error might be confusing; it isn't really clear to
+ the user what to do about it. Keep in mind that it has
+ several causes: (1) something/someone creates the file
+ during the time that CVS is running, (2) the repository
+ has two files whose names clash for the client because
+ of case-insensitivity or similar causes, (3) a special
+ case of this is that a file gets renamed for example
+ from a.c to A.C. A "cvs update" on a case-insensitive
+ client will get this error. Repeating the update takes
+ care of the problem, but is it clear to the user what
+ is going on and what to do about it?, (4) the client
+ has a file which the server doesn't know about (e.g. "?
+ foo" file), and that name clashes with a file the
+ server does know about, (5) classify.c will print the same
+ message for other reasons.
+
+ I hope the above paragraph makes it clear that making this
+ clearer is not a one-line fix. */
+ error (0, 0, "move away %s; it is in the way", short_pathname);
+
+ discard_file_and_return:
+ /* Now read and discard the file contents. */
+ usize = size;
+ nread = 0;
+ while (nread < usize)
+ {
+ toread = usize - nread;
+ if (toread > sizeof buf)
+ toread = sizeof buf;
+
+ nread += try_read_from_server (buf, toread);
+ if (nread == usize)
+ break;
+ }
+
+ free (mode_string);
+ free (entries_line);
+ return;
+ }
+
temp_filename = xmalloc (strlen (filename) + 80);
#ifdef USE_VMS_FILENAMES
/* A VMS rename of "blah.dat" to "foo" to implies a
@@ -1205,6 +1530,7 @@ update_entries (data_arg, ent_list, short_pathname, filename)
sprintf (temp_filename, ".new.%s", filename);
#endif /* _POSIX_NO_TRUNC */
#endif /* USE_VMS_FILENAMES */
+
buf = xmalloc (size);
/* Some systems, like OS/2 and Windows NT, end lines with CRLF
@@ -1219,36 +1545,66 @@ update_entries (data_arg, ent_list, short_pathname, filename)
else
bin = 0;
- fd = open (temp_filename,
- O_WRONLY | O_CREAT | O_TRUNC | (bin ? OPEN_BINARY : 0),
- 0777);
-
- if (fd < 0)
- error (1, errno, "writing %s", short_pathname);
+ if (data->contents == UPDATE_ENTRIES_RCS_DIFF)
+ {
+ /* This is an RCS change text. We just hold the change
+ text in memory. */
- if (use_gzip)
- fd = filter_through_gunzip (fd, 0, &gzip_pid);
+ if (use_gzip)
+ error (1, 0,
+ "server error: gzip invalid with RCS change text");
- if (size > 0)
- {
- read_from_server (buf, size);
-
- if (write (fd, buf, size) != size)
- error (1, errno, "writing %s", short_pathname);
+ read_from_server (buf, size);
}
-
- if (close (fd) < 0)
- error (1, errno, "writing %s", short_pathname);
- if (gzip_pid > 0)
+ else
{
- if (waitpid (gzip_pid, &gzip_status, 0) == -1)
- error (1, errno, "waiting for gzip process %ld",
- (long) gzip_pid);
- else if (gzip_status != 0)
- error (1, 0, "gzip process exited %d", gzip_status);
- }
+ int fd;
+ pid_t gzip_pid = 0;
+
+ fd = CVS_OPEN (temp_filename,
+ (O_WRONLY | O_CREAT | O_TRUNC
+ | (bin ? OPEN_BINARY : 0)),
+ 0777);
+
+ if (fd < 0)
+ {
+ /* I can see a case for making this a fatal error; for
+ a condition like disk full or network unreachable
+ (for a file server), carrying on and giving an
+ error on each file seems unnecessary. But if it is
+ a permission problem, or some such, then it is
+ entirely possible that future files will not have
+ the same problem. */
+ error (0, errno, "cannot write %s", short_pathname);
+ goto discard_file_and_return;
+ }
+
+ if (use_gzip)
+ fd = filter_through_gunzip (fd, 0, &gzip_pid);
+
+ if (size > 0)
+ {
+ read_from_server (buf, size);
+
+ if (write (fd, buf, size) != size)
+ error (1, errno, "writing %s", short_pathname);
+ }
+
+ if (close (fd) < 0)
+ error (1, errno, "writing %s", short_pathname);
+ if (gzip_pid > 0)
+ {
+ int gzip_status;
- gzip_pid = -1;
+ if (waitpid (gzip_pid, &gzip_status, 0) == -1)
+ error (1, errno, "waiting for gzip process %ld",
+ (long) gzip_pid);
+ else if (gzip_status != 0)
+ error (1, 0, "gzip process exited %d", gzip_status);
+ }
+
+ gzip_pid = -1;
+ }
/* Since gunzip writes files without converting LF to CRLF
(a reasonable behavior), we now have a patch file in LF
@@ -1256,6 +1612,8 @@ update_entries (data_arg, ent_list, short_pathname, filename)
it to patch; patch can handle it. However, if it's the
final source file, convert it. */
+ patch_failed = 0;
+
if (data->contents == UPDATE_ENTRIES_UPDATE)
{
#ifdef LINES_CRLF_TERMINATED
@@ -1267,30 +1625,51 @@ update_entries (data_arg, ent_list, short_pathname, filename)
{
convert_file (temp_filename, O_RDONLY | OPEN_BINARY,
filename, O_WRONLY | O_CREAT | O_TRUNC);
- if (unlink (temp_filename) < 0)
+ if ( CVS_UNLINK (temp_filename) < 0)
error (0, errno, "warning: couldn't delete %s",
temp_filename);
}
else
+#ifdef BROKEN_READWRITE_CONVERSION
+ {
+ /* If only stdio, not open/write/etc., do text/binary
+ conversion, use convert_file which can compensate
+ (FIXME: we could just use stdio instead which would
+ avoid the whole problem). */
+ if (!bin)
+ {
+ convert_file (temp_filename, O_RDONLY | OPEN_BINARY,
+ filename, O_WRONLY | O_CREAT | O_TRUNC);
+ if (CVS_UNLINK (temp_filename) < 0)
+ error (0, errno, "warning: couldn't delete %s",
+ temp_filename);
+ }
+ else
+ rename_file (temp_filename, filename);
+ }
+#else
rename_file (temp_filename, filename);
+#endif
#else /* ! LINES_CRLF_TERMINATED */
rename_file (temp_filename, filename);
#endif /* LINES_CRLF_TERMINATED */
}
- else
+ else if (data->contents == UPDATE_ENTRIES_PATCH)
{
int retcode;
- char backup[PATH_MAX];
+ char *backup;
struct stat s;
- (void) sprintf (backup, "%s~", filename);
+ backup = xmalloc (strlen (filename) + 5);
+ strcpy (backup, filename);
+ strcat (backup, "~");
(void) unlink_file (backup);
if (!isfile (filename))
error (1, 0, "patch original file %s does not exist",
short_pathname);
- if (stat (temp_filename, &s) < 0)
- error (1, 1, "can't stat patch file %s", temp_filename);
+ if ( CVS_STAT (temp_filename, &s) < 0)
+ error (1, errno, "can't stat patch file %s", temp_filename);
if (s.st_size == 0)
retcode = 0;
else
@@ -1322,27 +1701,126 @@ update_entries (data_arg, ent_list, short_pathname, filename)
(void) unlink_file (path_tmp);
free (path_tmp);
- /* Save this file to retrieve later. */
- failed_patches =
- (char **) xrealloc ((char *) failed_patches,
- ((failed_patches_count + 1)
- * sizeof (char *)));
- failed_patches[failed_patches_count] =
- xstrdup (short_pathname);
- ++failed_patches_count;
-
error (retcode == -1 ? 1 : 0, retcode == -1 ? old_errno : 0,
"could not patch %s%s", filename,
retcode == -1 ? "" : "; will refetch");
- stored_checksum_valid = 0;
+ patch_failed = 1;
+ }
+ free (backup);
+ }
+ else
+ {
+ struct stat s;
+ char *filebuf, *tobuf;
+ size_t filebufsize;
+ FILE *e;
+ size_t nread;
+ char *patchedbuf;
+ size_t patchedlen;
+
+ /* Handle UPDATE_ENTRIES_RCS_DIFF. */
+
+ if (!isfile (filename))
+ error (1, 0, "patch original file %s does not exist",
+ short_pathname);
+ if (CVS_STAT (filename, &s) < 0)
+ error (1, errno, "can't stat %s", short_pathname);
+
+ filebufsize = s.st_size;
+ filebuf = xmalloc (filebufsize);
+
+ e = open_file (filename, bin ? FOPEN_BINARY_READ : "r");
+
+ tobuf = filebuf;
+ nread = 0;
+ while (1)
+ {
+ size_t got;
+
+ got = fread (tobuf, 1, filebufsize - (tobuf - filebuf), e);
+ if (ferror (e))
+ error (1, errno, "can't read %s", short_pathname);
+ nread += got;
+ tobuf += got;
+
+ if (feof (e))
+ break;
+
+ /* It's probably paranoid to think S.ST_SIZE might be
+ too small to hold the entire file contents, but we
+ handle it just in case. */
+ if (tobuf == filebuf + filebufsize)
+ {
+ int c;
+ long off;
+
+ c = getc (e);
+ if (c == EOF)
+ break;
+ off = tobuf - filebuf;
+ expand_string (&filebuf, &filebufsize, filebufsize + 100);
+ tobuf = filebuf + off;
+ *tobuf++ = c;
+ ++nread;
+ }
+ }
+
+ fclose (e);
+
+ /* At this point the contents of the existing file are in
+ FILEBUF, and the length of the contents is in NREAD.
+ The contents of the patch from the network are in BUF,
+ and the length of the patch is in SIZE. */
+
+ if (! rcs_change_text (short_pathname, filebuf, nread, buf, size,
+ &patchedbuf, &patchedlen))
+ patch_failed = 1;
+ else
+ {
+ if (stored_checksum_valid)
+ {
+ struct MD5Context context;
+ unsigned char checksum[16];
+
+ /* We have a checksum. Check it before writing
+ the file out, so that we don't have to read it
+ back in again. */
+ MD5Init (&context);
+ MD5Update (&context, patchedbuf, patchedlen);
+ MD5Final (checksum, &context);
+ if (memcmp (checksum, stored_checksum, 16) != 0)
+ {
+ error (0, 0,
+ "checksum failure after patch to %s; will refetch",
+ short_pathname);
+
+ patch_failed = 1;
+ }
+
+ stored_checksum_valid = 0;
+ }
- return;
+ if (! patch_failed)
+ {
+ e = open_file (temp_filename,
+ bin ? FOPEN_BINARY_WRITE : "w");
+ if (fwrite (patchedbuf, 1, patchedlen, e) != patchedlen)
+ error (1, errno, "cannot write %s", temp_filename);
+ if (fclose (e) == EOF)
+ error (1, errno, "cannot close %s", temp_filename);
+ rename_file (temp_filename, filename);
+ }
+
+ free (patchedbuf);
}
+
+ free (filebuf);
}
+
free (temp_filename);
- if (stored_checksum_valid)
+ if (stored_checksum_valid && ! patch_failed)
{
FILE *e;
struct MD5Context context;
@@ -1360,7 +1838,7 @@ update_entries (data_arg, ent_list, short_pathname, filename)
* here using text mode, so its lines will be terminated the same
* way they were transmitted.
*/
- e = fopen (filename, "r");
+ e = CVS_FOPEN (filename, "r");
if (e == NULL)
error (1, errno, "could not open %s", short_pathname);
@@ -1385,19 +1863,27 @@ update_entries (data_arg, ent_list, short_pathname, filename)
"checksum failure after patch to %s; will refetch",
short_pathname);
- /* Save this file to retrieve later. */
- failed_patches =
- (char **) xrealloc ((char *) failed_patches,
- ((failed_patches_count + 1)
- * sizeof (char *)));
- failed_patches[failed_patches_count] =
- xstrdup (short_pathname);
- ++failed_patches_count;
-
- return;
+ patch_failed = 1;
}
}
+ if (patch_failed)
+ {
+ /* Save this file to retrieve later. */
+ failed_patches = (char **) xrealloc ((char *) failed_patches,
+ ((failed_patches_count + 1)
+ * sizeof (char *)));
+ failed_patches[failed_patches_count] = xstrdup (short_pathname);
+ ++failed_patches_count;
+
+ stored_checksum_valid = 0;
+
+ free (mode_string);
+ free (buf);
+
+ return;
+ }
+
{
/* FIXME: we should be respecting the umask. */
int status = change_mode (filename, mode_string);
@@ -1422,6 +1908,8 @@ update_entries (data_arg, ent_list, short_pathname, filename)
char *local_timestamp;
char *file_timestamp;
+ (void) time (&last_register_time);
+
local_timestamp = data->timestamp;
if (local_timestamp == NULL || ts[0] == '+')
file_timestamp = time_stamp (filename);
@@ -1459,6 +1947,7 @@ handle_checked_in (args, len)
{
struct update_entries_data dat;
dat.contents = UPDATE_ENTRIES_CHECKIN;
+ dat.existp = UPDATE_ENTRIES_EXISTING_OR_NEW;
dat.timestamp = NULL;
call_in_directory (args, update_entries, (char *)&dat);
}
@@ -1470,6 +1959,7 @@ handle_new_entry (args, len)
{
struct update_entries_data dat;
dat.contents = UPDATE_ENTRIES_CHECKIN;
+ dat.existp = UPDATE_ENTRIES_EXISTING_OR_NEW;
dat.timestamp = "dummy timestamp from new-entry";
call_in_directory (args, update_entries, (char *)&dat);
}
@@ -1481,6 +1971,35 @@ handle_updated (args, len)
{
struct update_entries_data dat;
dat.contents = UPDATE_ENTRIES_UPDATE;
+ dat.existp = UPDATE_ENTRIES_EXISTING_OR_NEW;
+ dat.timestamp = NULL;
+ call_in_directory (args, update_entries, (char *)&dat);
+}
+
+static void handle_created PROTO((char *, int));
+
+static void
+handle_created (args, len)
+ char *args;
+ int len;
+{
+ struct update_entries_data dat;
+ dat.contents = UPDATE_ENTRIES_UPDATE;
+ dat.existp = UPDATE_ENTRIES_NEW;
+ dat.timestamp = NULL;
+ call_in_directory (args, update_entries, (char *)&dat);
+}
+
+static void handle_update_existing PROTO((char *, int));
+
+static void
+handle_update_existing (args, len)
+ char *args;
+ int len;
+{
+ struct update_entries_data dat;
+ dat.contents = UPDATE_ENTRIES_UPDATE;
+ dat.existp = UPDATE_ENTRIES_EXISTING;
dat.timestamp = NULL;
call_in_directory (args, update_entries, (char *)&dat);
}
@@ -1492,6 +2011,8 @@ handle_merged (args, len)
{
struct update_entries_data dat;
dat.contents = UPDATE_ENTRIES_UPDATE;
+ /* Think this could be UPDATE_ENTRIES_EXISTING, but just in case... */
+ dat.existp = UPDATE_ENTRIES_EXISTING_OR_NEW;
dat.timestamp = "Result of merge";
call_in_directory (args, update_entries, (char *)&dat);
}
@@ -1503,6 +2024,21 @@ handle_patched (args, len)
{
struct update_entries_data dat;
dat.contents = UPDATE_ENTRIES_PATCH;
+ /* Think this could be UPDATE_ENTRIES_EXISTING, but just in case... */
+ dat.existp = UPDATE_ENTRIES_EXISTING_OR_NEW;
+ dat.timestamp = NULL;
+ call_in_directory (args, update_entries, (char *)&dat);
+}
+
+static void
+handle_rcs_diff (args, len)
+ char *args;
+ int len;
+{
+ struct update_entries_data dat;
+ dat.contents = UPDATE_ENTRIES_RCS_DIFF;
+ /* Think this could be UPDATE_ENTRIES_EXISTING, but just in case... */
+ dat.existp = UPDATE_ENTRIES_EXISTING_OR_NEW;
dat.timestamp = NULL;
call_in_directory (args, update_entries, (char *)&dat);
}
@@ -1533,6 +2069,11 @@ remove_entry_and_file (data, ent_list, short_pathname, filename)
char *filename;
{
Scratch_Entry (ent_list, filename);
+ /* Note that we don't ignore existence_error's here. The server
+ should be sending Remove-entry rather than Removed in cases
+ where the file does not exist. And if the user removes the
+ file halfway through a cvs command, we should be printing an
+ error. */
if (unlink_file (filename) < 0)
error (0, errno, "unable to remove %s", short_pathname);
}
@@ -1550,28 +2091,10 @@ static int
is_cvsroot_level (pathname)
char *pathname;
{
- char *short_pathname;
-
- if (strcmp (toplevel_repos, server_cvsroot) != 0)
+ if (strcmp (toplevel_repos, CVSroot_directory) != 0)
return 0;
- if (!use_directory)
- {
- if (strncmp (pathname, server_cvsroot, strlen (server_cvsroot)) != 0)
- error (1, 0,
- "server bug: pathname `%s' doesn't specify file in `%s'",
- pathname, server_cvsroot);
- short_pathname = pathname + strlen (server_cvsroot) + 1;
- if (short_pathname[-1] != '/')
- error (1, 0,
- "server bug: pathname `%s' doesn't specify file in `%s'",
- pathname, server_cvsroot);
- return strchr (short_pathname, '/') == NULL;
- }
- else
- {
- return strchr (pathname, '/') == NULL;
- }
+ return strchr (pathname, '/') == NULL;
}
static void
@@ -1595,7 +2118,7 @@ handle_set_static_directory (args, len)
if (strcmp (command_name, "export") == 0)
{
/* Swallow the repository. */
- read_line (NULL, 0);
+ read_line (NULL);
return;
}
call_in_directory (args, set_static, (char *)NULL);
@@ -1620,7 +2143,7 @@ handle_clear_static_directory (pathname, len)
if (strcmp (command_name, "export") == 0)
{
/* Swallow the repository. */
- read_line (NULL, 0);
+ read_line (NULL);
return;
}
@@ -1645,7 +2168,7 @@ set_sticky (data, ent_list, short_pathname, filename)
char *tagspec;
FILE *f;
- read_line (&tagspec, 0);
+ read_line (&tagspec);
f = open_file (CVSADM_TAG, "w+");
if (fprintf (f, "%s\n", tagspec) < 0)
error (1, errno, "writing %s", CVSADM_TAG);
@@ -1662,9 +2185,9 @@ handle_set_sticky (pathname, len)
if (strcmp (command_name, "export") == 0)
{
/* Swallow the repository. */
- read_line (NULL, 0);
+ read_line (NULL);
/* Swallow the tag line. */
- (void) read_line (NULL, 0);
+ read_line (NULL);
return;
}
if (is_cvsroot_level (pathname))
@@ -1675,9 +2198,9 @@ handle_set_sticky (pathname, len)
*/
/* Swallow the repository. */
- read_line (NULL, 0);
+ read_line (NULL);
/* Swallow the tag line. */
- (void) read_line (NULL, 0);
+ read_line (NULL);
return;
}
@@ -1703,7 +2226,7 @@ handle_clear_sticky (pathname, len)
if (strcmp (command_name, "export") == 0)
{
/* Swallow the repository. */
- read_line (NULL, 0);
+ read_line (NULL);
return;
}
@@ -1766,7 +2289,7 @@ handle_set_checkin_prog (args, len)
{
char *prog;
struct save_prog *p;
- read_line (&prog, 0);
+ read_line (&prog);
p = (struct save_prog *) xmalloc (sizeof (struct save_prog));
p->next = checkin_progs;
p->dir = xstrdup (args);
@@ -1781,7 +2304,7 @@ handle_set_update_prog (args, len)
{
char *prog;
struct save_prog *p;
- read_line (&prog, 0);
+ read_line (&prog);
p = (struct save_prog *) xmalloc (sizeof (struct save_prog));
p->next = update_progs;
p->dir = xstrdup (args);
@@ -1797,15 +2320,17 @@ do_deferred_progs ()
struct save_prog *p;
struct save_prog *q;
- char fname[PATH_MAX];
+ char *fname;
FILE *f;
- if (toplevel_wd[0] != '\0')
- {
- if (chdir (toplevel_wd) < 0)
- error (1, errno, "could not chdir to %s", toplevel_wd);
- }
+
+ if (toplevel_wd != NULL)
+ {
+ if (CVS_CHDIR (toplevel_wd) < 0)
+ error (1, errno, "could not chdir to %s", toplevel_wd);
+ }
for (p = checkin_progs; p != NULL; )
{
+ fname = xmalloc (strlen (p->dir) + sizeof CVSADM_CIPROG + 10);
sprintf (fname, "%s/%s", p->dir, CVSADM_CIPROG);
f = open_file (fname, "w");
if (fprintf (f, "%s\n", p->name) < 0)
@@ -1817,10 +2342,12 @@ do_deferred_progs ()
q = p->next;
free (p);
p = q;
+ free (fname);
}
checkin_progs = NULL;
- for (p = update_progs; p != NULL; p = p->next)
+ for (p = update_progs; p != NULL; )
{
+ fname = xmalloc (strlen (p->dir) + sizeof CVSADM_UPROG + 10);
sprintf (fname, "%s/%s", p->dir, CVSADM_UPROG);
f = open_file (fname, "w");
if (fprintf (f, "%s\n", p->name) < 0)
@@ -1829,50 +2356,14 @@ do_deferred_progs ()
error (1, errno, "closing %s", fname);
free (p->name);
free (p->dir);
+ q = p->next;
free (p);
+ p = q;
+ free (fname);
}
update_progs = NULL;
}
-static int client_isemptydir PROTO((char *));
-
-/*
- * Returns 1 if the argument directory exists and is completely empty,
- * other than the existence of the CVS directory entry. Zero otherwise.
- */
-static int
-client_isemptydir (dir)
- char *dir;
-{
- DIR *dirp;
- struct dirent *dp;
-
- if ((dirp = opendir (dir)) == NULL)
- {
- if (! existence_error (errno))
- error (0, errno, "cannot open directory %s for empty check", dir);
- return (0);
- }
- errno = 0;
- while ((dp = readdir (dirp)) != NULL)
- {
- if (strcmp (dp->d_name, ".") != 0 && strcmp (dp->d_name, "..") != 0 &&
- strcmp (dp->d_name, CVSADM) != 0)
- {
- (void) closedir (dirp);
- return (0);
- }
- }
- if (errno != 0)
- {
- error (0, errno, "cannot read directory %s", dir);
- (void) closedir (dirp);
- return (0);
- }
- (void) closedir (dirp);
- return (1);
-}
-
struct save_dir {
char *dir;
struct save_dir *next;
@@ -1886,7 +2377,9 @@ add_prune_candidate (dir)
{
struct save_dir *p;
- if (dir[0] == '.' && dir[1] == '\0')
+ if ((dir[0] == '.' && dir[1] == '\0')
+ || (prune_candidates != NULL
+ && strcmp (dir, prune_candidates->dir) == 0))
return;
p = (struct save_dir *) xmalloc (sizeof (struct save_dir));
p->dir = xstrdup (dir);
@@ -1902,22 +2395,34 @@ process_prune_candidates ()
struct save_dir *p;
struct save_dir *q;
- if (toplevel_wd[0] != '\0')
- {
- if (chdir (toplevel_wd) < 0)
- error (1, errno, "could not chdir to %s", toplevel_wd);
- }
+ if (toplevel_wd != NULL)
+ {
+ if (CVS_CHDIR (toplevel_wd) < 0)
+ error (1, errno, "could not chdir to %s", toplevel_wd);
+ }
for (p = prune_candidates; p != NULL; )
{
- if (client_isemptydir (p->dir))
+ if (isemptydir (p->dir, 1))
{
- unlink_file_dir (p->dir);
+ char *b;
+
+ if (unlink_file_dir (p->dir) < 0)
+ error (0, errno, "cannot remove %s", p->dir);
+ b = strrchr (p->dir, '/');
+ if (b == NULL)
+ Subdir_Deregister ((List *) NULL, (char *) NULL, p->dir);
+ else
+ {
+ *b = '\0';
+ Subdir_Deregister ((List *) NULL, p->dir, b + 1);
+ }
}
free (p->dir);
q = p->next;
free (p);
p = q;
}
+ prune_candidates = NULL;
}
/* Send a Repository line. */
@@ -1972,23 +2477,33 @@ send_repository (dir, repos, update_dir)
/* 80 is large enough for any of CVSADM_*. */
adm_name = xmalloc (strlen (dir) + 80);
- if (use_directory == -1)
- use_directory = supported_request ("Directory");
-
- if (use_directory)
- {
- send_to_server ("Directory ", 0);
- send_to_server (update_dir, 0);
- send_to_server ("\012", 1);
- send_to_server (repos, 0);
- send_to_server ("\012", 1);
- }
- else
+ send_to_server ("Directory ", 0);
{
- send_to_server ("Repository ", 0);
- send_to_server (repos, 0);
- send_to_server ("\012", 1);
+ /* Send the directory name. I know that this
+ sort of duplicates code elsewhere, but each
+ case seems slightly different... */
+ char buf[1];
+ char *p = update_dir;
+ while (*p != '\0')
+ {
+ assert (*p != '\012');
+ if (ISDIRSEP (*p))
+ {
+ buf[0] = '/';
+ send_to_server (buf, 1);
+ }
+ else
+ {
+ buf[0] = *p;
+ send_to_server (buf, 1);
+ }
+ ++p;
+ }
}
+ send_to_server ("\012", 1);
+ send_to_server (repos, 0);
+ send_to_server ("\012", 1);
+
if (supported_request ("Static-directory"))
{
adm_name[0] = '\0';
@@ -2011,7 +2526,7 @@ send_repository (dir, repos, update_dir)
else
sprintf (adm_name, "%s/%s", dir, CVSADM_TAG);
- f = fopen (adm_name, "r");
+ f = CVS_FOPEN (adm_name, "r");
if (f == NULL)
{
if (! existence_error (errno))
@@ -2020,7 +2535,7 @@ send_repository (dir, repos, update_dir)
else
{
char line[80];
- char *nl;
+ char *nl = NULL;
send_to_server ("Sticky ", 0);
while (fgets (line, sizeof (line), f) != NULL)
{
@@ -2043,7 +2558,7 @@ send_repository (dir, repos, update_dir)
else
sprintf (adm_name, "%s/%s", dir, CVSADM_CIPROG);
- f = fopen (adm_name, "r");
+ f = CVS_FOPEN (adm_name, "r");
if (f == NULL)
{
if (! existence_error (errno))
@@ -2052,7 +2567,7 @@ send_repository (dir, repos, update_dir)
else
{
char line[80];
- char *nl;
+ char *nl = NULL;
send_to_server ("Checkin-prog ", 0);
@@ -2078,7 +2593,7 @@ send_repository (dir, repos, update_dir)
else
sprintf (adm_name, "%s/%s", dir, CVSADM_UPROG);
- f = fopen (adm_name, "r");
+ f = CVS_FOPEN (adm_name, "r");
if (f == NULL)
{
if (! existence_error (errno))
@@ -2087,7 +2602,7 @@ send_repository (dir, repos, update_dir)
else
{
char line[80];
- char *nl;
+ char *nl = NULL;
send_to_server ("Update-prog ", 0);
@@ -2243,7 +2758,7 @@ client_expand_modules (argc, argv, local)
for (i = 0; i < argc; ++i)
send_arg (argv[i]);
- send_a_repository ("", server_cvsroot, "");
+ send_a_repository ("", CVSroot_directory, "");
send_to_server ("expand-modules\012", 0);
@@ -2259,8 +2774,10 @@ client_expand_modules (argc, argv, local)
}
void
-client_send_expansions (local)
- int local;
+client_send_expansions (local, where, build_dirs)
+ int local;
+ char *where;
+ int build_dirs;
{
int i;
char *argv[1];
@@ -2275,17 +2792,17 @@ client_send_expansions (local)
for (i = 0; i < modules_count; ++i)
{
- argv[0] = modules_vector[i];
+ argv[0] = where ? where : modules_vector[i];
if (isfile (argv[0]))
- send_files (1, argv, local, 0);
+ send_files (1, argv, local, 0, build_dirs ? SEND_BUILD_DIRS : 0);
}
- send_a_repository ("", server_cvsroot, "");
+ send_a_repository ("", CVSroot_directory, "");
}
void
client_nonexpanded_setup ()
{
- send_a_repository ("", server_cvsroot, "");
+ send_a_repository ("", CVSroot_directory, "");
}
static void
@@ -2293,8 +2810,13 @@ handle_m (args, len)
char *args;
int len;
{
- fwrite (args, len, sizeof (*args), stdout);
- putc ('\n', stdout);
+ /* In the case where stdout and stderr point to the same place,
+ fflushing stderr will make output happen in the correct order.
+ Often stderr will be line-buffered and this won't be needed,
+ but not always. */
+ fflush (stderr);
+ fwrite (args, len, sizeof (*args), stdout);
+ putc ('\n', stdout);
}
static void
@@ -2302,8 +2824,20 @@ handle_e (args, len)
char *args;
int len;
{
- fwrite (args, len, sizeof (*args), stderr);
- putc ('\n', stderr);
+ /* In the case where stdout and stderr point to the same place,
+ fflushing stdout will make output happen in the correct order. */
+ fflush (stdout);
+ fwrite (args, len, sizeof (*args), stderr);
+ putc ('\n', stderr);
+}
+
+/*ARGSUSED*/
+static void
+handle_f (args, len)
+ char *args;
+ int len;
+{
+ fflush (stderr);
}
#endif /* CLIENT_SUPPORT */
@@ -2328,8 +2862,12 @@ struct response responses[] =
RSP_LINE("Checksum", handle_checksum, response_type_normal, rs_optional),
RSP_LINE("Copy-file", handle_copy_file, response_type_normal, rs_optional),
RSP_LINE("Updated", handle_updated, response_type_normal, rs_essential),
+ RSP_LINE("Created", handle_created, response_type_normal, rs_optional),
+ RSP_LINE("Update-existing", handle_update_existing, response_type_normal,
+ rs_optional),
RSP_LINE("Merged", handle_merged, response_type_normal, rs_essential),
RSP_LINE("Patched", handle_patched, response_type_normal, rs_optional),
+ RSP_LINE("Rcs-diff", handle_rcs_diff, response_type_normal, rs_optional),
RSP_LINE("Mode", handle_mode, response_type_normal, rs_optional),
RSP_LINE("Removed", handle_removed, response_type_normal, rs_essential),
RSP_LINE("Remove-entry", handle_remove_entry, response_type_normal,
@@ -2355,6 +2893,7 @@ struct response responses[] =
rs_optional),
RSP_LINE("M", handle_m, response_type_normal, rs_essential),
RSP_LINE("E", handle_e, response_type_normal, rs_essential),
+ RSP_LINE("F", handle_f, response_type_normal, rs_optional),
/* Possibly should be response_type_error. */
RSP_LINE(NULL, NULL, response_type_normal, rs_essential)
@@ -2375,91 +2914,52 @@ send_to_server (str, len)
char *str;
size_t len;
{
- if (len == 0)
- len = strlen (str);
-
-#ifdef NO_SOCKET_TO_FD
- if (use_socket_style)
- {
- int just_wrtn = 0;
- size_t wrtn = 0;
-
-#ifdef VMS
- /* send() blocks under VMS */
- if (send (server_sock, str + wrtn, len - wrtn, 0) < 0)
- error (1, errno, "writing to server socket");
-#else /* VMS */
- while (wrtn < len)
- {
- just_wrtn = send (server_sock, str + wrtn, len - wrtn, 0);
+ static int nbytes;
- if (just_wrtn == -1)
- error (1, errno, "writing to server socket");
-
- wrtn += just_wrtn;
- if (wrtn == len)
- break;
- }
-#endif /* VMS */
- }
- else
-#endif /* NO_SOCKET_TO_FD */
- {
- size_t wrtn = 0;
+ if (len == 0)
+ len = strlen (str);
+
+ buf_output (to_server, str, len);
- while (wrtn < len)
- {
- wrtn += fwrite (str + wrtn, 1, len - wrtn, to_server);
-
- if (wrtn == len)
- break;
-
- if (ferror (to_server))
- error (1, errno, "writing to server");
- if (feof (to_server))
- error (1, 0, "premature end-of-file on server");
- }
+ /* There is no reason not to send data to the server, so do it
+ whenever we've accumulated enough information in the buffer to
+ make it worth sending. */
+ nbytes += len;
+ if (nbytes >= 2 * BUFFER_DATA_SIZE)
+ {
+ int status;
+
+ status = buf_send_output (to_server);
+ if (status != 0)
+ error (1, status, "error writing to server");
+ nbytes = 0;
}
-
- if (to_server_logfile)
- if (fwrite (str, 1, len, to_server_logfile) < len)
- error (0, errno, "writing to to-server logfile");
}
-/* Read up to LEN bytes from the server. Returns actual number of bytes
- read. Gives a fatal error on EOF or error. */
+/* Read up to LEN bytes from the server. Returns actual number of
+ bytes read, which will always be at least one; blocks if there is
+ no data available at all. Gives a fatal error on EOF or error. */
static size_t
try_read_from_server (buf, len)
char *buf;
size_t len;
{
- int nread;
+ int status, nread;
+ char *data;
-#ifdef NO_SOCKET_TO_FD
- if (use_socket_style)
+ status = buf_read_data (from_server, len, &data, &nread);
+ if (status != 0)
{
- nread = recv (server_sock, buf, len, 0);
- if (nread == -1)
- error (1, errno, "reading from server");
- }
- else
-#endif
- {
- nread = fread (buf, 1, len, from_server);
- if (ferror (from_server))
- error (1, errno, "reading from server");
- if (feof (from_server))
+ if (status == -1)
error (1, 0,
"end of file from server (consult above messages if any)");
+ else if (status == -2)
+ error (1, 0, "out of memory");
+ else
+ error (1, status, "reading from server");
}
- /* Log, if that's what we're doing. */
- if (from_server_logfile != NULL && nread > 0)
- {
- size_t towrite = nread;
- if (fwrite (buf, 1, towrite, from_server_logfile) < towrite)
- error (0, errno, "writing to from-server logfile");
- }
+ memcpy (buf, data, nread);
return nread;
}
@@ -2493,7 +2993,7 @@ get_server_responses ()
char *cmd;
int len;
- len = read_line (&cmd, 0);
+ len = read_line (&cmd);
for (rs = responses; rs->name != NULL; ++rs)
if (strncmp (cmd, rs->name, strlen (rs->name)) == 0)
{
@@ -2539,120 +3039,160 @@ int
get_responses_and_close ()
{
int errs = get_server_responses ();
+ int status;
+
+ if (last_entries != NULL)
+ {
+ Entries_Close (last_entries);
+ last_entries = NULL;
+ }
do_deferred_progs ();
if (client_prune_dirs)
process_prune_candidates ();
+ /* The calls to buf_shutdown are currently only meaningful when we
+ are using compression. First we shut down TO_SERVER. That
+ tells the server that its input is finished. It then shuts
+ down the buffer it is sending to us, at which point our shut
+ down of FROM_SERVER will complete. */
+
+ status = buf_shutdown (to_server);
+ if (status != 0)
+ error (0, status, "shutting down buffer to server");
+ status = buf_shutdown (from_server);
+ if (status != 0)
+ error (0, status, "shutting down buffer from server");
+
#ifdef NO_SOCKET_TO_FD
if (use_socket_style)
- {
- if (shutdown (server_sock, 2) < 0)
- error (1, errno, "shutting down server socket");
- }
+ {
+ if (shutdown (server_sock, 2) < 0)
+ error (1, 0, "shutting down server socket: %s", SOCK_STRERROR (SOCK_ERRNO));
+ }
else
#endif /* NO_SOCKET_TO_FD */
- {
-#if defined(HAVE_KERBEROS) || defined(USE_DIRECT_TCP) || defined(AUTH_CLIENT_SUPPORT)
- if (server_fd != -1)
- {
- if (shutdown (server_fd, 1) < 0)
- error (1, errno, "shutting down connection to %s", server_host);
+ {
+#if defined(HAVE_KERBEROS) || defined(AUTH_CLIENT_SUPPORT)
+ if (server_fd != -1)
+ {
+ if (shutdown (server_fd, 1) < 0)
+ error (1, 0, "shutting down connection to %s: %s",
+ CVSroot_hostname, SOCK_STRERROR (SOCK_ERRNO));
/*
* This test will always be true because we dup the descriptor
*/
- if (fileno (from_server) != fileno (to_server))
- {
- if (fclose (to_server) != 0)
- error (1, errno,
- "closing down connection to %s",
- server_host);
- }
- }
+ if (fileno (from_server_fp) != fileno (to_server_fp))
+ {
+ if (fclose (to_server_fp) != 0)
+ error (1, errno,
+ "closing down connection to %s",
+ CVSroot_hostname);
+ }
+ }
else
-#endif /* HAVE_KERBEROS || USE_DIRECT_TCP || AUTH_CLIENT_SUPPORT */
+#endif
#ifdef SHUTDOWN_SERVER
- SHUTDOWN_SERVER (fileno (to_server));
+ SHUTDOWN_SERVER (fileno (to_server_fp));
#else /* ! SHUTDOWN_SERVER */
- {
-
+ {
+
#ifdef START_RSH_WITH_POPEN_RW
- if (pclose (to_server) == EOF)
+ if (pclose (to_server_fp) == EOF)
#else /* ! START_RSH_WITH_POPEN_RW */
- if (fclose (to_server) == EOF)
+ if (fclose (to_server_fp) == EOF)
#endif /* START_RSH_WITH_POPEN_RW */
- {
- error (1, errno, "closing connection to %s", server_host);
- }
+ {
+ error (1, errno, "closing connection to %s",
+ CVSroot_hostname);
+ }
}
- if (getc (from_server) != EOF)
- error (0, 0, "dying gasps from %s unexpected", server_host);
- else if (ferror (from_server))
- error (0, errno, "reading from %s", server_host);
-
- fclose (from_server);
+ if (! buf_empty_p (from_server)
+ || getc (from_server_fp) != EOF)
+ error (0, 0, "dying gasps from %s unexpected", CVSroot_hostname);
+ else if (ferror (from_server_fp))
+ error (0, errno, "reading from %s", CVSroot_hostname);
+
+ fclose (from_server_fp);
#endif /* SHUTDOWN_SERVER */
- }
-
-#if ! RSH_NOT_TRANSPARENT
+ }
+
if (rsh_pid != -1
&& waitpid (rsh_pid, (int *) 0, 0) == -1)
error (1, errno, "waiting for process %d", rsh_pid);
-#endif /* ! RSH_NOT_TRANSPARENT */
server_started = 0;
+ /* see if we need to sleep before returning */
+ if (last_register_time)
+ {
+ time_t now;
+
+ (void) time (&now);
+ if (now == last_register_time)
+ sleep (1); /* to avoid time-stamp races */
+ }
+
return errs;
}
-#ifndef RSH_NOT_TRANSPARENT
static void start_rsh_server PROTO((int *, int *));
-#endif /* RSH_NOT_TRANSPARENT */
int
supported_request (name)
- char *name;
+ char *name;
{
- struct request *rq;
-
- for (rq = requests; rq->name; rq++)
- if (!strcmp (rq->name, name))
- return rq->status == rq_supported;
- error (1, 0, "internal error: testing support for unknown option?");
- /* NOTREACHED */
- return 0;
+ struct request *rq;
+
+ for (rq = requests; rq->name; rq++)
+ if (!strcmp (rq->name, name))
+ return rq->status == rq_supported;
+ error (1, 0, "internal error: testing support for unknown option?");
+ /* NOTREACHED */
+ return 0;
}
#ifdef AUTH_CLIENT_SUPPORT
-void
+static void init_sockaddr PROTO ((struct sockaddr_in *, char *,
+ unsigned int));
+
+static void
init_sockaddr (name, hostname, port)
struct sockaddr_in *name;
- const char *hostname;
- unsigned short int port;
+ char *hostname;
+ unsigned int port;
{
struct hostent *hostinfo;
+ unsigned short shortport = port;
memset (name, 0, sizeof (*name));
name->sin_family = AF_INET;
- name->sin_port = htons (port);
+ name->sin_port = htons (shortport);
hostinfo = gethostbyname (hostname);
if (hostinfo == NULL)
{
fprintf (stderr, "Unknown host %s.\n", hostname);
- exit (EXIT_FAILURE);
+ error_exit ();
}
name->sin_addr = *(struct in_addr *) hostinfo->h_addr;
}
-int
+static int auth_server_port_number PROTO ((void));
+
+static int
auth_server_port_number ()
{
- return CVS_AUTH_PORT;
+ struct servent *s = getservbyname ("cvspserver", "tcp");
+
+ if (s)
+ return ntohs (s->s_port);
+ else
+ return CVS_AUTH_PORT;
}
@@ -2679,29 +3219,34 @@ connect_to_pserver (tofdp, fromfdp, verify_only)
int port_number;
struct sockaddr_in client_sai;
- /* Does nothing if already called before now. */
- parse_cvsroot ();
-
sock = socket (AF_INET, SOCK_STREAM, 0);
if (sock == -1)
{
fprintf (stderr, "socket() failed\n");
- exit (EXIT_FAILURE);
+ error_exit ();
}
port_number = auth_server_port_number ();
- init_sockaddr (&client_sai, server_host, port_number);
+ init_sockaddr (&client_sai, CVSroot_hostname, port_number);
if (connect (sock, (struct sockaddr *) &client_sai, sizeof (client_sai))
< 0)
- error (1, errno, "connect to %s:%d failed", server_host,
- CVS_AUTH_PORT);
+ error (1, 0, "connect to %s:%d failed: %s", CVSroot_hostname,
+ port_number, SOCK_STRERROR (SOCK_ERRNO));
/* Run the authorization mini-protocol before anything else. */
{
int i;
- char ch, read_buf[PATH_MAX];
+ char ch;
+
+ /* Long enough to hold I LOVE YOU or I HATE YOU. Using a fixed-size
+ buffer seems better than letting an apeshit server chew up our
+ memory with illegal responses, and the value comes from
+ the protocol itself; it is not an arbitrary limit on data sent. */
+#define LARGEST_RESPONSE 80
+ char read_buf[LARGEST_RESPONSE];
+
char *begin = NULL;
- char *repository = server_cvsroot;
- char *username = server_user;
+ char *repository = CVSroot_directory;
+ char *username = CVSroot_username;
char *password = NULL;
char *end = NULL;
@@ -2717,7 +3262,7 @@ connect_to_pserver (tofdp, fromfdp, verify_only)
}
/* Get the password, probably from ~/.cvspass. */
- password = get_cvs_password (server_user, server_host, server_cvsroot);
+ password = get_cvs_password ();
/* Announce that we're starting the authorization protocol. */
send (sock, begin, strlen (begin), 0);
@@ -2747,11 +3292,12 @@ connect_to_pserver (tofdp, fromfdp, verify_only)
* end of both ACK and NACK, and we loop, reading until "\n".
*/
ch = 0;
- memset (read_buf, 0, PATH_MAX);
- for (i = 0; (i < (PATH_MAX - 1)) && (ch != '\n'); i++)
+ memset (read_buf, 0, LARGEST_RESPONSE);
+ for (i = 0; (i < (LARGEST_RESPONSE - 1)) && (ch != '\n'); i++)
{
if (recv (sock, &ch, 1, 0) < 0)
- error (1, errno, "recv() from server %s", server_host);
+ error (1, 0, "recv() from server %s: %s", CVSroot_hostname,
+ SOCK_STRERROR (SOCK_ERRNO));
read_buf[i] = ch;
}
@@ -2763,9 +3309,10 @@ connect_to_pserver (tofdp, fromfdp, verify_only)
{
error (0, 0,
"authorization failed: server %s rejected access",
- server_host);
- error (1, errno,
- "shutdown() failed (server %s)", server_host);
+ CVSroot_hostname);
+ error (1, 0,
+ "shutdown() failed (server %s): %s", CVSroot_hostname,
+ SOCK_STRERROR (SOCK_ERRNO));
}
if (verify_only)
@@ -2773,7 +3320,7 @@ connect_to_pserver (tofdp, fromfdp, verify_only)
else
error (1, 0,
"authorization failed: server %s rejected access",
- server_host);
+ CVSroot_hostname);
}
else if (strcmp (read_buf, "I LOVE YOU\n") != 0)
{
@@ -2782,19 +3329,22 @@ connect_to_pserver (tofdp, fromfdp, verify_only)
{
error (0, 0,
"unrecognized auth response from %s: %s",
- server_host, read_buf);
- error (1, errno, "shutdown() failed, server %s", server_host);
+ CVSroot_hostname, read_buf);
+ error (1, 0,
+ "shutdown() failed, server %s: %s", CVSroot_hostname,
+ SOCK_STRERROR (SOCK_ERRNO));
}
error (1, 0,
"unrecognized auth response from %s: %s",
- server_host, read_buf);
+ CVSroot_hostname, read_buf);
}
}
if (verify_only)
{
if (shutdown (sock, 2) < 0)
- error (0, errno, "shutdown() failed, server %s", server_host);
+ error (0, 0, "shutdown() failed, server %s: %s", CVSroot_hostname,
+ SOCK_STRERROR (SOCK_ERRNO));
return 1;
}
else
@@ -2820,158 +3370,154 @@ connect_to_pserver (tofdp, fromfdp, verify_only)
#endif /* AUTH_CLIENT_SUPPORT */
-#if HAVE_KERBEROS || USE_DIRECT_TCP
+#if HAVE_KERBEROS
/*
* FIXME: this function has not been changed to deal with
* NO_SOCKET_TO_FD (i.e., systems on which sockets cannot be converted
- * to file descriptors. The first person to try building a kerberos
- * client on such a system (OS/2, Windows 95, and maybe others) will
- * have to make take care of this.
+ * to file descriptors) or with SOCK_ERRNO/SOCK_STRERROR. The first
+ * person to try building a kerberos client on such a system (OS/2,
+ * Windows 95, and maybe others) will have to make take care of this.
*/
void
start_tcp_server (tofdp, fromfdp)
- int *tofdp, *fromfdp;
+ int *tofdp, *fromfdp;
{
- int tofd, fromfd;
-
- struct hostent *hp;
- char *hname;
- const char *portenv;
- int port;
- struct sockaddr_in sin;
- int s;
+ int tofd = -1, fromfd;
+ struct hostent *hp;
+ char *hname;
+ const char *portenv;
+ int port;
+ struct sockaddr_in sin;
+ int s;
#if HAVE_KERBEROS
- KTEXT_ST ticket;
- const char *realm;
+ KTEXT_ST ticket;
+ const char *realm;
#endif /* HAVE_KERBEROS */
- int status;
-
- /*
- * We look up the host to give a better error message if it
- * does not exist. However, we then pass server_host to
- * krb_sendauth, rather than the canonical name, because
- * krb_sendauth is going to do its own canonicalization anyhow
- * and that lets us not worry about the static storage used by
- * gethostbyname.
- */
- hp = gethostbyname (server_host);
- if (hp == NULL)
- error (1, 0, "%s: unknown host", server_host);
- hname = xmalloc (strlen (hp->h_name) + 1);
- strcpy (hname, hp->h_name);
+ int status;
+
+ /*
+ * We look up the host to give a better error message if it
+ * does not exist. However, we then pass CVSroot_hostname to
+ * krb_sendauth, rather than the canonical name, because
+ * krb_sendauth is going to do its own canonicalization anyhow
+ * and that lets us not worry about the static storage used by
+ * gethostbyname.
+ */
+ hp = gethostbyname (CVSroot_hostname);
+ if (hp == NULL)
+ error (1, 0, "%s: unknown host", CVSroot_hostname);
+ hname = xmalloc (strlen (hp->h_name) + 1);
+ strcpy (hname, hp->h_name);
#if HAVE_KERBEROS
- realm = krb_realmofhost (hname);
+ realm = krb_realmofhost (hname);
#endif /* HAVE_KERBEROS */
-
- /* Get CVS_CLIENT_PORT or look up cvs/tcp with CVS_PORT as default */
- portenv = getenv ("CVS_CLIENT_PORT");
- if (portenv != NULL)
+
+ /* Get CVS_CLIENT_PORT or look up cvs/tcp with CVS_PORT as default */
+ portenv = getenv ("CVS_CLIENT_PORT");
+ if (portenv != NULL)
{
- port = atoi (portenv);
- if (port <= 0)
- goto try_rsh_no_message;
- if (trace)
- fprintf(stderr, "Using TCP port %d to contact server.\n", port);
- port = htons (port);
+ port = atoi (portenv);
+ if (port <= 0)
+ {
+ error (0, 0, "CVS_CLIENT_PORT must be a positive number! If you");
+ error (0, 0, "are trying to force a connection via rsh, please");
+ error (0, 0, "put \":server:\" at the beginning of your CVSROOT");
+ error (1, 0, "variable.");
+ }
+ if (trace)
+ fprintf(stderr, "Using TCP port %d to contact server.\n", port);
+ port = htons (port);
}
- else
+ else
{
- struct servent *sp;
-
- sp = getservbyname ("cvs", "tcp");
- if (sp == NULL)
- port = htons (CVS_PORT);
- else
- port = sp->s_port;
+ struct servent *sp;
+
+ sp = getservbyname ("cvs", "tcp");
+ if (sp == NULL)
+ port = htons (CVS_PORT);
+ else
+ port = sp->s_port;
}
-
- s = socket (AF_INET, SOCK_STREAM, 0);
- if (s < 0)
- error (1, errno, "socket");
-
- memset (&sin, 0, sizeof sin);
- sin.sin_family = AF_INET;
- sin.sin_addr.s_addr = INADDR_ANY;
- sin.sin_port = 0;
-
- if (bind (s, (struct sockaddr *) &sin, sizeof sin) < 0)
- error (1, errno, "bind");
-
- memcpy (&sin.sin_addr, hp->h_addr, hp->h_length);
- sin.sin_port = port;
-
- tofd = -1;
- if (connect (s, (struct sockaddr *) &sin, sizeof sin) < 0)
+
+ s = socket (AF_INET, SOCK_STREAM, 0);
+ if (s < 0)
+ error (1, errno, "socket");
+
+ memset (&sin, 0, sizeof sin);
+ sin.sin_family = AF_INET;
+ sin.sin_addr.s_addr = INADDR_ANY;
+ sin.sin_port = 0;
+
+ if (bind (s, (struct sockaddr *) &sin, sizeof sin) < 0)
+ error (1, errno, "bind");
+
+ memcpy (&sin.sin_addr, hp->h_addr, hp->h_length);
+ sin.sin_port = port;
+
+ if (connect (s, (struct sockaddr *) &sin, sizeof sin) < 0)
{
- error (0, errno, "connect");
- close (s);
+ error (0, errno, "connect");
+ close (s);
}
- else
+ else
{
#ifdef HAVE_KERBEROS
- struct sockaddr_in laddr;
- int laddrlen;
- MSG_DAT msg_data;
- CREDENTIALS cred;
- Key_schedule sched;
-
- laddrlen = sizeof (laddr);
- if (getsockname (s, (struct sockaddr *) &laddr, &laddrlen) < 0)
- error (1, errno, "getsockname");
-
- /* We don't care about the checksum, and pass it as zero. */
- status = krb_sendauth (KOPT_DO_MUTUAL, s, &ticket, "rcmd",
- hname, realm, (unsigned long) 0, &msg_data,
- &cred, sched, &laddr, &sin, "KCVSV1.0");
- if (status != KSUCCESS)
+ struct sockaddr_in laddr;
+ int laddrlen;
+ MSG_DAT msg_data;
+ CREDENTIALS cred;
+
+ laddrlen = sizeof (laddr);
+ if (getsockname (s, (struct sockaddr *) &laddr, &laddrlen) < 0)
+ error (1, errno, "getsockname");
+
+ /* We don't care about the checksum, and pass it as zero. */
+ status = krb_sendauth (KOPT_DO_MUTUAL, s, &ticket, "rcmd",
+ hname, realm, (unsigned long) 0, &msg_data,
+ &cred, sched, &laddr, &sin, "KCVSV1.0");
+ if (status != KSUCCESS)
{
- error (0, 0, "kerberos: %s", krb_get_err_text(status));
- close (s);
+ error (0, 0, "kerberos: %s", krb_get_err_text(status));
+ close (s);
}
- else
+ else
{
+ memcpy (kblock, cred.session, sizeof (C_Block));
+
#endif /* HAVE_KERBEROS */
- server_fd = s;
- close_on_exec (server_fd);
- tofd = fromfd = s;
+ server_fd = s;
+ close_on_exec (server_fd);
+ tofd = fromfd = s;
#ifdef HAVE_KERBEROS
}
#endif /* HAVE_KERBEROS */
}
- if (tofd == -1)
+ if (tofd == -1)
{
- /* FIXME: Falling back like this is slow and we should probably
- just make it a fatal error (so that people use the right
- environment variables or, when we get around to implementing
- the right ones, access methods). */
- error (0, 0, "trying to start server using rsh");
- try_rsh_no_message:
- server_fd = -1;
-#if ! RSH_NOT_TRANSPARENT
- start_rsh_server (&tofd, &fromfd);
-#else /* RSH_NOT_TRANSPARENT */
-#if defined (START_SERVER)
- START_SERVER (&tofd, &fromfd, getcaller (),
- server_user, server_host, server_cvsroot);
-#endif /* defined (START_SERVER) */
-#endif /* ! RSH_NOT_TRANSPARENT */
+#ifdef HAVE_KERBEROS
+ error (0, 0, "Kerberos connect failed");
+#else
+ error (0, 0, "Direct TCP connect failed");
+#endif
+ error (1, 0, "couldn't connect to remote host %s", CVSroot_hostname);
}
- free (hname);
- /* Give caller the values it wants. */
- *tofdp = tofd;
- *fromfdp = fromfd;
+ free (hname);
+
+ /* Give caller the values it wants. */
+ *tofdp = tofd;
+ *fromfdp = fromfd;
}
-#endif /* HAVE_KERBEROS || USE_DIRECT_TCP */
+#endif /* HAVE_KERBEROS */
static int send_variable_proc PROTO ((Node *, void *));
@@ -2992,80 +3538,77 @@ send_variable_proc (node, closure)
void
start_server ()
{
- int tofd, fromfd;
- char *log = getenv ("CVS_CLIENT_LOG");
+ int tofd, fromfd;
+ char *log = getenv ("CVS_CLIENT_LOG");
- /* Note that generally speaking we do *not* fall back to a different
- way of connecting if the first one does not work. This is slow
- (*really* slow on a 14.4kbps link); the clean way to have a CVS
- which supports several ways of connecting is with access methods. */
+ /* Note that generally speaking we do *not* fall back to a different
+ way of connecting if the first one does not work. This is slow
+ (*really* slow on a 14.4kbps link); the clean way to have a CVS
+ which supports several ways of connecting is with access methods. */
- /* Init these to NULL. They will be set later if logging is on. */
- from_server_logfile = (FILE *) NULL;
- to_server_logfile = (FILE *) NULL;
+ switch (CVSroot_method)
+ {
#ifdef AUTH_CLIENT_SUPPORT
- if (use_authenticating_server)
- {
- /* Toss the return value. It will die with error if anything
- goes wrong anyway. */
- connect_to_pserver (&tofd, &fromfd, 0);
- }
- else
-#endif /* AUTH_CLIENT_SUPPORT */
- {
-#if HAVE_KERBEROS || USE_DIRECT_TCP
- start_tcp_server (&tofd, &fromfd);
-#else
+ case pserver_method:
+ /* Toss the return value. It will die with error if anything
+ goes wrong anyway. */
+ connect_to_pserver (&tofd, &fromfd, 0);
+ break;
+#endif
+
+#if HAVE_KERBEROS
+ case kserver_method:
+ start_tcp_server (&tofd, &fromfd);
+ break;
+#endif
-# if ! RSH_NOT_TRANSPARENT
- start_rsh_server (&tofd, &fromfd);
-# else
+ case ext_method:
+ start_rsh_server (&tofd, &fromfd);
+ break;
-# if defined(START_SERVER)
- START_SERVER (&tofd, &fromfd, getcaller (),
- server_user, server_host, server_cvsroot);
-# endif
+ case server_method:
+#if defined(START_SERVER)
+ START_SERVER (&tofd, &fromfd, getcaller (),
+ CVSroot_username, CVSroot_hostname,
+ CVSroot_directory);
+# if defined (START_SERVER_RETURNS_SOCKET) && defined (NO_SOCKET_TO_FD)
+ /* This is a system on which we can only write to a socket
+ using send/recv. Therefore its START_SERVER needs to
+ return a socket. */
+ use_socket_style = 1;
+ server_sock = tofd;
# endif
+
+#else
+ /* FIXME: It should be possible to implement this portably,
+ like pserver, which would get rid of the duplicated code
+ in {vms,windows-NT,...}/startserver.c. */
+ error (1, 0, "\
+the :server: access method is not supported by this port of CVS");
#endif
- }
+ break;
-#if defined(VMS) && defined(NO_SOCKET_TO_FD)
- /* Avoid mixing sockets with stdio */
- use_socket_style = 1;
- server_sock = tofd;
-#endif /* VMS && NO_SOCKET_TO_FD */
+ default:
+ error (1, 0, "\
+(start_server internal error): unknown access method");
+ break;
+ }
/* "Hi, I'm Darlene and I'll be your server tonight..." */
server_started = 1;
- /* Set up logfiles, if any. */
- if (log)
+#ifdef NO_SOCKET_TO_FD
+ if (use_socket_style)
{
- int len = strlen (log);
- char *buf = xmalloc (len + 5);
- char *p;
-
- strcpy (buf, log);
- p = buf + len;
-
- strcpy (p, ".in");
- to_server_logfile = open_file (buf, "w");
- if (to_server_logfile == NULL)
- error (0, errno, "opening to-server logfile %s", buf);
-
- strcpy (p, ".out");
- from_server_logfile = open_file (buf, "w");
- if (from_server_logfile == NULL)
- error (0, errno, "opening from-server logfile %s", buf);
-
- free (buf);
+ to_server = socket_buffer_initialize (server_sock, 0,
+ buf_memory_error);
+ from_server = socket_buffer_initialize (server_sock, 1,
+ buf_memory_error);
}
-
-#ifdef NO_SOCKET_TO_FD
- if (! use_socket_style)
+ else
#endif /* NO_SOCKET_TO_FD */
- {
+ {
/* todo: some OS's don't need these calls... */
close_on_exec (tofd);
close_on_exec (fromfd);
@@ -3081,26 +3624,65 @@ start_server ()
}
/* These will use binary mode on systems which have it. */
- to_server = fdopen (tofd, FOPEN_BINARY_WRITE);
- if (to_server == NULL)
- error (1, errno, "cannot fdopen %d for write", tofd);
- from_server = fdopen (fromfd, FOPEN_BINARY_READ);
- if (from_server == NULL)
- error (1, errno, "cannot fdopen %d for read", fromfd);
- }
+ to_server_fp = fdopen (tofd, FOPEN_BINARY_WRITE);
+ if (to_server_fp == NULL)
+ error (1, errno, "cannot fdopen %d for write", tofd);
+ to_server = stdio_buffer_initialize (to_server_fp, 0,
+ buf_memory_error);
+
+ from_server_fp = fdopen (fromfd, FOPEN_BINARY_READ);
+ if (from_server_fp == NULL)
+ error (1, errno, "cannot fdopen %d for read", fromfd);
+ from_server = stdio_buffer_initialize (from_server_fp, 1,
+ buf_memory_error);
+ }
+
+ /* Set up logfiles, if any. */
+ if (log)
+ {
+ int len = strlen (log);
+ char *buf = xmalloc (len + 5);
+ char *p;
+ FILE *fp;
+
+ strcpy (buf, log);
+ p = buf + len;
+
+ /* Open logfiles in binary mode so that they reflect
+ exactly what was transmitted and received (that is
+ more important than that they be maximally
+ convenient to view). */
+ strcpy (p, ".in");
+ fp = open_file (buf, "wb");
+ if (fp == NULL)
+ error (0, errno, "opening to-server logfile %s", buf);
+ else
+ to_server = log_buffer_initialize (to_server, fp, 0,
+ buf_memory_error);
+
+ strcpy (p, ".out");
+ fp = open_file (buf, "wb");
+ if (fp == NULL)
+ error (0, errno, "opening from-server logfile %s", buf);
+ else
+ from_server = log_buffer_initialize (from_server, fp, 1,
+ buf_memory_error);
+
+ free (buf);
+ }
/* Clear static variables. */
if (toplevel_repos != NULL)
- free (toplevel_repos);
+ free (toplevel_repos);
toplevel_repos = NULL;
if (last_dir_name != NULL)
- free (last_dir_name);
+ free (last_dir_name);
last_dir_name = NULL;
if (last_repos != NULL)
- free (last_repos);
+ free (last_repos);
last_repos = NULL;
if (last_update_dir != NULL)
- free (last_update_dir);
+ free (last_update_dir);
last_update_dir = NULL;
stored_checksum_valid = 0;
stored_mode_valid = 0;
@@ -3108,7 +3690,7 @@ start_server ()
if (strcmp (command_name, "init") != 0)
{
send_to_server ("Root ", 0);
- send_to_server (server_cvsroot, 0);
+ send_to_server (CVSroot_directory, 0);
send_to_server ("\012", 1);
}
@@ -3127,7 +3709,7 @@ start_server ()
send_to_server ("valid-requests\012", 0);
if (get_server_responses ())
- exit (EXIT_FAILURE);
+ error_exit ();
/*
* Now handle global options.
@@ -3207,9 +3789,55 @@ start_server ()
"This server does not support the global -l option.");
}
}
+ if (cvsencrypt)
+ {
+#ifdef ENCRYPTION
+ /* Turn on encryption before turning on compression. We do
+ not want to try to compress the encrypted stream. Instead,
+ we want to encrypt the compressed stream. If we can't turn
+ on encryption, bomb out; don't let the user think the data
+ is being encrypted when it is not. */
+#ifdef HAVE_KERBEROS
+ if (CVSroot_method == kserver_method)
+ {
+ if (! supported_request ("Kerberos-encrypt"))
+ error (1, 0, "This server does not support encryption");
+ send_to_server ("Kerberos-encrypt\012", 0);
+ to_server = krb_encrypt_buffer_initialize (to_server, 0, sched,
+ kblock,
+ buf_memory_error);
+ from_server = krb_encrypt_buffer_initialize (from_server, 1,
+ sched, kblock,
+ buf_memory_error);
+ }
+ else
+#endif /* HAVE_KERBEROS */
+ error (1, 0, "Encryption is only supported when using Kerberos");
+#else /* ! ENCRYPTION */
+ error (1, 0, "This client does not support encryption");
+#endif /* ! ENCRYPTION */
+ }
if (gzip_level)
{
- if (supported_request ("gzip-file-contents"))
+ if (supported_request ("Gzip-stream"))
+ {
+ char gzip_level_buf[5];
+ send_to_server ("Gzip-stream ", 0);
+ sprintf (gzip_level_buf, "%d", gzip_level);
+ send_to_server (gzip_level_buf, 0);
+ send_to_server ("\012", 1);
+
+ /* All further communication with the server will be
+ compressed. */
+
+ to_server = compress_buffer_initialize (to_server, 0, gzip_level,
+ buf_memory_error);
+ from_server = compress_buffer_initialize (from_server, 1,
+ gzip_level,
+ buf_memory_error);
+ }
+#ifndef NO_CLIENT_GZIP_PROCESS
+ else if (supported_request ("gzip-file-contents"))
{
char gzip_level_buf[5];
send_to_server ("gzip-file-contents ", 0);
@@ -3217,10 +3845,16 @@ start_server ()
send_to_server (gzip_level_buf, 0);
send_to_server ("\012", 1);
+
+ file_gzip_level = gzip_level;
}
+#endif
else
{
fprintf (stderr, "server doesn't support gzip-file-contents\n");
+ /* Setting gzip_level to 0 prevents us from giving the
+ error twice if update has to contact the server again
+ to fetch unpatchable files. */
gzip_level = 0;
}
}
@@ -3239,7 +3873,6 @@ start_server ()
walklist (variable_list, send_variable_proc, NULL);
}
-#ifndef RSH_NOT_TRANSPARENT
/* Contact the server by starting it with rsh. */
/* Right now, we have two different definitions for this function,
@@ -3258,68 +3891,81 @@ start_server ()
static void
start_rsh_server (tofdp, fromfdp)
- int *tofdp, *fromfdp;
+ int *tofdp, *fromfdp;
{
- int pipes[2];
-
- /* If you're working through firewalls, you can set the
- CVS_RSH environment variable to a script which uses rsh to
- invoke another rsh on a proxy machine. */
- char *cvs_rsh = getenv ("CVS_RSH");
- char *cvs_server = getenv ("CVS_SERVER");
- char command[PATH_MAX];
- int i = 0;
- /* This needs to fit "rsh", "-b", "-l", "USER", "host",
- "cmd (w/ args)", and NULL. We leave some room to grow. */
- char *rsh_argv[10];
-
- if (!cvs_rsh)
- cvs_rsh = "rsh";
- if (!cvs_server)
- cvs_server = "cvs";
-
- /* If you are running a very old (Nov 3, 1994, before 1.5)
- * version of the server, you need to make sure that your .bashrc
- * on the server machine does not set CVSROOT to something
- * containing a colon (or better yet, upgrade the server). */
-
- /* The command line starts out with rsh. */
- rsh_argv[i++] = cvs_rsh;
-
+ int pipes[2];
+
+ /* If you're working through firewalls, you can set the
+ CVS_RSH environment variable to a script which uses rsh to
+ invoke another rsh on a proxy machine. */
+ char *cvs_rsh = getenv ("CVS_RSH");
+ char *cvs_server = getenv ("CVS_SERVER");
+ int i = 0;
+ /* This needs to fit "rsh", "-b", "-l", "USER", "host",
+ "cmd (w/ args)", and NULL. We leave some room to grow. */
+ char *rsh_argv[10];
+
+ if (!cvs_rsh)
+ /* People sometimes suggest or assume that this should default
+ to "remsh" on systems like HPUX in which that is the
+ system-supplied name for the rsh program. However, that
+ causes various problems (keep in mind that systems such as
+ HPUX might have non-system-supplied versions of "rsh", like
+ a Kerberized one, which one might want to use). If we
+ based the name on what is found in the PATH of the person
+ who runs configure, that would make it harder to
+ consistently produce the same result in the face of
+ different people producing binary distributions. If we
+ based it on "remsh" always being the default for HPUX
+ (e.g. based on uname), that might be slightly better but
+ would require us to keep track of what the defaults are for
+ each system type, and probably would cope poorly if the
+ existence of remsh or rsh varies from OS version to OS
+ version. Therefore, it seems best to have the default
+ remain "rsh", and tell HPUX users to specify remsh, for
+ example in CVS_RSH or other such mechanisms to be devised,
+ if that is what they want (the manual already tells them
+ that). */
+ cvs_rsh = "rsh";
+ if (!cvs_server)
+ cvs_server = "cvs";
+
+ /* The command line starts out with rsh. */
+ rsh_argv[i++] = cvs_rsh;
+
#ifdef RSH_NEEDS_BINARY_FLAG
- /* "-b" for binary, under OS/2. */
- rsh_argv[i++] = "-b";
+ /* "-b" for binary, under OS/2. */
+ rsh_argv[i++] = "-b";
#endif /* RSH_NEEDS_BINARY_FLAG */
- /* Then we strcat more things on the end one by one. */
- if (server_user != NULL)
+ /* Then we strcat more things on the end one by one. */
+ if (CVSroot_username != NULL)
{
- rsh_argv[i++] = "-l";
- rsh_argv[i++] = server_user;
+ rsh_argv[i++] = "-l";
+ rsh_argv[i++] = CVSroot_username;
}
-
- rsh_argv[i++] = server_host;
- rsh_argv[i++] = cvs_server;
- rsh_argv[i++] = "server";
- /* Mark the end of the arg list. */
- rsh_argv[i] = (char *) NULL;
+ rsh_argv[i++] = CVSroot_hostname;
+ rsh_argv[i++] = cvs_server;
+ rsh_argv[i++] = "server";
+
+ /* Mark the end of the arg list. */
+ rsh_argv[i] = (char *) NULL;
- if (trace)
+ if (trace)
{
- fprintf (stderr, " -> Starting server: ");
- fprintf (stderr, "%s", command);
- putc ('\n', stderr);
+ fprintf (stderr, " -> Starting server: ");
+ putc ('\n', stderr);
}
-
- /* Do the deed. */
- rsh_pid = popenRW (rsh_argv, pipes);
- if (rsh_pid < 0)
- error (1, errno, "cannot start server via rsh");
-
- /* Give caller the file descriptors. */
- *tofdp = pipes[0];
- *fromfdp = pipes[1];
+
+ /* Do the deed. */
+ rsh_pid = popenRW (rsh_argv, pipes);
+ if (rsh_pid < 0)
+ error (1, errno, "cannot start server via rsh");
+
+ /* Give caller the file descriptors. */
+ *tofdp = pipes[0];
+ *fromfdp = pipes[1];
}
#else /* ! START_RSH_WITH_POPEN_RW */
@@ -3346,7 +3992,7 @@ start_rsh_server (tofdp, fromfdp)
versions of rsh that grab switches out of the middle of the
command (they're calling the GNU getopt routines incorrectly). */
command = xmalloc (strlen (cvs_server)
- + strlen (server_cvsroot)
+ + strlen (CVSroot_directory)
+ 50);
/* If you are running a very old (Nov 3, 1994, before 1.5)
@@ -3360,15 +4006,15 @@ start_rsh_server (tofdp, fromfdp)
char **p = argv;
*p++ = cvs_rsh;
- *p++ = server_host;
+ *p++ = CVSroot_hostname;
/* If the login names differ between client and server
* pass it on to rsh.
*/
- if (server_user != NULL)
+ if (CVSroot_username != NULL)
{
*p++ = "-l";
- *p++ = server_user;
+ *p++ = CVSroot_username;
}
*p++ = command;
@@ -3388,10 +4034,10 @@ start_rsh_server (tofdp, fromfdp)
if (rsh_pid < 0)
error (1, errno, "cannot start server via rsh");
}
+ free (command);
}
#endif /* START_RSH_WITH_POPEN_RW */
-#endif /* ! RSH_NOT_TRANSPARENT */
@@ -3423,6 +4069,10 @@ send_arg (string)
static void send_modified PROTO ((char *, char *, Vers_TS *));
+/* VERS->OPTIONS specifies whether the file is binary or not. NOTE: BEFORE
+ using any other fields of the struct vers, we would need to fix
+ client_process_import_file to set them up. */
+
static void
send_modified (file, short_pathname, vers)
char *file;
@@ -3437,8 +4087,11 @@ send_modified (file, short_pathname, vers)
int bufsize;
int bin;
+ if (trace)
+ (void) fprintf (stderr, " -> Sending file `%s' to server\n", file);
+
/* Don't think we can assume fstat exists. */
- if (stat (file, &sb) < 0)
+ if ( CVS_STAT (file, &sb) < 0)
error (1, errno, "reading %s", short_pathname);
mode_string = mode_to_string (sb.st_mode);
@@ -3459,25 +4112,43 @@ send_modified (file, short_pathname, vers)
else
bin = 0;
- fd = open (file, O_RDONLY | (bin ? OPEN_BINARY : 0));
+#ifdef BROKEN_READWRITE_CONVERSION
+ if (!bin)
+ {
+ /* If only stdio, not open/write/etc., do text/binary
+ conversion, use convert_file which can compensate
+ (FIXME: we could just use stdio instead which would
+ avoid the whole problem). */
+ char tfile[1024]; strcpy(tfile, file); strcat(tfile, ".CVSBFCTMP");
+ convert_file (file, O_RDONLY,
+ tfile, O_WRONLY | O_CREAT | O_TRUNC | OPEN_BINARY);
+ fd = CVS_OPEN (tfile, O_RDONLY | OPEN_BINARY);
+ if (fd < 0)
+ error (1, errno, "reading %s", short_pathname);
+ }
+ else
+ fd = CVS_OPEN (file, O_RDONLY | OPEN_BINARY);
+#else
+ fd = CVS_OPEN (file, O_RDONLY | (bin ? OPEN_BINARY : 0));
+#endif
if (fd < 0)
error (1, errno, "reading %s", short_pathname);
- if (gzip_level && sb.st_size > 100)
+ if (file_gzip_level && sb.st_size > 100)
{
int nread, newsize = 0, gzip_status;
pid_t gzip_pid;
char *bufp = buf;
int readsize = 8192;
#ifdef LINES_CRLF_TERMINATED
- char tempfile[L_tmpnam];
+ char *tempfile;
int converting;
#endif /* LINES_CRLF_TERMINATED */
#ifdef LINES_CRLF_TERMINATED
- /* Assume everything in a "cvs import" is text. */
if (vers == NULL)
+ /* "Can't happen". */
converting = 1;
else
/* Otherwise, we convert things unless they're binary. */
@@ -3503,7 +4174,7 @@ send_modified (file, short_pathname, vers)
if (close (fd) < 0)
error (0, errno, "warning: can't close %s", short_pathname);
- tmpnam (tempfile);
+ tempfile = cvs_temp_name ();
convert_file (file, O_RDONLY,
tempfile,
O_WRONLY | O_CREAT | O_TRUNC | OPEN_BINARY);
@@ -3513,13 +4184,13 @@ send_modified (file, short_pathname, vers)
do remember something obscure in the manuals about propagating
the translation mode to created processes via environment
variables, ick. */
- fd = open (tempfile, O_RDONLY | OPEN_BINARY);
+ fd = CVS_OPEN (tempfile, O_RDONLY | OPEN_BINARY);
if (fd < 0)
error (1, errno, "reading %s", short_pathname);
}
#endif /* LINES_CRLF_TERMINATED */
- fd = filter_through_gzip (fd, 1, gzip_level, &gzip_pid);
+ fd = filter_through_gzip (fd, 1, file_gzip_level, &gzip_pid);
/* FIXME: is there any reason to go through all this realloc'ing
when we could just be writing the data to the network as we read
@@ -3558,9 +4229,11 @@ send_modified (file, short_pathname, vers)
#if LINES_CRLF_TERMINATED
if (converting)
{
- if (unlink (tempfile) < 0)
+ if ( CVS_UNLINK (tempfile) < 0)
error (0, errno,
"warning: can't remove temp file %s", tempfile);
+ free (tempfile);
+ tempfile = NULL;
}
#endif /* LINES_CRLF_TERMINATED */
@@ -3613,48 +4286,80 @@ send_modified (file, short_pathname, vers)
sprintf (tmp, "%lu\012", (unsigned long) newsize);
send_to_server (tmp, 0);
}
+#ifdef BROKEN_READWRITE_CONVERSION
+ if (!bin)
+ {
+ char tfile[1024]; strcpy(tfile, file); strcat(tfile, ".CVSBFCTMP");
+ if (CVS_UNLINK (tfile) < 0)
+ error (0, errno, "warning: can't remove temp file %s", tfile);
+ }
+#endif
/*
* Note that this only ends with a newline if the file ended with
* one.
*/
if (newsize > 0)
- send_to_server (buf, newsize);
+ send_to_server (buf, newsize);
}
free (buf);
free (mode_string);
}
-static int send_fileproc PROTO ((struct file_info *finfo));
+/* The address of an instance of this structure is passed to
+ send_fileproc, send_filesdoneproc, and send_direntproc, as the
+ callerdat parameter. */
+
+struct send_data
+{
+ /* Each of the following flags are zero for clear or nonzero for set. */
+ int build_dirs;
+ int force;
+ int no_contents;
+};
+
+static int send_fileproc PROTO ((void *callerdat, struct file_info *finfo));
/* Deal with one file. */
static int
-send_fileproc (finfo)
+send_fileproc (callerdat, finfo)
+ void *callerdat;
struct file_info *finfo;
{
+ struct send_data *args = (struct send_data *) callerdat;
Vers_TS *vers;
+ struct file_info xfinfo;
+ /* File name to actually use. Might differ in case from
+ finfo->file. */
+ char *filename;
send_a_repository ("", finfo->repository, finfo->update_dir);
- vers = Version_TS ((char *)NULL, (char *)NULL, (char *)NULL,
- (char *)NULL,
- finfo->file, 0, 0, finfo->entries, (RCSNode *)NULL);
+ xfinfo = *finfo;
+ xfinfo.repository = NULL;
+ xfinfo.rcs = NULL;
+ vers = Version_TS (&xfinfo, NULL, NULL, NULL, 0, 0);
+
+ if (vers->entdata != NULL)
+ filename = vers->entdata->user;
+ else
+ filename = finfo->file;
if (vers->vn_user != NULL)
{
- char *tmp;
-
- tmp = xmalloc (strlen (finfo->file) + strlen (vers->vn_user)
- + strlen (vers->options) + 200);
- sprintf (tmp, "Entry /%s/%s/%s%s/%s/",
- finfo->file, vers->vn_user,
- vers->ts_conflict == NULL ? "" : "+",
- (vers->ts_conflict == NULL ? ""
- : (vers->ts_user != NULL &&
- strcmp (vers->ts_conflict, vers->ts_user) == 0
- ? "="
- : "modified")),
- vers->options);
+ char *tmp;
+
+ tmp = xmalloc (strlen (filename) + strlen (vers->vn_user)
+ + strlen (vers->options) + 200);
+ sprintf (tmp, "Entry /%s/%s/%s%s/%s/",
+ filename, vers->vn_user,
+ vers->ts_conflict == NULL ? "" : "+",
+ (vers->ts_conflict == NULL ? ""
+ : (vers->ts_user != NULL &&
+ strcmp (vers->ts_conflict, vers->ts_user) == 0
+ ? "="
+ : "modified")),
+ vers->options);
/* The Entries request. */
/* Not sure about whether this deals with -k and stuff right. */
@@ -3679,33 +4384,28 @@ send_fileproc (finfo)
* Do we want to print "file was lost" like normal CVS?
* Would it always be appropriate?
*/
- /* File no longer exists. */
- if (!use_unchanged)
- {
- /* if the server is old, use the old request... */
- send_to_server ("Lost ", 0);
- send_to_server (finfo->file, 0);
- send_to_server ("\012", 1);
- /*
- * Otherwise, don't do anything for missing files,
- * they just happen.
- */
- }
+ /* File no longer exists. Don't do anything, missing files
+ just happen. */
}
else if (vers->ts_rcs == NULL
+ || args->force
|| strcmp (vers->ts_user, vers->ts_rcs) != 0)
{
- send_modified (finfo->file, finfo->fullname, vers);
+ if (args->no_contents
+ && supported_request ("Is-modified"))
+ {
+ send_to_server ("Is-modified ", 0);
+ send_to_server (filename, 0);
+ send_to_server ("\012", 1);
+ }
+ else
+ send_modified (filename, finfo->fullname, vers);
}
else
{
- /* Only use this request if the server supports it... */
- if (use_unchanged)
- {
- send_to_server ("Unchanged ", 0);
- send_to_server (finfo->file, 0);
- send_to_server ("\012", 1);
- }
+ send_to_server ("Unchanged ", 0);
+ send_to_server (filename, 0);
+ send_to_server ("\012", 1);
}
/* if this directory has an ignore list, add this file to it */
@@ -3745,25 +4445,27 @@ send_ignproc (file, dir)
}
}
-static int send_filesdoneproc PROTO ((int, char *, char *));
+static int send_filesdoneproc PROTO ((void *, int, char *, char *, List *));
static int
-send_filesdoneproc (err, repository, update_dir)
+send_filesdoneproc (callerdat, err, repository, update_dir, entries)
+ void *callerdat;
int err;
char *repository;
char *update_dir;
+ List *entries;
{
/* if this directory has an ignore list, process it then free it */
if (ignlist)
{
- ignore_files (ignlist, update_dir, send_ignproc);
+ ignore_files (ignlist, entries, update_dir, send_ignproc);
dellist (&ignlist);
}
return (err);
}
-static Dtype send_dirent_proc PROTO ((char *, char *, char *));
+static Dtype send_dirent_proc PROTO ((void *, char *, char *, char *, List *));
/*
* send_dirent_proc () is called back by the recursion processor before a
@@ -3774,20 +4476,18 @@ static Dtype send_dirent_proc PROTO ((char *, char *, char *));
*
*/
static Dtype
-send_dirent_proc (dir, repository, update_dir)
+send_dirent_proc (callerdat, dir, repository, update_dir, entries)
+ void *callerdat;
char *dir;
char *repository;
char *update_dir;
+ List *entries;
{
+ struct send_data *args = (struct send_data *) callerdat;
int dir_exists;
+ char *cvsadm_name;
char *cvsadm_repos_name;
- /*
- * If the directory does not exist yet (e.g. "cvs update -d
- * foo"), no need to send any files from it.
- */
- dir_exists = isdir (dir);
-
if (ignore_directory (update_dir))
{
/* print the warm fuzzy message */
@@ -3796,6 +4496,19 @@ send_dirent_proc (dir, repository, update_dir)
return (R_SKIP_ALL);
}
+ /*
+ * If the directory does not exist yet (e.g. "cvs update -d foo"),
+ * no need to send any files from it. If the directory does not
+ * have a CVS directory, then we pretend that it does not exist.
+ * Otherwise, we will fail when trying to open the Entries file.
+ * This case will happen when checking out a module defined as
+ * ``-a .''.
+ */
+ cvsadm_name = xmalloc (strlen (dir) + sizeof (CVSADM) + 10);
+ sprintf (cvsadm_name, "%s/%s", dir, CVSADM);
+ dir_exists = isdir (cvsadm_name);
+ free (cvsadm_name);
+
/* initialize the ignore list for this directory */
ignlist = getlist ();
@@ -3818,7 +4531,14 @@ send_dirent_proc (dir, repository, update_dir)
free (repos);
}
else
- send_a_repository (dir, repository, update_dir);
+ {
+ /* Don't send a non-existent directory unless we are building
+ new directories (build_dirs is true). Otherwise, CVS may
+ see a D line in an Entries file, and recreate a directory
+ which the user removed by hand. */
+ if (dir_exists || args->build_dirs)
+ send_a_repository (dir, repository, update_dir);
+ }
free (cvsadm_repos_name);
return (dir_exists ? R_PROCESS : R_SKIP_ALL);
@@ -3826,27 +4546,35 @@ send_dirent_proc (dir, repository, update_dir)
/*
* Send each option in a string to the server, one by one.
- * This assumes that the options are single characters. For
- * more complex parsing, do it yourself.
+ * This assumes that the options are separated by spaces, for example
+ * STRING might be "--foo -C5 -y".
*/
void
send_option_string (string)
char *string;
{
+ char *copy;
char *p;
- char it[3];
-
- for (p = string; p[0]; p++) {
- if (p[0] == ' ')
- continue;
- if (p[0] == '-')
- continue;
- it[0] = '-';
- it[1] = p[0];
- it[2] = '\0';
- send_arg (it);
+
+ copy = xstrdup (string);
+ p = copy;
+ while (1)
+ {
+ char *s;
+ char l;
+
+ for (s = p; *s != ' ' && *s != '\0'; s++)
+ ;
+ l = *s;
+ *s = '\0';
+ if (s != p)
+ send_arg (p);
+ if (l == '\0')
+ break;
+ p = s + 1;
}
+ free (copy);
}
@@ -3859,8 +4587,6 @@ send_file_names (argc, argv, flags)
unsigned int flags;
{
int i;
- char *p;
- char *q;
int level;
int max_level;
@@ -3873,25 +4599,9 @@ send_file_names (argc, argv, flags)
max_level = 0;
for (i = 0; i < argc; ++i)
{
- p = argv[i];
- level = 0;
- do
- {
- q = strchr (p, '/');
- if (q != NULL)
- ++q;
- if (p[0] == '.' && p[1] == '.' && (p[2] == '\0' || p[2] == '/'))
- {
- --level;
- if (-level > max_level)
- max_level = -level;
- }
- else if (p[0] == '.' && (p[1] == '\0' || p[1] == '/'))
- ;
- else
- ++level;
- p = q;
- } while (p != NULL);
+ level = pathname_levels (argv[i]);
+ if (level > max_level)
+ max_level = level;
}
if (max_level > 0)
{
@@ -3918,6 +4628,46 @@ send_file_names (argc, argv, flags)
{
char buf[1];
char *p = argv[i];
+ char *line = NULL;
+
+#ifdef FILENAMES_CASE_INSENSITIVE
+ /* We want to send the file name as it appears
+ in CVS/Entries. We put this inside an ifdef
+ to avoid doing all these system calls in
+ cases where fncmp is just strcmp anyway. */
+ /* For now just do this for files in the local
+ directory. Would be nice to handle the
+ non-local case too, though. */
+ /* The isdir check could more gracefully be replaced
+ with a way of having Entries_Open report back the
+ error to us and letting us ignore existence_error.
+ Or some such. */
+ if (p == last_component (p) && isdir (CVSADM))
+ {
+ List *entries;
+ Node *node;
+
+ /* If we were doing non-local directory,
+ we would save_cwd, CVS_CHDIR
+ like in update.c:isemptydir. */
+ /* Note that if we are adding a directory,
+ the following will read the entry
+ that we just wrote there, that is, we
+ will get the case specified on the
+ command line, not the case of the
+ directory in the filesystem. This
+ is correct behavior. */
+ entries = Entries_Open (0);
+ node = findnode_fn (entries, p);
+ if (node != NULL)
+ {
+ line = xstrdup (node->key);
+ p = line;
+ delnode (node);
+ }
+ Entries_Close (entries);
+ }
+#endif /* FILENAMES_CASE_INSENSITIVE */
send_to_server ("Argument ", 0);
@@ -3940,6 +4690,8 @@ send_file_names (argc, argv, flags)
++p;
}
send_to_server ("\012", 1);
+ if (line != NULL)
+ free (line);
}
if (flags & SEND_EXPAND_WILD)
@@ -3952,20 +4704,24 @@ send_file_names (argc, argv, flags)
}
-/*
- * Send Repository, Modified and Entry. argc and argv contain only
- * the files to operate on (or empty for everything), not options.
- * local is nonzero if we should not recurse (-l option). Also sends
- * Argument lines for argc and argv, so should be called after options
- * are sent.
- */
+/* Send Repository, Modified and Entry. argc and argv contain only
+ the files to operate on (or empty for everything), not options.
+ local is nonzero if we should not recurse (-l option). flags &
+ SEND_BUILD_DIRS is nonzero if nonexistent directories should be
+ sent. flags & SEND_FORCE is nonzero if we should send unmodified
+ files to the server as though they were modified. flags &
+ SEND_NO_CONTENTS means that this command only needs to know
+ _whether_ a file is modified, not the contents. Also sends Argument
+ lines for argc and argv, so should be called after options are sent. */
void
-send_files (argc, argv, local, aflag)
+send_files (argc, argv, local, aflag, flags)
int argc;
char **argv;
int local;
int aflag;
+ unsigned int flags;
{
+ struct send_data args;
int err;
/*
@@ -3973,12 +4729,15 @@ send_files (argc, argv, local, aflag)
* But we don't actually use it, so I don't think it matters what we pass
* for aflag here.
*/
+ args.build_dirs = flags & SEND_BUILD_DIRS;
+ args.force = flags & SEND_FORCE;
+ args.no_contents = flags & SEND_NO_CONTENTS;
err = start_recursion
(send_fileproc, send_filesdoneproc,
- send_dirent_proc, (DIRLEAVEPROC)NULL,
- argc, argv, local, W_LOCAL, aflag, 0, (char *)NULL, 0, 0);
+ send_dirent_proc, (DIRLEAVEPROC)NULL, (void *) &args,
+ argc, argv, local, W_LOCAL, aflag, 0, (char *)NULL, 0);
if (err)
- exit (EXIT_FAILURE);
+ error_exit ();
if (toplevel_repos == NULL)
/*
* This happens if we are not processing any files,
@@ -3987,7 +4746,7 @@ send_files (argc, argv, local, aflag)
* latter case; I don't think toplevel_repos matters for the
* former.
*/
- toplevel_repos = xstrdup (server_cvsroot);
+ toplevel_repos = xstrdup (CVSroot_directory);
send_repository ("", toplevel_repos, ".");
}
@@ -4003,36 +4762,56 @@ client_import_setup (repository)
* Process the argument import file.
*/
int
-client_process_import_file (message, vfile, vtag, targc, targv, repository)
+client_process_import_file (message, vfile, vtag, targc, targv, repository,
+ all_files_binary)
char *message;
char *vfile;
char *vtag;
int targc;
char *targv[];
char *repository;
+ int all_files_binary;
{
- char *short_pathname;
- int first_time;
-
- /* FIXME: I think this is always false now that we call
- client_import_setup at the start. */
-
- first_time = toplevel_repos == NULL;
+ char *update_dir;
+ char *fullname;
+ Vers_TS vers;
- if (first_time)
- send_a_repository ("", repository, "");
+ assert (toplevel_repos != NULL);
if (strncmp (repository, toplevel_repos, strlen (toplevel_repos)) != 0)
error (1, 0,
"internal error: pathname `%s' doesn't specify file in `%s'",
repository, toplevel_repos);
- short_pathname = repository + strlen (toplevel_repos) + 1;
- if (!first_time)
+ if (strcmp (repository, toplevel_repos) == 0)
+ {
+ update_dir = "";
+ fullname = xstrdup (vfile);
+ }
+ else
+ {
+ update_dir = repository + strlen (toplevel_repos) + 1;
+
+ fullname = xmalloc (strlen (vfile) + strlen (update_dir) + 10);
+ strcpy (fullname, update_dir);
+ strcat (fullname, "/");
+ strcat (fullname, vfile);
+ }
+
+ send_a_repository ("", repository, update_dir);
+ if (all_files_binary)
+ {
+ vers.options = xmalloc (4); /* strlen("-kb") + 1 */
+ strcpy (vers.options, "-kb");
+ }
+ else
{
- send_a_repository ("", repository, short_pathname);
+ vers.options = wrap_rcsoption (vfile, 1);
}
- send_modified (vfile, short_pathname, NULL);
+ send_modified (vfile, fullname, &vers);
+ if (vers.options != NULL)
+ free (vers.options);
+ free (fullname);
return 0;
}
@@ -4049,7 +4828,7 @@ client_import_done ()
*/
/* FIXME: "can't happen" now that we call client_import_setup
at the beginning. */
- toplevel_repos = xstrdup (server_cvsroot);
+ toplevel_repos = xstrdup (CVSroot_directory);
send_repository ("", toplevel_repos, ".");
}
@@ -4092,9 +4871,10 @@ notified_a_file (data, ent_list, short_pathname, filename)
{
if (feof (fp))
{
+ free (line);
if (fclose (fp) < 0)
error (0, errno, "cannot close %s", CVSADM_NOTIFY);
- if (unlink (CVSADM_NOTIFY) < 0)
+ if ( CVS_UNLINK (CVSADM_NOTIFY) < 0)
error (0, errno, "cannot remove %s", CVSADM_NOTIFY);
return;
}
@@ -4134,6 +4914,7 @@ notified_a_file (data, ent_list, short_pathname, filename)
error (0, errno, "cannot close %s", CVSADM_NOTIFYTMP);
goto error_exit;
}
+ free (line);
if (fclose (fp) < 0)
{
error (0, errno, "cannot close %s", CVSADM_NOTIFY);
@@ -4152,6 +4933,7 @@ notified_a_file (data, ent_list, short_pathname, filename)
error2:
(void) fclose (newf);
error_exit:
+ free (line);
(void) fclose (fp);
}
@@ -4234,257 +5016,13 @@ client_senddate (date)
option_with_arg ("-D", buf);
}
-int
-client_commit (argc, argv)
- int argc;
- char **argv;
-{
- parse_cvsroot ();
-
- return commit (argc, argv);
-}
-
-int
-client_update (argc, argv)
- int argc;
- char **argv;
-{
- parse_cvsroot ();
-
- return update (argc, argv);
-}
-
-int
-client_checkout (argc, argv)
- int argc;
- char **argv;
-{
- parse_cvsroot ();
-
- return checkout (argc, argv);
-}
-
-int
-client_diff (argc, argv)
- int argc;
- char **argv;
-{
- parse_cvsroot ();
-
- return diff (argc, argv); /* Call real code */
-}
-
-int
-client_status (argc, argv)
- int argc;
- char **argv;
-{
- parse_cvsroot ();
- return status (argc, argv);
-}
-
-int
-client_log (argc, argv)
- int argc;
- char **argv;
-{
-
- parse_cvsroot ();
-
- return cvslog (argc, argv); /* Call real code */
-}
-
-int
-client_add (argc, argv)
- int argc;
- char **argv;
-{
-
- parse_cvsroot ();
-
- return add (argc, argv); /* Call real code */
-}
-
-int
-client_remove (argc, argv)
- int argc;
- char **argv;
-{
-
- parse_cvsroot ();
-
- return cvsremove (argc, argv); /* Call real code */
-}
-
-int
-client_rdiff (argc, argv)
- int argc;
- char **argv;
-{
-
- parse_cvsroot ();
-
- return patch (argc, argv); /* Call real code */
-}
-
-int
-client_tag (argc, argv)
- int argc;
- char **argv;
-{
-
- parse_cvsroot ();
-
- return tag (argc, argv); /* Call real code */
-}
-
-int
-client_rtag (argc, argv)
- int argc;
- char **argv;
-{
-
- parse_cvsroot ();
-
- return rtag (argc, argv); /* Call real code */
-}
-
-int
-client_import (argc, argv)
- int argc;
- char **argv;
-{
-
- parse_cvsroot ();
-
- return import (argc, argv); /* Call real code */
-}
-
-int
-client_admin (argc, argv)
- int argc;
- char **argv;
-{
-
- parse_cvsroot ();
-
- return admin (argc, argv); /* Call real code */
-}
-
-int
-client_export (argc, argv)
- int argc;
- char **argv;
-{
-
- parse_cvsroot ();
-
- return checkout (argc, argv); /* Call real code */
-}
-
-int
-client_history (argc, argv)
- int argc;
- char **argv;
-{
-
- parse_cvsroot ();
-
- return history (argc, argv); /* Call real code */
-}
-
-int
-client_release (argc, argv)
- int argc;
- char **argv;
-{
-
- parse_cvsroot ();
-
- return release (argc, argv); /* Call real code */
-}
-
-int
-client_watch (argc, argv)
- int argc;
- char **argv;
-{
-
- parse_cvsroot ();
-
- return watch (argc, argv); /* Call real code */
-}
-
-int
-client_watchers (argc, argv)
- int argc;
- char **argv;
-{
-
- parse_cvsroot ();
-
- return watchers (argc, argv); /* Call real code */
-}
-
-int
-client_editors (argc, argv)
- int argc;
- char **argv;
-{
-
- parse_cvsroot ();
-
- return editors (argc, argv); /* Call real code */
-}
-
-int
-client_edit (argc, argv)
- int argc;
- char **argv;
-{
-
- parse_cvsroot ();
-
- return edit (argc, argv); /* Call real code */
-}
-
-int
-client_unedit (argc, argv)
- int argc;
- char **argv;
-{
-
- parse_cvsroot ();
-
- return unedit (argc, argv); /* Call real code */
-}
-
void
send_init_command ()
{
- /* This is here because we need the server_cvsroot variable. */
+ /* This is here because we need the CVSroot_directory variable. */
send_to_server ("init ", 0);
- send_to_server (server_cvsroot, 0);
+ send_to_server (CVSroot_directory, 0);
send_to_server ("\012", 0);
}
-int
-client_init (argc, argv)
- int argc;
- char **argv;
-{
- parse_cvsroot ();
-
- return init (argc, argv); /* Call real code */
-}
-
-int
-client_annotate (argc, argv)
- int argc;
- char **argv;
-{
- parse_cvsroot ();
-
- return annotate (argc, argv); /* Call real code */
-}
#endif /* CLIENT_SUPPORT */
diff --git a/contrib/cvs/src/client.h b/contrib/cvs/src/client.h
index b238c32..1f9c27f 100644
--- a/contrib/cvs/src/client.h
+++ b/contrib/cvs/src/client.h
@@ -5,45 +5,27 @@ extern char *mode_to_string PROTO((mode_t));
extern int change_mode PROTO((char *, char *));
extern int gzip_level;
+extern int file_gzip_level;
extern int filter_through_gzip PROTO((int, int, int, pid_t *));
extern int filter_through_gunzip PROTO((int, int, pid_t *));
-#ifdef CLIENT_SUPPORT
-/*
- * Functions to perform CVS commands via the protocol. argc and argv
- * are the arguments and the return value is the exit status (zero success
- * nonzero failure).
- */
-extern int client_commit PROTO((int argc, char **argv));
-extern int client_update PROTO((int argc, char **argv));
-extern int client_checkout PROTO((int argc, char **argv));
-extern int client_diff PROTO((int argc, char **argv));
-extern int client_log PROTO((int argc, char **argv));
-extern int client_add PROTO((int argc, char **argv));
-extern int client_remove PROTO((int argc, char **argv));
-extern int client_status PROTO((int argc, char **argv));
-extern int client_rdiff PROTO((int argc, char **argv));
-extern int client_tag PROTO((int argc, char **argv));
-extern int client_rtag PROTO((int argc, char **argv));
-extern int client_import PROTO((int argc, char **argv));
-extern int client_admin PROTO((int argc, char **argv));
-extern int client_export PROTO((int argc, char **argv));
-extern int client_history PROTO((int argc, char **argv));
-extern int client_release PROTO((int argc, char **argv));
-extern int client_watch PROTO((int argc, char **argv));
-extern int client_watchers PROTO((int argc, char **argv));
-extern int client_editors PROTO((int argc, char **argv));
-extern int client_edit PROTO((int argc, char **argv));
-extern int client_unedit PROTO((int argc, char **argv));
-extern int client_init PROTO ((int argc, char **argv));
-extern int client_annotate PROTO ((int argc, char **argv));
+#if defined (CLIENT_SUPPORT) || defined (SERVER_SUPPORT)
-/*
- * Flag variable for seeing whether common code is running as a client
- * or to do a local operation.
- */
-extern int client_active;
+extern int cvsencrypt;
+
+#ifdef ENCRYPTION
+#ifdef HAVE_KERBEROS
+
+/* We can't declare the arguments without including krb.h, and I don't
+ want to do that in every file. */
+extern struct buffer *krb_encrypt_buffer_initialize ();
+
+#endif /* HAVE_KERBEROS */
+#endif /* ENCRYPTION */
+#endif /* defined (CLIENT_SUPPORT) || defined (SERVER_SUPPORT) */
+
+#ifdef CLIENT_SUPPORT
/*
* Flag variable for seeing whether the server has been started yet.
* As of this writing, only edit.c:notify_check() uses it.
@@ -62,7 +44,11 @@ int connect_to_pserver PROTO((int *tofdp, int* fromfdp, int verify_only));
#endif /* AUTH_CLIENT_SUPPORT */
#ifdef AUTH_SERVER_SUPPORT
-extern void authenticate_connection PROTO ((void));
+extern void pserver_authenticate_connection PROTO ((void));
+#endif
+
+#if defined (SERVER_SUPPORT) && defined (HAVE_KERBEROS)
+extern void kserver_authenticate_connection PROTO ((void));
#endif
/* Talking to the server. */
@@ -96,16 +82,13 @@ send_file_names PROTO((int argc, char **argv, unsigned int flags));
* local is nonzero if we should not recurse (-l option).
*/
void
-send_files PROTO((int argc, char **argv, int local, int aflag));
+send_files PROTO((int argc, char **argv, int local, int aflag,
+ unsigned int flags));
-/*
- * Like send_files but never send "Unchanged"--just send the contents of the
- * file in that case. This is used to fix it if you import a directory which
- * happens to have CVS directories (yes it is obscure but the testsuite tests
- * it).
- */
-void
-send_files_contents PROTO((int argc, char **argv, int local, int aflag));
+/* Flags for send_files. */
+#define SEND_BUILD_DIRS 1
+#define SEND_FORCE 2
+#define SEND_NO_CONTENTS 4
/* Send an argument to the remote server. */
void
@@ -174,18 +157,19 @@ extern struct response responses[];
extern void client_senddate PROTO((const char *date));
extern void client_expand_modules PROTO((int argc, char **argv, int local));
-extern void client_send_expansions PROTO((int local));
+extern void client_send_expansions PROTO((int local, char *where,
+ int build_dirs));
extern void client_nonexpanded_setup PROTO((void));
extern void send_init_command PROTO ((void));
extern char **failed_patches;
extern int failed_patches_count;
-extern char toplevel_wd[];
+extern char *toplevel_wd;
extern void client_import_setup PROTO((char *repository));
extern int client_process_import_file
PROTO((char *message, char *vfile, char *vtag,
- int targc, char *targv[], char *repository));
+ int targc, char *targv[], char *repository, int all_files_binary));
extern void client_import_done PROTO((void));
extern void client_notify PROTO((char *, char *, char *, int, char *));
#endif /* CLIENT_SUPPORT */
diff --git a/contrib/cvs/src/commit.c b/contrib/cvs/src/commit.c
index ac81790..c0c3597 100644
--- a/contrib/cvs/src/commit.c
+++ b/contrib/cvs/src/commit.c
@@ -14,37 +14,47 @@
*
*/
+#include <assert.h>
#include "cvs.h"
#include "getline.h"
#include "edit.h"
#include "fileattr.h"
-static Dtype check_direntproc PROTO((char *dir, char *repos, char *update_dir));
-static int check_fileproc PROTO((struct file_info *finfo));
-static int check_filesdoneproc PROTO((int err, char *repos, char *update_dir));
+static Dtype check_direntproc PROTO ((void *callerdat, char *dir,
+ char *repos, char *update_dir,
+ List *entries));
+static int check_fileproc PROTO ((void *callerdat, struct file_info *finfo));
+static int check_filesdoneproc PROTO ((void *callerdat, int err,
+ char *repos, char *update_dir,
+ List *entries));
static int checkaddfile PROTO((char *file, char *repository, char *tag,
char *options, RCSNode **rcsnode));
-static Dtype commit_direntproc PROTO((char *dir, char *repos, char *update_dir));
-static int commit_dirleaveproc PROTO((char *dir, int err, char *update_dir));
-static int commit_fileproc PROTO((struct file_info *finfo));
-static int commit_filesdoneproc PROTO((int err, char *repository, char *update_dir));
-static int finaladd PROTO((char *file, char *revision, char *tag,
- char *options, char *update_dir,
- char *repository, List *entries));
+static Dtype commit_direntproc PROTO ((void *callerdat, char *dir,
+ char *repos, char *update_dir,
+ List *entries));
+static int commit_dirleaveproc PROTO ((void *callerdat, char *dir,
+ int err, char *update_dir,
+ List *entries));
+static int commit_fileproc PROTO ((void *callerdat, struct file_info *finfo));
+static int commit_filesdoneproc PROTO ((void *callerdat, int err,
+ char *repository, char *update_dir,
+ List *entries));
+static int finaladd PROTO((struct file_info *finfo, char *revision, char *tag,
+ char *options));
static int findmaxrev PROTO((Node * p, void *closure));
-static int lock_RCS PROTO((char *user, char *rcs, char *rev, char *repository));
-static int lockrcsfile PROTO((char *file, char *repository, char *rev));
+static int lock_RCS PROTO((char *user, RCSNode *rcs, char *rev,
+ char *repository));
static int precommit_list_proc PROTO((Node * p, void *closure));
static int precommit_proc PROTO((char *repository, char *filter));
-static int remove_file PROTO((char *file, char *repository, char *tag,
- char *message, List *entries, RCSNode *rcsnode));
+static int remove_file PROTO ((struct file_info *finfo, char *tag,
+ char *message));
static void fix_rcs_modes PROTO((char *rcs, char *user));
static void fixaddfile PROTO((char *file, char *repository));
-static void fixbranch PROTO((char *file, char *repository, char *branch));
-static void unlockrcs PROTO((char *file, char *repository));
+static void fixbranch PROTO((RCSNode *, char *branch));
+static void unlockrcs PROTO((RCSNode *rcs));
static void ci_delproc PROTO((Node *p));
static void masterlist_delproc PROTO((Node *p));
-static void locate_rcs PROTO((char *file, char *repository, char *rcs));
+static char *locate_rcs PROTO((char *file, char *repository));
struct commit_info
{
@@ -65,6 +75,7 @@ static int run_module_prog = 1;
static int aflag;
static char *tag;
static char *write_dirtag;
+static int write_dirnonbranch;
static char *logfile;
static List *mulist;
static char *message;
@@ -85,37 +96,150 @@ static const char *const commit_usage[] =
};
#ifdef CLIENT_SUPPORT
+/* Identify a file which needs "? foo" or a Questionable request. */
+struct question {
+ /* The two fields for the Directory request. */
+ char *dir;
+ char *repos;
+
+ /* The file name. */
+ char *file;
+
+ struct question *next;
+};
+
struct find_data {
List *ulist;
int argc;
char **argv;
+
+ /* This is used from dirent to filesdone time, for each directory,
+ to make a list of files we have already seen. */
+ List *ignlist;
+
+ /* Linked list of files which need "? foo" or a Questionable request. */
+ struct question *questionables;
+
+ /* Only good within functions called from the filesdoneproc. Stores
+ the repository (pointer into storage managed by the recursion
+ processor. */
+ char *repository;
+
+ /* Non-zero if we should force the commit. This is enabled by
+ either -f or -r options, unlike force_ci which is just -f. */
+ int force;
};
-/* Pass as a static until we get around to fixing start_recursion to
- pass along a void * where we can stash it. */
-struct find_data *find_data_static;
+static Dtype find_dirent_proc PROTO ((void *callerdat, char *dir,
+ char *repository, char *update_dir,
+ List *entries));
+
+static Dtype
+find_dirent_proc (callerdat, dir, repository, update_dir, entries)
+ void *callerdat;
+ char *dir;
+ char *repository;
+ char *update_dir;
+ List *entries;
+{
+ struct find_data *find_data = (struct find_data *)callerdat;
+
+ /* initialize the ignore list for this directory */
+ find_data->ignlist = getlist ();
+ return R_PROCESS;
+}
+
+/* Here as a static until we get around to fixing ignore_files to pass
+ it along as an argument. */
+static struct find_data *find_data_static;
+
+static void find_ignproc PROTO ((char *, char *));
+
+static void
+find_ignproc (file, dir)
+ char *file;
+ char *dir;
+{
+ struct question *p;
+
+ p = (struct question *) xmalloc (sizeof (struct question));
+ p->dir = xstrdup (dir);
+ p->repos = xstrdup (find_data_static->repository);
+ p->file = xstrdup (file);
+ p->next = find_data_static->questionables;
+ find_data_static->questionables = p;
+}
+
+static int find_filesdoneproc PROTO ((void *callerdat, int err,
+ char *repository, char *update_dir,
+ List *entries));
+
+static int
+find_filesdoneproc (callerdat, err, repository, update_dir, entries)
+ void *callerdat;
+ int err;
+ char *repository;
+ char *update_dir;
+ List *entries;
+{
+ struct find_data *find_data = (struct find_data *)callerdat;
+ find_data->repository = repository;
+
+ /* if this directory has an ignore list, process it then free it */
+ if (find_data->ignlist)
+ {
+ find_data_static = find_data;
+ ignore_files (find_data->ignlist, entries, update_dir, find_ignproc);
+ dellist (&find_data->ignlist);
+ }
+
+ find_data->repository = NULL;
+
+ return err;
+}
-static int find_fileproc PROTO ((struct file_info *finfo));
+static int find_fileproc PROTO ((void *callerdat, struct file_info *finfo));
/* Machinery to find out what is modified, added, and removed. It is
possible this should be broken out into a new client_classify function;
merging it with classify_file is almost sure to be a mess, though,
because classify_file has all kinds of repository processing. */
static int
-find_fileproc (finfo)
+find_fileproc (callerdat, finfo)
+ void *callerdat;
struct file_info *finfo;
{
Vers_TS *vers;
enum classify_type status;
Node *node;
- struct find_data *args = find_data_static;
+ struct find_data *args = (struct find_data *)callerdat;
+ struct logfile_info *data;
+ struct file_info xfinfo;
+
+ /* if this directory has an ignore list, add this file to it */
+ if (args->ignlist)
+ {
+ Node *p;
+
+ p = getnode ();
+ p->type = FILES;
+ p->key = xstrdup (finfo->file);
+ if (addnode (args->ignlist, p) != 0)
+ freenode (p);
+ }
- vers = Version_TS ((char *)NULL, (char *)NULL, (char *)NULL,
- (char *)NULL,
- finfo->file, 0, 0, finfo->entries, (RCSNode *)NULL);
+ xfinfo = *finfo;
+ xfinfo.repository = NULL;
+ xfinfo.rcs = NULL;
+
+ vers = Version_TS (&xfinfo, NULL, NULL, NULL, 0, 0);
if (vers->ts_user == NULL
&& vers->vn_user != NULL
&& vers->vn_user[0] == '-')
+ /* FIXME: If vn_user is starts with "-" but ts_user is
+ non-NULL, what classify_file does is print "%s should be
+ removed and is still there". I'm not sure what it does
+ then. We probably should do the same. */
status = T_REMOVED;
else if (vers->vn_user == NULL)
{
@@ -129,10 +253,15 @@ find_fileproc (finfo)
else if (vers->ts_user != NULL
&& vers->vn_user != NULL
&& vers->vn_user[0] == '0')
+ /* FIXME: If vn_user is "0" but ts_user is NULL, what classify_file
+ does is print "new-born %s has disappeared" and removes the entry.
+ We probably should do the same. */
status = T_ADDED;
else if (vers->ts_user != NULL
&& vers->ts_rcs != NULL
- && strcmp (vers->ts_user, vers->ts_rcs) != 0)
+ && (args->force || strcmp (vers->ts_user, vers->ts_rcs) != 0))
+ /* If we are forcing commits, pretend that the file is
+ modified. */
status = T_MODIFIED;
else
{
@@ -146,13 +275,19 @@ find_fileproc (finfo)
node = getnode ();
node->key = xstrdup (finfo->fullname);
+ data = (struct logfile_info *) xmalloc (sizeof (struct logfile_info));
+ data->type = status;
+ data->tag = xstrdup (vers->tag);
+ data->rev_old = data->rev_new = NULL;
+
node->type = UPDATE;
node->delproc = update_delproc;
- node->data = (char *) status;
+ node->data = (char *) data;
(void)addnode (args->ulist, node);
++args->argc;
+ freevers_ts (&vers);
return 0;
}
@@ -198,7 +333,7 @@ commit (argc, argv)
#endif /* CVS_BADROOT */
optind = 1;
- while ((c = getopt (argc, argv, "nlRm:fF:r:")) != -1)
+ while ((c = getopt (argc, argv, "+nlRm:fF:r:")) != -1)
{
switch (c)
{
@@ -270,7 +405,7 @@ commit (argc, argv)
error (1, 0, "cannot specify both a message and a log file");
/* FIXME: Why is this binary? Needs more investigation. */
- if ((logfd = open (logfile, O_RDONLY | OPEN_BINARY)) < 0)
+ if ((logfd = CVS_OPEN (logfile, O_RDONLY | OPEN_BINARY)) < 0)
error (1, errno, "cannot open log file %s", logfile);
if (fstat(logfd, &statbuf) < 0)
@@ -294,21 +429,31 @@ commit (argc, argv)
ign_setup ();
- /* Note that we don't do ignore file processing here, and we
- don't call ignore_files. This means that we won't print "?
- foo" for stray files. Sounds OK, the doc only promises
- that update does that. */
find_args.ulist = getlist ();
find_args.argc = 0;
- find_data_static = &find_args;
- err = start_recursion (find_fileproc, (FILESDONEPROC) NULL,
- (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL,
- argc, argv, local, W_LOCAL, 0, 0,
- (char *)NULL, 0, 0);
+ find_args.questionables = NULL;
+ find_args.ignlist = NULL;
+ find_args.repository = NULL;
+
+ /* It is possible that only a numeric tag should set this.
+ I haven't really thought about it much.
+ Anyway, I suspect that setting it unnecessarily only causes
+ a little unneeded network traffic. */
+ find_args.force = force_ci || tag != NULL;
+
+ err = start_recursion (find_fileproc, find_filesdoneproc,
+ find_dirent_proc, (DIRLEAVEPROC) NULL,
+ (void *)&find_args,
+ argc, argv, local, W_LOCAL, 0, 0,
+ (char *)NULL, 0);
if (err)
error (1, 0, "correct above errors first!");
if (find_args.argc == 0)
+ /* Nothing to commit. Exit now without contacting the
+ server (note that this means that we won't print "?
+ foo" for files which merit it, because we don't know
+ what is in the CVSROOT/cvsignore file). */
return 0;
/* Now we keep track of which files we actually are going to
@@ -319,12 +464,16 @@ commit (argc, argv)
find_args.argc = 0;
walklist (find_args.ulist, copy_ulist, &find_args);
- /*
- * Do this before calling do_editor; don't ask for a log
- * message if we can't talk to the server. But do it after we
- * have made the checks that we can locally (to more quickly
- * catch syntax errors, the case where no files are modified,
- * added or removed, etc.). */
+ /* Do this before calling do_editor; don't ask for a log
+ message if we can't talk to the server. But do it after we
+ have made the checks that we can locally (to more quickly
+ catch syntax errors, the case where no files are modified,
+ added or removed, etc.).
+
+ On the other hand, calling start_server before do_editor
+ means that we chew up server resources the whole time that
+ the user has the editor open (hours or days if the user
+ forgets about it), which seems dubious. */
start_server ();
/*
@@ -334,9 +483,55 @@ commit (argc, argv)
if (use_editor)
do_editor (".", &message, (char *)NULL, find_args.ulist);
+ /* Run the user-defined script to verify/check information in
+ *the log message
+ */
+ do_verify (message, (char *)NULL);
+
/* We always send some sort of message, even if empty. */
option_with_arg ("-m", message);
+ /* OK, now process all the questionable files we have been saving
+ up. */
+ {
+ struct question *p;
+ struct question *q;
+
+ p = find_args.questionables;
+ while (p != NULL)
+ {
+ if (ign_inhibit_server || !supported_request ("Questionable"))
+ {
+ cvs_output ("? ", 2);
+ if (p->dir[0] != '\0')
+ {
+ cvs_output (p->dir, 0);
+ cvs_output ("/", 1);
+ }
+ cvs_output (p->file, 0);
+ cvs_output ("\n", 1);
+ }
+ else
+ {
+ send_to_server ("Directory ", 0);
+ send_to_server (p->dir[0] == '\0' ? "." : p->dir, 0);
+ send_to_server ("\012", 1);
+ send_to_server (p->repos, 0);
+ send_to_server ("\012", 1);
+
+ send_to_server ("Questionable ", 0);
+ send_to_server (p->file, 0);
+ send_to_server ("\012", 1);
+ }
+ free (p->dir);
+ free (p->repos);
+ free (p->file);
+ q = p->next;
+ free (p);
+ p = q;
+ }
+ }
+
if (local)
send_arg("-l");
if (force_ci)
@@ -351,7 +546,18 @@ commit (argc, argv)
previous versions of client/server CVS, but it probably is a Good
Thing, or at least Not Such A Bad Thing. */
send_file_names (find_args.argc, find_args.argv, 0);
- send_files (find_args.argc, find_args.argv, local, 0);
+
+ /* FIXME: This whole find_args.force/SEND_FORCE business is a
+ kludge. It would seem to be a server bug that we have to
+ say that files are modified when they are not. This makes
+ "cvs commit -r 2" across a whole bunch of files a very slow
+ operation (and it isn't documented in cvsclient.texi). I
+ haven't looked at the server code carefully enough to be
+ _sure_ why this is needed, but if it is because RCS_CI
+ wants the file to exist, then it would be relatively simple
+ (but not trivial) to fix in the server. */
+ send_files (find_args.argc, find_args.argv, local, 0,
+ find_args.force ? SEND_FORCE : 0);
send_to_server ("ci\012", 0);
return get_responses_and_close ();
@@ -378,28 +584,28 @@ commit (argc, argv)
* Run the recursion processor to verify the files are all up-to-date
*/
err = start_recursion (check_fileproc, check_filesdoneproc,
- check_direntproc, (DIRLEAVEPROC) NULL, argc,
- argv, local, W_LOCAL, aflag, 0, (char *) NULL, 1,
- 0);
+ check_direntproc, (DIRLEAVEPROC) NULL, NULL, argc,
+ argv, local, W_LOCAL, aflag, 0, (char *) NULL, 1);
if (err)
{
- lock_tree_cleanup ();
+ Lock_Cleanup ();
error (1, 0, "correct above errors first!");
}
/*
* Run the recursion processor to commit the files
*/
+ write_dirnonbranch = 0;
if (noexec == 0)
err = start_recursion (commit_fileproc, commit_filesdoneproc,
- commit_direntproc, commit_dirleaveproc,
+ commit_direntproc, commit_dirleaveproc, NULL,
argc, argv, local, W_LOCAL, aflag, 0,
- (char *) NULL, 1, 0);
+ (char *) NULL, 1);
/*
* Unlock all the dirs and clean up
*/
- lock_tree_cleanup ();
+ Lock_Cleanup ();
dellist (&mulist);
if (last_register_time)
@@ -416,23 +622,18 @@ commit (argc, argv)
return (err);
}
-/*
- * Check to see if a file is ok to commit and make sure all files are
- * up-to-date
- */
-/* ARGSUSED */
-static int
-check_fileproc (finfo)
+/* This routine determines the status of a given file and retrieves
+ the version information that is associated with that file. */
+
+static
+Ctype
+classify_file_internal (finfo, vers)
struct file_info *finfo;
+ Vers_TS **vers;
{
- Ctype status;
- char *xdir;
- Node *p;
- List *ulist, *cilist;
- Vers_TS *vers;
- struct commit_info *ci;
int save_noexec, save_quiet, save_really_quiet;
-
+ Ctype status;
+
save_noexec = noexec;
save_quiet = quiet;
save_really_quiet = really_quiet;
@@ -444,19 +645,16 @@ check_fileproc (finfo)
/* If the tag is for the trunk, make sure we're at the head */
if (numdots (tag) < 2)
{
- status = Classify_File (finfo->file, (char *) NULL, (char *) NULL,
- (char *) NULL, 1, aflag, finfo->repository,
- finfo->entries, finfo->rcs, &vers, finfo->update_dir, 0);
+ status = Classify_File (finfo, (char *) NULL, (char *) NULL,
+ (char *) NULL, 1, aflag, vers, 0);
if (status == T_UPTODATE || status == T_MODIFIED ||
status == T_ADDED)
{
Ctype xstatus;
- freevers_ts (&vers);
- xstatus = Classify_File (finfo->file, tag, (char *) NULL,
- (char *) NULL, 1, aflag, finfo->repository,
- finfo->entries, finfo->rcs, &vers, finfo->update_dir,
- 0);
+ freevers_ts (vers);
+ xstatus = Classify_File (finfo, tag, (char *) NULL,
+ (char *) NULL, 1, aflag, vers, 0);
if (xstatus == T_REMOVE_ENTRY)
status = T_MODIFIED;
else if (status == T_MODIFIED && xstatus == T_CONFLICT)
@@ -479,36 +677,55 @@ check_fileproc (finfo)
cp = strrchr (xtag, '.');
*cp = '\0';
}
- status = Classify_File (finfo->file, xtag, (char *) NULL,
- (char *) NULL, 1, aflag, finfo->repository,
- finfo->entries, finfo->rcs, &vers, finfo->update_dir, 0);
+ status = Classify_File (finfo, xtag, (char *) NULL,
+ (char *) NULL, 1, aflag, vers, 0);
if ((status == T_REMOVE_ENTRY || status == T_CONFLICT)
&& (cp = strrchr (xtag, '.')) != NULL)
{
/* pluck one more dot off the revision */
*cp = '\0';
- freevers_ts (&vers);
- status = Classify_File (finfo->file, xtag, (char *) NULL,
- (char *) NULL, 1, aflag, finfo->repository,
- finfo->entries, finfo->rcs, &vers, finfo->update_dir,
- 0);
+ freevers_ts (vers);
+ status = Classify_File (finfo, xtag, (char *) NULL,
+ (char *) NULL, 1, aflag, vers, 0);
if (status == T_UPTODATE || status == T_REMOVE_ENTRY)
status = T_MODIFIED;
}
/* now, muck with vers to make the tag correct */
- free (vers->tag);
- vers->tag = xstrdup (tag);
+ free ((*vers)->tag);
+ (*vers)->tag = xstrdup (tag);
free (xtag);
}
}
else
- status = Classify_File (finfo->file, tag, (char *) NULL, (char *) NULL,
- 1, 0, finfo->repository, finfo->entries, finfo->rcs, &vers,
- finfo->update_dir, 0);
+ status = Classify_File (finfo, tag, (char *) NULL, (char *) NULL,
+ 1, 0, vers, 0);
noexec = save_noexec;
quiet = save_quiet;
really_quiet = save_really_quiet;
+ return status;
+}
+
+/*
+ * Check to see if a file is ok to commit and make sure all files are
+ * up-to-date
+ */
+/* ARGSUSED */
+static int
+check_fileproc (callerdat, finfo)
+ void *callerdat;
+ struct file_info *finfo;
+{
+ Ctype status;
+ char *xdir;
+ Node *p;
+ List *ulist, *cilist;
+ Vers_TS *vers;
+ struct commit_info *ci;
+ struct logfile_info *li;
+
+ status = classify_file_internal (finfo, &vers);
+
/*
* If the force-commit option is enabled, and the file in question
* appears to be up-to-date, just make it look modified so that
@@ -538,7 +755,8 @@ check_fileproc (finfo)
* - can't have a sticky tag that is not a branch
* Also,
* - if status is T_REMOVED, can't have a numeric tag
- * - if status is T_ADDED, rcs file must not exist
+ * - if status is T_ADDED, rcs file must not exist unless on
+ * a branch
* - if status is T_ADDED, can't have a non-trunk numeric rev
* - if status is T_MODIFIED and a Conflict marker exists, don't
* allow the commit if timestamp is identical or if we find
@@ -597,22 +815,7 @@ check_fileproc (finfo)
return (1);
}
- /*
- * If the timestamps differ, look for Conflict indicators
- * in the file to see if we should block the commit anyway
- */
- run_setup ("%s", GREP);
- run_arg (RCS_MERGE_PAT);
- run_arg (finfo->file);
- retcode = run_exec (RUN_TTY, DEVNULL, RUN_TTY, RUN_REALLY);
-
- if (retcode == -1)
- {
- error (1, errno,
- "fork failed while examining conflict in `%s'",
- finfo->fullname);
- }
- else if (retcode == 0)
+ if (file_has_markers (finfo))
{
error (0, 0,
"file `%s' still contains conflict indicators",
@@ -632,18 +835,29 @@ check_fileproc (finfo)
}
if (status == T_ADDED)
{
- char rcs[PATH_MAX];
-
- /* Don't look in the attic; if it exists there we will
- move it back out in checkaddfile. */
- sprintf(rcs, "%s/%s%s", finfo->repository, finfo->file, RCSEXT);
- if (isreadable (rcs))
+ if (vers->tag == NULL)
{
- error (0, 0,
- "cannot add file `%s' when RCS file `%s' already exists",
- finfo->fullname, rcs);
- freevers_ts (&vers);
- return (1);
+ char *rcs;
+
+ rcs = xmalloc (strlen (finfo->repository)
+ + strlen (finfo->file)
+ + sizeof RCSEXT
+ + 5);
+
+ /* Don't look in the attic; if it exists there we
+ will move it back out in checkaddfile. */
+ sprintf(rcs, "%s/%s%s", finfo->repository, finfo->file,
+ RCSEXT);
+ if (isreadable (rcs))
+ {
+ error (0, 0,
+ "cannot add file `%s' when RCS file `%s' already exists",
+ finfo->fullname, rcs);
+ freevers_ts (&vers);
+ free (rcs);
+ return (1);
+ }
+ free (rcs);
}
if (vers->tag && isdigit (*vers->tag) &&
numdots (vers->tag) > 1)
@@ -689,7 +903,13 @@ check_fileproc (finfo)
p->key = xstrdup (finfo->file);
p->type = UPDATE;
p->delproc = update_delproc;
- p->data = (char *) status;
+ li = ((struct logfile_info *)
+ xmalloc (sizeof (struct logfile_info)));
+ li->type = status;
+ li->tag = xstrdup (vers->tag);
+ li->rev_old = xstrdup (vers->vn_rcs);
+ li->rev_new = NULL;
+ p->data = (char *) li;
(void) addnode (ulist, p);
p = getnode ();
@@ -730,10 +950,12 @@ check_fileproc (finfo)
*/
/* ARGSUSED */
static Dtype
-check_direntproc (dir, repos, update_dir)
+check_direntproc (callerdat, dir, repos, update_dir, entries)
+ void *callerdat;
char *dir;
char *repos;
char *update_dir;
+ List *entries;
{
if (!quiet)
error (0, 0, "Examining %s", update_dir);
@@ -749,8 +971,12 @@ precommit_list_proc (p, closure)
Node *p;
void *closure;
{
- if (p->data == (char *) T_ADDED || p->data == (char *) T_MODIFIED ||
- p->data == (char *) T_REMOVED)
+ struct logfile_info *li;
+
+ li = (struct logfile_info *) p->data;
+ if (li->type == T_ADDED
+ || li->type == T_MODIFIED
+ || li->type == T_REMOVED)
{
run_arg (p->key);
}
@@ -797,10 +1023,12 @@ precommit_proc (repository, filter)
*/
/* ARGSUSED */
static int
-check_filesdoneproc (err, repos, update_dir)
+check_filesdoneproc (callerdat, err, repos, update_dir, entries)
+ void *callerdat;
int err;
char *repos;
char *update_dir;
+ List *entries;
{
int n;
Node *p;
@@ -830,18 +1058,33 @@ check_filesdoneproc (err, repos, update_dir)
* Do the work of committing a file
*/
static int maxrev;
-static char sbranch[PATH_MAX];
+static char *sbranch;
/* ARGSUSED */
static int
-commit_fileproc (finfo)
+commit_fileproc (callerdat, finfo)
+ void *callerdat;
struct file_info *finfo;
{
Node *p;
int err = 0;
List *ulist, *cilist;
struct commit_info *ci;
- char rcs[PATH_MAX];
+
+ /* Keep track of whether write_dirtag is a branch tag.
+ Note that if it is a branch tag in some files and a nonbranch tag
+ in others, treat it as a nonbranch tag. It is possible that case
+ should elicit a warning or an error. */
+ if (write_dirtag != NULL
+ && finfo->rcs != NULL)
+ {
+ char *rev = RCS_getversion (finfo->rcs, write_dirtag, NULL, 1, NULL);
+ if (rev != NULL
+ && !RCS_nodeisbranch (finfo->rcs, write_dirtag))
+ write_dirnonbranch = 1;
+ if (rev != NULL)
+ free (rev);
+ }
if (finfo->update_dir[0] == '\0')
p = findnode (mulist, ".");
@@ -862,11 +1105,13 @@ commit_fileproc (finfo)
* with files as args from the command line. In that latter case, we
* need to get the commit message ourselves
*/
- if (use_editor && !got_message)
- {
+ if (!(got_message))
+ {
got_message = 1;
- do_editor (finfo->update_dir, &message, finfo->repository, ulist);
- }
+ if (use_editor)
+ do_editor (finfo->update_dir, &message, finfo->repository, ulist);
+ do_verify (message, finfo->repository);
+ }
p = findnode (cilist, finfo->file);
if (p == NULL)
@@ -875,9 +1120,12 @@ commit_fileproc (finfo)
ci = (struct commit_info *) p->data;
if (ci->status == T_MODIFIED)
{
- if (lockrcsfile (finfo->file, finfo->repository, ci->rev) != 0)
+ if (finfo->rcs == NULL)
+ error (1, 0, "internal error: no parsed RCS file");
+ if (lock_RCS (finfo->file, finfo->rcs, ci->rev,
+ finfo->repository) != 0)
{
- unlockrcs (finfo->file, finfo->repository);
+ unlockrcs (finfo->rcs);
err = 1;
goto out;
}
@@ -896,15 +1144,17 @@ commit_fileproc (finfo)
Since the branch test was done in check_fileproc for
modified files, we need to stub it in again here. */
- if (ci->tag) {
- locate_rcs (finfo->file, finfo->repository, rcs);
+ if (ci->tag)
+ {
+ if (finfo->rcs == NULL)
+ error (1, 0, "internal error: no parsed RCS file");
ci->rev = RCS_whatbranch (finfo->rcs, ci->tag);
- err = Checkin ('A', finfo->file, finfo->update_dir, finfo->repository, rcs, ci->rev,
- ci->tag, ci->options, message, finfo->entries);
+ err = Checkin ('A', finfo, finfo->rcs->path, ci->rev,
+ ci->tag, ci->options, message);
if (err != 0)
{
- unlockrcs (finfo->file, finfo->repository);
- fixbranch (finfo->file, finfo->repository, sbranch);
+ unlockrcs (finfo->rcs);
+ fixbranch (finfo->rcs, sbranch);
}
(void) time (&last_register_time);
@@ -932,36 +1182,37 @@ commit_fileproc (finfo)
}
/* XXX - an added file with symbolic -r should add tag as well */
- err = finaladd (finfo->file, ci->rev ? ci->rev : xrev, ci->tag, ci->options,
- finfo->update_dir, finfo->repository, finfo->entries);
+ err = finaladd (finfo, ci->rev ? ci->rev : xrev, ci->tag, ci->options);
if (xrev)
free (xrev);
}
else if (ci->status == T_MODIFIED)
{
- locate_rcs (finfo->file, finfo->repository, rcs);
- err = Checkin ('M', finfo->file, finfo->update_dir, finfo->repository,
- rcs, ci->rev, ci->tag,
- ci->options, message, finfo->entries);
+ err = Checkin ('M', finfo,
+ finfo->rcs->path, ci->rev, ci->tag,
+ ci->options, message);
(void) time (&last_register_time);
if (err != 0)
{
- unlockrcs (finfo->file, finfo->repository);
- fixbranch (finfo->file, finfo->repository, sbranch);
+ unlockrcs (finfo->rcs);
+ fixbranch (finfo->rcs, sbranch);
}
}
else if (ci->status == T_REMOVED)
{
- err = remove_file (finfo->file, finfo->repository, ci->tag, message,
- finfo->entries, finfo->rcs);
+ err = remove_file (finfo, ci->tag, message);
#ifdef SERVER_SUPPORT
if (server_active) {
server_scratch_entry_only ();
- server_updated (finfo->file, finfo->update_dir, finfo->repository,
+ server_updated (finfo,
+ NULL,
+
/* Doesn't matter, it won't get checked. */
- SERVER_UPDATED, (struct stat *) NULL,
+ SERVER_UPDATED,
+
+ (struct stat *) NULL,
(unsigned char *) NULL);
}
#endif
@@ -979,6 +1230,33 @@ out:
if (p)
delnode (p);
}
+ else
+ {
+ /* On success, retrieve the new version number of the file and
+ copy it into the log information (see logmsg.c
+ (logfile_write) for more details). We should only update
+ the version number for files that have been added or
+ modified but not removed. Why? classify_file_internal
+ will return the version number of a file even after it has
+ been removed from the archive, which is not the behavior we
+ want for our commitlog messages; we want the old version
+ number and then "NONE." */
+
+ if (ci->status != T_REMOVED)
+ {
+ p = findnode (ulist, finfo->file);
+ if (p)
+ {
+ Vers_TS *vers;
+ struct logfile_info *li;
+
+ (void) classify_file_internal (finfo, &vers);
+ li = (struct logfile_info *) p->data;
+ li->rev_new = xstrdup (vers->vn_rcs);
+ freevers_ts (&vers);
+ }
+ }
+ }
return (err);
}
@@ -988,12 +1266,13 @@ out:
*/
/* ARGSUSED */
static int
-commit_filesdoneproc (err, repository, update_dir)
+commit_filesdoneproc (callerdat, err, repository, update_dir, entries)
+ void *callerdat;
int err;
char *repository;
char *update_dir;
+ List *entries;
{
- char *xtag = (char *) NULL;
Node *p;
List *ulist;
@@ -1005,21 +1284,17 @@ commit_filesdoneproc (err, repository, update_dir)
got_message = 0;
- /* see if we need to specify a per-directory or -r option tag */
- if (tag == NULL)
- ParseTag (&xtag, (char **) NULL);
- Update_Logfile (repository, message, tag ? tag : xtag, (FILE *) 0, ulist);
- if (xtag)
- free (xtag);
+ Update_Logfile (repository, message, (FILE *) 0, ulist);
/* Build the administrative files if necessary. */
{
char *p;
- if (strncmp (CVSroot, repository, strlen (CVSroot)) != 0)
- error (0, 0, "internal error: repository doesn't begin with root");
- p = repository + strlen (CVSroot);
+ if (strncmp (CVSroot_directory, repository,
+ strlen (CVSroot_directory)) != 0)
+ error (0, 0, "internal error: repository (%s) doesn't begin with root (%s)", repository, CVSroot_directory);
+ p = repository + strlen (CVSroot_directory);
if (*p == '/')
++p;
if (strcmp ("CVSROOT", p) == 0)
@@ -1042,7 +1317,7 @@ commit_filesdoneproc (err, repository, update_dir)
{
FILE *fp;
- if ((fp = fopen (CVSADM_CIPROG, "r")) != NULL)
+ if ((fp = CVS_FOPEN (CVSADM_CIPROG, "r")) != NULL)
{
char *line;
int line_length;
@@ -1059,10 +1334,12 @@ commit_filesdoneproc (err, repository, update_dir)
line[--line_length] = '\0';
repository = Name_Repository ((char *) NULL, update_dir);
run_setup ("%s %s", line, repository);
- (void) printf ("%s %s: Executing '", program_name,
- command_name);
+ cvs_output (program_name, 0);
+ cvs_output (" ", 1);
+ cvs_output (command_name, 0);
+ cvs_output (": Executing '", 0);
run_print (stdout);
- (void) printf ("'\n");
+ cvs_output ("'\n", 0);
(void) run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL);
free (repository);
}
@@ -1092,10 +1369,12 @@ commit_filesdoneproc (err, repository, update_dir)
*/
/* ARGSUSED */
static Dtype
-commit_direntproc (dir, repos, update_dir)
+commit_direntproc (callerdat, dir, repos, update_dir, entries)
+ void *callerdat;
char *dir;
char *repos;
char *update_dir;
+ List *entries;
{
Node *p;
List *ulist;
@@ -1117,13 +1396,12 @@ commit_direntproc (dir, repos, update_dir)
error (0, 0, "Committing %s", update_dir);
/* get commit message */
+ real_repos = Name_Repository (dir, update_dir);
+ got_message = 1;
if (use_editor)
- {
- got_message = 1;
- real_repos = Name_Repository (dir, update_dir);
do_editor (update_dir, &message, real_repos, ulist);
- free (real_repos);
- }
+ do_verify (message, real_repos);
+ free (real_repos);
return (R_PROCESS);
}
@@ -1132,20 +1410,21 @@ commit_direntproc (dir, repos, update_dir)
*/
/* ARGSUSED */
static int
-commit_dirleaveproc (dir, err, update_dir)
+commit_dirleaveproc (callerdat, dir, err, update_dir, entries)
+ void *callerdat;
char *dir;
int err;
char *update_dir;
+ List *entries;
{
/* update the per-directory tag info */
+ /* FIXME? Why? The "commit examples" node of cvs.texinfo briefly
+ mentions commit -r being sticky, but apparently in the context of
+ this being a confusing feature! */
if (err == 0 && write_dirtag != NULL)
{
- WriteTag ((char *) NULL, write_dirtag, (char *) NULL);
-#ifdef SERVER_SUPPORT
- if (server_active)
- server_set_sticky (update_dir, Name_Repository (dir, update_dir),
- write_dirtag, (char *) NULL);
-#endif
+ WriteTag (NULL, write_dirtag, NULL, write_dirnonbranch,
+ update_dir, Name_Repository (dir, update_dir));
}
return (err);
@@ -1164,6 +1443,8 @@ findmaxrev (p, closure)
Entnode *entdata;
entdata = (Entnode *) p->data;
+ if (entdata->type != ENT_FILE)
+ return (0);
cp = strchr (entdata->version, '.');
if (cp != NULL)
*cp = '\0';
@@ -1182,17 +1463,13 @@ findmaxrev (p, closure)
* link to keep it relative after we move it into the attic.
*/
static int
-remove_file (file, repository, tag, message, entries, rcsnode)
- char *file;
- char *repository;
+remove_file (finfo, tag, message)
+ struct file_info *finfo;
char *tag;
char *message;
- List *entries;
- RCSNode *rcsnode;
{
mode_t omask;
int retcode;
- char rcs[PATH_MAX];
char *tmp;
int branch;
@@ -1200,6 +1477,7 @@ remove_file (file, repository, tag, message, entries, rcsnode)
char *corev;
char *rev;
char *prev_rev;
+ char *old_path;
corev = NULL;
rev = NULL;
@@ -1207,20 +1485,22 @@ remove_file (file, repository, tag, message, entries, rcsnode)
retcode = 0;
- locate_rcs (file, repository, rcs);
+ if (finfo->rcs == NULL)
+ error (1, 0, "internal error: no parsed RCS file");
branch = 0;
- if (tag && !(branch = RCS_isbranch (rcsnode, tag)))
+ if (tag && !(branch = RCS_isbranch (finfo->rcs, tag)))
{
/* a symbolic tag is specified; just remove the tag from the file */
- if ((retcode = RCS_deltag (rcs, tag, 1)) != 0)
+ if ((retcode = RCS_deltag (finfo->rcs, tag, 1)) != 0)
{
if (!quiet)
error (0, retcode == -1 ? errno : 0,
- "failed to remove tag `%s' from `%s'", tag, rcs);
+ "failed to remove tag `%s' from `%s'", tag,
+ finfo->fullname);
return (1);
}
- Scratch_Entry (entries, file);
+ Scratch_Entry (finfo->entries, finfo->file);
return (0);
}
@@ -1228,32 +1508,29 @@ remove_file (file, repository, tag, message, entries, rcsnode)
/* commit a new, dead revision. */
/* Print message indicating that file is going to be removed. */
- (void) printf ("Removing %s;\n", file);
+ cvs_output ("Removing ", 0);
+ cvs_output (finfo->fullname, 0);
+ cvs_output (";\n", 0);
rev = NULL;
- lockflag = RCS_FLAGS_LOCK;
+ lockflag = 1;
if (branch)
{
char *branchname;
- rev = RCS_whatbranch (rcsnode, tag);
+ rev = RCS_whatbranch (finfo->rcs, tag);
if (rev == NULL)
{
error (0, 0, "cannot find branch \"%s\".", tag);
return (1);
}
- if (rcsnode == NULL)
- {
- error (0, 0, "boy, I'm confused.");
- return (1);
- }
- branchname = RCS_getbranch (rcsnode, rev, 1);
+ branchname = RCS_getbranch (finfo->rcs, rev, 1);
if (branchname == NULL)
{
/* no revision exists on this branch. use the previous
revision but do not lock. */
- corev = RCS_gettag (rcsnode, tag, 1, 0);
+ corev = RCS_gettag (finfo->rcs, tag, 1, (int *) NULL);
prev_rev = xstrdup(rev);
lockflag = 0;
} else
@@ -1265,24 +1542,18 @@ remove_file (file, repository, tag, message, entries, rcsnode)
} else /* Not a branch */
{
-
/* Get current head revision of file. */
- if (rcsnode == NULL)
- {
- error (0, 0, "could not find parsed rcsfile %s", file);
- return (1);
- }
- prev_rev = RCS_head (rcsnode);
+ prev_rev = RCS_head (finfo->rcs);
}
/* if removing without a tag or a branch, then make sure the default
branch is the trunk. */
if (!tag && !branch)
{
- if (RCS_setbranch (rcs, NULL) != 0)
+ if (RCS_setbranch (finfo->rcs, NULL) != 0)
{
error (0, 0, "cannot change branch to default for %s",
- rcs);
+ finfo->fullname);
return (1);
}
}
@@ -1293,71 +1564,85 @@ remove_file (file, repository, tag, message, entries, rcsnode)
temp directory which is the kludgy way in which server.c
tells time_stamp that the file is no longer around. Remove
it so we can create temp files with that name (ignore errors). */
- unlink_file (file);
+ unlink_file (finfo->file);
}
#endif
/* check something out. Generally this is the head. If we have a
- particular rev, then name it. except when creating a branch,
- lock the rev we're checking out. */
- retcode = RCS_checkout (rcs, "", rev ? corev : NULL, NULL, RUN_TTY,
- lockflag, 1);
+ particular rev, then name it. */
+ retcode = RCS_checkout (finfo->rcs, finfo->file, rev ? corev : NULL,
+ (char *) NULL, (char *) NULL, RUN_TTY,
+ (RCSCHECKOUTPROC) NULL, (void *) NULL);
if (retcode != 0)
{
if (!quiet)
error (0, retcode == -1 ? errno : 0,
- "failed to check out `%s'", rcs);
+ "failed to check out `%s'", finfo->fullname);
return (1);
}
+ /* Except when we are creating a branch, lock the revision so that
+ we can check in the new revision. */
+ if (lockflag)
+ RCS_lock (finfo->rcs, rev ? corev : NULL, 0);
+
if (corev != NULL)
free (corev);
- retcode = RCS_checkin (rcs, NULL, message, rev, RCS_FLAGS_DEAD, 1);
+ retcode = RCS_checkin (finfo->rcs->path, finfo->file, message, rev,
+ RCS_FLAGS_DEAD | RCS_FLAGS_QUIET);
if (retcode != 0)
{
if (!quiet)
error (0, retcode == -1 ? errno : 0,
- "failed to commit dead revision for `%s'", rcs);
+ "failed to commit dead revision for `%s'", finfo->fullname);
return (1);
}
if (rev != NULL)
free (rev);
+ old_path = finfo->rcs->path;
if (!branch)
{
/* this was the head; really move it into the Attic */
- tmp = xmalloc(strlen(repository) +
+ tmp = xmalloc(strlen(finfo->repository) +
sizeof('/') +
sizeof(CVSATTIC) +
sizeof('/') +
- strlen(file) +
+ strlen(finfo->file) +
sizeof(RCSEXT) + 1);
- (void) sprintf (tmp, "%s/%s", repository, CVSATTIC);
+ (void) sprintf (tmp, "%s/%s", finfo->repository, CVSATTIC);
omask = umask (cvsumask);
(void) CVS_MKDIR (tmp, 0777);
(void) umask (omask);
- (void) sprintf (tmp, "%s/%s/%s%s", repository, CVSATTIC, file, RCSEXT);
+ (void) sprintf (tmp, "%s/%s/%s%s", finfo->repository, CVSATTIC, finfo->file, RCSEXT);
- if (strcmp (rcs, tmp) != 0
- && rename (rcs, tmp) == -1
- && (isreadable (rcs) || !isreadable (tmp)))
+ if (strcmp (finfo->rcs->path, tmp) != 0
+ && CVS_RENAME (finfo->rcs->path, tmp) == -1
+ && (isreadable (finfo->rcs->path) || !isreadable (tmp)))
{
free(tmp);
return (1);
}
- free(tmp);
+ /* The old value of finfo->rcs->path is in old_path, and is
+ freed below. */
+ finfo->rcs->path = tmp;
}
/* Print message that file was removed. */
- (void) printf ("%s <-- %s\n", rcs, file);
- (void) printf ("new revision: delete; ");
- (void) printf ("previous revision: %s\n", prev_rev);
- (void) printf ("done\n");
+ cvs_output (old_path, 0);
+ cvs_output (" <-- ", 0);
+ cvs_output (finfo->file, 0);
+ cvs_output ("\nnew revision: delete; previous revision: ", 0);
+ cvs_output (prev_rev, 0);
+ cvs_output ("\ndone\n", 0);
free(prev_rev);
- Scratch_Entry (entries, file);
+ if (old_path != finfo->rcs->path)
+ free (old_path);
+
+ Scratch_Entry (finfo->entries, finfo->file);
return (0);
}
@@ -1365,31 +1650,30 @@ remove_file (file, repository, tag, message, entries, rcsnode)
* Do the actual checkin for added files
*/
static int
-finaladd (file, rev, tag, options, update_dir, repository, entries)
- char *file;
+finaladd (finfo, rev, tag, options)
+ struct file_info *finfo;
char *rev;
char *tag;
char *options;
- char *update_dir;
- char *repository;
- List *entries;
{
int ret;
- char tmp[PATH_MAX];
- char rcs[PATH_MAX];
+ char *rcs;
- locate_rcs (file, repository, rcs);
- ret = Checkin ('A', file, update_dir, repository, rcs, rev, tag, options,
- message, entries);
+ rcs = locate_rcs (finfo->file, finfo->repository);
+ ret = Checkin ('A', finfo, rcs, rev, tag, options, message);
if (ret == 0)
{
- (void) sprintf (tmp, "%s/%s%s", CVSADM, file, CVSEXT_LOG);
+ char *tmp = xmalloc (strlen (finfo->file) + sizeof (CVSADM)
+ + sizeof (CVSEXT_LOG) + 10);
+ (void) sprintf (tmp, "%s/%s%s", CVSADM, finfo->file, CVSEXT_LOG);
(void) unlink_file (tmp);
+ free (tmp);
}
else
- fixaddfile (file, repository);
+ fixaddfile (finfo->file, finfo->repository);
(void) time (&last_register_time);
+ free (rcs);
return (ret);
}
@@ -1398,18 +1682,14 @@ finaladd (file, rev, tag, options, update_dir, repository, entries)
* Unlock an rcs file
*/
static void
-unlockrcs (file, repository)
- char *file;
- char *repository;
+unlockrcs (rcs)
+ RCSNode *rcs;
{
- char rcs[PATH_MAX];
- int retcode = 0;
-
- locate_rcs (file, repository, rcs);
+ int retcode;
if ((retcode = RCS_unlock (rcs, NULL, 0)) != 0)
error (retcode == -1 ? 1 : 0, retcode == -1 ? errno : 0,
- "could not unlock %s", rcs);
+ "could not unlock %s", rcs->path);
}
/*
@@ -1421,10 +1701,10 @@ fixaddfile (file, repository)
char *repository;
{
RCSNode *rcsfile;
- char rcs[PATH_MAX];
+ char *rcs;
int save_really_quiet;
- locate_rcs (file, repository, rcs);
+ rcs = locate_rcs (file, repository);
save_really_quiet = really_quiet;
really_quiet = 1;
if ((rcsfile = RCS_parsercsfile (rcs)) == NULL)
@@ -1432,26 +1712,24 @@ fixaddfile (file, repository)
else
freercsnode (&rcsfile);
really_quiet = save_really_quiet;
+ free (rcs);
}
/*
* put the branch back on an rcs file
*/
static void
-fixbranch (file, repository, branch)
- char *file;
- char *repository;
+fixbranch (rcs, branch)
+ RCSNode *rcs;
char *branch;
{
- char rcs[PATH_MAX];
- int retcode = 0;
+ int retcode;
- if (branch != NULL && branch[0] != '\0')
+ if (branch != NULL)
{
- locate_rcs (file, repository, rcs);
if ((retcode = RCS_setbranch (rcs, branch)) != 0)
error (retcode == -1 ? 1 : 0, retcode == -1 ? errno : 0,
- "cannot restore branch to %s for %s", branch, rcs);
+ "cannot restore branch to %s for %s", branch, rcs->path);
}
}
@@ -1469,74 +1747,110 @@ checkaddfile (file, repository, tag, options, rcsnode)
char *options;
RCSNode **rcsnode;
{
- char rcs[PATH_MAX];
- char fname[PATH_MAX];
+ char *rcs;
+ char *fname;
mode_t omask;
int retcode = 0;
int newfile = 0;
+ RCSNode *rcsfile = NULL;
+ int retval;
if (tag)
{
- (void) sprintf(rcs, "%s/%s", repository, CVSATTIC);
- omask = umask (cvsumask);
- if (CVS_MKDIR (rcs, 0777) != 0 && errno != EEXIST)
- error (1, errno, "cannot make directory `%s'", rcs);;
- (void) umask (omask);
- (void) sprintf (rcs, "%s/%s/%s%s", repository, CVSATTIC, file, RCSEXT);
+ rcs = xmalloc (strlen (repository) + strlen (file)
+ + sizeof (RCSEXT) + sizeof (CVSATTIC) + 10);
+ (void) sprintf (rcs, "%s/%s%s", repository, file, RCSEXT);
+ if (! isreadable (rcs))
+ {
+ (void) sprintf(rcs, "%s/%s", repository, CVSATTIC);
+ omask = umask (cvsumask);
+ if (CVS_MKDIR (rcs, 0777) != 0 && errno != EEXIST)
+ error (1, errno, "cannot make directory `%s'", rcs);;
+ (void) umask (omask);
+ (void) sprintf (rcs, "%s/%s/%s%s", repository, CVSATTIC, file,
+ RCSEXT);
+ }
}
else
- locate_rcs (file, repository, rcs);
+ rcs = locate_rcs (file, repository);
- if (isreadable(rcs))
+ if (isreadable (rcs))
{
/* file has existed in the past. Prepare to resurrect. */
- char oldfile[PATH_MAX];
char *rev;
- RCSNode *rcsfile;
+
+ if ((rcsfile = *rcsnode) == NULL)
+ {
+ error (0, 0, "could not find parsed rcsfile %s", file);
+ retval = 1;
+ goto out;
+ }
if (tag == NULL)
{
+ char *oldfile;
+
/* we are adding on the trunk, so move the file out of the
Attic. */
- strcpy (oldfile, rcs);
+ oldfile = xstrdup (rcs);
sprintf (rcs, "%s/%s%s", repository, file, RCSEXT);
- if (strcmp (oldfile, rcs) == 0
- || rename (oldfile, rcs) != 0
- || isreadable (oldfile)
+ if (strcmp (oldfile, rcs) == 0)
+ {
+ error (0, 0, "internal error: confused about attic for %s",
+ oldfile);
+ out1:
+ free (oldfile);
+ retval = 1;
+ goto out;
+ }
+ if (CVS_RENAME (oldfile, rcs) != 0)
+ {
+ error (0, errno, "failed to move `%s' out of the attic",
+ oldfile);
+ goto out1;
+ }
+ if (isreadable (oldfile)
|| !isreadable (rcs))
{
- error (0, 0, "failed to move `%s' out of the attic.",
- file);
- return (1);
+ error (0, 0, "\
+internal error: `%s' didn't move out of the attic",
+ oldfile);
+ goto out1;
}
+ free (oldfile);
+ free (rcsfile->path);
+ rcsfile->path = xstrdup (rcs);
}
- if ((rcsfile = *rcsnode) == NULL)
- {
- error (0, 0, "could not find parsed rcsfile %s", file);
- return (1);
- }
-
- rev = RCS_getversion (rcsfile, tag, NULL, 1, 0);
+ rev = RCS_getversion (rcsfile, tag, NULL, 1, (int *) NULL);
/* and lock it */
- if (lock_RCS (file, rcs, rev, repository)) {
+ if (lock_RCS (file, rcsfile, rev, repository))
+ {
error (0, 0, "cannot lock `%s'.", rcs);
- free (rev);
- return (1);
+ if (rev != NULL)
+ free (rev);
+ retval = 1;
+ goto out;
}
- free (rev);
- } else {
+ if (rev != NULL)
+ free (rev);
+ }
+ else
+ {
/* this is the first time we have ever seen this file; create
an rcs file. */
run_setup ("%s%s -x,v/ -i", Rcsbin, RCS);
+ fname = xmalloc (strlen (file) + sizeof (CVSADM)
+ + sizeof (CVSEXT_LOG) + 10);
(void) sprintf (fname, "%s/%s%s", CVSADM, file, CVSEXT_LOG);
/* If the file does not exist, no big deal. In particular, the
server does not (yet at least) create CVSEXT_LOG files. */
if (isfile (fname))
run_args ("-t%s/%s%s", CVSADM, file, CVSEXT_LOG);
+ free (fname);
/* Set RCS keyword expansion options. */
if (options && options[0] == '-' && options[1] == 'k')
@@ -1546,7 +1860,8 @@ checkaddfile (file, repository, tag, options, rcsnode)
{
error (retcode == -1 ? 1 : 0, retcode == -1 ? errno : 0,
"could not create %s", rcs);
- return (1);
+ retval = 1;
+ goto out;
}
newfile = 1;
}
@@ -1558,6 +1873,8 @@ checkaddfile (file, repository, tag, options, rcsnode)
char *tmp;
/* move the new file out of the way. */
+ fname = xmalloc (strlen (file) + sizeof (CVSADM)
+ + sizeof (CVSPREFIX) + 10);
(void) sprintf (fname, "%s/%s%s", CVSADM, CVSPREFIX, file);
rename_file (file, fname);
copy_file (DEVNULL, file);
@@ -1567,22 +1884,40 @@ checkaddfile (file, repository, tag, options, rcsnode)
(void) sprintf (tmp, "file %s was initially added on branch %s.",
file, tag);
retcode = RCS_checkin (rcs, NULL, tmp, NULL,
- RCS_FLAGS_DEAD | RCS_FLAGS_QUIET, 0);
+ RCS_FLAGS_DEAD | RCS_FLAGS_QUIET);
free (tmp);
if (retcode != 0)
{
error (retcode == -1 ? 1 : 0, retcode == -1 ? errno : 0,
"could not create initial dead revision %s", rcs);
- return (1);
+ retval = 1;
+ goto out;
}
/* put the new file back where it was */
rename_file (fname, file);
-
+ free (fname);
+
+ assert (rcsfile == NULL);
+ rcsfile = RCS_parse (file, repository);
+ if (rcsfile == NULL)
+ {
+ error (0, 0, "could not read %s", rcs);
+ retval = 1;
+ goto out;
+ }
+ if (rcsnode != NULL)
+ {
+ assert (*rcsnode == NULL);
+ *rcsnode = rcsfile;
+ }
+
/* and lock it once again. */
- if (lock_RCS (file, rcs, NULL, repository)) {
+ if (lock_RCS (file, rcsfile, NULL, repository))
+ {
error (0, 0, "cannot lock `%s'.", rcs);
- return (1);
+ retval = 1;
+ goto out;
}
}
@@ -1590,78 +1925,71 @@ checkaddfile (file, repository, tag, options, rcsnode)
{
/* when adding with a tag, we need to stub a branch, if it
doesn't already exist. */
- RCSNode *rcsfile;
- rcsfile = RCS_parse (file, repository);
if (rcsfile == NULL)
{
- error (0, 0, "could not read %s", rcs);
- return (1);
+ if (rcsnode != NULL && *rcsnode != NULL)
+ rcsfile = *rcsnode;
+ else
+ {
+ rcsfile = RCS_parse (file, repository);
+ if (rcsfile == NULL)
+ {
+ error (0, 0, "could not read %s", rcs);
+ retval = 1;
+ goto out;
+ }
+ }
}
-
- if (!RCS_nodeisbranch (rcsfile, tag)) {
+
+ if (!RCS_nodeisbranch (rcsfile, tag))
+ {
/* branch does not exist. Stub it. */
char *head;
char *magicrev;
-
- head = RCS_getversion (rcsfile, NULL, NULL, 0, 0);
+
+ head = RCS_getversion (rcsfile, NULL, NULL, 0, (int *) NULL);
magicrev = RCS_magicrev (rcsfile, head);
- if ((retcode = RCS_settag(rcs, tag, magicrev)) != 0)
+
+ retcode = RCS_settag (rcsfile, tag, magicrev);
+
+ free (head);
+ free (magicrev);
+
+ if (retcode != 0)
{
error (retcode == -1 ? 1 : 0, retcode == -1 ? errno : 0,
"could not stub branch %s for %s", tag, rcs);
- return (1);
- }
-
- freercsnode (&rcsfile);
-
- /* reparse the file, then add it to our list. */
- rcsfile = RCS_parse (file, repository);
- if (rcsfile == NULL)
- {
- error (0, 0, "could not reparse %s", rcs);
- return (1);
+ retval = 1;
+ goto out;
}
-
- free (head);
- free (magicrev);
}
else
{
/* lock the branch. (stubbed branches need not be locked.) */
- if (lock_RCS (file, rcs, NULL, repository)) {
+ if (lock_RCS (file, rcsfile, NULL, repository))
+ {
error (0, 0, "cannot lock `%s'.", rcs);
- return (1);
+ retval = 1;
+ goto out;
}
}
- if (rcsnode)
- freercsnode(rcsnode);
- *rcsnode = rcsfile;
+ if (rcsnode && *rcsnode != rcsfile)
+ {
+ freercsnode(rcsnode);
+ *rcsnode = rcsfile;
+ }
}
fileattr_newfile (file);
fix_rcs_modes (rcs, file);
- return (0);
-}
-
-/*
- * Lock the rcs file ``file''
- */
-static int
-lockrcsfile (file, repository, rev)
- char *file;
- char *repository;
- char *rev;
-{
- char rcs[PATH_MAX];
+ retval = 0;
- locate_rcs (file, repository, rcs);
- if (lock_RCS (file, rcs, rev, repository) != 0)
- return (1);
- else
- return (0);
+ out:
+ free (rcs);
+ return retval;
}
/*
@@ -1673,11 +2001,10 @@ lockrcsfile (file, repository, rev)
static int
lock_RCS (user, rcs, rev, repository)
char *user;
- char *rcs;
+ RCSNode *rcs;
char *rev;
char *repository;
{
- RCSNode *rcsfile;
char *branch = NULL;
int err = 0;
@@ -1692,29 +2019,19 @@ lock_RCS (user, rcs, rev, repository)
*/
if (rev == NULL || (rev && isdigit (*rev) && numdots (rev) < 2))
{
- if ((rcsfile = RCS_parsercsfile (rcs)) == NULL)
- {
- /* invalid rcs file? */
- err = 1;
- }
- else
+ branch = xstrdup (rcs->branch);
+ if (branch != NULL)
{
- /* rcsfile is valid */
- branch = xstrdup (rcsfile->branch);
- freercsnode (&rcsfile);
- if (branch != NULL)
+ if (RCS_setbranch (rcs, NULL) != 0)
{
- if (RCS_setbranch (rcs, NULL) != 0)
- {
- error (0, 0, "cannot change branch to default for %s",
- rcs);
- if (branch)
- free (branch);
- return (1);
- }
+ error (0, 0, "cannot change branch to default for %s",
+ rcs->path);
+ if (branch)
+ free (branch);
+ return (1);
}
- err = RCS_lock(rcs, NULL, 0);
}
+ err = RCS_lock(rcs, NULL, 0);
}
else
{
@@ -1723,52 +2040,96 @@ lock_RCS (user, rcs, rev, repository)
if (err == 0)
{
+ if (sbranch != NULL)
+ free (sbranch);
if (branch)
{
- (void) strcpy (sbranch, branch);
- free (branch);
+ sbranch = branch;
}
else
- sbranch[0] = '\0';
+ sbranch = NULL;
return (0);
}
/* try to restore the branch if we can on error */
if (branch != NULL)
- fixbranch (user, repository, branch);
+ fixbranch (rcs, branch);
if (branch)
free (branch);
return (1);
}
-/*
- * Called when "add"ing files to the RCS respository, as it is necessary to
- * preserve the file modes in the same fashion that RCS does. This would be
- * automatic except that we are placing the RCS ,v file very far away from
- * the user file, and I can't seem to convince RCS of the location of the
- * user file. So we munge it here, after the ,v file has been successfully
- * initialized with "rcs -i".
- */
+/* Called when "add"ing files to the RCS respository. It doesn't seem to
+ be possible to get RCS to use the right mode, so we change it after
+ the fact. */
+
static void
fix_rcs_modes (rcs, user)
char *rcs;
char *user;
{
struct stat sb;
+ mode_t rcs_mode;
- if (stat (user, &sb) != -1)
- (void) chmod (rcs, (int) sb.st_mode & ~0222);
+ if (CVS_STAT (user, &sb) < 0)
+ {
+ /* FIXME: Should be ->fullname. */
+ error (0, errno, "warning: cannot stat %s", user);
+ return;
+ }
+
+ /* Now we compute the new mode.
+
+ The algorithm that we use is:
+
+ Write permission is always off (this is what RCS and CVS have always
+ done).
+
+ If S_IRUSR is on (user read), then the read permission of
+ the RCS file will be on. It would seem that if this is off,
+ then other users can't do "cvs update" and such, so perhaps this
+ should be hardcoded to being on (it is a strange case, though--the
+ case in which a user file doesn't have user read permission on).
+
+ If S_IXUSR is on (user execute), then set execute permission
+ on the RCS file. This allows other users who check out the file
+ to get the right setting for whether a shell script (for example)
+ has the executable bit set.
+
+ The result of that calculation is modified by CVSUMASK. The
+ reason, of course, that the read and execute settings take the
+ user bit and copy it to all three bits (user, group, other), is
+ that it should be CVSUMASK, not the umask of individual users,
+ which is the sole determiner of modes in the repository. */
+
+ rcs_mode = 0;
+ if (sb.st_mode & S_IRUSR)
+ rcs_mode |= S_IRUSR | S_IRGRP | S_IROTH;
+ if (sb.st_mode & S_IXUSR)
+ rcs_mode |= S_IXUSR | S_IXGRP | S_IXOTH;
+ rcs_mode &= ~cvsumask;
+ if (chmod (rcs, rcs_mode) < 0)
+ error (0, errno, "warning: cannot change mode of %s", rcs);
}
/*
- * free an UPDATE node's data (really nothing to do)
+ * free an UPDATE node's data
*/
void
update_delproc (p)
Node *p;
{
- p->data = (char *) NULL;
+ struct logfile_info *li;
+
+ li = (struct logfile_info *) p->data;
+ if (li->tag)
+ free (li->tag);
+ if (li->rev_old)
+ free (li->rev_old);
+ if (li->rev_new)
+ free (li->rev_new);
+ free (li);
}
/*
@@ -1805,15 +2166,23 @@ masterlist_delproc (p)
free (ml);
}
-/*
- * Find an RCS file in the repository.
- */
-static void
-locate_rcs (file, repository, rcs)
+/* Find an RCS file in the repository. Most parts of CVS will want to
+ rely instead on RCS_parse which performs a similar operation and is
+ called by recurse.c which then puts the result in useful places
+ like the rcs field of struct file_info.
+
+ REPOSITORY is the repository (including the directory) and FILE is
+ the filename within that directory (without RCSEXT). Returns a
+ newly-malloc'd array containing the absolute pathname of the RCS
+ file that was found. */
+static char *
+locate_rcs (file, repository)
char *file;
char *repository;
- char *rcs;
{
+ char *rcs;
+
+ rcs = xmalloc (strlen (repository) + strlen (file) + sizeof (RCSEXT) + 10);
(void) sprintf (rcs, "%s/%s%s", repository, file, RCSEXT);
if (!isreadable (rcs))
{
@@ -1821,4 +2190,5 @@ locate_rcs (file, repository, rcs)
if (!isreadable (rcs))
(void) sprintf (rcs, "%s/%s%s", repository, file, RCSEXT);
}
+ return rcs;
}
diff --git a/contrib/cvs/src/create_adm.c b/contrib/cvs/src/create_adm.c
index fd7fd4d..0ef6e57 100644
--- a/contrib/cvs/src/create_adm.c
+++ b/contrib/cvs/src/create_adm.c
@@ -16,32 +16,34 @@
/* update_dir includes dir as its last component. */
void
-Create_Admin (dir, update_dir, repository, tag, date)
+Create_Admin (dir, update_dir, repository, tag, date, nonbranch)
char *dir;
char *update_dir;
char *repository;
char *tag;
char *date;
+ int nonbranch;
{
FILE *fout;
char *cp;
- char tmp[PATH_MAX];
+ char *tmp;
#ifdef SERVER_SUPPORT
if (trace)
{
- char wd[PATH_MAX];
- getwd (wd);
+ char *wd = xgetwd ();
fprintf (stderr, "%c-> Create_Admin (%s, %s, %s, %s, %s) in %s\n",
(server_active) ? 'S' : ' ',
dir, update_dir, repository, tag ? tag : "",
date ? date : "", wd);
+ free (wd);
}
#endif
if (noexec)
return;
+ tmp = xmalloc (strlen (dir) + 100);
if (dir != NULL)
(void) sprintf (tmp, "%s/%s", dir, CVSADM);
else
@@ -53,12 +55,12 @@ Create_Admin (dir, update_dir, repository, tag, date)
/* record the current cvs root for later use */
- Create_Root (dir, CVSroot);
+ Create_Root (dir, CVSroot_original);
if (dir != NULL)
(void) sprintf (tmp, "%s/%s", dir, CVSADM_REP);
else
(void) strcpy (tmp, CVSADM_REP);
- fout = fopen (tmp, "w+");
+ fout = CVS_FOPEN (tmp, "w+");
if (fout == NULL)
{
if (update_dir[0] == '\0')
@@ -67,20 +69,21 @@ Create_Admin (dir, update_dir, repository, tag, date)
error (1, errno, "cannot open %s/%s", update_dir, CVSADM_REP);
}
cp = repository;
- strip_path (cp);
+ strip_trailing_slashes (cp);
#ifdef RELATIVE_REPOS
/*
* If the Repository file is to hold a relative path, try to strip off
* the leading CVSroot argument.
*/
- if (CVSroot != NULL)
+ if (CVSroot_directory != NULL)
{
- char path[PATH_MAX];
+ char *path = xmalloc (strlen (CVSroot_directory) + 10);
- (void) sprintf (path, "%s/", CVSroot);
+ (void) sprintf (path, "%s/", CVSroot_directory);
if (strncmp (repository, path, strlen (path)) == 0)
cp = repository + strlen (path);
+ free (path);
}
#endif
@@ -104,7 +107,7 @@ Create_Admin (dir, update_dir, repository, tag, date)
(void) sprintf (tmp, "%s/%s", dir, CVSADM_ENT);
else
(void) strcpy (tmp, CVSADM_ENT);
- fout = fopen (tmp, "w+");
+ fout = CVS_FOPEN (tmp, "w+");
if (fout == NULL)
{
if (update_dir[0] == '\0')
@@ -121,12 +124,11 @@ Create_Admin (dir, update_dir, repository, tag, date)
}
/* Create a new CVS/Tag file */
- WriteTag (dir, tag, date);
+ WriteTag (dir, tag, date, nonbranch, update_dir, repository);
#ifdef SERVER_SUPPORT
if (server_active)
{
- server_set_sticky (update_dir, repository, tag, date);
server_template (update_dir, repository);
}
@@ -137,4 +139,5 @@ Create_Admin (dir, update_dir, repository, tag, date)
}
#endif
+ free (tmp);
}
diff --git a/contrib/cvs/src/cvs.h b/contrib/cvs/src/cvs.h
index 8e50f5d..81659f3 100644
--- a/contrib/cvs/src/cvs.h
+++ b/contrib/cvs/src/cvs.h
@@ -1,4 +1,10 @@
-/* $CVSid: @(#)cvs.h 1.86 94/10/22 $ */
+/*
+ * Copyright (c) 1992, Brian Berliner and Jeff Polk
+ * 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 kit.
+ */
/*
* basic information used in all source files
@@ -76,7 +82,6 @@ extern int errno;
#include "hash.h"
#if defined(SERVER_SUPPORT) || defined(CLIENT_SUPPORT)
-#include "server.h"
#include "client.h"
#endif
@@ -93,7 +98,10 @@ extern int errno;
#include "rcs.h"
-/* XXX - for now this is static */
+/* This actually gets set in system.h. Note that the _ONLY_ reason for
+ this is if various system calls (getwd, getcwd, readlink) require/want
+ us to use it. All other parts of CVS allocate pathname buffers
+ dynamically, and we want to keep it that way. */
#ifndef PATH_MAX
#ifdef MAXPATHLEN
#define PATH_MAX MAXPATHLEN+2
@@ -102,22 +110,8 @@ extern int errno;
#endif
#endif /* PATH_MAX */
-/* just in case this implementation does not define this */
-#ifndef L_tmpnam
-#define L_tmpnam 50
-#endif
-
-
-/*
- * Copyright (c) 1992, Brian Berliner and Jeff Polk
- * 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.
- *
- * Definitions for the CVS Administrative directory and the files it contains.
- * Here as #define's to make changing the names a simple task.
- */
+/* Definitions for the CVS Administrative directory and the files it contains.
+ Here as #define's to make changing the names a simple task. */
#ifdef USE_VMS_FILENAMES
#define CVSADM "CVS"
@@ -177,6 +171,7 @@ extern int errno;
#define CVSROOTADM_COMMITINFO "commitinfo"
#define CVSROOTADM_TAGINFO "taginfo"
#define CVSROOTADM_EDITINFO "editinfo"
+#define CVSROOTADM_VERIFYMSG "verifymsg"
#define CVSROOTADM_HISTORY "history"
#define CVSROOTADM_VALTAGS "val-tags"
#define CVSROOTADM_IGNORE "cvsignore"
@@ -184,6 +179,9 @@ extern int errno;
#define CVSROOTADM_WRAPPER "cvswrappers"
#define CVSROOTADM_NOTIFY "notify"
#define CVSROOTADM_USERS "users"
+#define CVSROOTADM_READERS "readers"
+#define CVSROOTADM_WRITERS "writers"
+#define CVSROOTADM_PASSWD "passwd"
#define CVSNULLREPOS "Emptydir" /* an empty directory */
@@ -205,8 +203,29 @@ extern int errno;
#define CVSDOTIGNORE ".cvsignore"
#define CVSDOTWRAPPER ".cvswrappers"
+/* Command attributes -- see function lookup_command_attribute(). */
+#define CVS_CMD_IGNORE_ADMROOT 1
+
+/* Set if CVS does _not_ need to create a CVS/Root file upon
+ completion of this command. The name is confusing, both because
+ the meaning is closer to "does not use working directory" than
+ "uses working directory" and because the flag isn't really as
+ general purpose as it seems (cvs release sets it). */
+
+#define CVS_CMD_USES_WORK_DIR 2
+
+#define CVS_CMD_MODIFIES_REPOSITORY 4
+
/* miscellaneous CVS defines */
+
+/* This is the string which is at the start of the non-log-message lines
+ that we put up for the user when they edit the log message. */
#define CVSEDITPREFIX "CVS: "
+/* Number of characters in CVSEDITPREFIX to compare when deciding to strip
+ off those lines. We don't check for the space, to accomodate users who
+ have editors which strip trailing spaces. */
+#define CVSEDITPREFIXLEN 4
+
#define CVSLCKAGE (60*60) /* 1-hour old lock files cleaned up */
#define CVSLCKSLEEP 30 /* wait 30 seconds before retrying */
#define CVSBRANCH "1.1.1" /* RCS branch used for vendor srcs */
@@ -237,12 +256,15 @@ extern int errno;
#define CVSREAD_DFLT FALSE /* writable files by default */
#define RCSBIN_ENV "RCSBIN" /* RCS binary directory */
-/* #define RCSBIN_DFLT Set by config.h */
+/* #define RCSBIN_DFLT Set by options.h */
+
+#define TMPDIR_ENV "TMPDIR" /* Temporary directory */
+/* #define TMPDIR_DFLT Set by options.h */
#define EDITOR1_ENV "CVSEDITOR" /* which editor to use */
#define EDITOR2_ENV "VISUAL" /* which editor to use */
#define EDITOR3_ENV "EDITOR" /* which editor to use */
-/* #define EDITOR_DFLT Set by config.h */
+/* #define EDITOR_DFLT Set by options.h */
#define CVSROOT_ENV "CVSROOT" /* source directory root */
#define CVSROOT_DFLT NULL /* No dflt; must set for checkout */
@@ -251,7 +273,7 @@ extern int errno;
#define WRAPPER_ENV "CVSWRAPPERS" /* name of the wrapper file */
#define CVSUMASK_ENV "CVSUMASK" /* Effective umask for repository */
-/* #define CVSUMASK_DFLT Set by config.h */
+/* #define CVSUMASK_DFLT Set by options.h */
/*
* If the beginning of the Repository matches the following string, strip it
@@ -261,20 +283,21 @@ extern int errno;
*/
#define REPOS_STRIP "/master/"
-/*
- * The maximum number of files per each CVS directory. This is mainly for
- * sizing arrays statically rather than dynamically. 3000 seems plenty for
- * now.
- */
-#define MAXFILEPERDIR 3000
-#define MAXLINELEN 5000 /* max input line from a file */
-#define MAXPROGLEN 30000 /* max program length to system() */
-#define MAXLISTLEN 40000 /* For [A-Z]list holders */
-#define MAXDATELEN 50 /* max length for a date */
+/* Large enough to hold DATEFORM. Not an arbitrary limit as long as
+ it is used for that purpose, and not to hold a string from the
+ command line, the client, etc. */
+#define MAXDATELEN 50
+
+/* The type of an entnode. */
+enum ent_type
+{
+ ENT_FILE, ENT_SUBDIR
+};
/* structure of a entry record */
struct entnode
{
+ enum ent_type type;
char *user;
char *version;
char *timestamp;
@@ -292,96 +315,22 @@ enum mtype
};
/*
- * defines for Classify_File() to determine the current state of a file.
- * These are also used as types in the data field for the list we make for
- * Update_Logfile in commit, import, and add.
- */
-enum classify_type
-{
- T_UNKNOWN = 1, /* no old-style analog existed */
- T_CONFLICT, /* C (conflict) list */
- T_NEEDS_MERGE, /* G (needs merging) list */
- T_MODIFIED, /* M (needs checked in) list */
- T_CHECKOUT, /* O (needs checkout) list */
- T_ADDED, /* A (added file) list */
- T_REMOVED, /* R (removed file) list */
- T_REMOVE_ENTRY, /* W (removed entry) list */
- T_UPTODATE, /* File is up-to-date */
-#ifdef SERVER_SUPPORT
- T_PATCH, /* P Like C, but can patch */
-#endif
- T_TITLE /* title for node type */
-};
-typedef enum classify_type Ctype;
-
-/*
- * a struct vers_ts contains all the information about a file including the
- * user and rcs file names, and the version checked out and the head.
- *
- * this is usually obtained from a call to Version_TS which takes a tag argument
- * for the RCS file if desired
- */
-struct vers_ts
-{
- /* rcs version user file derives from, from CVS/Entries.
- * it can have the following special values:
- * empty = no user file
- * 0 = user file is new
- * -vers = user file to be removed. */
- char *vn_user;
-
- /* Numeric revision number corresponding to ->vn_tag (->vn_tag
- will often be symbolic). */
- char *vn_rcs;
- /* If ->tag corresponds to a tag which really exists in this file,
- this is just a copy of ->tag. If not, this is either NULL or
- the head revision. (Or something like that, see RCS_getversion
- and friends). */
- char *vn_tag;
-
- /* This is the timestamp from stating the file in the working directory.
- It is NULL if there is no file in the working directory. */
- char *ts_user;
- /* Timestamp from CVS/Entries. For the server, ts_user and ts_rcs
- are computed in a slightly different way, but the fact remains that
- if they are equal the file in the working directory is unmodified
- and if they differ it is modified. */
- char *ts_rcs;
-
- /* Options from CVS/Entries (keyword expansion). */
- char *options;
-
- /* If non-NULL, there was a conflict (or merely a merge? See merge_file)
- and the time stamp in this field is the time stamp of the working
- directory file which was created with the conflict markers in it.
- This is from CVS/Entries. */
- char *ts_conflict;
-
- /* Tag specified on the command line, or if none, tag stored in
- CVS/Entries. */
- char *tag;
- /* Date specified on the command line, or if none, date stored in
- CVS/Entries. */
- char *date;
-
- /* Pointer to entries file node */
- Entnode *entdata;
-
- /* Pointer to parsed src file info */
- RCSNode *srcfile;
-};
-typedef struct vers_ts Vers_TS;
-
-/*
* structure used for list-private storage by Entries_Open() and
- * Version_TS().
+ * Version_TS() and Find_Directories().
*/
struct stickydirtag
{
+ /* These fields pass sticky tag information from Entries_Open() to
+ Version_TS(). */
int aflag;
char *tag;
char *date;
- char *options;
+ int nonbranch;
+
+ /* This field is set by Entries_Open() if there was subdirectory
+ information; Find_Directories() uses it to see whether it needs
+ to scan the directory itself. */
+ int subdirs;
};
/* Flags for find_{names,dirs} routines */
@@ -397,11 +346,14 @@ enum direnter_type
R_SKIP_DIRS, /* don't process sub-dirs */
R_SKIP_ALL /* don't process files or dirs */
};
+#ifdef ENUMS_CAN_BE_TROUBLE
+typedef int Dtype;
+#else
typedef enum direnter_type Dtype;
+#endif
extern char *program_name, *program_path, *command_name;
-extern char *Rcsbin, *Editor, *CVSroot;
-extern char *CVSADM_Root;
+extern char *Rcsbin, *Tmpdir, *Editor;
extern int cvsadmin_root;
extern char *CurDir;
extern int really_quiet, quiet;
@@ -409,32 +361,48 @@ extern int use_editor;
extern int cvswrite;
extern mode_t cvsumask;
+/* Access method specified in CVSroot. */
+typedef enum {
+ local_method, server_method, pserver_method, kserver_method, ext_method
+} CVSmethod;
+extern char *method_names[]; /* change this in root.c if you change
+ the enum above */
+
+extern char *CVSroot_original; /* the active, complete CVSroot string */
+extern int client_active; /* nonzero if we are doing remote access */
+extern CVSmethod CVSroot_method; /* one of the enum values above */
+extern char *CVSroot_username; /* the username or NULL if method == local */
+extern char *CVSroot_hostname; /* the hostname or NULL if method == local */
+extern char *CVSroot_directory; /* the directory name */
+
extern int trace; /* Show all commands */
extern int noexec; /* Don't modify disk anywhere */
extern int logoff; /* Don't write history entry */
+#ifdef AUTH_SERVER_SUPPORT
+extern char *Pserver_Repos; /* used to check that same repos is
+ transmitted in pserver auth and in
+ CVS protocol. */
+#endif /* AUTH_SERVER_SUPPORT */
+
extern char hostname[];
/* Externs that are included directly in the CVS sources */
-int RCS_settag PROTO((const char *, const char *, const char *));
-int RCS_deltag PROTO((const char *, const char *, int));
-int RCS_setbranch PROTO((const char *, const char *));
-int RCS_lock PROTO((const char *, const char *, int));
-int RCS_unlock PROTO((const char *, const char *, int));
+int RCS_exec_settag PROTO((const char *, const char *, const char *));
+int RCS_exec_deltag PROTO((const char *, const char *, int));
+int RCS_exec_setbranch PROTO((const char *, const char *));
+int RCS_exec_lock PROTO((const char *, const char *, int));
+int RCS_exec_unlock PROTO((const char *, const char *, int));
int RCS_merge PROTO((const char *, const char *, const char *, const char *));
-int RCS_checkout PROTO ((char *rcsfile, char *workfile, char *tag,
- char *options,
- char *sout, int flags, int noerr));
/* Flags used by RCS_* functions. See the description of the individual
functions for which flags mean what for each function. */
-#define RCS_FLAGS_LOCK 1
-#define RCS_FLAGS_FORCE 2
-#define RCS_FLAGS_DEAD 4
-#define RCS_FLAGS_QUIET 8
-#define RCS_FLAGS_MODTIME 16
+#define RCS_FLAGS_FORCE 1
+#define RCS_FLAGS_DEAD 2
+#define RCS_FLAGS_QUIET 4
+#define RCS_FLAGS_MODTIME 8
int RCS_checkin PROTO ((char *rcsfile, char *workfile, char *message,
- char *rev, int flags, int noerr));
+ char *rev, int flags));
@@ -442,30 +410,35 @@ int RCS_checkin PROTO ((char *rcsfile, char *workfile, char *message,
DBM *open_module PROTO((void));
FILE *open_file PROTO((const char *, const char *));
-List *Find_Directories PROTO((char *repository, int which));
+List *Find_Directories PROTO((char *repository, int which, List *entries));
void Entries_Close PROTO((List *entries));
List *Entries_Open PROTO((int aflag));
+void Subdirs_Known PROTO((List *entries));
+void Subdir_Register PROTO((List *, const char *, const char *));
+void Subdir_Deregister PROTO((List *, const char *, const char *));
char *Make_Date PROTO((char *rawdate));
char *Name_Repository PROTO((char *dir, char *update_dir));
char *Name_Root PROTO((char *dir, char *update_dir));
+int parse_cvsroot PROTO((char *CVSroot));
+void set_local_cvsroot PROTO((char *dir));
void Create_Root PROTO((char *dir, char *rootdir));
int same_directories PROTO((char *dir1, char *dir2));
char *Short_Repository PROTO((char *repository));
char *gca PROTO((char *rev1, char *rev2));
char *getcaller PROTO((void));
char *time_stamp PROTO((char *file));
+
char *xmalloc PROTO((size_t bytes));
void *xrealloc PROTO((void *ptr, size_t bytes));
+void expand_string PROTO ((char **, size_t *, size_t));
char *xstrdup PROTO((const char *str));
void strip_trailing_newlines PROTO((char *str));
-int No_Difference PROTO((char *file, Vers_TS * vers, List * entries,
- char *repository, char *update_dir));
+int pathname_levels PROTO ((char *path));
+
typedef int (*CALLPROC) PROTO((char *repository, char *value));
int Parse_Info PROTO((char *infofile, char *repository, CALLPROC callproc, int all));
-int Reader_Lock PROTO((char *xrepository));
typedef RETSIGTYPE (*SIGCLEANUPPROC) PROTO(());
int SIG_register PROTO((int sig, SIGCLEANUPPROC sigcleanup));
-int Writer_Lock PROTO((List * list));
int isdir PROTO((const char *file));
int isfile PROTO((const char *file));
int islink PROTO((const char *file));
@@ -475,6 +448,7 @@ int isaccessible PROTO((const char *file, const int mode));
int isabsolute PROTO((const char *filename));
char *last_component PROTO((char *path));
char *get_homedir PROTO ((void));
+char *cvs_temp_name PROTO ((void));
int numdots PROTO((const char *s));
int unlink_file PROTO((const char *f));
@@ -486,29 +460,31 @@ int yesno PROTO((void));
void *valloc PROTO((size_t bytes));
time_t get_date PROTO((char *date, struct timeb *now));
void Create_Admin PROTO((char *dir, char *update_dir,
- char *repository, char *tag, char *date));
+ char *repository, char *tag, char *date,
+ int nonbranch));
+/* Locking subsystem (implemented in lock.c). */
+
+int Reader_Lock PROTO((char *xrepository));
void Lock_Cleanup PROTO((void));
/* Writelock an entire subtree, well the part specified by ARGC, ARGV, LOCAL,
and AFLAG, anyway. */
void lock_tree_for_write PROTO ((int argc, char **argv, int local, int aflag));
-/* Remove locks set by lock_tree_for_write. Currently removes readlocks
- too. */
-void lock_tree_cleanup PROTO ((void));
+/* See lock.c for description. */
+extern void lock_dir_for_write PROTO ((char *));
-void ParseTag PROTO((char **tagp, char **datep));
void Scratch_Entry PROTO((List * list, char *fname));
-void WriteTag PROTO((char *dir, char *tag, char *date));
+void ParseTag PROTO((char **tagp, char **datep, int *nonbranchp));
+void WriteTag PROTO ((char *dir, char *tag, char *date, int nonbranch,
+ char *update_dir, char *repository));
void cat_module PROTO((int status));
void check_entries PROTO((char *dir));
void close_module PROTO((DBM * db));
void copy_file PROTO((const char *from, const char *to));
-void (*error_set_cleanup PROTO((void (*) (void)))) PROTO ((void));
void fperror PROTO((FILE * fp, int status, int errnum, char *message,...));
void free_names PROTO((int *pargc, char *argv[]));
-void freevers_ts PROTO((Vers_TS ** versp));
extern int ign_name PROTO ((char *name));
void ign_add PROTO((char *ign, int hold));
@@ -517,15 +493,16 @@ void ign_setup PROTO((void));
void ign_dir_add PROTO((char *name));
int ignore_directory PROTO((char *name));
typedef void (*Ignore_proc) PROTO ((char *, char *));
-extern void ignore_files PROTO ((List *, char *, Ignore_proc));
+extern void ignore_files PROTO ((List *, List *, char *, Ignore_proc));
extern int ign_inhibit_server;
extern int ign_case;
#include "update.h"
-void line2argv PROTO((int *pargc, char *argv[], char *line));
+void line2argv PROTO ((int *pargc, char ***argv, char *line));
void make_directories PROTO((const char *name));
void make_directory PROTO((const char *name));
+extern int mkdir_if_needed PROTO ((char *name));
void rename_file PROTO((const char *from, const char *to));
/* Expand wildcards in each element of (ARGC,ARGV). This is according to the
files which exist in the current directory, and accordingly to OS-specific
@@ -537,31 +514,27 @@ void rename_file PROTO((const char *from, const char *to));
extern void expand_wild PROTO ((int argc, char **argv,
int *pargc, char ***pargv));
-void strip_path PROTO((char *path));
+#ifdef SERVER_SUPPORT
+extern int cvs_casecmp PROTO ((char *, char *));
+extern int fopen_case PROTO ((char *, char *, FILE **, char **));
+#endif
+
void strip_trailing_slashes PROTO((char *path));
void update_delproc PROTO((Node * p));
void usage PROTO((const char *const *cpp));
void xchmod PROTO((char *fname, int writable));
char *xgetwd PROTO((void));
-int Checkin PROTO((int type, char *file, char *update_dir,
- char *repository, char *rcs, char *rev,
- char *tag, char *options, char *message, List *entries));
-Ctype Classify_File PROTO((char *file, char *tag, char *date, char *options,
- int force_tag_match, int aflag, char *repository,
- List *entries, RCSNode *rcsnode, Vers_TS **versp,
- char *update_dir, int pipeout));
List *Find_Names PROTO((char *repository, int which, int aflag,
List ** optentries));
void Register PROTO((List * list, char *fname, char *vn, char *ts,
char *options, char *tag, char *date, char *ts_conflict));
-void Update_Logfile PROTO((char *repository, char *xmessage, char *xrevision,
- FILE * xlogfp, List * xchanges));
-Vers_TS *Version_TS PROTO((char *repository, char *options, char *tag,
- char *date, char *user, int force_tag_match,
- int set_time, List * entries, RCSNode * rcs));
+void Update_Logfile PROTO((char *repository, char *xmessage, FILE * xlogfp,
+ List * xchanges));
void do_editor PROTO((char *dir, char **messagep,
char *repository, List * changes));
+void do_verify PROTO((char *message, char *repository));
+
typedef int (*CALLBACKPROC) PROTO((int *pargc, char *argv[], char *where,
char *mwhere, char *mfile, int horten, int local_specified,
char *omodule, char *msg));
@@ -595,10 +568,15 @@ struct file_info
RCSNode *rcs;
};
-typedef int (*FILEPROC) PROTO((struct file_info *finfo));
-typedef int (*FILESDONEPROC) PROTO((int err, char *repository, char *update_dir));
-typedef Dtype (*DIRENTPROC) PROTO((char *dir, char *repos, char *update_dir));
-typedef int (*DIRLEAVEPROC) PROTO((char *dir, int err, char *update_dir));
+typedef int (*FILEPROC) PROTO ((void *callerdat, struct file_info *finfo));
+typedef int (*FILESDONEPROC) PROTO ((void *callerdat, int err,
+ char *repository, char *update_dir,
+ List *entries));
+typedef Dtype (*DIRENTPROC) PROTO ((void *callerdat, char *dir,
+ char *repos, char *update_dir,
+ List *entries));
+typedef int (*DIRLEAVEPROC) PROTO ((void *callerdat, char *dir, int err,
+ char *update_dir, List *entries));
extern int mkmodules PROTO ((char *dir));
extern int init PROTO ((int argc, char **argv));
@@ -606,22 +584,20 @@ extern int init PROTO ((int argc, char **argv));
int do_module PROTO((DBM * db, char *mname, enum mtype m_type, char *msg,
CALLBACKPROC callback_proc, char *where, int shorten,
int local_specified, int run_module_prog, char *extra_arg));
-int do_recursion PROTO((FILEPROC xfileproc, FILESDONEPROC xfilesdoneproc,
- DIRENTPROC xdirentproc, DIRLEAVEPROC xdirleaveproc,
- Dtype xflags, int xwhich, int xaflag, int xreadlock,
- int xdosrcs));
void history_write PROTO((int type, char *update_dir, char *revs, char *name,
char *repository));
int start_recursion PROTO((FILEPROC fileproc, FILESDONEPROC filesdoneproc,
DIRENTPROC direntproc, DIRLEAVEPROC dirleaveproc,
+ void *callerdat,
int argc, char *argv[], int local, int which,
int aflag, int readlock, char *update_preload,
- int dosrcs, int wd_is_repos));
+ int dosrcs));
void SIG_beginCrSect PROTO((void));
void SIG_endCrSect PROTO((void));
void read_cvsrc PROTO((int *argc, char ***argv, char *cmdname));
char *make_message_rcslegal PROTO((char *message));
+extern int file_has_markers PROTO ((struct file_info *));
/* flags for run_exec(), the fast system() for CVS */
#define RUN_NORMAL 0x0000 /* no special behaviour */
@@ -651,18 +627,142 @@ int filter_stream_through_program PROTO((int, int, char **, pid_t *));
pid_t waitpid PROTO((pid_t, int *, int));
+/*
+ * a struct vers_ts contains all the information about a file including the
+ * user and rcs file names, and the version checked out and the head.
+ *
+ * this is usually obtained from a call to Version_TS which takes a
+ * tag argument for the RCS file if desired
+ */
+struct vers_ts
+{
+ /* rcs version user file derives from, from CVS/Entries.
+ * it can have the following special values:
+ * empty = no user file
+ * 0 = user file is new
+ * -vers = user file to be removed. */
+ char *vn_user;
+
+ /* Numeric revision number corresponding to ->vn_tag (->vn_tag
+ will often be symbolic). */
+ char *vn_rcs;
+ /* If ->tag is a simple tag in the RCS file--a tag which really
+ exists which is not a magic revision--and if ->date is NULL,
+ then this is a copy of ->tag. Otherwise, it is a copy of
+ ->vn_rcs. */
+ char *vn_tag;
+
+ /* This is the timestamp from stating the file in the working directory.
+ It is NULL if there is no file in the working directory. It is
+ "Is-modified" if we know the file is modified but don't have its
+ contents. */
+ char *ts_user;
+ /* Timestamp from CVS/Entries. For the server, ts_user and ts_rcs
+ are computed in a slightly different way, but the fact remains that
+ if they are equal the file in the working directory is unmodified
+ and if they differ it is modified. */
+ char *ts_rcs;
+
+ /* Options from CVS/Entries (keyword expansion). */
+ char *options;
+
+ /* If non-NULL, there was a conflict (or merely a merge? See merge_file)
+ and the time stamp in this field is the time stamp of the working
+ directory file which was created with the conflict markers in it.
+ This is from CVS/Entries. */
+ char *ts_conflict;
+
+ /* Tag specified on the command line, or if none, tag stored in
+ CVS/Entries. */
+ char *tag;
+ /* Date specified on the command line, or if none, date stored in
+ CVS/Entries. */
+ char *date;
+ /* If this is 1, then tag is not a branch tag. If this is 0, then
+ tag may or may not be a branch tag. */
+ int nonbranch;
+
+ /* Pointer to entries file node */
+ Entnode *entdata;
+
+ /* Pointer to parsed src file info */
+ RCSNode *srcfile;
+};
+typedef struct vers_ts Vers_TS;
+
+Vers_TS *Version_TS PROTO ((struct file_info *finfo, char *options, char *tag,
+ char *date, int force_tag_match,
+ int set_time));
+void freevers_ts PROTO ((Vers_TS ** versp));
+
+/* Miscellaneous CVS infrastructure which layers on top of the recursion
+ processor (for example, needs struct file_info). */
+
+int Checkin PROTO ((int type, struct file_info *finfo, char *rcs, char *rev,
+ char *tag, char *options, char *message));
+int No_Difference PROTO ((struct file_info *finfo, Vers_TS *vers));
+
+/*
+ * defines for Classify_File() to determine the current state of a file.
+ * These are also used as types in the data field for the list we make for
+ * Update_Logfile in commit, import, and add.
+ */
+enum classify_type
+{
+ T_UNKNOWN = 1, /* no old-style analog existed */
+ T_CONFLICT, /* C (conflict) list */
+ T_NEEDS_MERGE, /* G (needs merging) list */
+ T_MODIFIED, /* M (needs checked in) list */
+ T_CHECKOUT, /* O (needs checkout) list */
+ T_ADDED, /* A (added file) list */
+ T_REMOVED, /* R (removed file) list */
+ T_REMOVE_ENTRY, /* W (removed entry) list */
+ T_UPTODATE, /* File is up-to-date */
+#ifdef SERVER_SUPPORT
+ T_PATCH, /* P Like C, but can patch */
+#endif
+ T_TITLE /* title for node type */
+};
+typedef enum classify_type Ctype;
+
+Ctype Classify_File PROTO
+ ((struct file_info *finfo, char *tag, char *date, char *options,
+ int force_tag_match, int aflag, Vers_TS **versp, int pipeout));
+
+/*
+ * structure used for list nodes passed to Update_Logfile() and
+ * do_editor().
+ */
+struct logfile_info
+{
+ enum classify_type type;
+ char *tag;
+ char *rev_old; /* rev number before a commit/modify,
+ NULL for add or import */
+ char *rev_new; /* rev number after a commit/modify,
+ add, or import, NULL for remove */
+};
+
/* Wrappers. */
typedef enum { WRAP_MERGE, WRAP_COPY } WrapMergeMethod;
-typedef enum { WRAP_TOCVS, WRAP_FROMCVS, WRAP_CONFLICT } WrapMergeHas;
+typedef enum {
+ /* -t and -f wrapper options. Treating directories as single files. */
+ WRAP_TOCVS,
+ WRAP_FROMCVS,
+ /* -k wrapper option. Default keyword expansion options. */
+ WRAP_RCSOPTION
+} WrapMergeHas;
void wrap_setup PROTO((void));
int wrap_name_has PROTO((const char *name,WrapMergeHas has));
+char *wrap_rcsoption PROTO ((const char *fileName, int asFlag));
char *wrap_tocvs_process_file PROTO((const char *fileName));
int wrap_merge_is_copy PROTO((const char *fileName));
-char *wrap_fromcvs_process_file PROTO((const char *fileName));
+void wrap_fromcvs_process_file PROTO ((const char *fileName));
void wrap_add_file PROTO((const char *file,int temp));
void wrap_add PROTO((char *line,int temp));
+void wrap_send PROTO ((void));
/* Pathname expansion */
char *expand_path PROTO((char *name, char *file, int line));
@@ -678,13 +778,45 @@ int unedit PROTO ((int argc, char **argv));
int editors PROTO ((int argc, char **argv));
int watchers PROTO ((int argc, char **argv));
extern int annotate PROTO ((int argc, char **argv));
+extern int add PROTO ((int argc, char **argv));
+extern int admin PROTO ((int argc, char **argv));
+extern int checkout PROTO ((int argc, char **argv));
+extern int commit PROTO ((int argc, char **argv));
+extern int diff PROTO ((int argc, char **argv));
+extern int history PROTO ((int argc, char **argv));
+extern int import PROTO ((int argc, char **argv));
+extern int cvslog PROTO ((int argc, char **argv));
+#ifdef AUTH_CLIENT_SUPPORT
+extern int login PROTO((int argc, char **argv));
+int logout PROTO((int argc, char **argv));
+#endif /* AUTH_CLIENT_SUPPORT */
+extern int patch PROTO((int argc, char **argv));
+extern int release PROTO((int argc, char **argv));
+extern int cvsremove PROTO((int argc, char **argv));
+extern int rtag PROTO((int argc, char **argv));
+extern int status PROTO((int argc, char **argv));
+extern int cvstag PROTO((int argc, char **argv));
+
+extern unsigned long int lookup_command_attribute PROTO((char *));
#if defined(AUTH_CLIENT_SUPPORT) || defined(AUTH_SERVER_SUPPORT)
char *scramble PROTO ((char *str));
char *descramble PROTO ((char *str));
#endif /* AUTH_CLIENT_SUPPORT || AUTH_SERVER_SUPPORT */
+#ifdef AUTH_CLIENT_SUPPORT
+char *get_cvs_password PROTO((void));
+#endif /* AUTH_CLIENT_SUPPORT */
+
extern void tag_check_valid PROTO ((char *, int, char **, int, int, char *));
+extern void tag_check_valid_join PROTO ((char *, int, char **, int, int,
+ char *));
+
+extern void cvs_output PROTO ((const char *, size_t));
+extern void cvs_outerr PROTO ((const char *, size_t));
+extern void cvs_flusherr PROTO ((void));
+extern void cvs_flushout PROTO ((void));
-extern void cvs_output PROTO ((char *, size_t));
-extern void cvs_outerr PROTO ((char *, size_t));
+#if defined(SERVER_SUPPORT) || defined(CLIENT_SUPPORT)
+#include "server.h"
+#endif
diff --git a/contrib/cvs/src/cvsbug.sh b/contrib/cvs/src/cvsbug.sh
index ab26cfc..fd6ae7c 100755
--- a/contrib/cvs/src/cvsbug.sh
+++ b/contrib/cvs/src/cvsbug.sh
@@ -7,8 +7,6 @@
# This file is part of GNU GNATS.
# Modified by Berliner for CVS.
#
-#ident "@(#)cvs/src:$Name: $:$Id: cvsbug.sh,v 1.10 1995/11/15 00:18:00 woods Exp $"
-#
# GNU GNATS is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
@@ -18,10 +16,6 @@
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GNU GNATS; see the file COPYING. If not, write to
-# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
# The version of this send-pr.
VERSION=3.2
@@ -237,11 +231,14 @@ fi
case "$FORMAT" in
lisp) echo "$CATEGORIES" | \
- awk 'BEGIN {printf "( "} {printf "(\"%s\") ",$0} END {printf ")\n"}'
+ awk 'BEGIN {printf "( "}
+ {printf "(\"%s\") ",$0}
+ END {printf ")\n"}'
exit 0
;;
norm) l=`echo "$CATEGORIES" | \
- awk 'BEGIN {max = 0; } { if (length($0) > max) { max = length($0); } }
+ awk 'BEGIN {max = 0; }
+ { if (length($0) > max) { max = length($0); } }
END {print max + 1;}'`
c=`expr 70 / $l`
if [ $c -eq 0 ]; then c=1; fi
@@ -316,7 +313,8 @@ __EOF__
# Format the categories so they fit onto lines.
l=`echo "$CATEGORIES" | \
- awk 'BEGIN {max = 0; } { if (length($0) > max) { max = length($0); } }
+ awk 'BEGIN {max = 0; }
+ { if (length($0) > max) { max = length($0); } }
END {print max + 1;}'`
c=`expr 61 / $l`
if [ $c -eq 0 ]; then c=1; fi
diff --git a/contrib/cvs/src/cvsrc.c b/contrib/cvs/src/cvsrc.c
index 140ce1c..819013c 100644
--- a/contrib/cvs/src/cvsrc.c
+++ b/contrib/cvs/src/cvsrc.c
@@ -55,13 +55,6 @@ read_cvsrc (argc, argv, cmdname)
if (*argc == -1)
return;
- /* setup the new options list */
-
- new_argc = 1;
- max_new_argv = (*argc) + GROW;
- new_argv = (char **) xmalloc (max_new_argv * sizeof (char*));
- new_argv[0] = xstrdup ((*argv)[0]);
-
/* determine filename for ~/.cvsrc */
homedir = get_homedir ();
@@ -105,30 +98,28 @@ read_cvsrc (argc, argv, cmdname)
fclose (cvsrcfile);
+ /* setup the new options list */
+
+ new_argc = 1;
+ max_new_argv = (*argc) + GROW;
+ new_argv = (char **) xmalloc (max_new_argv * sizeof (char*));
+ new_argv[0] = xstrdup ((*argv)[0]);
+
if (found)
{
/* skip over command in the options line */
- optstart = strtok (line + command_len, "\t \n");
-
- do
+ for (optstart = strtok (line + command_len, "\t \n");
+ optstart;
+ optstart = strtok (NULL, "\t \n"))
{
- new_argv [new_argc] = xstrdup (optstart);
- new_argv [new_argc+1] = NULL;
- new_argc += 1;
+ new_argv [new_argc++] = xstrdup (optstart);
if (new_argc >= max_new_argv)
{
- char **tmp_argv;
max_new_argv += GROW;
- tmp_argv = (char **) xmalloc (max_new_argv * sizeof (char*));
- for (i = 0; i <= new_argc; i++)
- tmp_argv[i] = new_argv[i];
- free(new_argv);
- new_argv = tmp_argv;
+ new_argv = (char **) xrealloc (new_argv, max_new_argv * sizeof (char*));
}
-
}
- while ((optstart = strtok (NULL, "\t \n")) != NULL);
}
if (line != NULL)
@@ -136,10 +127,14 @@ read_cvsrc (argc, argv, cmdname)
/* now copy the remaining arguments */
+ if (new_argc + *argc > max_new_argv)
+ {
+ max_new_argv = new_argc + *argc;
+ new_argv = (char **) xrealloc (new_argv, max_new_argv * sizeof (char*));
+ }
for (i=1; i < *argc; i++)
{
- new_argv [new_argc] = (*argv)[i];
- new_argc += 1;
+ new_argv [new_argc++] = (*argv)[i];
}
*argc = new_argc;
diff --git a/contrib/cvs/src/diff.c b/contrib/cvs/src/diff.c
index 7520cec..8253a2f 100644
--- a/contrib/cvs/src/diff.c
+++ b/contrib/cvs/src/diff.c
@@ -16,46 +16,159 @@
#include "cvs.h"
-static Dtype diff_dirproc PROTO((char *dir, char *pos_repos, char *update_dir));
-static int diff_filesdoneproc PROTO((int err, char *repos, char *update_dir));
-static int diff_dirleaveproc PROTO((char *dir, int err, char *update_dir));
-static int diff_file_nodiff PROTO((char *file, char *repository, List *entries,
- RCSNode *rcs, Vers_TS *vers));
-static int diff_fileproc PROTO((struct file_info *finfo));
+enum diff_file
+{
+ DIFF_ERROR,
+ DIFF_ADDED,
+ DIFF_REMOVED,
+ DIFF_DIFFERENT,
+ DIFF_SAME
+};
+
+static Dtype diff_dirproc PROTO ((void *callerdat, char *dir,
+ char *pos_repos, char *update_dir,
+ List *entries));
+static int diff_filesdoneproc PROTO ((void *callerdat, int err,
+ char *repos, char *update_dir,
+ List *entries));
+static int diff_dirleaveproc PROTO ((void *callerdat, char *dir,
+ int err, char *update_dir,
+ List *entries));
+static enum diff_file diff_file_nodiff PROTO ((struct file_info *finfo,
+ Vers_TS *vers,
+ enum diff_file));
+static int diff_fileproc PROTO ((void *callerdat, struct file_info *finfo));
static void diff_mark_errors PROTO((int err));
static char *diff_rev1, *diff_rev2;
static char *diff_date1, *diff_date2;
static char *use_rev1, *use_rev2;
-#ifdef SERVER_SUPPORT
/* Revision of the user file, if it is unchanged from something in the
repository and we want to use that fact. */
static char *user_file_rev;
-#endif
static char *options;
-static char opts[PATH_MAX];
+static char *opts;
+static size_t opts_allocated = 1;
static int diff_errors;
static int empty_files = 0;
+/* FIXME: should be documenting all the options here. They don't
+ perfectly match rcsdiff options (for example, we always support
+ --ifdef and --context, but rcsdiff only does if diff does). */
static const char *const diff_usage[] =
{
- "Usage: %s %s [-lN] [rcsdiff-options]\n",
-#ifdef CVS_DIFFDATE
+ "Usage: %s %s [-lNR] [rcsdiff-options]\n",
" [[-r rev1 | -D date1] [-r rev2 | -D date2]] [files...] \n",
-#else
- " [-r rev1 [-r rev2]] [files...] \n",
-#endif
"\t-l\tLocal directory only, not recursive\n",
+ "\t-R\tProcess directories recursively.\n",
"\t-D d1\tDiff revision for date against working file.\n",
"\t-D d2\tDiff rev1/date1 against date2.\n",
"\t-N\tinclude diffs for added and removed files.\n",
"\t-r rev1\tDiff revision for rev1 against working file.\n",
"\t-r rev2\tDiff rev1/date1 against rev2.\n",
+ "\t--ifdef=arg\tOutput diffs in ifdef format.\n",
+ "(consult the documentation for your diff program for rcsdiff-options.\n",
+ "The most popular is -c for context diffs but there are many more).\n",
NULL
};
+/* I copied this array directly out of diff.c in diffutils 2.7, after
+ removing the following entries, none of which seem relevant to use
+ with CVS:
+ --help
+ --version
+ --recursive
+ --unidirectional-new-file
+ --starting-file
+ --exclude
+ --exclude-from
+ --sdiff-merge-assist
+
+ I changed the options which take optional arguments (--context and
+ --unified) to return a number rather than a letter, so that the
+ optional argument could be handled more easily. I changed the
+ --paginate and --brief options to return a number, since -l and -q
+ mean something else to cvs diff.
+
+ The numbers 129- that appear in the fourth element of some entries
+ tell the big switch in `diff' how to process those options. -- Ian
+
+ The following options, which diff lists as "An alias, no longer
+ recommended" have been removed: --file-label --entire-new-file
+ --ascii --print. */
+
+static struct option const longopts[] =
+{
+ {"ignore-blank-lines", 0, 0, 'B'},
+ {"context", 2, 0, 143},
+ {"ifdef", 1, 0, 147},
+ {"show-function-line", 1, 0, 'F'},
+ {"speed-large-files", 0, 0, 'H'},
+ {"ignore-matching-lines", 1, 0, 'I'},
+ {"label", 1, 0, 'L'},
+ {"new-file", 0, 0, 'N'},
+ {"initial-tab", 0, 0, 'T'},
+ {"width", 1, 0, 'W'},
+ {"text", 0, 0, 'a'},
+ {"ignore-space-change", 0, 0, 'b'},
+ {"minimal", 0, 0, 'd'},
+ {"ed", 0, 0, 'e'},
+ {"forward-ed", 0, 0, 'f'},
+ {"ignore-case", 0, 0, 'i'},
+ {"paginate", 0, 0, 144},
+ {"rcs", 0, 0, 'n'},
+ {"show-c-function", 0, 0, 'p'},
+
+ /* This is a potentially very useful option, except the output is so
+ silly. It would be much better for it to look like "cvs rdiff -s"
+ which displays all the same info, minus quite a few lines of
+ extraneous garbage. */
+ {"brief", 0, 0, 145},
+
+ {"report-identical-files", 0, 0, 's'},
+ {"expand-tabs", 0, 0, 't'},
+ {"ignore-all-space", 0, 0, 'w'},
+ {"side-by-side", 0, 0, 'y'},
+ {"unified", 2, 0, 146},
+ {"left-column", 0, 0, 129},
+ {"suppress-common-lines", 0, 0, 130},
+ {"old-line-format", 1, 0, 132},
+ {"new-line-format", 1, 0, 133},
+ {"unchanged-line-format", 1, 0, 134},
+ {"line-format", 1, 0, 135},
+ {"old-group-format", 1, 0, 136},
+ {"new-group-format", 1, 0, 137},
+ {"unchanged-group-format", 1, 0, 138},
+ {"changed-group-format", 1, 0, 139},
+ {"horizon-lines", 1, 0, 140},
+ {"binary", 0, 0, 142},
+ {0, 0, 0, 0}
+};
+
+static void strcat_and_allocate PROTO ((char **, size_t *, const char *));
+
+/* *STR is a pointer to a malloc'd string. *LENP is its allocated
+ length. Add SRC to the end of it, reallocating if necessary. */
+static void
+strcat_and_allocate (str, lenp, src)
+ char **str;
+ size_t *lenp;
+ const char *src;
+{
+ size_t new_size;
+
+ new_size = strlen (*str) + strlen (src) + 1;
+ if (*str == NULL || new_size >= *lenp)
+ {
+ while (new_size >= *lenp)
+ *lenp *= 2;
+ *str = xrealloc (*str, *lenp);
+ }
+ strcat (*str, src);
+}
+
int
diff (argc, argv)
int argc;
@@ -65,6 +178,7 @@ diff (argc, argv)
int c, err = 0;
int local = 0;
int which;
+ int option_index;
if (argc == -1)
usage (diff_usage);
@@ -74,47 +188,63 @@ diff (argc, argv)
* intercept the -r arguments for doing revision diffs; and -l/-R for a
* non-recursive/recursive diff.
*/
-#ifdef SERVER_SUPPORT
- /* Need to be able to do this command more than once (according to
- the protocol spec, even if the current client doesn't use it). */
+
+ /* For server, need to be able to do this command more than once
+ (according to the protocol spec, even if the current client
+ doesn't use it). */
+ if (opts == NULL)
+ {
+ opts_allocated = 1;
+ opts = xmalloc (opts_allocated);
+ }
opts[0] = '\0';
-#endif
+
optind = 1;
- while ((c = getopt (argc, argv,
- "abcdefhilnpqtuw0123456789BHNQRTC:D:F:I:L:V:k:r:")) != -1)
+ 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 't': case 'u':
- case 'w': 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': case 'Q':
+ 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);
- (void) strcat (opts, tmp);
- if (c == 'Q')
+ strcat_and_allocate (&opts, &opts_allocated, tmp);
+ break;
+ case 'C': case 'F': case 'I': case 'L': case 'U': case 'V':
+ case 'W':
+ (void) sprintf (tmp, " -%c", (char) c);
+ strcat_and_allocate (&opts, &opts_allocated, tmp);
+ strcat_and_allocate (&opts, &opts_allocated, optarg);
+ break;
+ case 147:
+ /* --ifdef. */
+ strcat_and_allocate (&opts, &opts_allocated, " -D");
+ strcat_and_allocate (&opts, &opts_allocated, optarg);
+ break;
+ case 129: case 130: case 131: 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:
+ strcat_and_allocate (&opts, &opts_allocated, " --");
+ strcat_and_allocate (&opts, &opts_allocated,
+ longopts[option_index].name);
+ if (longopts[option_index].has_arg == 1
+ || (longopts[option_index].has_arg == 2
+ && optarg != NULL))
{
- quiet = 1;
- really_quiet = 1;
- c = 'q';
+ strcat_and_allocate (&opts, &opts_allocated, "=");
+ strcat_and_allocate (&opts, &opts_allocated, optarg);
}
break;
- case 'C': case 'F': case 'I': case 'L': case 'V':
-#ifndef CVS_DIFFDATE
- case 'D':
-#endif
- (void) sprintf (tmp, " -%c%s", (char) c, optarg);
- (void) strcat (opts, tmp);
- break;
case 'R':
local = 0;
break;
case 'l':
local = 1;
break;
- case 'q':
- quiet = 1;
- break;
case 'k':
if (options)
free (options);
@@ -129,7 +259,6 @@ diff (argc, argv)
else
diff_rev1 = optarg;
break;
-#ifdef CVS_DIFFDATE
case 'D':
if (diff_rev2 != NULL || diff_date2 != NULL)
error (1, 0,
@@ -139,7 +268,6 @@ diff (argc, argv)
else
diff_date1 = Make_Date (optarg);
break;
-#endif
case 'N':
empty_files = 1;
break;
@@ -168,6 +296,8 @@ diff (argc, argv)
if (empty_files)
send_arg("-N");
send_option_string (opts);
+ if (options[0] != '\0')
+ send_arg (options);
if (diff_rev1)
option_with_arg ("-r", diff_rev1);
if (diff_date1)
@@ -178,15 +308,12 @@ diff (argc, argv)
client_senddate (diff_date2);
send_file_names (argc, argv, SEND_EXPAND_WILD);
-#if 0
- /* FIXME: We shouldn't have to send current files to diff two
- revs, but it doesn't work yet and I haven't debugged it.
- So send the files -- it's slower but it works.
- gnu@cygnus.com Apr94 */
+
/* Send the current files unless diffing two revs from the archive */
if (diff_rev2 == NULL && diff_date2 == NULL)
-#endif
- send_files (argc, argv, local, 0);
+ send_files (argc, argv, local, 0, 0);
+ else
+ send_files (argc, argv, local, 0, SEND_NO_CONTENTS);
send_to_server ("diff\012", 0);
err = get_responses_and_close ();
@@ -201,15 +328,15 @@ diff (argc, argv)
tag_check_valid (diff_rev2, argc, argv, local, 0, "");
which = W_LOCAL;
- if (diff_rev2 != NULL || diff_date2 != NULL)
+ if (diff_rev1 != NULL || diff_date1 != NULL)
which |= W_REPOS | W_ATTIC;
wrap_setup ();
/* start the recursion processor */
err = start_recursion (diff_fileproc, diff_filesdoneproc, diff_dirproc,
- diff_dirleaveproc, argc, argv, local,
- which, 0, 1, (char *) NULL, 1, 0);
+ diff_dirleaveproc, NULL, argc, argv, local,
+ which, 0, 1, (char *) NULL, 1);
/* clean up */
free (options);
@@ -221,26 +348,19 @@ diff (argc, argv)
*/
/* ARGSUSED */
static int
-diff_fileproc (finfo)
+diff_fileproc (callerdat, finfo)
+ void *callerdat;
struct file_info *finfo;
{
int status, err = 2; /* 2 == trouble, like rcsdiff */
Vers_TS *vers;
- enum {
- DIFF_ERROR,
- DIFF_ADDED,
- DIFF_REMOVED,
- DIFF_NEITHER
- } empty_file = DIFF_NEITHER;
- char tmp[L_tmpnam+1];
+ enum diff_file empty_file = DIFF_DIFFERENT;
+ char *tmp;
char *tocvsPath;
- char fname[PATH_MAX];
+ char *fname;
-#ifdef SERVER_SUPPORT
user_file_rev = 0;
-#endif
- vers = Version_TS (finfo->repository, (char *) NULL, (char *) NULL, (char *) NULL,
- finfo->file, 1, 0, finfo->entries, finfo->rcs);
+ vers = Version_TS (finfo, NULL, NULL, NULL, 1, 0);
if (diff_rev2 != NULL || diff_date2 != NULL)
{
@@ -249,10 +369,46 @@ diff_fileproc (finfo)
}
else if (vers->vn_user == NULL)
{
- error (0, 0, "I know nothing about %s", finfo->fullname);
- freevers_ts (&vers);
- diff_mark_errors (err);
- return (err);
+ /* The file does not exist in the working directory. */
+ if ((diff_rev1 != NULL || diff_date1 != NULL)
+ && vers->srcfile != NULL)
+ {
+ /* The file does exist in the repository. */
+ if (empty_files)
+ empty_file = DIFF_REMOVED;
+ else
+ {
+ int exists;
+
+ exists = 0;
+ /* special handling for TAG_HEAD */
+ if (diff_rev1 && strcmp (diff_rev1, TAG_HEAD) == 0)
+ exists = vers->vn_rcs != NULL;
+ else
+ {
+ Vers_TS *xvers;
+
+ xvers = Version_TS (finfo, NULL, diff_rev1, diff_date1,
+ 1, 0);
+ exists = xvers->vn_rcs != NULL;
+ freevers_ts (&xvers);
+ }
+ if (exists)
+ error (0, 0,
+ "%s no longer exists, no comparison available",
+ finfo->fullname);
+ freevers_ts (&vers);
+ diff_mark_errors (err);
+ return (err);
+ }
+ }
+ else
+ {
+ error (0, 0, "I know nothing about %s", finfo->fullname);
+ freevers_ts (&vers);
+ diff_mark_errors (err);
+ return (err);
+ }
}
else if (vers->vn_user[0] == '0' && vers->vn_user[1] == '\0')
{
@@ -299,7 +455,6 @@ diff_fileproc (finfo)
diff_mark_errors (err);
return (err);
}
-#ifdef SERVER_SUPPORT
else if (!strcmp (vers->ts_user, vers->ts_rcs))
{
/* The user file matches some revision in the repository
@@ -307,18 +462,76 @@ diff_fileproc (finfo)
have a copy of the user file around). */
user_file_rev = vers->vn_user;
}
-#endif
}
}
- if (empty_file == DIFF_NEITHER && diff_file_nodiff (finfo->file, finfo->repository, finfo->entries, finfo->rcs, vers))
+ empty_file = diff_file_nodiff (finfo, vers, empty_file);
+ if (empty_file == DIFF_SAME || empty_file == DIFF_ERROR)
{
freevers_ts (&vers);
- return (0);
+ if (empty_file == DIFF_SAME)
+ {
+ /* In the server case, would be nice to send a "Checked-in"
+ response, so that the client can rewrite its timestamp.
+ server_checked_in by itself isn't the right thing (it
+ needs a server_register), but I'm not sure what is.
+ It isn't clear to me how "cvs status" handles this (that
+ is, for a client which sends Modified not Is-modified to
+ "cvs status"), but it does. */
+ return (0);
+ }
+ else
+ {
+ diff_mark_errors (err);
+ return (err);
+ }
}
- /* FIXME: Check whether use_rev1 and use_rev2 are dead and deal
- accordingly. */
+ if (empty_file == DIFF_DIFFERENT)
+ {
+ int dead1, dead2;
+
+ if (use_rev1 == NULL)
+ dead1 = 0;
+ else
+ dead1 = RCS_isdead (vers->srcfile, use_rev1);
+ if (use_rev2 == NULL)
+ dead2 = 0;
+ else
+ dead2 = RCS_isdead (vers->srcfile, use_rev2);
+
+ if (dead1 && dead2)
+ {
+ freevers_ts (&vers);
+ return (0);
+ }
+ else if (dead1)
+ {
+ if (empty_files)
+ empty_file = DIFF_ADDED;
+ else
+ {
+ error (0, 0, "%s is a new entry, no comparison available",
+ finfo->fullname);
+ freevers_ts (&vers);
+ diff_mark_errors (err);
+ return (err);
+ }
+ }
+ else if (dead2)
+ {
+ if (empty_files)
+ empty_file = DIFF_REMOVED;
+ else
+ {
+ error (0, 0, "%s was removed, no comparison available",
+ finfo->fullname);
+ freevers_ts (&vers);
+ diff_mark_errors (err);
+ return (err);
+ }
+ }
+ }
/* Output an "Index:" line for patch to use */
(void) fflush (stdout);
@@ -329,10 +542,14 @@ diff_fileproc (finfo)
if (tocvsPath)
{
/* Backup the current version of the file to CVS/,,filename */
+ fname = xmalloc (strlen (finfo->file)
+ + sizeof CVSADM
+ + sizeof CVSPREFIX
+ + 10);
sprintf(fname,"%s/%s%s",CVSADM, CVSPREFIX, finfo->file);
if (unlink_file_dir (fname) < 0)
if (! existence_error (errno))
- error (1, errno, "cannot remove %s", finfo->file);
+ error (1, errno, "cannot remove %s", fname);
rename_file (finfo->file, fname);
/* Copy the wrapped file to the current directory then go to work */
copy_file (tocvsPath, finfo->file);
@@ -348,23 +565,44 @@ diff_fileproc (finfo)
if (empty_file == DIFF_ADDED)
{
- run_setup ("%s %s %s %s", DIFF, opts, DEVNULL, finfo->file);
+ if (use_rev2 == NULL)
+ run_setup ("%s %s %s %s", DIFF, opts, DEVNULL, finfo->file);
+ else
+ {
+ int retcode;
+
+ tmp = cvs_temp_name ();
+ retcode = RCS_checkout (vers->srcfile, (char *) NULL,
+ use_rev2, (char *) NULL,
+ (*options
+ ? options
+ : vers->options),
+ tmp, (RCSCHECKOUTPROC) NULL,
+ (void *) NULL);
+ if (retcode == -1)
+ {
+ (void) CVS_UNLINK (tmp);
+ error (1, errno, "fork failed during checkout of %s",
+ vers->srcfile->path);
+ }
+ /* FIXME: what if retcode > 0? */
+
+ run_setup ("%s %s %s %s", DIFF, opts, DEVNULL, tmp);
+ }
}
else
{
int retcode;
- /*
- * FIXME: Should be setting use_rev1 using the logic in
- * diff_file_nodiff, and using that revision. This code
- * is broken for "cvs diff -N -r foo".
- */
- retcode = RCS_checkout (vers->srcfile->path, NULL, vers->vn_rcs,
- *options ? options : vers->options, tmpnam (tmp),
- 0, 0);
+ tmp = cvs_temp_name ();
+ retcode = RCS_checkout (vers->srcfile, (char *) NULL,
+ use_rev1, (char *) NULL,
+ *options ? options : vers->options,
+ tmp, (RCSCHECKOUTPROC) NULL,
+ (void *) NULL);
if (retcode == -1)
{
- (void) unlink (tmp);
+ (void) CVS_UNLINK (tmp);
error (1, errno, "fork failed during checkout of %s",
vers->srcfile->path);
}
@@ -409,13 +647,18 @@ diff_fileproc (finfo)
if (! existence_error (errno))
error (1, errno, "cannot remove %s", finfo->file);
- rename_file (fname,finfo->file);
+ rename_file (fname, finfo->file);
if (unlink_file (tocvsPath) < 0)
- error (1, errno, "cannot remove %s", finfo->file);
+ error (1, errno, "cannot remove %s", tocvsPath);
+ free (fname);
}
- if (empty_file == DIFF_REMOVED)
- (void) unlink (tmp);
+ if (empty_file == DIFF_REMOVED
+ || (empty_file == DIFF_ADDED && use_rev2 != NULL))
+ {
+ (void) CVS_UNLINK (tmp);
+ free (tmp);
+ }
(void) fflush (stdout);
freevers_ts (&vers);
@@ -441,10 +684,12 @@ diff_mark_errors (err)
*/
/* ARGSUSED */
static Dtype
-diff_dirproc (dir, pos_repos, update_dir)
+diff_dirproc (callerdat, dir, pos_repos, update_dir, entries)
+ void *callerdat;
char *dir;
char *pos_repos;
char *update_dir;
+ List *entries;
{
/* XXX - check for dirs we don't want to process??? */
@@ -462,10 +707,12 @@ diff_dirproc (dir, pos_repos, update_dir)
*/
/* ARGSUSED */
static int
-diff_filesdoneproc (err, repos, update_dir)
+diff_filesdoneproc (callerdat, err, repos, update_dir, entries)
+ void *callerdat;
int err;
char *repos;
char *update_dir;
+ List *entries;
{
return (diff_errors);
}
@@ -475,27 +722,26 @@ diff_filesdoneproc (err, repos, update_dir)
*/
/* ARGSUSED */
static int
-diff_dirleaveproc (dir, err, update_dir)
+diff_dirleaveproc (callerdat, dir, err, update_dir, entries)
+ void *callerdat;
char *dir;
int err;
char *update_dir;
+ List *entries;
{
return (diff_errors);
}
/*
- * verify that a file is different 0=same 1=different
+ * verify that a file is different
*/
-static int
-diff_file_nodiff (file, repository, entries, rcs, vers)
- char *file;
- char *repository;
- List *entries;
- RCSNode *rcs;
+static enum diff_file
+diff_file_nodiff (finfo, vers, empty_file)
+ struct file_info *finfo;
Vers_TS *vers;
+ enum diff_file empty_file;
{
Vers_TS *xvers;
- char tmp[L_tmpnam+1];
int retcode;
/* free up any old use_rev* variables and reset 'em */
@@ -512,23 +758,9 @@ diff_file_nodiff (file, repository, entries, rcs, vers)
use_rev1 = xstrdup (vers->vn_rcs);
else
{
- xvers = Version_TS (repository, (char *) NULL, diff_rev1,
- diff_date1, file, 1, 0, entries, rcs);
- if (xvers->vn_rcs == NULL)
- {
- /* Don't gripe if it doesn't exist, just ignore! */
- if (! isfile (file))
- /* null statement */ ;
- else if (diff_rev1)
- error (0, 0, "tag %s is not in file %s", diff_rev1, file);
- else
- error (0, 0, "no revision for date %s in file %s",
- diff_date1, file);
-
- freevers_ts (&xvers);
- return (1);
- }
- use_rev1 = xstrdup (xvers->vn_rcs);
+ xvers = Version_TS (finfo, NULL, diff_rev1, diff_date1, 1, 0);
+ if (xvers->vn_rcs != NULL)
+ use_rev1 = xstrdup (xvers->vn_rcs);
freevers_ts (&xvers);
}
}
@@ -539,36 +771,85 @@ diff_file_nodiff (file, repository, entries, rcs, vers)
use_rev2 = xstrdup (vers->vn_rcs);
else
{
- xvers = Version_TS (repository, (char *) NULL, diff_rev2,
- diff_date2, file, 1, 0, entries, rcs);
- if (xvers->vn_rcs == NULL)
- {
- /* Don't gripe if it doesn't exist, just ignore! */
- if (! isfile (file))
- /* null statement */ ;
- else if (diff_rev1)
- error (0, 0, "tag %s is not in file %s", diff_rev2, file);
- else
- error (0, 0, "no revision for date %s in file %s",
- diff_date2, file);
-
- freevers_ts (&xvers);
- return (1);
- }
- use_rev2 = xstrdup (xvers->vn_rcs);
+ xvers = Version_TS (finfo, NULL, diff_rev2, diff_date2, 1, 0);
+ if (xvers->vn_rcs != NULL)
+ use_rev2 = xstrdup (xvers->vn_rcs);
freevers_ts (&xvers);
}
+ if (use_rev1 == NULL)
+ {
+ /* The first revision does not exist. If EMPTY_FILES is
+ true, treat this as an added file. Otherwise, warn
+ about the missing tag. */
+ if (use_rev2 == NULL)
+ /* At least in the case where DIFF_REV1 and DIFF_REV2
+ are both numeric, we should be returning some kind
+ of error (see basicb-8a0 in testsuite). The symbolic
+ case may be more complicated. */
+ return DIFF_SAME;
+ else if (empty_files)
+ return DIFF_ADDED;
+ else if (diff_rev1)
+ error (0, 0, "tag %s is not in file %s", diff_rev1,
+ finfo->fullname);
+ else
+ error (0, 0, "no revision for date %s in file %s",
+ diff_date1, finfo->fullname);
+ return DIFF_ERROR;
+ }
+
+ if (use_rev2 == NULL)
+ {
+ /* The second revision does not exist. If EMPTY_FILES is
+ true, treat this as a removed file. Otherwise warn
+ about the missing tag. */
+ if (empty_files)
+ return DIFF_REMOVED;
+ else if (diff_rev2)
+ error (0, 0, "tag %s is not in file %s", diff_rev2,
+ finfo->fullname);
+ else
+ error (0, 0, "no revision for date %s in file %s",
+ diff_date2, finfo->fullname);
+ return DIFF_ERROR;
+ }
+
/* now, see if we really need to do the diff */
- if (use_rev1 && use_rev2) {
- return (strcmp (use_rev1, use_rev2) == 0);
- } else {
- error(0, 0, "No HEAD revision for file %s", file);
- return (1);
+ if (strcmp (use_rev1, use_rev2) == 0)
+ return DIFF_SAME;
+ else
+ return DIFF_DIFFERENT;
+ }
+
+ if ((diff_rev1 || diff_date1) && use_rev1 == NULL)
+ {
+ /* The first revision does not exist, and no second revision
+ was given. */
+ if (empty_files)
+ {
+ if (empty_file == DIFF_REMOVED)
+ return DIFF_SAME;
+ else
+ {
+ if (user_file_rev && use_rev2 == NULL)
+ use_rev2 = xstrdup (user_file_rev);
+ return DIFF_ADDED;
+ }
+ }
+ else
+ {
+ if (diff_rev1)
+ error (0, 0, "tag %s is not in file %s", diff_rev1,
+ finfo->fullname);
+ else
+ error (0, 0, "no revision for date %s in file %s",
+ diff_date1, finfo->fullname);
+ return DIFF_ERROR;
}
}
-#ifdef SERVER_SUPPORT
- if (user_file_rev)
+
+ if (user_file_rev)
{
/* drop user_file_rev into first unused use_rev */
if (!use_rev1)
@@ -582,42 +863,45 @@ diff_file_nodiff (file, repository, entries, rcs, vers)
/* now, see if we really need to do the diff */
if (use_rev1 && use_rev2)
{
- return (strcmp (use_rev1, use_rev2) == 0);
+ if (strcmp (use_rev1, use_rev2) == 0)
+ return DIFF_SAME;
+ else
+ return DIFF_DIFFERENT;
}
-#endif /* SERVER_SUPPORT */
- if (use_rev1 == NULL || strcmp (use_rev1, vers->vn_user) == 0)
+
+ if (use_rev1 == NULL
+ || (vers->vn_user != NULL && strcmp (use_rev1, vers->vn_user) == 0))
{
- if (strcmp (vers->ts_rcs, vers->ts_user) == 0 &&
- (!(*options) || strcmp (options, vers->options) == 0))
+ if (empty_file == DIFF_DIFFERENT
+ && vers->ts_user != NULL
+ && strcmp (vers->ts_rcs, vers->ts_user) == 0
+ && (!(*options) || strcmp (options, vers->options) == 0))
{
- return (1);
+ return DIFF_SAME;
+ }
+ if (use_rev1 == NULL
+ && (vers->vn_user[0] != '0' || vers->vn_user[1] != '\0'))
+ {
+ if (vers->vn_user[0] == '-')
+ use_rev1 = xstrdup (vers->vn_user + 1);
+ else
+ use_rev1 = xstrdup (vers->vn_user);
}
- if (use_rev1 == NULL)
- use_rev1 = xstrdup (vers->vn_user);
}
+ /* If we already know that the file is being added or removed,
+ then we don't want to do an actual file comparison here. */
+ if (empty_file != DIFF_DIFFERENT)
+ return empty_file;
+
/*
* with 0 or 1 -r option specified, run a quick diff to see if we
* should bother with it at all.
*/
- retcode = RCS_checkout (vers->srcfile->path, NULL, use_rev1,
- *options ? options : vers->options, tmpnam (tmp), 0, 0);
- switch (retcode)
- {
- case 0: /* everything ok */
- if (xcmp (file, tmp) == 0)
- {
- (void) unlink (tmp);
- return (1);
- }
- break;
- case -1: /* fork failed */
- (void) unlink (tmp);
- error (1, errno, "fork failed during checkout of %s",
- vers->srcfile->path);
- default:
- break;
- }
- (void) unlink (tmp);
- return (0);
+
+ retcode = RCS_cmp_file (vers->srcfile, use_rev1,
+ *options ? options : vers->options,
+ finfo->file);
+
+ return retcode == 0 ? DIFF_SAME : DIFF_DIFFERENT;
}
diff --git a/contrib/cvs/src/edit.c b/contrib/cvs/src/edit.c
index 0473a03..8d3bbb1 100644
--- a/contrib/cvs/src/edit.c
+++ b/contrib/cvs/src/edit.c
@@ -8,11 +8,7 @@
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ GNU General Public License for more details. */
#include "cvs.h"
#include "getline.h"
@@ -29,23 +25,26 @@ static int setting_tedit;
static int setting_tunedit;
static int setting_tcommit;
-static int onoff_fileproc PROTO ((struct file_info *finfo));
+static int onoff_fileproc PROTO ((void *callerdat, struct file_info *finfo));
static int
-onoff_fileproc (finfo)
+onoff_fileproc (callerdat, finfo)
+ void *callerdat;
struct file_info *finfo;
{
fileattr_set (finfo->file, "_watched", turning_on ? "" : NULL);
return 0;
}
-static int onoff_filesdoneproc PROTO ((int, char *, char *));
+static int onoff_filesdoneproc PROTO ((void *, int, char *, char *, List *));
static int
-onoff_filesdoneproc (err, repository, update_dir)
+onoff_filesdoneproc (callerdat, err, repository, update_dir, entries)
+ void *callerdat;
int err;
char *repository;
char *update_dir;
+ List *entries;
{
if (setting_default)
fileattr_set (NULL, "_watched", turning_on ? "" : NULL);
@@ -62,13 +61,16 @@ watch_onoff (argc, argv)
int err;
optind = 1;
- while ((c = getopt (argc, argv, "l")) != -1)
+ while ((c = getopt (argc, argv, "+lR")) != -1)
{
switch (c)
{
case 'l':
local = 1;
break;
+ case 'R':
+ local = 0;
+ break;
case '?':
default:
usage (watch_usage);
@@ -88,10 +90,7 @@ watch_onoff (argc, argv)
if (local)
send_arg ("-l");
send_file_names (argc, argv, SEND_EXPAND_WILD);
- /* FIXME: We shouldn't have to send current files, but I'm not sure
- whether it works. So send the files --
- it's slower but it works. */
- send_files (argc, argv, local, 0);
+ send_files (argc, argv, local, 0, SEND_NO_CONTENTS);
send_to_server (turning_on ? "watch-on\012" : "watch-off\012", 0);
return get_responses_and_close ();
}
@@ -102,11 +101,11 @@ watch_onoff (argc, argv)
lock_tree_for_write (argc, argv, local, 0);
err = start_recursion (onoff_fileproc, onoff_filesdoneproc,
- (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL,
+ (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL, NULL,
argc, argv, local, W_LOCAL, 0, 0, (char *)NULL,
- 0, 0);
+ 0);
- lock_tree_cleanup ();
+ Lock_Cleanup ();
return err;
}
@@ -128,10 +127,11 @@ watch_off (argc, argv)
return watch_onoff (argc, argv);
}
-static int dummy_fileproc PROTO ((struct file_info *finfo));
+static int dummy_fileproc PROTO ((void *callerdat, struct file_info *finfo));
static int
-dummy_fileproc (finfo)
+dummy_fileproc (callerdat, finfo)
+ void *callerdat;
struct file_info *finfo;
{
/* This is a pretty hideous hack, but the gist of it is that recurse.c
@@ -140,7 +140,7 @@ dummy_fileproc (finfo)
return 0;
}
-static int ncheck_fileproc PROTO ((struct file_info *finfo));
+static int ncheck_fileproc PROTO ((void *callerdat, struct file_info *finfo));
/* Check for and process notifications. Local only. I think that doing
this as a fileproc is the only way to catch all the
@@ -149,7 +149,8 @@ static int ncheck_fileproc PROTO ((struct file_info *finfo));
processed the directory. */
static int
-ncheck_fileproc (finfo)
+ncheck_fileproc (callerdat, finfo)
+ void *callerdat;
struct file_info *finfo;
{
int notif_type;
@@ -165,7 +166,7 @@ ncheck_fileproc (finfo)
/* We send notifications even if noexec. I'm not sure which behavior
is most sensible. */
- fp = fopen (CVSADM_NOTIFY, "r");
+ fp = CVS_FOPEN (CVSADM_NOTIFY, "r");
if (fp == NULL)
{
if (!existence_error (errno))
@@ -212,7 +213,7 @@ ncheck_fileproc (finfo)
if (fclose (fp) < 0)
error (0, errno, "cannot close %s", CVSADM_NOTIFY);
- if (unlink (CVSADM_NOTIFY) < 0)
+ if ( CVS_UNLINK (CVSADM_NOTIFY) < 0)
error (0, errno, "cannot remove %s", CVSADM_NOTIFY);
return 0;
@@ -243,9 +244,9 @@ send_notifications (argc, argv, local)
}
err += start_recursion (dummy_fileproc, (FILESDONEPROC) NULL,
- (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL,
+ (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL, NULL,
argc, argv, local, W_LOCAL, 0, 0, (char *)NULL,
- 0, 0);
+ 0);
send_to_server ("noop\012", 0);
if (strcmp (command_name, "release") == 0)
@@ -260,18 +261,19 @@ send_notifications (argc, argv, local)
lock_tree_for_write (argc, argv, local, 0);
err += start_recursion (ncheck_fileproc, (FILESDONEPROC) NULL,
- (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL,
+ (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL, NULL,
argc, argv, local, W_LOCAL, 0, 0, (char *)NULL,
- 0, 0);
- lock_tree_cleanup ();
+ 0);
+ Lock_Cleanup ();
}
return err;
}
-static int edit_fileproc PROTO ((struct file_info *finfo));
+static int edit_fileproc PROTO ((void *callerdat, struct file_info *finfo));
static int
-edit_fileproc (finfo)
+edit_fileproc (callerdat, finfo)
+ void *callerdat;
struct file_info *finfo;
{
FILE *fp;
@@ -313,19 +315,10 @@ edit_fileproc (finfo)
copy so that if the user removes the working file, then restores it
with "cvs update" (which clears _editors but does not update
CVSADM_BASE), then a future "cvs edit" can still win. */
- /* Could save a system call by only calling mkdir if trying to create
- the output file fails. But copy_file isn't set up to facilitate
- that. */
- if (CVS_MKDIR (CVSADM_BASE, 0777) < 0)
- {
- if (errno != EEXIST
-#ifdef EACCESS
- /* OS/2; see longer comment in client.c. */
- && errno != EACCESS
-#endif
- )
- error (1, errno, "cannot mkdir %s", CVSADM_BASE);
- }
+ /* Could save a system call by only calling mkdir_if_needed if
+ trying to create the output file fails. But copy_file isn't
+ set up to facilitate that. */
+ mkdir_if_needed (CVSADM_BASE);
basefilename = xmalloc (10 + sizeof CVSADM_BASE + strlen (finfo->file));
strcpy (basefilename, CVSADM_BASE);
strcat (basefilename, "/");
@@ -338,10 +331,11 @@ edit_fileproc (finfo)
static const char *const edit_usage[] =
{
- "Usage: %s %s [-l] [files...]\n",
+ "Usage: %s %s [-lR] [files...]\n",
"-l: Local directory only, not recursive\n",
+ "-R: Process directories recursively\n",
"-a: Specify what actions for temporary watch, one of\n",
- " edit,unedit,commit.all,none\n",
+ " edit,unedit,commit,all,none\n",
NULL
};
@@ -363,13 +357,16 @@ edit (argc, argv)
setting_tunedit = 0;
setting_tcommit = 0;
optind = 1;
- while ((c = getopt (argc, argv, "la:")) != -1)
+ while ((c = getopt (argc, argv, "+lRa:")) != -1)
{
switch (c)
{
case 'l':
local = 1;
break;
+ case 'R':
+ local = 0;
+ break;
case 'a':
a_omitted = 0;
if (strcmp (optarg, "edit") == 0)
@@ -412,19 +409,20 @@ edit (argc, argv)
/* No need to readlock since we aren't doing anything to the
repository. */
err = start_recursion (edit_fileproc, (FILESDONEPROC) NULL,
- (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL,
+ (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL, NULL,
argc, argv, local, W_LOCAL, 0, 0, (char *)NULL,
- 0, 0);
+ 0);
err += send_notifications (argc, argv, local);
return err;
}
-static int unedit_fileproc PROTO ((struct file_info *finfo));
+static int unedit_fileproc PROTO ((void *callerdat, struct file_info *finfo));
static int
-unedit_fileproc (finfo)
+unedit_fileproc (callerdat, finfo)
+ void *callerdat;
struct file_info *finfo;
{
FILE *fp;
@@ -494,13 +492,16 @@ unedit (argc, argv)
usage (edit_usage);
optind = 1;
- while ((c = getopt (argc, argv, "l")) != -1)
+ while ((c = getopt (argc, argv, "+lR")) != -1)
{
switch (c)
{
case 'l':
local = 1;
break;
+ case 'R':
+ local = 0;
+ break;
case '?':
default:
usage (edit_usage);
@@ -513,9 +514,9 @@ unedit (argc, argv)
/* No need to readlock since we aren't doing anything to the
repository. */
err = start_recursion (unedit_fileproc, (FILESDONEPROC) NULL,
- (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL,
+ (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL, NULL,
argc, argv, local, W_LOCAL, 0, 0, (char *)NULL,
- 0, 0);
+ 0);
err += send_notifications (argc, argv, local);
@@ -768,16 +769,16 @@ notify_do (type, filename, who, val, watches, repository)
size_t line_len = 0;
args.notifyee = NULL;
- usersname = xmalloc (strlen (CVSroot)
+ usersname = xmalloc (strlen (CVSroot_directory)
+ sizeof CVSROOTADM
+ sizeof CVSROOTADM_USERS
+ 20);
- strcpy (usersname, CVSroot);
+ strcpy (usersname, CVSroot_directory);
strcat (usersname, "/");
strcat (usersname, CVSROOTADM);
strcat (usersname, "/");
strcat (usersname, CVSROOTADM_USERS);
- fp = fopen (usersname, "r");
+ fp = CVS_FOPEN (usersname, "r");
if (fp == NULL && !existence_error (errno))
error (0, errno, "cannot read %s", usersname);
if (fp != NULL)
@@ -871,7 +872,7 @@ notify_check (repository, update_dir)
/* We send notifications even if noexec. I'm not sure which behavior
is most sensible. */
- fp = fopen (CVSADM_NOTIFY, "r");
+ fp = CVS_FOPEN (CVSADM_NOTIFY, "r");
if (fp == NULL)
{
if (!existence_error (errno))
@@ -897,7 +898,8 @@ notify_check (repository, update_dir)
client_notify (repository, update_dir, filename, notif_type, val);
}
-
+ if (line)
+ free (line);
if (ferror (fp))
error (0, errno, "cannot read %s", CVSADM_NOTIFY);
if (fclose (fp) < 0)
@@ -911,14 +913,17 @@ notify_check (repository, update_dir)
static const char *const editors_usage[] =
{
- "Usage: %s %s [files...]\n",
+ "Usage: %s %s [-lR] [files...]\n",
+ "\t-l\tProcess this directory only (not recursive).\n",
+ "\t-R\tProcess directories recursively.\n",
NULL
};
-static int editors_fileproc PROTO ((struct file_info *finfo));
+static int editors_fileproc PROTO ((void *callerdat, struct file_info *finfo));
static int
-editors_fileproc (finfo)
+editors_fileproc (callerdat, finfo)
+ void *callerdat;
struct file_info *finfo;
{
char *them;
@@ -979,13 +984,16 @@ editors (argc, argv)
usage (editors_usage);
optind = 1;
- while ((c = getopt (argc, argv, "l")) != -1)
+ while ((c = getopt (argc, argv, "+lR")) != -1)
{
switch (c)
{
case 'l':
local = 1;
break;
+ case 'R':
+ local = 0;
+ break;
case '?':
default:
usage (editors_usage);
@@ -1004,17 +1012,14 @@ editors (argc, argv)
if (local)
send_arg ("-l");
send_file_names (argc, argv, SEND_EXPAND_WILD);
- /* FIXME: We shouldn't have to send current files, but I'm not sure
- whether it works. So send the files --
- it's slower but it works. */
- send_files (argc, argv, local, 0);
+ send_files (argc, argv, local, 0, SEND_NO_CONTENTS);
send_to_server ("editors\012", 0);
return get_responses_and_close ();
}
#endif /* CLIENT_SUPPORT */
return start_recursion (editors_fileproc, (FILESDONEPROC) NULL,
- (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL,
+ (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL, NULL,
argc, argv, local, W_LOCAL, 0, 1, (char *)NULL,
- 0, 0);
+ 0);
}
diff --git a/contrib/cvs/src/edit.h b/contrib/cvs/src/edit.h
index 0a823ad..7c274a6 100644
--- a/contrib/cvs/src/edit.h
+++ b/contrib/cvs/src/edit.h
@@ -8,11 +8,7 @@
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ GNU General Public License for more details. */
extern int watch_on PROTO ((int argc, char **argv));
extern int watch_off PROTO ((int argc, char **argv));
diff --git a/contrib/cvs/src/entries.c b/contrib/cvs/src/entries.c
index 350f7f8..03e29de 100644
--- a/contrib/cvs/src/entries.c
+++ b/contrib/cvs/src/entries.c
@@ -16,17 +16,25 @@
static Node *AddEntryNode PROTO((List * list, Entnode *entnode));
-static Entnode *fgetentent PROTO((FILE *));
+static Entnode *fgetentent PROTO((FILE *, char *, int *));
static int fputentent PROTO((FILE *, Entnode *));
+static Entnode *subdir_record PROTO((int, const char *, const char *));
+
static FILE *entfile;
static char *entfilename; /* for error messages */
/*
* Construct an Entnode
*/
-Entnode *
-Entnode_Create(user, vn, ts, options, tag, date, ts_conflict)
+static Entnode *Entnode_Create PROTO ((enum ent_type, const char *,
+ const char *, const char *,
+ const char *, const char *,
+ const char *, const char *));
+
+static Entnode *
+Entnode_Create(type, user, vn, ts, options, tag, date, ts_conflict)
+ enum ent_type type;
const char *user;
const char *vn;
const char *ts;
@@ -39,6 +47,7 @@ Entnode_Create(user, vn, ts, options, tag, date, ts_conflict)
/* Note that timestamp and options must be non-NULL */
ent = (Entnode *) xmalloc (sizeof (Entnode));
+ ent->type = type;
ent->user = xstrdup (user);
ent->version = xstrdup (vn);
ent->timestamp = xstrdup (ts ? ts : "");
@@ -53,7 +62,9 @@ Entnode_Create(user, vn, ts, options, tag, date, ts_conflict)
/*
* Destruct an Entnode
*/
-void
+static void Entnode_Destroy PROTO ((Entnode *));
+
+static void
Entnode_Destroy (ent)
Entnode *ent;
{
@@ -79,7 +90,14 @@ write_ent_proc (node, closure)
Node *node;
void *closure;
{
- if (fputentent(entfile, (Entnode *) node->data))
+ Entnode *entnode;
+
+ entnode = (Entnode *) node->data;
+
+ if (closure != NULL && entnode->type != ENT_FILE)
+ *(int *) closure = 1;
+
+ if (fputentent(entfile, entnode))
error (1, errno, "cannot write %s", entfilename);
return (0);
@@ -93,10 +111,26 @@ static void
write_entries (list)
List *list;
{
+ int sawdir;
+
+ sawdir = 0;
+
/* open the new one and walk the list writing entries */
entfilename = CVSADM_ENTBAK;
entfile = open_file (entfilename, "w+");
- (void) walklist (list, write_ent_proc, NULL);
+ (void) walklist (list, write_ent_proc, (void *) &sawdir);
+ if (! sawdir)
+ {
+ struct stickydirtag *sdtp;
+
+ /* We didn't write out any directories. Check the list
+ private data to see whether subdirectory information is
+ known. If it is, we need to write out an empty D line. */
+ sdtp = (struct stickydirtag *) list->list->data;
+ if (sdtp == NULL || sdtp->subdirs)
+ if (fprintf (entfile, "D\n") < 0)
+ error (1, errno, "cannot write %s", entfilename);
+ }
if (fclose (entfile) == EOF)
error (1, errno, "error closing %s", entfilename);
@@ -128,13 +162,26 @@ Scratch_Entry (list, fname)
/* hashlookup to see if it is there */
if ((node = findnode_fn (list, fname)) != NULL)
{
+ if (!noexec)
+ {
+ entfilename = CVSADM_ENTLOG;
+ entfile = open_file (entfilename, "a");
+
+ if (fprintf (entfile, "R ") < 0)
+ error (1, errno, "cannot write %s", entfilename);
+
+ write_ent_proc (node, NULL);
+
+ if (fclose (entfile) == EOF)
+ error (1, errno, "error closing %s", entfilename);
+ }
+
delnode (node); /* delete the node */
+
#ifdef SERVER_SUPPORT
if (server_active)
server_scratch (fname);
#endif
- if (!noexec)
- write_entries (list); /* re-write the file */
}
}
@@ -179,17 +226,22 @@ Register (list, fname, vn, ts, options, tag, date, ts_conflict)
#endif
}
- entnode = Entnode_Create(fname, vn, ts, options, tag, date, ts_conflict);
+ entnode = Entnode_Create (ENT_FILE, fname, vn, ts, options, tag, date,
+ ts_conflict);
node = AddEntryNode (list, entnode);
if (!noexec)
{
- entfile = open_file (CVSADM_ENTLOG, "a");
-
+ entfilename = CVSADM_ENTLOG;
+ entfile = open_file (entfilename, "a");
+
+ if (fprintf (entfile, "A ") < 0)
+ error (1, errno, "cannot write %s", entfilename);
+
write_ent_proc (node, NULL);
if (fclose (entfile) == EOF)
- error (1, errno, "error closing %s", CVSADM_ENTLOG);
+ error (1, errno, "error closing %s", entfilename);
}
}
@@ -207,20 +259,21 @@ freesdt (p)
free (sdtp->tag);
if (sdtp->date)
free (sdtp->date);
- if (sdtp->options)
- free (sdtp->options);
free ((char *) sdtp);
}
static Entnode *
-fgetentent(fpin)
+fgetentent(fpin, cmd, sawdir)
FILE *fpin;
+ char *cmd;
+ int *sawdir;
{
Entnode *ent;
char *line;
size_t line_chars_allocated;
register char *cp;
- char *user, *vn, *ts, *options;
+ enum ent_type type;
+ char *l, *user, *vn, *ts, *options;
char *tag_or_date, *tag, *date, *ts_conflict;
line = NULL;
@@ -229,10 +282,39 @@ fgetentent(fpin)
ent = NULL;
while (getline (&line, &line_chars_allocated, fpin) > 0)
{
- if (line[0] != '/')
+ l = line;
+
+ /* If CMD is not NULL, we are reading an Entries.Log file.
+ Each line in the Entries.Log file starts with a single
+ character command followed by a space. For backward
+ compatibility, the absence of a space indicates an add
+ command. */
+ if (cmd != NULL)
+ {
+ if (l[1] != ' ')
+ *cmd = 'A';
+ else
+ {
+ *cmd = l[0];
+ l += 2;
+ }
+ }
+
+ type = ENT_FILE;
+
+ if (l[0] == 'D')
+ {
+ type = ENT_SUBDIR;
+ *sawdir = 1;
+ ++l;
+ /* An empty D line is permitted; it is a signal that this
+ Entries file lists all known subdirectories. */
+ }
+
+ if (l[0] != '/')
continue;
- user = line + 1;
+ user = l + 1;
if ((cp = strchr (user, '/')) == NULL)
continue;
*cp++ = '\0';
@@ -258,7 +340,7 @@ fgetentent(fpin)
tag = tag_or_date + 1;
else if (*tag_or_date == 'D')
date = tag_or_date + 1;
-
+
if ((ts_conflict = strchr (ts, '+')))
*ts_conflict++ = '\0';
@@ -274,7 +356,7 @@ fgetentent(fpin)
*/
{
struct stat sb;
- if (strlen (ts) > 30 && stat (user, &sb) == 0)
+ if (strlen (ts) > 30 && CVS_STAT (user, &sb) == 0)
{
char *c = ctime (&sb.st_mtime);
@@ -288,7 +370,8 @@ fgetentent(fpin)
}
}
- ent = Entnode_Create(user, vn, ts, options, tag, date, ts_conflict);
+ ent = Entnode_Create (type, user, vn, ts, options, tag, date,
+ ts_conflict);
break;
}
@@ -301,6 +384,16 @@ fputentent(fp, p)
FILE *fp;
Entnode *p;
{
+ switch (p->type)
+ {
+ case ENT_FILE:
+ break;
+ case ENT_SUBDIR:
+ if (fprintf (fp, "D") < 0)
+ return 1;
+ break;
+ }
+
if (fprintf (fp, "/%s/%s/%s", p->user, p->version, p->timestamp) < 0)
return 1;
if (p->conflict)
@@ -339,10 +432,13 @@ Entries_Open (aflag)
int aflag;
{
List *entries;
+ struct stickydirtag *sdtp = NULL;
Entnode *ent;
char *dirtag, *dirdate;
+ int dirnonbranch;
int do_rewrite = 0;
FILE *fpin;
+ int sawdir;
/* get a fresh list... */
entries = getlist ();
@@ -351,28 +447,29 @@ Entries_Open (aflag)
* Parse the CVS/Tag file, to get any default tag/date settings. Use
* list-private storage to tuck them away for Version_TS().
*/
- ParseTag (&dirtag, &dirdate);
+ ParseTag (&dirtag, &dirdate, &dirnonbranch);
if (aflag || dirtag || dirdate)
{
- struct stickydirtag *sdtp;
-
sdtp = (struct stickydirtag *) xmalloc (sizeof (*sdtp));
memset ((char *) sdtp, 0, sizeof (*sdtp));
sdtp->aflag = aflag;
sdtp->tag = xstrdup (dirtag);
sdtp->date = xstrdup (dirdate);
+ sdtp->nonbranch = dirnonbranch;
/* feed it into the list-private area */
entries->list->data = (char *) sdtp;
entries->list->delproc = freesdt;
}
- fpin = fopen (CVSADM_ENT, "r");
+ sawdir = 0;
+
+ fpin = CVS_FOPEN (CVSADM_ENT, "r");
if (fpin == NULL)
error (0, errno, "cannot open %s for reading", CVSADM_ENT);
else
{
- while ((ent = fgetentent (fpin)) != NULL)
+ while ((ent = fgetentent (fpin, (char *) NULL, &sawdir)) != NULL)
{
(void) AddEntryNode (entries, ent);
}
@@ -380,17 +477,48 @@ Entries_Open (aflag)
fclose (fpin);
}
- fpin = fopen (CVSADM_ENTLOG, "r");
+ fpin = CVS_FOPEN (CVSADM_ENTLOG, "r");
if (fpin != NULL)
{
- while ((ent = fgetentent (fpin)) != NULL)
+ char cmd;
+ Node *node;
+
+ while ((ent = fgetentent (fpin, &cmd, &sawdir)) != NULL)
{
- (void) AddEntryNode (entries, ent);
+ switch (cmd)
+ {
+ case 'A':
+ (void) AddEntryNode (entries, ent);
+ break;
+ case 'R':
+ node = findnode_fn (entries, ent->user);
+ if (node != NULL)
+ delnode (node);
+ Entnode_Destroy (ent);
+ break;
+ default:
+ /* Ignore unrecognized commands. */
+ break;
+ }
}
do_rewrite = 1;
fclose (fpin);
}
+ /* Update the list private data to indicate whether subdirectory
+ information is known. Nonexistent list private data is taken
+ to mean that it is known. */
+ if (sdtp != NULL)
+ sdtp->subdirs = sawdir;
+ else if (! sawdir)
+ {
+ sdtp = (struct stickydirtag *) xmalloc (sizeof (*sdtp));
+ memset ((char *) sdtp, 0, sizeof (*sdtp));
+ sdtp->subdirs = 0;
+ entries->list->data = (char *) sdtp;
+ entries->list->delproc = freesdt;
+ }
+
if (do_rewrite && !noexec)
write_entries (entries);
@@ -471,17 +599,23 @@ AddEntryNode (list, entdata)
* Write out/Clear the CVS/Tag file.
*/
void
-WriteTag (dir, tag, date)
+WriteTag (dir, tag, date, nonbranch, update_dir, repository)
char *dir;
char *tag;
char *date;
+ int nonbranch;
+ char *update_dir;
+ char *repository;
{
FILE *fout;
- char tmp[PATH_MAX];
+ char *tmp;
if (noexec)
return;
+ tmp = xmalloc ((dir ? strlen (dir) : 0)
+ + sizeof (CVSADM_TAG)
+ + 10);
if (dir == NULL)
(void) strcpy (tmp, CVSADM_TAG);
else
@@ -492,8 +626,16 @@ WriteTag (dir, tag, date)
fout = open_file (tmp, "w+");
if (tag)
{
- if (fprintf (fout, "T%s\n", tag) < 0)
- error (1, errno, "write to %s failed", tmp);
+ if (nonbranch)
+ {
+ if (fprintf (fout, "N%s\n", tag) < 0)
+ error (1, errno, "write to %s failed", tmp);
+ }
+ else
+ {
+ if (fprintf (fout, "T%s\n", tag) < 0)
+ error (1, errno, "write to %s failed", tmp);
+ }
}
else
{
@@ -506,15 +648,32 @@ WriteTag (dir, tag, date)
else
if (unlink_file (tmp) < 0 && ! existence_error (errno))
error (1, errno, "cannot remove %s", tmp);
+ free (tmp);
+#ifdef SERVER_SUPPORT
+ if (server_active)
+ server_set_sticky (update_dir, repository, tag, date, nonbranch);
+#endif
}
-/*
- * Parse the CVS/Tag file for the current directory.
- */
+/* Parse the CVS/Tag file for the current directory.
+
+ If it contains a date, sets *DATEP to the date in a newly malloc'd
+ string, *TAGP to NULL, and *NONBRANCHP to an unspecified value.
+
+ If it contains a branch tag, sets *TAGP to the tag in a newly
+ malloc'd string, *NONBRANCHP to 0, and *DATEP to NULL.
+
+ If it contains a nonbranch tag, sets *TAGP to the tag in a newly
+ malloc'd string, *NONBRANCHP to 1, and *DATEP to NULL.
+
+ If it does not exist, or contains something unrecognized by this
+ version of CVS, set *DATEP and *TAGP to NULL and *NONBRANCHP to
+ an unspecified value. */
void
-ParseTag (tagp, datep)
+ParseTag (tagp, datep, nonbranchp)
char **tagp;
char **datep;
+ int *nonbranchp;
{
FILE *fp;
@@ -522,7 +681,12 @@ ParseTag (tagp, datep)
*tagp = (char *) NULL;
if (datep)
*datep = (char *) NULL;
- fp = fopen (CVSADM_TAG, "r");
+ /* Always store a value here, even in the 'D' case where the value
+ is unspecified. Shuts up tools which check for references to
+ uninitialized memory. */
+ if (nonbranchp != NULL)
+ *nonbranchp = 0;
+ fp = CVS_FOPEN (CVSADM_TAG, "r");
if (fp)
{
char *line;
@@ -531,18 +695,195 @@ ParseTag (tagp, datep)
line = NULL;
line_chars_allocated = 0;
-
+
if ((line_length = getline (&line, &line_chars_allocated, fp)) > 0)
{
/* Remove any trailing newline. */
if (line[line_length - 1] == '\n')
line[--line_length] = '\0';
- if (*line == 'T' && tagp)
- *tagp = xstrdup (line + 1);
- else if (*line == 'D' && datep)
- *datep = xstrdup (line + 1);
+ switch (*line)
+ {
+ case 'T':
+ if (tagp != NULL)
+ *tagp = xstrdup (line + 1);
+ break;
+ case 'D':
+ if (datep != NULL)
+ *datep = xstrdup (line + 1);
+ break;
+ case 'N':
+ if (tagp != NULL)
+ *tagp = xstrdup (line + 1);
+ if (nonbranchp != NULL)
+ *nonbranchp = 1;
+ break;
+ default:
+ /* Silently ignore it; it may have been
+ written by a future version of CVS which extends the
+ syntax. */
+ break;
+ }
}
(void) fclose (fp);
free (line);
}
}
+
+/*
+ * This is called if all subdirectory information is known, but there
+ * aren't any subdirectories. It records that fact in the list
+ * private data.
+ */
+
+void
+Subdirs_Known (entries)
+ List *entries;
+{
+ struct stickydirtag *sdtp;
+
+ /* If there is no list private data, that means that the
+ subdirectory information is known. */
+ sdtp = (struct stickydirtag *) entries->list->data;
+ if (sdtp != NULL && ! sdtp->subdirs)
+ {
+ FILE *fp;
+
+ sdtp->subdirs = 1;
+ if (!noexec)
+ {
+ /* Create Entries.Log so that Entries_Close will do something. */
+ fp = open_file (CVSADM_ENTLOG, "a");
+ if (fclose (fp) == EOF)
+ error (1, errno, "cannot close %s", CVSADM_ENTLOG);
+ }
+ }
+}
+
+/* Record subdirectory information. */
+
+static Entnode *
+subdir_record (cmd, parent, dir)
+ int cmd;
+ const char *parent;
+ const char *dir;
+{
+ Entnode *entnode;
+
+ /* None of the information associated with a directory is
+ currently meaningful. */
+ entnode = Entnode_Create (ENT_SUBDIR, dir, "", "", "",
+ (char *) NULL, (char *) NULL,
+ (char *) NULL);
+
+ if (!noexec)
+ {
+ if (parent == NULL)
+ entfilename = CVSADM_ENTLOG;
+ else
+ {
+ entfilename = xmalloc (strlen (parent)
+ + sizeof CVSADM_ENTLOG
+ + 10);
+ sprintf (entfilename, "%s/%s", parent, CVSADM_ENTLOG);
+ }
+
+ entfile = CVS_FOPEN (entfilename, "a");
+ if (entfile == NULL)
+ {
+ int save_errno = errno;
+
+ /* It is not an error if there is no CVS administration
+ directory. Permitting this case simplifies some
+ calling code. */
+
+ if (parent == NULL)
+ {
+ if (! isdir (CVSADM))
+ return entnode;
+ }
+ else
+ {
+ sprintf (entfilename, "%s/%s", parent, CVSADM);
+ if (! isdir (entfilename))
+ {
+ free (entfilename);
+ entfilename = NULL;
+ return entnode;
+ }
+ }
+
+ error (1, save_errno, "cannot open %s", entfilename);
+ }
+
+ if (fprintf (entfile, "%c ", cmd) < 0)
+ error (1, errno, "cannot write %s", entfilename);
+
+ if (fputentent (entfile, entnode) != 0)
+ error (1, errno, "cannot write %s", entfilename);
+
+ if (fclose (entfile) == EOF)
+ error (1, errno, "error closing %s", entfilename);
+
+ if (parent != NULL)
+ {
+ free (entfilename);
+ entfilename = NULL;
+ }
+ }
+
+ return entnode;
+}
+
+/*
+ * Record the addition of a new subdirectory DIR in PARENT. PARENT
+ * may be NULL, which means the current directory. ENTRIES is the
+ * current entries list; it may be NULL, which means that it need not
+ * be updated.
+ */
+
+void
+Subdir_Register (entries, parent, dir)
+ List *entries;
+ const char *parent;
+ const char *dir;
+{
+ Entnode *entnode;
+
+ /* Ignore attempts to register ".". These can happen in the
+ server code. */
+ if (dir[0] == '.' && dir[1] == '\0')
+ return;
+
+ entnode = subdir_record ('A', parent, dir);
+
+ if (entries != NULL && (parent == NULL || strcmp (parent, ".") == 0))
+ (void) AddEntryNode (entries, entnode);
+ else
+ Entnode_Destroy (entnode);
+}
+
+/*
+ * Record the removal of a subdirectory. The arguments are the same
+ * as for Subdir_Register.
+ */
+
+void
+Subdir_Deregister (entries, parent, dir)
+ List *entries;
+ const char *parent;
+ const char *dir;
+{
+ Entnode *entnode;
+
+ entnode = subdir_record ('R', parent, dir);
+ Entnode_Destroy (entnode);
+
+ if (entries != NULL && (parent == NULL || strcmp (parent, ".") == 0))
+ {
+ Node *p;
+
+ p = findnode_fn (entries, dir);
+ if (p != NULL)
+ delnode (p);
+ }
+}
diff --git a/contrib/cvs/src/error.c b/contrib/cvs/src/error.c
index 8a10cc7..5c7eef5 100644
--- a/contrib/cvs/src/error.c
+++ b/contrib/cvs/src/error.c
@@ -9,11 +9,7 @@
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ GNU General Public License for more details. */
/* David MacKenzie */
/* Brian Berliner added support for CVS */
@@ -30,7 +26,7 @@ int error_use_protocol;
#ifdef HAVE_VPRINTF
-#if __STDC__
+#ifdef __STDC__
#include <stdarg.h>
#define VA_START(args, lastarg) va_start(args, lastarg)
#else /* ! __STDC__ */
@@ -54,38 +50,43 @@ int error_use_protocol;
#include <stdlib.h>
#include <string.h>
#else /* ! STDC_HEADERS */
-#if __STDC__
+#ifdef __STDC__
void exit(int status);
#else /* ! __STDC__ */
void exit ();
#endif /* __STDC__ */
#endif /* STDC_HEADERS */
+#ifndef strerror
extern char *strerror ();
+#endif
extern int vasprintf ();
-typedef void (*fn_returning_void) PROTO((void));
-
-/* Function to call before exiting. */
-static fn_returning_void cleanup_fn;
-
-fn_returning_void
-error_set_cleanup (arg)
- fn_returning_void arg;
+void
+error_exit PROTO ((void))
{
- fn_returning_void retval = cleanup_fn;
- cleanup_fn = arg;
- return retval;
+ Lock_Cleanup();
+#ifdef SERVER_SUPPORT
+ if (server_active)
+ server_cleanup (0);
+#endif
+#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 (EXIT_FAILURE);
}
/* Print the program name and error message MESSAGE, which is a printf-style
format string with optional args.
If ERRNUM is nonzero, print its corresponding system error message.
- Exit with status EXIT_FAILURE if STATUS is nonzero. */
+ Exit with status EXIT_FAILURE if STATUS is nonzero. If MESSAGE is "",
+ no need to print a message. */
/* VARARGS */
void
-#if defined (HAVE_VPRINTF) && __STDC__
+#if defined (HAVE_VPRINTF) && defined (__STDC__)
error (int status, int errnum, const char *message, ...)
#else
error (status, errnum, message, va_alist)
@@ -95,19 +96,10 @@ error (status, errnum, message, va_alist)
va_dcl
#endif
{
- FILE *out = stderr;
-#ifdef HAVE_VPRINTF
- va_list args;
-#endif
-
- if (error_use_protocol)
- {
- out = stdout;
- printf ("E ");
- }
-
#ifdef HAVE_VPRINTF
+ if (message[0] != '\0')
{
+ va_list args;
char *mess = NULL;
char *entire;
size_t len;
@@ -157,10 +149,7 @@ error (status, errnum, message, va_alist)
free (mess);
}
}
- if (error_use_protocol)
- fputs (entire ? entire : "out of memory", out);
- else
- cvs_outerr (entire ? entire : "out of memory", 0);
+ cvs_outerr (entire ? entire : "out of memory\n", 0);
if (entire != NULL)
free (entire);
}
@@ -169,45 +158,53 @@ error (status, errnum, message, va_alist)
/* I think that all relevant systems have vprintf these days. But
just in case, I'm leaving this code here. */
- if (command_name && *command_name)
+ if (message[0] != '\0')
{
- if (status)
- fprintf (out, "%s [%s aborted]: ", program_name, command_name);
+ FILE *out = stderr;
+
+ if (error_use_protocol)
+ {
+ out = stdout;
+ printf ("E ");
+ }
+
+ if (command_name && *command_name)
+ {
+ if (status)
+ fprintf (out, "%s [%s aborted]: ", program_name, command_name);
+ else
+ fprintf (out, "%s %s: ", program_name, command_name);
+ }
else
- fprintf (out, "%s %s: ", program_name, command_name);
- }
- else
- fprintf (out, "%s: ", program_name);
+ fprintf (out, "%s: ", program_name);
#ifdef HAVE_VPRINTF
- VA_START (args, message);
- vfprintf (out, message, args);
- va_end (args);
+ VA_START (args, message);
+ vfprintf (out, message, args);
+ va_end (args);
#else
#ifdef HAVE_DOPRNT
- _doprnt (message, &args, out);
+ _doprnt (message, &args, out);
#else
- fprintf (out, message, a1, a2, a3, a4, a5, a6, a7, a8);
+ fprintf (out, message, a1, a2, a3, a4, a5, a6, a7, a8);
#endif
#endif
- if (errnum)
- fprintf (out, ": %s", strerror (errnum));
- putc ('\n', out);
+ if (errnum)
+ fprintf (out, ": %s", strerror (errnum));
+ putc ('\n', out);
+
+ /* In the error_use_protocol case, this probably does
+ something useful. In most other cases, I suspect it is a
+ noop (either stderr is line buffered or we haven't written
+ anything to stderr) or unnecessary (if stderr is not line
+ buffered, maybe there is a reason....). */
+ fflush (out);
+ }
#endif /* No HAVE_VPRINTF */
- /* In the error_use_protocol case, this probably does something useful.
- In most other cases, I suspect it is a noop (either stderr is line
- buffered or we haven't written anything to stderr) or unnecessary
- (if stderr is not line buffered, maybe there is a reason....). */
- fflush (out);
-
if (status)
- {
- if (cleanup_fn)
- (*cleanup_fn) ();
- exit (EXIT_FAILURE);
- }
+ error_exit ();
}
/* Print the program name and error message MESSAGE, which is a printf-style
@@ -216,7 +213,7 @@ error (status, errnum, message, va_alist)
Exit with status EXIT_FAILURE if STATUS is nonzero. */
/* VARARGS */
void
-#if defined (HAVE_VPRINTF) && __STDC__
+#if defined (HAVE_VPRINTF) && defined (__STDC__)
fperror (FILE *fp, int status, int errnum, char *message, ...)
#else
fperror (fp, status, errnum, message, va_alist)
@@ -248,9 +245,5 @@ fperror (fp, status, errnum, message, va_alist)
putc ('\n', fp);
fflush (fp);
if (status)
- {
- if (cleanup_fn)
- (*cleanup_fn) ();
- exit (EXIT_FAILURE);
- }
+ error_exit ();
}
diff --git a/contrib/cvs/src/error.h b/contrib/cvs/src/error.h
index 7d4f535..e0fde4a 100644
--- a/contrib/cvs/src/error.h
+++ b/contrib/cvs/src/error.h
@@ -9,15 +9,21 @@
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ GNU General Public License for more details. */
#ifndef _error_h_
#define _error_h_
+/* Add prototype support. Normally this is done in cvs.h, but that
+ doesn't get included from lib/savecwd.c. */
+#ifndef PROTO
+#if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)
+#define PROTO(ARGS) ARGS
+#else
+#define PROTO(ARGS) ()
+#endif
+#endif
+
#ifndef __attribute__
/* This feature is available in gcc versions 2.5 and later. */
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
@@ -31,13 +37,17 @@
# endif
#endif
-#if __STDC__
+#ifdef __STDC__
void error (int, int, const char *, ...) \
__attribute__ ((__format__ (__printf__, 3, 4)));
#else
void error ();
#endif
+/* Exit due to an error. Similar to error (1, 0, "message"), but call
+ it in the case where the message has already been printed. */
+extern void error_exit PROTO ((void));
+
/* If non-zero, error will use the CVS protocol to report error
messages. This will only be set in the CVS server parent process;
most other code is run via do_cvs_command, which forks off a child
diff --git a/contrib/cvs/src/expand_path.c b/contrib/cvs/src/expand_path.c
index 9898051..7d0bc39 100644
--- a/contrib/cvs/src/expand_path.c
+++ b/contrib/cvs/src/expand_path.c
@@ -81,10 +81,12 @@ variable_set (nameval)
}
/* This routine will expand the pathname to account for ~ and $
- characters as described above. If an error occurs, an error
- message is printed via error() and NULL is returned. FILE and
- LINE are the filename and linenumber to include in the error
- message. */
+ characters as described above. Returns a pointer to a newly
+ malloc'd string. If an error occurs, an error message is printed
+ via error() and NULL is returned. FILE and LINE are the filename
+ and linenumber to include in the error message. FILE must point
+ to something; LINE can be zero to indicate the line number is not
+ known. */
char *
expand_path (name, file, line)
char *name;
@@ -93,40 +95,82 @@ expand_path (name, file, line)
{
char *s;
char *d;
- /* FIXME: arbitrary limit. */
- char mybuf[PATH_MAX];
- char buf[PATH_MAX];
+
+ char *mybuf = NULL;
+ size_t mybuf_size = 0;
+ char *buf = NULL;
+ size_t buf_size = 0;
+
+ size_t doff;
+
char *result;
+
+ /* Sorry this routine is so ugly; it is a head-on collision
+ between the `traditional' unix *d++ style and the need to
+ dynamically allocate. It would be much cleaner (and probably
+ faster, not that this is a bottleneck for CVS) with more use of
+ strcpy & friends, but I haven't taken the effort to rewrite it
+ thusly. */
+
+ /* First copy from NAME to MYBUF, expanding $<foo> as we go. */
s = name;
d = mybuf;
+ doff = d - mybuf;
+ expand_string (&mybuf, &mybuf_size, doff + 1);
+ d = mybuf + doff;
while ((*d++ = *s))
+ {
if (*s++ == '$')
{
char *p = d;
char *e;
int flag = (*s == '{');
+ doff = d - mybuf;
+ expand_string (&mybuf, &mybuf_size, doff + 1);
+ d = mybuf + doff;
for (; (*d++ = *s); s++)
+ {
if (flag
? *s =='}'
: isalnum (*s) == 0 && *s != '_')
break;
- *--d = 0;
+ doff = d - mybuf;
+ expand_string (&mybuf, &mybuf_size, doff + 1);
+ d = mybuf + doff;
+ }
+ *--d = '\0';
e = expand_variable (&p[flag], file, line);
if (e)
{
+ doff = d - mybuf;
+ expand_string (&mybuf, &mybuf_size, doff + 1);
+ d = mybuf + doff;
for (d = &p[-1]; (*d++ = *e++);)
- ;
+ {
+ doff = d - mybuf;
+ expand_string (&mybuf, &mybuf_size, doff + 1);
+ d = mybuf + doff;
+ }
--d;
if (flag && *s)
s++;
}
else
/* expand_variable has already printed an error message. */
- return NULL;
+ goto error_exit;
}
- *d = 0;
+ doff = d - mybuf;
+ expand_string (&mybuf, &mybuf_size, doff + 1);
+ d = mybuf + doff;
+ }
+ doff = d - mybuf;
+ expand_string (&mybuf, &mybuf_size, doff + 1);
+ d = mybuf + doff;
+ *d = '\0';
+
+ /* Then copy from MYBUF to BUF, expanding ~. */
s = mybuf;
d = buf;
/* If you don't want ~username ~/ to be expanded simply remove
@@ -156,8 +200,15 @@ expand_path (name, file, line)
}
t = ps->pw_dir;
}
+ doff = d - buf;
+ expand_string (&buf, &buf_size, doff + 1);
+ d = buf + doff;
while ((*d++ = *t++))
- ;
+ {
+ doff = d - buf;
+ expand_string (&buf, &buf_size, doff + 1);
+ d = buf + doff;
+ }
--d;
if (*p == 0)
*p = '/'; /* always add / */
@@ -166,12 +217,35 @@ expand_path (name, file, line)
else
--s;
/* Kill up to here */
+ doff = d - buf;
+ expand_string (&buf, &buf_size, doff + 1);
+ d = buf + doff;
while ((*d++ = *s++))
- ;
- *d=0;
- result = xmalloc (sizeof(char) * strlen(buf)+1);
- strcpy (result, buf);
+ {
+ doff = d - buf;
+ expand_string (&buf, &buf_size, doff + 1);
+ d = buf + doff;
+ }
+ doff = d - buf;
+ expand_string (&buf, &buf_size, doff + 1);
+ d = buf + doff;
+ *d = '\0';
+
+ /* OK, buf contains the value we want to return. Clean up and return
+ it. */
+ free (mybuf);
+ /* Save a little memory with xstrdup; buf will tend to allocate
+ more than it needs to. */
+ result = xstrdup (buf);
+ free (buf);
return result;
+
+ error_exit:
+ if (mybuf != NULL)
+ free (mybuf);
+ if (buf != NULL)
+ free (buf);
+ return NULL;
}
static char *
@@ -181,7 +255,7 @@ expand_variable (name, file, line)
int line;
{
if (strcmp (name, CVSROOT_ENV) == 0)
- return CVSroot;
+ return CVSroot_original;
else if (strcmp (name, RCSBIN_ENV) == 0)
return Rcsbin;
else if (strcmp (name, EDITOR1_ENV) == 0)
@@ -231,10 +305,10 @@ expand_variable (name, file, line)
that various crazy syntaxes might be invented for inserting
information about revisions, branches, etc. */
if (line != 0)
- error (0, 0, "%s:%d: unrecognized varaible syntax %s",
+ error (0, 0, "%s:%d: unrecognized variable syntax %s",
file, line, name);
else
- error (0, 0, "%s: unrecognized varaible syntax %s",
+ error (0, 0, "%s: unrecognized variable syntax %s",
file, name);
return NULL;
}
diff --git a/contrib/cvs/src/fileattr.c b/contrib/cvs/src/fileattr.c
index 827c69c..eda7753 100644
--- a/contrib/cvs/src/fileattr.c
+++ b/contrib/cvs/src/fileattr.c
@@ -8,11 +8,7 @@
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ GNU General Public License for more details. */
#include "cvs.h"
#include "getline.h"
@@ -35,6 +31,14 @@ static int attr_read_attempted;
/* Have the in-memory attributes been modified since we read them? */
static int attrs_modified;
+/* More in-memory attributes: linked list of unrecognized
+ fileattr lines. We pass these on unchanged. */
+struct unrecog {
+ char *line;
+ struct unrecog *next;
+};
+static struct unrecog *unrecog_head;
+
/* Note that if noone calls fileattr_get, this is very cheap. No stat(),
no open(), no nothing. */
void
@@ -45,6 +49,7 @@ fileattr_startdir (repos)
fileattr_stored_repos = xstrdup (repos);
assert (attrlist == NULL);
attr_read_attempted = 0;
+ assert (unrecog_head == NULL);
}
static void
@@ -84,7 +89,7 @@ fileattr_read ()
strcat (fname, CVSREP_FILEATTR);
attr_read_attempted = 1;
- fp = fopen (fname, FOPEN_BINARY_READ);
+ fp = CVS_FOPEN (fname, FOPEN_BINARY_READ);
if (fp == NULL)
{
if (!existence_error (errno))
@@ -112,7 +117,12 @@ fileattr_read ()
newnode->delproc = fileattr_delproc;
newnode->key = xstrdup (line + 1);
newnode->data = xstrdup (p);
- addnode (attrlist, newnode);
+ if (addnode (attrlist, newnode) != 0)
+ /* If the same filename appears twice in the file, discard
+ any line other than the first for that filename. This
+ is the way that CVS has behaved since file attributes
+ were first introduced. */
+ free (newnode);
}
else if (line[0] == 'D')
{
@@ -123,7 +133,17 @@ fileattr_read ()
++p;
fileattr_default_attrs = xstrdup (p);
}
- /* else just ignore the line, for future expansion. */
+ else
+ {
+ /* Unrecognized type, we want to just preserve the line without
+ changing it, for future expansion. */
+ struct unrecog *new;
+
+ new = (struct unrecog *) xmalloc (sizeof (struct unrecog));
+ new->line = xstrdup (line);
+ new->next = unrecog_head;
+ unrecog_head = new;
+ }
}
if (ferror (fp))
error (0, errno, "cannot read %s", fname);
@@ -137,8 +157,8 @@ fileattr_read ()
char *
fileattr_get (filename, attrname)
- char *filename;
- char *attrname;
+ const char *filename;
+ const char *attrname;
{
Node *node;
size_t attrname_len = strlen (attrname);
@@ -180,8 +200,8 @@ fileattr_get (filename, attrname)
char *
fileattr_get0 (filename, attrname)
- char *filename;
- char *attrname;
+ const char *filename;
+ const char *attrname;
{
char *cp;
char *cpend;
@@ -202,8 +222,8 @@ fileattr_get0 (filename, attrname)
char *
fileattr_modify (list, attrname, attrval, namevalsep, entsep)
char *list;
- char *attrname;
- char *attrval;
+ const char *attrname;
+ const char *attrval;
int namevalsep;
int entsep;
{
@@ -298,15 +318,13 @@ fileattr_modify (list, attrname, attrval, namevalsep, entsep)
void
fileattr_set (filename, attrname, attrval)
- char *filename;
- char *attrname;
- char *attrval;
+ const char *filename;
+ const char *attrname;
+ const char *attrval;
{
Node *node;
char *p;
- attrs_modified = 1;
-
if (filename == NULL)
{
p = fileattr_modify (fileattr_default_attrs, attrname, attrval,
@@ -314,6 +332,7 @@ fileattr_set (filename, attrname, attrval)
if (fileattr_default_attrs != NULL)
free (fileattr_default_attrs);
fileattr_default_attrs = p;
+ attrs_modified = 1;
return;
}
if (attrlist == NULL)
@@ -346,17 +365,20 @@ fileattr_set (filename, attrname, attrval)
}
p = fileattr_modify (node->data, attrname, attrval, '=', ';');
- free (node->data);
- node->data = NULL;
if (p == NULL)
delnode (node);
else
+ {
+ free (node->data);
node->data = p;
+ }
+
+ attrs_modified = 1;
}
void
fileattr_newfile (filename)
- char *filename;
+ const char *filename;
{
Node *node;
@@ -423,7 +445,9 @@ fileattr_write ()
strcat (fname, "/");
strcat (fname, CVSREP_FILEATTR);
- if (list_isempty (attrlist) && fileattr_default_attrs == NULL)
+ if (list_isempty (attrlist)
+ && fileattr_default_attrs == NULL
+ && unrecog_head == NULL)
{
/* There are no attributes. */
if (unlink_file (fname) < 0)
@@ -440,7 +464,7 @@ fileattr_write ()
strcpy (fname, fileattr_stored_repos);
strcat (fname, "/");
strcat (fname, CVSREP);
- if (rmdir (fname) < 0)
+ if (CVS_RMDIR (fname) < 0)
{
if (errno != ENOTEMPTY
@@ -456,7 +480,7 @@ fileattr_write ()
}
omask = umask (cvsumask);
- fp = fopen (fname, FOPEN_BINARY_WRITE);
+ fp = CVS_FOPEN (fname, FOPEN_BINARY_WRITE);
if (fp == NULL)
{
if (existence_error (errno))
@@ -481,7 +505,7 @@ fileattr_write ()
}
free (repname);
- fp = fopen (fname, FOPEN_BINARY_WRITE);
+ fp = CVS_FOPEN (fname, FOPEN_BINARY_WRITE);
}
if (fp == NULL)
{
@@ -491,13 +515,32 @@ fileattr_write ()
}
}
(void) umask (omask);
+
+ /* First write the "F" attributes. */
walklist (attrlist, writeattr_proc, fp);
+
+ /* Then the "D" attribute. */
if (fileattr_default_attrs != NULL)
{
fputs ("D\t", fp);
fputs (fileattr_default_attrs, fp);
fputs ("\012", fp);
}
+
+ /* Then any other attributes. */
+ while (unrecog_head != NULL)
+ {
+ struct unrecog *p;
+
+ p = unrecog_head;
+ fputs (p->line, fp);
+ fputs ("\012", fp);
+
+ unrecog_head = p->next;
+ free (p->line);
+ free (p);
+ }
+
if (fclose (fp) < 0)
error (0, errno, "cannot close %s", fname);
attrs_modified = 0;
diff --git a/contrib/cvs/src/fileattr.h b/contrib/cvs/src/fileattr.h
index c24c035..c6362af 100644
--- a/contrib/cvs/src/fileattr.h
+++ b/contrib/cvs/src/fileattr.h
@@ -8,11 +8,7 @@
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ GNU General Public License for more details. */
#ifndef FILEATTR_H
@@ -27,6 +23,13 @@
ENT-TYPE is 'D', and FILENAME empty, to specify default attributes
to be used for newly added files.
+ Other ENT-TYPE are reserved for future expansion. CVS 1.9 and older
+ will delete them any time it writes file attributes. Current versions
+ of CVS will preserve them.
+
+ Note that the order of the line is not significant; CVS is free to
+ rearrange them at its convenience.
+
There is currently no way of quoting tabs or linefeeds in the
filename, '=' in ATTRNAME, ';' in ATTRVAL, etc. I'm not sure
whether I think we need one. Note: the current implementation also
@@ -66,11 +69,12 @@ extern void fileattr_startdir PROTO ((char *repos));
by '\0' or ';'. Return NULL if said file lacks said attribute.
If FILENAME is NULL, return default attributes (attributes for
files created in the future). */
-extern char *fileattr_get PROTO ((char *filename, char *attrname));
+extern char *fileattr_get PROTO ((const char *filename, const char *attrname));
/* Like fileattr_get, but return a pointer to a newly malloc'd string
terminated by '\0' (or NULL if said file lacks said attribute). */
-extern char *fileattr_get0 PROTO ((char *filename, char *attrname));
+extern char *fileattr_get0 PROTO ((const char *filename,
+ const char *attrname));
/* This is just a string manipulation function; it does not manipulate
file attributes as such.
@@ -94,26 +98,26 @@ extern char *fileattr_get0 PROTO ((char *filename, char *attrname));
=> "abc=val;def=v2"
fileattr_modify ("abc=v1;def=v2", "def", "val", '=', ';'))
=> "abc=v1;def=val"
- fileattr_modify ("abc=v1;def=v2", "xxx", "val"))
+ fileattr_modify ("abc=v1;def=v2", "xxx", "val", '=', ';'))
=> "abc=v1;def=v2;xxx=val"
fileattr_modify ("abc=v1;def=v2;ghi=v3", "def", "val", '=', ';'))
=> "abc=v1;def=val;ghi=v3"
*/
-extern char *fileattr_modify PROTO ((char *list, char *attrname,
- char *attrval, int namevalsep,
+extern char *fileattr_modify PROTO ((char *list, const char *attrname,
+ const char *attrval, int namevalsep,
int entsep));
/* Set attribute ATTRNAME for file FILENAME to ATTRVAL. If ATTRVAL is NULL,
the attribute is removed. Changes are not written to disk until the
next call to fileattr_write. If FILENAME is NULL, set attributes for
files created in the future. If ATTRVAL is NULL, remove that attribute. */
-extern void fileattr_set PROTO ((char *filename, char *attrname,
- char *attrval));
+extern void fileattr_set PROTO ((const char *filename, const char *attrname,
+ const char *attrval));
/* Set the attributes for file FILENAME in whatever manner is appropriate
for a newly created file. */
-extern void fileattr_newfile PROTO ((char *filename));
+extern void fileattr_newfile PROTO ((const char *filename));
/* Write out all modified attributes. */
extern void fileattr_write PROTO ((void));
diff --git a/contrib/cvs/src/filesubr.c b/contrib/cvs/src/filesubr.c
index 086da83..71df566 100644
--- a/contrib/cvs/src/filesubr.c
+++ b/contrib/cvs/src/filesubr.c
@@ -11,11 +11,7 @@
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ GNU General Public License for more details. */
/* These functions were moved out of subr.c because they need different
definitions under operating systems (like, say, Windows NT) with different
@@ -23,14 +19,6 @@
#include "cvs.h"
-/*
- * I don't know of a convenient way to test this at configure time, or else
- * I'd certainly do it there.
- */
-#if defined(NeXT)
-#define LOSING_TMPNAM_FUNCTION
-#endif
-
static int deep_remove_dir PROTO((const char *path));
/*
@@ -290,6 +278,22 @@ make_directories (name)
(void) mkdir (name, 0777);
}
+/* Create directory NAME if it does not already exist; fatal error for
+ other errors. Returns 0 if directory was created; 1 if it already
+ existed. */
+int
+mkdir_if_needed (name)
+ char *name;
+{
+ if (mkdir (name, 0777) < 0)
+ {
+ if (errno != EEXIST)
+ error (1, errno, "cannot make directory %s", name);
+ return 1;
+ }
+ return 0;
+}
+
/*
* Change the mode of a file, either adding write permissions, or removing
* all write permissions. Either change honors the current umask setting.
@@ -451,47 +455,62 @@ deep_remove_dir (path)
{
DIR *dirp;
struct dirent *dp;
- char buf[PATH_MAX];
- if (rmdir (path) != 0 && (errno == ENOTEMPTY || errno == EEXIST))
+ if (rmdir (path) != 0)
{
- if ((dirp = opendir (path)) == NULL)
- /* If unable to open the directory return
- * an error
- */
- return -1;
-
- while ((dp = readdir (dirp)) != NULL)
+ if (errno == ENOTEMPTY
+ || errno == EEXIST
+ /* Ugly workaround for ugly AIX 4.1 (and 3.2) header bug
+ (it defines ENOTEMPTY and EEXIST to 17 but actually
+ returns 87). */
+ || (ENOTEMPTY == 17 && EEXIST == 17 && errno == 87))
{
- if (strcmp (dp->d_name, ".") == 0 ||
- strcmp (dp->d_name, "..") == 0)
- continue;
+ if ((dirp = opendir (path)) == NULL)
+ /* If unable to open the directory return
+ * an error
+ */
+ return -1;
- sprintf (buf, "%s/%s", path, dp->d_name);
-
- /* See comment in unlink_file_dir explanation of why we use
- isdir instead of just calling unlink and checking the
- status. */
- if (isdir(buf))
+ while ((dp = readdir (dirp)) != NULL)
{
- if (deep_remove_dir(buf))
+ char *buf;
+
+ if (strcmp (dp->d_name, ".") == 0 ||
+ strcmp (dp->d_name, "..") == 0)
+ continue;
+
+ buf = xmalloc (strlen (path) + strlen (dp->d_name) + 5);
+ sprintf (buf, "%s/%s", path, dp->d_name);
+
+ /* See comment in unlink_file_dir explanation of why we use
+ isdir instead of just calling unlink and checking the
+ status. */
+ if (isdir(buf))
{
- closedir(dirp);
- return -1;
+ if (deep_remove_dir(buf))
+ {
+ closedir(dirp);
+ free (buf);
+ return -1;
+ }
}
- }
- else
- {
- if (unlink (buf) != 0)
+ else
{
- closedir(dirp);
- return -1;
+ if (unlink (buf) != 0)
+ {
+ closedir(dirp);
+ free (buf);
+ return -1;
+ }
}
+ free (buf);
}
+ closedir (dirp);
+ return rmdir (path);
}
- closedir (dirp);
- return rmdir (path);
- }
+ else
+ return -1;
+ }
/* Was able to remove the directory return 0 */
return 0;
@@ -596,24 +615,55 @@ xcmp (file1, file2)
(void) close (fd2);
return (ret);
}
-
-#ifdef LOSING_TMPNAM_FUNCTION
-char *tmpnam(char *s)
+
+/* Generate a unique temporary filename. Returns a pointer to a newly
+ malloc'd string containing the name. Returns successfully or not at
+ all. */
+/* There are at least three functions for generating temporary
+ filenames. We use tempnam (SVID 3) if possible, else mktemp (BSD
+ 4.3), and as last resort tmpnam (POSIX). Reason is that tempnam and
+ mktemp both allow to specify the directory in which the temporary
+ file will be created. */
+#ifdef HAVE_TEMPNAM
+char *
+cvs_temp_name ()
{
- static char value[L_tmpnam+1];
-
- if (s){
- strcpy(s,"/tmp/cvsXXXXXX");
- mktemp(s);
- return s;
- }else{
- strcpy(value,"/tmp/cvsXXXXXX");
- mktemp(s);
- return value;
- }
+ char *retval;
+
+ retval = tempnam (Tmpdir, "cvs");
+ if (retval == NULL)
+ error (1, errno, "cannot generate temporary filename");
+ /* tempnam returns a pointer to a newly malloc'd string, so there's
+ no need for a xstrdup */
+ return retval;
+}
+#else
+char *
+cvs_temp_name ()
+{
+# ifdef HAVE_MKTEMP
+ char *value;
+ char *retval;
+
+ value = xmalloc (strlen (Tmpdir) + 40);
+ sprintf (value, "%s/%s", Tmpdir, "cvsXXXXXX" );
+ retval = mktemp (value);
+
+ if (retval == NULL)
+ error (1, errno, "cannot generate temporary filename");
+ return value;
+# else
+ char value[L_tmpnam + 1];
+ char *retval;
+
+ retval = tmpnam (value);
+ if (retval == NULL)
+ error (1, errno, "cannot generate temporary filename");
+ return xstrdup (value);
+# endif
}
#endif
-
+
/* Return non-zero iff FILENAME is absolute.
Trivial under Unix, but more complicated under other systems. */
int
@@ -638,11 +688,28 @@ last_component (path)
}
/* Return the home directory. Returns a pointer to storage
- managed by this function or its callees (currently getenv). */
+ managed by this function or its callees (currently getenv).
+ This function will return the same thing every time it is
+ called. */
char *
get_homedir ()
{
- return getenv ("HOME");
+ static char *home = NULL;
+ char *env = getenv ("HOME");
+ struct passwd *pw;
+
+ if (home != NULL)
+ return home;
+
+ if (env)
+ home = env;
+ else if ((pw = (struct passwd *) getpwuid (getuid ()))
+ && pw->pw_dir)
+ home = xstrdup (pw->pw_dir);
+ else
+ return 0;
+
+ return home;
}
/* See cvs.h for description. On unix this does nothing, because the
@@ -660,3 +727,132 @@ expand_wild (argc, argv, pargc, pargv)
for (i = 0; i < argc; ++i)
(*pargv)[i] = xstrdup (argv[i]);
}
+
+#ifdef SERVER_SUPPORT
+/* Case-insensitive string compare. I know that some systems
+ have such a routine, but I'm not sure I see any reasons for
+ dealing with the hair of figuring out whether they do (I haven't
+ looked into whether this is a performance bottleneck; I would guess
+ not). */
+int
+cvs_casecmp (str1, str2)
+ char *str1;
+ char *str2;
+{
+ char *p;
+ char *q;
+ int pqdiff;
+
+ p = str1;
+ q = str2;
+ while ((pqdiff = tolower (*p) - tolower (*q)) == 0)
+ {
+ if (*p == '\0')
+ return 0;
+ ++p;
+ ++q;
+ }
+ return pqdiff;
+}
+
+/* Case-insensitive file open. As you can see, this is an expensive
+ call. We don't regard it as our main strategy for dealing with
+ case-insensitivity. Returns errno code or 0 for success. Puts the
+ new file in *FP. NAME and MODE are as for fopen. If PATHP is not
+ NULL, then put a malloc'd string containing the pathname as found
+ into *PATHP. *PATHP is only set if the return value is 0.
+
+ Might be cleaner to separate the file finding (which just gives
+ *PATHP) from the file opening (which the caller can do). For one
+ thing, might make it easier to know whether to put NAME or *PATHP
+ into error messages. */
+int
+fopen_case (name, mode, fp, pathp)
+ char *name;
+ char *mode;
+ FILE **fp;
+ char **pathp;
+{
+ struct dirent *dp;
+ DIR *dirp;
+ char *dir;
+ char *fname;
+ char *found_name;
+ int retval;
+
+ /* Separate NAME into directory DIR and filename within the directory
+ FNAME. */
+ dir = xstrdup (name);
+ fname = strrchr (dir, '/');
+ if (fname == NULL)
+ error (1, 0, "internal error: relative pathname in fopen_case");
+ *fname++ = '\0';
+
+ found_name = NULL;
+ dirp = CVS_OPENDIR (dir);
+ if (dirp == NULL)
+ {
+ if (existence_error (errno))
+ {
+ /* This can happen if we are looking in the Attic and the Attic
+ directory does not exist. Return the error to the caller;
+ they know what to do with it. */
+ retval = errno;
+ goto out;
+ }
+ else
+ {
+ /* Give a fatal error; that way the error message can be
+ more specific than if we returned the error to the caller. */
+ error (1, errno, "cannot read directory %s", dir);
+ }
+ }
+ errno = 0;
+ while ((dp = readdir (dirp)) != NULL)
+ {
+ if (cvs_casecmp (dp->d_name, fname) == 0)
+ {
+ if (found_name != NULL)
+ error (1, 0, "%s is ambiguous; could mean %s or %s",
+ fname, dp->d_name, found_name);
+ found_name = xstrdup (dp->d_name);
+ }
+ }
+ if (errno != 0)
+ error (1, errno, "cannot read directory %s", dir);
+ closedir (dirp);
+
+ if (found_name == NULL)
+ {
+ *fp = NULL;
+ retval = ENOENT;
+ }
+ else
+ {
+ char *p;
+
+ /* Copy the found name back into DIR. We are assuming that
+ found_name is the same length as fname, which is true as
+ long as the above code is just ignoring case and not other
+ aspects of filename syntax. */
+ p = dir + strlen (dir);
+ *p++ = '/';
+ strcpy (p, found_name);
+ *fp = fopen (dir, mode);
+ if (*fp == NULL)
+ retval = errno;
+ else
+ retval = 0;
+ }
+
+ if (pathp == NULL)
+ free (dir);
+ else if (retval != 0)
+ free (dir);
+ else
+ *pathp = dir;
+ free (found_name);
+ out:
+ return retval;
+}
+#endif /* SERVER_SUPPORT */
diff --git a/contrib/cvs/src/find_names.c b/contrib/cvs/src/find_names.c
index 4885437..a7a91bb 100644
--- a/contrib/cvs/src/find_names.c
+++ b/contrib/cvs/src/find_names.c
@@ -18,8 +18,11 @@
#include "cvs.h"
-static int find_dirs PROTO((char *dir, List * list, int checkadm));
+static int find_dirs PROTO((char *dir, List * list, int checkadm,
+ List *entries));
static int find_rcs PROTO((char *dir, List * list));
+static int add_subdir_proc PROTO((Node *, void *));
+static int register_subdir_proc PROTO((Node *, void *));
static List *filelist;
@@ -32,8 +35,13 @@ add_entries_proc (node, closure)
Node *node;
void *closure;
{
+ Entnode *entnode;
Node *fnode;
+ entnode = (Entnode *) node->data;
+ if (entnode->type != ENT_FILE)
+ return (0);
+
fnode = getnode ();
fnode->type = FILES;
fnode->key = xstrdup (node->key);
@@ -63,7 +71,6 @@ Find_Names (repository, which, aflag, optentries)
{
List *entries;
List *files;
- char dir[PATH_MAX];
/* make a list for the files */
files = filelist = getlist ();
@@ -95,8 +102,11 @@ Find_Names (repository, which, aflag, optentries)
/* search the attic too */
if (which & W_ATTIC)
{
+ char *dir;
+ dir = xmalloc (strlen (repository) + sizeof (CVSATTIC) + 10);
(void) sprintf (dir, "%s/%s", repository, CVSATTIC);
(void) find_rcs (dir, files);
+ free (dir);
}
}
@@ -106,12 +116,55 @@ Find_Names (repository, which, aflag, optentries)
}
/*
+ * Add an entry from the subdirs list to the directories list. This
+ * is called via walklist.
+ */
+
+static int
+add_subdir_proc (p, closure)
+ Node *p;
+ void *closure;
+{
+ List *dirlist = (List *) closure;
+ Entnode *entnode;
+ Node *dnode;
+
+ entnode = (Entnode *) p->data;
+ if (entnode->type != ENT_SUBDIR)
+ return 0;
+
+ dnode = getnode ();
+ dnode->type = DIRS;
+ dnode->key = xstrdup (entnode->user);
+ if (addnode (dirlist, dnode) != 0)
+ freenode (dnode);
+ return 0;
+}
+
+/*
+ * Register a subdirectory. This is called via walklist.
+ */
+
+/*ARGSUSED*/
+static int
+register_subdir_proc (p, closure)
+ Node *p;
+ void *closure;
+{
+ List *entries = (List *) closure;
+
+ Subdir_Register (entries, (char *) NULL, p->key);
+ return 0;
+}
+
+/*
* create a list of directories to traverse from the current directory
*/
List *
-Find_Directories (repository, which)
+Find_Directories (repository, which, entries)
char *repository;
int which;
+ List *entries;
{
List *dirlist;
@@ -121,28 +174,60 @@ Find_Directories (repository, which)
/* find the local ones */
if (which & W_LOCAL)
{
- /* look only for CVS controlled sub-directories */
- if (find_dirs (".", dirlist, 1) != 0)
- error (1, errno, "cannot open current directory");
+ List *tmpentries;
+ struct stickydirtag *sdtp;
+
+ /* Look through the Entries file. */
+
+ if (entries != NULL)
+ tmpentries = entries;
+ else if (isfile (CVSADM_ENT))
+ tmpentries = Entries_Open (0);
+ else
+ tmpentries = NULL;
+
+ if (tmpentries != NULL)
+ sdtp = (struct stickydirtag *) tmpentries->list->data;
+
+ /* If we do have an entries list, then if sdtp is NULL, or if
+ sdtp->subdirs is nonzero, all subdirectory information is
+ recorded in the entries list. */
+ if (tmpentries != NULL && (sdtp == NULL || sdtp->subdirs))
+ walklist (tmpentries, add_subdir_proc, (void *) dirlist);
+ else
+ {
+ /* This is an old working directory, in which subdirectory
+ information is not recorded in the Entries file. Find
+ the subdirectories the hard way, and, if possible, add
+ it to the Entries file for next time. */
+ if (find_dirs (".", dirlist, 1, tmpentries) != 0)
+ error (1, errno, "cannot open current directory");
+ if (tmpentries != NULL)
+ {
+ if (! list_isempty (dirlist))
+ walklist (dirlist, register_subdir_proc,
+ (void *) tmpentries);
+ else
+ Subdirs_Known (tmpentries);
+ }
+ }
+
+ if (entries == NULL && tmpentries != NULL)
+ Entries_Close (tmpentries);
}
/* look for sub-dirs in the repository */
if ((which & W_REPOS) && repository)
{
/* search the repository */
- if (find_dirs (repository, dirlist, 0) != 0)
+ if (find_dirs (repository, dirlist, 0, entries) != 0)
error (1, errno, "cannot open directory %s", repository);
-#ifdef ATTIC_DIR_SUPPORT /* XXX - FIXME */
- /* search the attic too */
- if (which & W_ATTIC)
- {
- char dir[PATH_MAX];
-
- (void) sprintf (dir, "%s/%s", repository, CVSATTIC);
- (void) find_dirs (dir, dirlist, 0);
- }
-#endif
+ /* We don't need to look in the attic because directories
+ never go in the attic. In the future, there hopefully will
+ be a better mechanism for detecting whether a directory in
+ the repository is alive or dead; it may or may not involve
+ moving directories to the attic. */
}
/* sort the list into alphabetical order and return it */
@@ -165,7 +250,7 @@ find_rcs (dir, list)
DIR *dirp;
/* set up to read the dir */
- if ((dirp = opendir (dir)) == NULL)
+ if ((dirp = CVS_OPENDIR (dir)) == NULL)
return (1);
/* read the dir, grabbing the ,v files */
@@ -189,23 +274,27 @@ find_rcs (dir, list)
}
/*
- * Finds all the subdirectories of the argument dir and adds them to the
- * specified list. Sub-directories without a CVS administration directory
- * are optionally ignored Returns 0 for success or 1 on error.
+ * Finds all the subdirectories of the argument dir and adds them to
+ * the specified list. Sub-directories without a CVS administration
+ * directory are optionally ignored. If ENTRIES is not NULL, all
+ * files on the list are ignored. Returns 0 for success or 1 on
+ * error.
*/
static int
-find_dirs (dir, list, checkadm)
+find_dirs (dir, list, checkadm, entries)
char *dir;
List *list;
int checkadm;
+ List *entries;
{
Node *p;
- char tmp[PATH_MAX];
+ char *tmp = NULL;
+ size_t tmp_size = 0;
struct dirent *dp;
DIR *dirp;
/* set up to read the dir */
- if ((dirp = opendir (dir)) == NULL)
+ if ((dirp = CVS_OPENDIR (dir)) == NULL)
return (1);
/* read the dir, grabbing sub-dirs */
@@ -218,6 +307,12 @@ find_dirs (dir, list, checkadm)
strcmp (dp->d_name, CVSREP) == 0)
continue;
+ /* findnode() is going to be significantly faster than stat()
+ because it involves no system calls. That is why we bother
+ with the entries argument, and why we check this first. */
+ if (entries != NULL && findnode (entries, dp->d_name) != NULL)
+ continue;
+
#ifdef DT_DIR
if (dp->d_type != DT_DIR)
{
@@ -228,6 +323,9 @@ find_dirs (dir, list, checkadm)
if (fnmatch (RCSPAT, dp->d_name, 0) == 0)
continue;
+ expand_string (&tmp,
+ &tmp_size,
+ strlen (dir) + strlen (dp->d_name) + 10);
sprintf (tmp, "%s/%s", dir, dp->d_name);
if (!isdir (tmp))
continue;
@@ -247,6 +345,8 @@ find_dirs (dir, list, checkadm)
if (dp->d_type == DT_LNK)
continue;
#endif
+ /* Note that we only get here if we already set tmp
+ above. */
if (islink (tmp))
continue;
#ifdef DT_DIR
@@ -254,6 +354,10 @@ find_dirs (dir, list, checkadm)
#endif
/* check for new style */
+ expand_string (&tmp,
+ &tmp_size,
+ (strlen (dir) + strlen (dp->d_name)
+ + sizeof (CVSADM) + 10));
(void) sprintf (tmp, "%s/%s/%s", dir, dp->d_name, CVSADM);
if (!isdir (tmp))
continue;
@@ -267,5 +371,7 @@ find_dirs (dir, list, checkadm)
freenode (p);
}
(void) closedir (dirp);
+ if (tmp != NULL)
+ free (tmp);
return (0);
}
diff --git a/contrib/cvs/src/hash.c b/contrib/cvs/src/hash.c
index 2197db0..a978d1f 100644
--- a/contrib/cvs/src/hash.c
+++ b/contrib/cvs/src/hash.c
@@ -10,7 +10,10 @@
#include "cvs.h"
#include <assert.h>
-/* global caches */
+/* Global caches. The idea is that we maintain a linked list of "free"d
+ nodes or lists, and get new items from there. It has been suggested
+ to use an obstack instead, but off the top of my head, I'm not sure
+ that would gain enough to be worth worrying about. */
static List *listcache = NULL;
static Node *nodecache = NULL;
@@ -98,15 +101,27 @@ dellist (listp)
if ((p = (*listp)->hasharray[i]) != (Node *) NULL)
{
/* put the nodes into the cache */
+#ifndef NOCACHE
p->type = UNKNOWN;
p->next = nodecache;
nodecache = p;
+#else
+ /* If NOCACHE is defined we turn off the cache. This can make
+ it easier to tools to determine where items were allocated
+ and freed, for tracking down memory leaks and the like. */
+ free (p);
+#endif
}
}
/* put it on the cache */
+#ifndef NOCACHE
(*listp)->next = listcache;
listcache = *listp;
+#else
+ free ((*listp)->list);
+ free (*listp);
+#endif
*listp = (List *) NULL;
}
@@ -195,9 +210,13 @@ freenode (p)
freenode_mem (p);
/* then put it in the cache */
+#ifndef NOCACHE
p->type = UNKNOWN;
p->next = nodecache;
nodecache = p;
+#else
+ free (p);
+#endif
}
/*
@@ -332,6 +351,19 @@ list_isempty (list)
return list == NULL || list->list->next == list->list;
}
+static int (*client_comp) PROTO ((const Node *, const Node *));
+static int qsort_comp PROTO ((const void *, const void *));
+
+static int
+qsort_comp (elem1, elem2)
+ const void *elem1;
+ const void *elem2;
+{
+ Node **node1 = (Node **) elem1;
+ Node **node2 = (Node **) elem2;
+ return client_comp (*node1, *node2);
+}
+
/*
* sort the elements of a list (in place)
*/
@@ -340,49 +372,48 @@ sortlist (list, comp)
List *list;
int (*comp) PROTO ((const Node *, const Node *));
{
- Node *head, *remain, *p, *q;
+ Node *head, *remain, *p, **array;
+ int i, n;
/* save the old first element of the list */
head = list->list;
remain = head->next;
- /* make the header node into a null list of it's own */
- head->next = head->prev = head;
+ /* count the number of nodes in the list */
+ n = 0;
+ for (p = remain; p != head; p = p->next)
+ n++;
- /* while there are nodes remaining, do insert sort */
- while (remain != head)
- {
- /* take one from the list */
- p = remain;
- remain = remain->next;
+ /* allocate an array of nodes and populate it */
+ array = (Node **) xmalloc (sizeof(Node *) * n);
+ i = 0;
+ for (p = remain; p != head; p = p->next)
+ array[i++] = p;
- /* traverse the sorted list looking for the place to insert it */
- for (q = head->next; q != head; q = q->next)
- {
- if (comp (p, q) < 0)
- {
- /* p comes before q */
- p->next = q;
- p->prev = q->prev;
- p->prev->next = p;
- q->prev = p;
- break;
- }
- }
- if (q == head)
- {
- /* it belongs at the end of the list */
- p->next = head;
- p->prev = head->prev;
- p->prev->next = p;
- head->prev = p;
- }
+ /* sort the array of nodes */
+ client_comp = comp;
+ qsort (array, n, sizeof(Node *), qsort_comp);
+
+ /* rebuild the list from beginning to end */
+ head->next = head->prev = head;
+ for (i = 0; i < n; i++)
+ {
+ p = array[i];
+ p->next = head;
+ p->prev = head->prev;
+ p->prev->next = p;
+ head->prev = p;
}
+
+ /* release the array of nodes */
+ free (array);
}
/* Debugging functions. Quite useful to call from within gdb. */
-char *
+static char *nodetypestring PROTO ((Ntype));
+
+static char *
nodetypestring (type)
Ntype type;
{
@@ -400,6 +431,7 @@ nodetypestring (type)
case NDBMNODE: return("NDBMNODE");
case FILEATTR: return("FILEATTR");
case VARIABLE: return("VARIABLE");
+ case RCSFIELD: return("RCSFIELD");
}
return("<trash>");
@@ -423,6 +455,11 @@ printnode (node, closure)
return(0);
}
+/* This is global, not static, so that its name is unique and to avoid
+ compiler warnings about it not being used. But it is not used by CVS;
+ it exists so one can call it from a debugger. */
+void printlist PROTO ((List *));
+
void
printlist (list)
List *list;
diff --git a/contrib/cvs/src/hash.h b/contrib/cvs/src/hash.h
index dd83665..a22bc10 100644
--- a/contrib/cvs/src/hash.h
+++ b/contrib/cvs/src/hash.h
@@ -1,5 +1,3 @@
-/* $CVSid: @(#)hash.h 1.23 94/10/07 $ */
-
/*
* Copyright (c) 1992, Brian Berliner and Jeff Polk
*
@@ -20,7 +18,7 @@ enum ntype
{
UNKNOWN, HEADER, ENTRIES, FILES, LIST, RCSNODE,
RCSVERS, DIRS, UPDATE, LOCK, NDBMNODE, FILEATTR,
- VARIABLE
+ VARIABLE, RCSFIELD
};
typedef enum ntype Ntype;
diff --git a/contrib/cvs/src/history.c b/contrib/cvs/src/history.c
index 81c71ff..7d28e81 100644
--- a/contrib/cvs/src/history.c
+++ b/contrib/cvs/src/history.c
@@ -17,6 +17,7 @@
* X is a single character showing the type of event:
* T "Tag" cmd.
* O "Checkout" cmd.
+ * E "Export" cmd.
* F "Release" cmd.
* W "Update" cmd - No User file, Remove from Entries file.
* U "Update" cmd - File was checked out over User file.
@@ -40,18 +41,18 @@
* command was typed.
* T "A" --> New Tag, "D" --> Delete Tag
* Otherwise it is the Tag or Date to modify.
- * O,F A "" (null field)
+ * O,F,E A "" (null field)
*
* rev(s) Revision number or tag.
* T The Tag to apply.
- * O The Tag or Date, if specified, else "" (null field).
+ * O,E The Tag or Date, if specified, else "" (null field).
* F "" (null field)
* W The Tag or Date, if specified, else "" (null field).
* U The Revision checked out over the User file.
* G,C The Revision(s) involved in merge.
* M,A,R RCS Revision affected.
*
- * argument The module (for [TOUF]) or file (for [WUGCMAR]) affected.
+ * argument The module (for [TOEUF]) or file (for [WUGCMAR]) affected.
*
*
*** Report categories: "User" and "Since" modifiers apply to all reports.
@@ -59,7 +60,7 @@
*
* Extract list of record types
*
- * -e, -x [TOFWUGCMAR]
+ * -e, -x [TOEFWUGCMAR]
*
* Extracted records are simply printed, No analysis is performed.
* All "field" modifiers apply. -e chooses all types.
@@ -177,6 +178,7 @@
*/
#include "cvs.h"
+#include "savecwd.h"
static struct hrec
{
@@ -206,7 +208,7 @@ static void save_file PROTO((char *dir, char *name, char *module));
static void save_module PROTO((char *module));
static void save_user PROTO((char *name));
-#define ALL_REC_TYPES "TOFWUCGMAR"
+#define ALL_REC_TYPES "TOEFWUCGMAR"
#define USER_INCREMENT 2
#define FILE_INCREMENT 128
#define MODULE_INCREMENT 5
@@ -236,13 +238,24 @@ static char *tz_name = "+0000";
static char tz_name[] = "LT";
#endif
+/* -r, -t, or -b options, malloc'd. These are "" if the option in
+ question is not specified or is overridden by another option. The
+ main reason for using "" rather than NULL is historical. Together
+ with since_date, these are a mutually exclusive set; one overrides the
+ others. */
+static char *since_rev;
+static char *since_tag;
+static char *backto;
+/* -D option, or 0 if not specified. */
static time_t since_date;
-static char since_rev[20]; /* Maxrev ~= 99.99.99.999 */
-static char since_tag[64];
+
static struct hrec *last_since_tag;
-static char backto[128];
static struct hrec *last_backto;
-static char rec_types[20];
+
+/* Record types to look for, malloc'd. Probably could be statically
+ allocated, but only if we wanted to check for duplicates more than
+ we do. */
+static char *rec_types;
static int hrec_count;
static int hrec_max;
@@ -265,6 +278,12 @@ static int mod_count; /* Number of elements used */
static char *histfile; /* Ptr to the history file name */
+/* This is pretty unclear. First of all, separating "flags" vs.
+ "options" (I think the distinction is that "options" take arguments)
+ is nonstandard, and not something we do elsewhere in CVS. Second of
+ all, what does "reports" mean? I think it means that you can only
+ supply one of those options, but "reports" hardly has that meaning in
+ a self-explanatory way. */
static const char *const history_usg[] =
{
"Usage: %s %s [-report] [-flags] [-options args] [files...]\n\n",
@@ -273,7 +292,7 @@ static const char *const history_usg[] =
" -c Committed (Modified) files\n",
" -o Checked out modules\n",
" -m <module> Look for specified module (repeatable)\n",
- " -x [TOFWUCGMAR] Extract by record type\n",
+ " -x [TOEFWUCGMAR] Extract by record type\n",
" Flags:\n",
" -a All users (Default is self)\n",
" -e Everything (same as -x, but all record types)\n",
@@ -367,13 +386,17 @@ history (argc, argv)
char **argv;
{
int i, c;
- char fname[PATH_MAX];
+ char *fname;
if (argc == -1)
usage (history_usg);
+ since_rev = xstrdup ("");
+ since_tag = xstrdup ("");
+ backto = xstrdup ("");
+ rec_types = xstrdup ("");
optind = 1;
- while ((c = getopt (argc, argv, "Tacelow?D:b:f:m:n:p:r:t:u:x:X:z:")) != -1)
+ while ((c = getopt (argc, argv, "+Tacelow?D:b:f:m:n:p:r:t:u:x:X:z:")) != -1)
{
switch (c)
{
@@ -391,7 +414,8 @@ history (argc, argv)
case 'e':
report_count++;
extract++;
- (void) strcpy (rec_types, ALL_REC_TYPES);
+ free (rec_types);
+ rec_types = xstrdup (ALL_REC_TYPES);
break;
case 'l': /* Find Last file record */
last_entry = 1;
@@ -421,13 +445,8 @@ history (argc, argv)
*since_rev = *since_tag = '\0';
since_date = 0;
}
- if (strlen (optarg) >= sizeof (backto))
- {
- error (0, 0, "backto truncated to %d bytes",
- sizeof (backto) - 1);
- optarg[sizeof (backto) - 1] = '\0';
- }
- (void) strcpy (backto, optarg);
+ free (backto);
+ backto = xstrdup (optarg);
break;
case 'f': /* For specified file */
save_file ("", optarg, (char *) NULL);
@@ -448,7 +467,8 @@ history (argc, argv)
*since_tag = *backto = '\0';
since_date = 0;
}
- (void) strcpy (since_rev, optarg);
+ free (since_rev);
+ since_rev = xstrdup (optarg);
break;
case 't': /* Since specified Tag/Rev */
if (since_date || *since_rev || *backto)
@@ -457,7 +477,8 @@ history (argc, argv)
*since_rev = *backto = '\0';
since_date = 0;
}
- (void) strcpy (since_tag, optarg); /* tag */
+ free (since_tag);
+ since_tag = xstrdup (optarg);
break;
case 'u': /* For specified username */
save_user (optarg);
@@ -472,7 +493,8 @@ history (argc, argv)
if (!strchr (ALL_REC_TYPES, *cp))
error (1, 0, "%c is not a valid report type", *cp);
}
- (void) strcpy (rec_types, optarg);
+ free (rec_types);
+ rec_types = xstrdup (optarg);
break;
case 'z':
#ifndef HAVE_RCS5
@@ -564,9 +586,9 @@ history (argc, argv)
send_arg("-m");
for (mod = mod_list; mod < &mod_list[mod_count]; ++mod)
option_with_arg ("-n", *mod);
- if (since_rev != NULL)
+ if (*since_rev)
option_with_arg ("-r", since_rev);
- if (since_tag != NULL)
+ if (*since_tag)
option_with_arg ("-t", since_tag);
for (mod = user_list; mod < &user_list[user_count]; ++mod)
option_with_arg ("-u", *mod);
@@ -588,7 +610,10 @@ history (argc, argv)
if (tag_report)
{
if (!strchr (rec_types, 'T'))
+ {
+ rec_types = xrealloc (rec_types, strlen (rec_types) + 5);
(void) strcat (rec_types, "T");
+ }
}
else if (extract)
{
@@ -597,7 +622,8 @@ history (argc, argv)
}
else if (modified)
{
- (void) strcpy (rec_types, "MAR");
+ free (rec_types);
+ rec_types = xstrdup ("MAR");
/*
* If the user has not specified a date oriented flag ("Since"), sort
* by Repository/file before date. Default is "just" date.
@@ -616,7 +642,8 @@ history (argc, argv)
}
else if (module_report)
{
- (void) strcpy (rec_types, last_entry ? "OMAR" : ALL_REC_TYPES);
+ free (rec_types);
+ rec_types = xstrdup (last_entry ? "OMAR" : ALL_REC_TYPES);
module_sort++;
repos_sort++;
file_sort++;
@@ -625,7 +652,8 @@ history (argc, argv)
else
/* Must be "checkout" or default */
{
- (void) strcpy (rec_types, "OF");
+ free (rec_types);
+ rec_types = xstrdup ("OF");
/* See comments in "modified" above */
if (!last_entry && user_list)
user_sort++;
@@ -639,7 +667,10 @@ history (argc, argv)
/* If we're looking back to a Tag value, must consider "Tag" records */
if (*since_tag && !strchr (rec_types, 'T'))
+ {
+ rec_types = xrealloc (rec_types, strlen (rec_types) + 5);
(void) strcat (rec_types, "T");
+ }
argc -= c;
argv += c;
@@ -647,14 +678,23 @@ history (argc, argv)
save_file ("", argv[i], (char *) NULL);
if (histfile)
- (void) strcpy (fname, histfile);
+ fname = xstrdup (histfile);
else
- (void) sprintf (fname, "%s/%s/%s", CVSroot,
+ {
+ fname = xmalloc (strlen (CVSroot_directory) + sizeof (CVSROOTADM)
+ + sizeof (CVSROOTADM_HISTORY) + 10);
+ (void) sprintf (fname, "%s/%s/%s", CVSroot_directory,
CVSROOTADM, CVSROOTADM_HISTORY);
+ }
read_hrecs (fname);
qsort ((PTR) hrec_head, hrec_count, sizeof (struct hrec), sort_order);
report_hrecs ();
+ free (fname);
+ free (since_rev);
+ free (since_tag);
+ free (backto);
+ free (rec_types);
return (0);
}
@@ -667,7 +707,8 @@ history_write (type, update_dir, revs, name, repository)
char *name;
char *repository;
{
- char fname[PATH_MAX], workdir[PATH_MAX], homedir[PATH_MAX];
+ char *fname;
+ char *workdir;
char *username = getcaller ();
int fd;
char *line;
@@ -678,13 +719,16 @@ history_write (type, update_dir, revs, name, repository)
if (logoff) /* History is turned off by cmd line switch */
return;
- (void) sprintf (fname, "%s/%s/%s", CVSroot, CVSROOTADM, CVSROOTADM_HISTORY);
+ fname = xmalloc (strlen (CVSroot_directory) + sizeof (CVSROOTADM)
+ + sizeof (CVSROOTADM_HISTORY) + 10);
+ (void) sprintf (fname, "%s/%s/%s", CVSroot_directory,
+ CVSROOTADM, CVSROOTADM_HISTORY);
/* turn off history logging if the history file does not exist */
if (!isfile (fname))
{
logoff = 1;
- return;
+ goto out;
}
if (trace)
@@ -695,8 +739,8 @@ history_write (type, update_dir, revs, name, repository)
fprintf (stderr, "-> fopen(%s,a)\n", fname);
#endif
if (noexec)
- return;
- fd = open (fname, O_WRONLY | O_APPEND | O_CREAT | OPEN_BINARY, 0666);
+ goto out;
+ fd = CVS_OPEN (fname, O_WRONLY | O_APPEND | O_CREAT | OPEN_BINARY, 0666);
if (fd < 0)
error (1, errno, "cannot open history file: %s", fname);
@@ -720,13 +764,21 @@ history_write (type, update_dir, revs, name, repository)
else
{
/* Try harder to find a "homedir" */
- if (!getwd (workdir))
- error (1, errno, "can't getwd in history");
- if (chdir (pwdir) < 0)
+ struct saved_cwd cwd;
+ char *homedir;
+
+ if (save_cwd (&cwd))
+ error_exit ();
+
+ if ( CVS_CHDIR (pwdir) < 0)
error (1, errno, "can't chdir(%s)", pwdir);
- if (!getwd (homedir))
+ homedir = xgetwd ();
+ if (homedir == NULL)
error (1, errno, "can't getwd in %s", pwdir);
- (void) chdir (workdir);
+
+ if (restore_cwd (&cwd, NULL))
+ error_exit ();
+ free_cwd (&cwd);
i = strlen (homedir);
if (!strncmp (CurDir, homedir, i))
@@ -734,6 +786,7 @@ history_write (type, update_dir, revs, name, repository)
PrCurDir += i; /* Point to '/' separator */
tilde = "~";
}
+ free (homedir);
}
}
}
@@ -748,6 +801,8 @@ history_write (type, update_dir, revs, name, repository)
else
update_dir = "";
+ workdir = xmalloc (strlen (tilde) + strlen (PrCurDir) + strlen (slash)
+ + strlen (update_dir) + 10);
(void) sprintf (workdir, "%s%s%s%s", tilde, PrCurDir, slash, update_dir);
/*
@@ -821,6 +876,9 @@ history_write (type, update_dir, revs, name, repository)
free (line);
if (close (fd) != 0)
error (1, errno, "cannot close history file: %s", fname);
+ free (workdir);
+ out:
+ free (fname);
}
/*
@@ -968,7 +1026,7 @@ fill_hrec (line, hr)
NEXT_BAR (repos);
NEXT_BAR (rev);
hr->idx = idx++;
- if (strchr ("FOT", *(hr->type)))
+ if (strchr ("FOET", *(hr->type)))
hr->mod = line;
NEXT_BAR (file); /* This returns ptr to next line or final '\0' */
@@ -994,7 +1052,7 @@ read_hrecs (fname)
struct hrec *hr;
struct stat st_buf;
- if ((fd = open (fname, O_RDONLY | OPEN_BINARY)) < 0)
+ if ((fd = CVS_OPEN (fname, O_RDONLY | OPEN_BINARY)) < 0)
error (1, errno, "cannot open history file: %s", fname);
if (fstat (fd, &st_buf) < 0)
@@ -1134,9 +1192,19 @@ select_hrec (hr)
{
Vers_TS *vers;
time_t t;
-
- vers = Version_TS (hr->repos, (char *) NULL, since_rev, (char *) NULL,
- hr->file, 1, 0, (List *) NULL, (RCSNode *) NULL);
+ struct file_info finfo;
+
+ memset (&finfo, 0, sizeof finfo);
+ finfo.file = hr->file;
+ /* Not used, so don't worry about it. */
+ finfo.update_dir = NULL;
+ finfo.fullname = finfo.file;
+ finfo.repository = hr->repos;
+ finfo.entries = NULL;
+ finfo.rcs = NULL;
+
+ vers = Version_TS (&finfo, (char *) NULL, since_rev, (char *) NULL,
+ 1, 0);
if (vers->vn_rcs)
{
if ((t = RCS_getrevtime (vers->srcfile, vers->vn_rcs, (char *) 0, 0))
@@ -1208,7 +1276,7 @@ select_hrec (hr)
*/
if (!strchr (rec_types, *(hr->type)))
return (0);
- if (!strchr ("TFO", *(hr->type))) /* Don't bother with "file" if "TFO" */
+ if (!strchr ("TFOE", *(hr->type))) /* Don't bother with "file" if "TFOE" */
{
if (file_list) /* If file_list is null, accept all */
{
@@ -1220,7 +1288,7 @@ select_hrec (hr)
* the concatenation of the repository and file from hrec.
* 3. Else compare the file_list entry against the hrec file.
*/
- char cmpfile[PATH_MAX];
+ char *cmpfile = NULL;
if (*(cp = fl->l_file) == '*')
{
@@ -1236,8 +1304,12 @@ select_hrec (hr)
{
if (strchr (cp, '/'))
{
- (void) sprintf (cp2 = cmpfile, "%s/%s",
+ cmpfile = xmalloc (strlen (hr->repos)
+ + strlen (hr->file)
+ + 10);
+ (void) sprintf (cmpfile, "%s/%s",
hr->repos, hr->file);
+ cp2 = cmpfile;
}
else
{
@@ -1250,6 +1322,8 @@ select_hrec (hr)
hr->mod = fl->l_module;
break;
}
+ if (cmpfile != NULL)
+ free (cmpfile);
}
}
if (!count)
@@ -1308,7 +1382,7 @@ report_hrecs ()
hr++;
for (count = hrec_count; count--; lr = hr, hr++)
{
- char repos[PATH_MAX];
+ char *repos;
if (!count)
hr = NULL;
@@ -1316,7 +1390,7 @@ report_hrecs ()
continue;
ty = *(lr->type);
- (void) strcpy (repos, lr->repos);
+ repos = xstrdup (lr->repos);
if ((cp = strrchr (repos, '/')) != NULL)
{
if (lr->mod && !strcmp (++cp, lr->mod))
@@ -1334,6 +1408,7 @@ report_hrecs ()
rev_len = i;
if (lr->mod && (i = strlen (lr->mod)) > mod_len)
mod_len = i;
+ free (repos);
}
/* Walk through hrec array setting "lr" (Last Record) to each element.
@@ -1347,7 +1422,8 @@ report_hrecs ()
*/
for (lr = hrec_head, hr = (lr + 1); hrec_count--; lr = hr, hr++)
{
- char workdir[PATH_MAX], repos[PATH_MAX];
+ char *workdir;
+ char *repos;
if (!hrec_count)
hr = NULL;
@@ -1368,6 +1444,7 @@ report_hrecs ()
tm->tm_mday, tm->tm_hour, tm->tm_min, tz_name,
user_len, lr->user);
+ workdir = xmalloc (strlen (lr->dir) + strlen (lr->end) + 10);
(void) sprintf (workdir, "%s%s", lr->dir, lr->end);
if ((cp = strrchr (workdir, '/')) != NULL)
{
@@ -1376,6 +1453,7 @@ report_hrecs ()
(void) strcpy (cp, "*");
}
}
+ repos = xmalloc (strlen (lr->repos) + 10);
(void) strcpy (repos, lr->repos);
if ((cp = strrchr (repos, '/')) != NULL)
{
@@ -1395,11 +1473,13 @@ report_hrecs ()
(void) printf (" {%s}", workdir);
break;
case 'F':
+ case 'E':
case 'O':
if (lr->rev && *(lr->rev))
(void) printf (" [%s]", lr->rev);
(void) printf (" %-*s =%s%-*s %s", repos_len, repos, lr->mod,
- mod_len + 1 - strlen (lr->mod), "=", workdir);
+ mod_len + 1 - (int) strlen (lr->mod),
+ "=", workdir);
break;
case 'W':
case 'U':
@@ -1417,6 +1497,8 @@ report_hrecs ()
break;
}
(void) putchar ('\n');
+ free (workdir);
+ free (repos);
}
}
diff --git a/contrib/cvs/src/ignore.c b/contrib/cvs/src/ignore.c
index 25c2269..05e2f1f 100644
--- a/contrib/cvs/src/ignore.c
+++ b/contrib/cvs/src/ignore.c
@@ -1,8 +1,19 @@
+/* This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details. */
+
/*
* .cvsignore file support contributed by David G. Grubbs <dgg@odi.com>
*/
#include "cvs.h"
+#include "getline.h"
/*
* Ignore file section.
@@ -19,7 +30,7 @@ static int ign_count; /* Number of active entries */
static int s_ign_count = 0;
static int ign_size; /* This many slots available (plus
* one for a NULL) */
-static int ign_hold; /* Index where first "temporary" item
+static int ign_hold = -1; /* Index where first "temporary" item
* is held */
const char *ign_default = ". .. core RCSLOG tags TAGS RCS SCCS .make.state\
@@ -42,8 +53,7 @@ int ign_inhibit_server;
void
ign_setup ()
{
- struct passwd *pw;
- char file[PATH_MAX];
+ char *home_dir;
char *tmp;
ign_inhibit_server = 0;
@@ -61,17 +71,23 @@ ign_setup ()
if (!client_active)
#endif
{
+ char *file = xmalloc (strlen (CVSroot_directory) + sizeof (CVSROOTADM)
+ + sizeof (CVSROOTADM_IGNORE) + 10);
/* Then add entries found in repository, if it exists */
- (void) sprintf (file, "%s/%s/%s", CVSroot, CVSROOTADM,
- CVSROOTADM_IGNORE);
+ (void) sprintf (file, "%s/%s/%s", CVSroot_directory,
+ CVSROOTADM, CVSROOTADM_IGNORE);
ign_add_file (file, 0);
+ free (file);
}
/* Then add entries found in home dir, (if user has one) and file exists */
- if ((pw = (struct passwd *) getpwuid (getuid ())) && pw->pw_dir)
+ home_dir = get_homedir ();
+ if (home_dir)
{
- (void) sprintf (file, "%s/%s", pw->pw_dir, CVSDOTIGNORE);
+ char *file = xmalloc (strlen (home_dir) + sizeof (CVSDOTIGNORE) + 10);
+ (void) sprintf (file, "%s/%s", home_dir, CVSDOTIGNORE);
ign_add_file (file, 0);
+ free (file);
}
/* Then add entries found in CVSIGNORE environment variable. */
@@ -91,7 +107,8 @@ ign_add_file (file, hold)
int hold;
{
FILE *fp;
- char line[1024];
+ char *line = NULL;
+ size_t line_allocated = 0;
/* restore the saved list (if any) */
if (s_ign_list != NULL)
@@ -112,7 +129,7 @@ ign_add_file (file, hold)
if (hold)
{
/* re-set if we had already done a temporary file */
- if (ign_hold)
+ if (ign_hold >= 0)
{
int i;
@@ -128,17 +145,20 @@ ign_add_file (file, hold)
}
/* load the file */
- fp = fopen (file, "r");
+ fp = CVS_FOPEN (file, "r");
if (fp == NULL)
{
if (! existence_error (errno))
error (0, errno, "cannot open %s", file);
return;
}
- while (fgets (line, sizeof (line), fp))
+ while (getline (&line, &line_allocated, fp) >= 0)
ign_add (line, hold);
+ if (ferror (fp))
+ error (0, errno, "cannot read %s", file);
if (fclose (fp) < 0)
error (0, errno, "cannot close %s", file);
+ free (line);
}
/* Parse a line of space-separated wildcards and add them to the list. */
@@ -188,11 +208,11 @@ ign_add (ign, hold)
/* temporarily reset the ignore list */
int i;
- if (ign_hold)
+ if (ign_hold >= 0)
{
for (i = ign_hold; i < ign_count; i++)
free (ign_list[i]);
- ign_hold = 0;
+ ign_hold = -1;
}
s_ign_list = (char **) xmalloc (ign_count * sizeof (char *));
for (i = 0; i < ign_count; i++)
@@ -230,8 +250,9 @@ ign_add (ign, hold)
}
}
-/* Set to 1 if ignore file patterns should be matched in a case-insensitive
- fashion. */
+/* Set to 1 if filenames should be matched in a case-insensitive
+ fashion. Note that, contrary to the name and placement in ignore.c,
+ this is no longer just for ignore patterns. */
int ign_case;
/* Return 1 if the given filename should be ignored by update or import. */
@@ -327,29 +348,45 @@ int ignore_directory (name)
}
/*
- * Process the current directory, looking for files not in ILIST and not on
- * the global ignore list for this directory. If we find one, call PROC
- * passing it the name of the file and the update dir.
+ * Process the current directory, looking for files not in ILIST and
+ * not on the global ignore list for this directory. If we find one,
+ * call PROC passing it the name of the file and the update dir.
+ * ENTRIES is the entries list, which is used to identify known
+ * directories. ENTRIES may be NULL, in which case we assume that any
+ * directory with a CVS administration directory is known.
*/
void
-ignore_files (ilist, update_dir, proc)
+ignore_files (ilist, entries, update_dir, proc)
List *ilist;
+ List *entries;
char *update_dir;
Ignore_proc proc;
{
+ int subdirs;
DIR *dirp;
struct dirent *dp;
struct stat sb;
char *file;
char *xdir;
+ /* Set SUBDIRS if we have subdirectory information in ENTRIES. */
+ if (entries == NULL)
+ subdirs = 0;
+ else
+ {
+ struct stickydirtag *sdtp;
+
+ sdtp = (struct stickydirtag *) entries->list->data;
+ subdirs = sdtp == NULL || sdtp->subdirs;
+ }
+
/* we get called with update_dir set to "." sometimes... strip it */
if (strcmp (update_dir, ".") == 0)
xdir = "";
else
xdir = update_dir;
- dirp = opendir (".");
+ dirp = CVS_OPENDIR (".");
if (dirp == NULL)
return;
@@ -363,6 +400,34 @@ ignore_files (ilist, update_dir, proc)
continue;
if (findnode_fn (ilist, file) != NULL)
continue;
+ if (subdirs)
+ {
+ Node *node;
+
+ node = findnode_fn (entries, file);
+ if (node != NULL
+ && ((Entnode *) node->data)->type == ENT_SUBDIR)
+ {
+ char *p;
+ int dir;
+
+ /* For consistency with past behaviour, we only ignore
+ this directory if there is a CVS subdirectory.
+ This will normally be the case, but the user may
+ have messed up the working directory somehow. */
+ p = xmalloc (strlen (file) + sizeof CVSADM + 10);
+ sprintf (p, "%s/%s", file, CVSADM);
+ dir = isdir (p);
+ free (p);
+ if (dir)
+ continue;
+ }
+ }
+
+ /* We could be ignoring FIFOs and other files which are neither
+ regular files nor directories here. */
+ if (ign_name (file))
+ continue;
if (
#ifdef DT_DIR
@@ -377,11 +442,19 @@ ignore_files (ilist, update_dir, proc)
#endif
S_ISDIR(sb.st_mode))
{
- char temp[PATH_MAX];
-
- (void) sprintf (temp, "%s/%s", file, CVSADM);
- if (isdir (temp))
- continue;
+ if (! subdirs)
+ {
+ char *temp;
+
+ temp = xmalloc (strlen (file) + sizeof (CVSADM) + 10);
+ (void) sprintf (temp, "%s/%s", file, CVSADM);
+ if (isdir (temp))
+ {
+ free (temp);
+ continue;
+ }
+ free (temp);
+ }
}
#ifdef S_ISLNK
else if (
@@ -395,10 +468,6 @@ ignore_files (ilist, update_dir, proc)
#endif
}
- /* We could be ignoring FIFOs and other files which are neither
- regular files nor directories here. */
- if (ign_name (file))
- continue;
(*proc) (file, xdir);
}
(void) closedir (dirp);
diff --git a/contrib/cvs/src/import.c b/contrib/cvs/src/import.c
index 98c1635..a37bd4d 100644
--- a/contrib/cvs/src/import.c
+++ b/contrib/cvs/src/import.c
@@ -25,8 +25,9 @@ static char *get_comment PROTO((char *user));
static int add_rcs_file PROTO((char *message, char *rcs, char *user, char *vtag,
int targc, char *targv[]));
static int expand_at_signs PROTO((char *buf, off_t size, FILE *fp));
-static int add_rev PROTO((char *message, char *rcs, char *vfile, char *vers));
-static int add_tags PROTO((char *rcs, char *vfile, char *vtag, int targc,
+static int add_rev PROTO((char *message, RCSNode *rcs, char *vfile,
+ char *vers));
+static int add_tags PROTO((RCSNode *rcs, char *vfile, char *vtag, int targc,
char *targv[]));
static int import_descend PROTO((char *message, char *vtag, int targc, char *targv[]));
static int import_descend_dir PROTO((char *message, char *dir, char *vtag,
@@ -38,10 +39,10 @@ static int update_rcs_file PROTO((char *message, char *vfile, char *vtag, int ta
static void add_log PROTO((int ch, char *fname));
static int repos_len;
-static char vhead[50];
-static char vbranch[50];
+static char *vhead;
+static char *vbranch;
static FILE *logfp;
-static char repository[PATH_MAX];
+static char *repository;
static int conflicts;
static int use_file_modtime;
static char *keyword_opt = NULL;
@@ -65,11 +66,12 @@ import (argc, argv)
char **argv;
{
char *message = NULL;
- char tmpfile[L_tmpnam+1];
+ char *tmpfile;
char *cp;
int i, c, msglen, err;
List *ulist;
Node *p;
+ struct logfile_info *li;
if (argc == -1)
usage (import_usage);
@@ -77,9 +79,9 @@ import (argc, argv)
ign_setup ();
wrap_setup ();
- (void) strcpy (vbranch, CVSBRANCH);
+ vbranch = xstrdup (CVSBRANCH);
optind = 1;
- while ((c = getopt (argc, argv, "Qqdb:m:I:k:W:")) != -1)
+ while ((c = getopt (argc, argv, "+Qqdb:m:I:k:W:")) != -1)
{
switch (c)
{
@@ -98,7 +100,8 @@ import (argc, argv)
use_file_modtime = 1;
break;
case 'b':
- (void) strcpy (vbranch, optarg);
+ free (vbranch);
+ vbranch = xstrdup (optarg);
break;
case 'm':
#ifdef FORCE_USE_EDITOR
@@ -115,7 +118,7 @@ import (argc, argv)
/* RCS_check_kflag returns strings of the form -kxx. We
only use it for validation, so we can free the value
as soon as it is returned. */
- free (RCS_check_kflag(optarg));
+ free (RCS_check_kflag (optarg));
keyword_opt = optarg;
break;
case 'W':
@@ -133,22 +136,32 @@ import (argc, argv)
usage (import_usage);
for (i = 1; i < argc; i++) /* check the tags for validity */
+ {
+ int j;
+
RCS_check_tag (argv[i]);
+ for (j = 1; j < i; j++)
+ if (strcmp (argv[j], argv[i]) == 0)
+ error (1, 0, "tag `%s' was specified more than once", argv[i]);
+ }
/* XXX - this should be a module, not just a pathname */
if (! isabsolute (argv[0]))
{
- if (CVSroot == NULL)
+ if (CVSroot_directory == NULL)
{
error (0, 0, "missing CVSROOT environment variable\n");
error (1, 0, "Set it or specify the '-d' option to %s.",
program_name);
}
- (void) sprintf (repository, "%s/%s", CVSroot, argv[0]);
- repos_len = strlen (CVSroot);
+ repository = xmalloc (strlen (CVSroot_directory) + strlen (argv[0])
+ + 10);
+ (void) sprintf (repository, "%s/%s", CVSroot_directory, argv[0]);
+ repos_len = strlen (CVSroot_directory);
}
else
{
+ repository = xmalloc (strlen (argv[0]) + 5);
(void) strcpy (repository, argv[0]);
repos_len = 0;
}
@@ -164,16 +177,15 @@ import (argc, argv)
error (1, 0, "%s is not a numeric branch", vbranch);
if (numdots (vbranch) != 2)
error (1, 0, "Only branches with two dots are supported: %s", vbranch);
- (void) strcpy (vhead, vbranch);
+ vhead = xstrdup (vbranch);
cp = strrchr (vhead, '.');
*cp = '\0';
#ifdef CLIENT_SUPPORT
if (client_active)
{
- /* Do this now; don't ask for a log message if we can't talk to the
- server. But if there is a syntax error in the options, give
- an error message without connecting. */
+ /* For rationale behind calling start_server before do_editor, see
+ commit.c */
start_server ();
}
#endif
@@ -181,9 +193,9 @@ import (argc, argv)
if (use_editor)
{
do_editor ((char *) NULL, &message, repository,
- (List *) NULL);
+ (List *) NULL);
}
-
+ do_verify (message, repository);
msglen = message == NULL ? 0 : strlen (message);
if (msglen == 0 || message[msglen - 1] != '\n')
{
@@ -219,6 +231,7 @@ import (argc, argv)
send_arg ("-I");
send_arg ("!");
}
+ wrap_send ();
{
int i;
@@ -244,9 +257,10 @@ import (argc, argv)
make_directories (repository);
/* Create the logfile that will be logged upon completion */
- if ((logfp = fopen (tmpnam (tmpfile), "w+")) == NULL)
+ tmpfile = cvs_temp_name ();
+ if ((logfp = CVS_FOPEN (tmpfile, "w+")) == NULL)
error (1, errno, "cannot create temporary file `%s'", tmpfile);
- (void) unlink (tmpfile); /* to be sure it goes away */
+ (void) CVS_UNLINK (tmpfile); /* to be sure it goes away */
(void) fprintf (logfp, "\nVendor Tag:\t%s\n", argv[1]);
(void) fprintf (logfp, "Release Tags:\t");
for (i = 2; i < argc; i++)
@@ -298,18 +312,26 @@ import (argc, argv)
p->type = UPDATE;
p->delproc = update_delproc;
p->key = xstrdup ("- Imported sources");
- p->data = (char *) T_TITLE;
+ li = (struct logfile_info *) xmalloc (sizeof (struct logfile_info));
+ li->type = T_TITLE;
+ li->tag = xstrdup (vbranch);
+ li->rev_old = li->rev_new = NULL;
+ p->data = (char *) li;
(void) addnode (ulist, p);
- Update_Logfile (repository, message, vbranch, logfp, ulist);
+ Update_Logfile (repository, message, logfp, ulist);
dellist (&ulist);
(void) fclose (logfp);
/* Make sure the temporary file goes away, even on systems that don't let
you delete a file that's in use. */
- unlink (tmpfile);
+ CVS_UNLINK (tmpfile);
+ free (tmpfile);
if (message)
free (message);
+ free (repository);
+ free (vbranch);
+ free (vhead);
return (err);
}
@@ -333,7 +355,7 @@ import_descend (message, vtag, targc, targv)
ign_add_file (CVSDOTIGNORE, 1);
wrap_add_file (CVSDOTWRAPPER, 1);
- if ((dirp = opendir (".")) == NULL)
+ if ((dirp = CVS_OPENDIR (".")) == NULL)
{
err++;
}
@@ -365,7 +387,7 @@ import_descend (message, vtag, targc, targv)
#endif
&& !wrap_name_has (dp->d_name, WRAP_TOCVS)
)
- {
+ {
Node *n;
if (dirlist == NULL)
@@ -377,7 +399,7 @@ import_descend (message, vtag, targc, targv)
}
else if (
#ifdef DT_DIR
- dp->d_type == DT_LNK || dp->d_type == DT_UNKNOWN &&
+ dp->d_type == DT_LNK || dp->d_type == DT_UNKNOWN &&
#endif
islink (dp->d_name))
{
@@ -389,8 +411,10 @@ import_descend (message, vtag, targc, targv)
#ifdef CLIENT_SUPPORT
if (client_active)
err += client_process_import_file (message, dp->d_name,
- vtag, targc, targv,
- repository);
+ vtag, targc, targv,
+ repository,
+ keyword_opt != NULL &&
+ keyword_opt[0] == 'b');
else
#endif
err += process_import_file (message, dp->d_name,
@@ -400,7 +424,7 @@ import_descend (message, vtag, targc, targv)
(void) closedir (dirp);
}
- if (dirlist != NULL)
+ if (dirlist != NULL)
{
Node *head, *p;
@@ -427,28 +451,39 @@ process_import_file (message, vfile, vtag, targc, targv)
int targc;
char *targv[];
{
- char attic_name[PATH_MAX];
- char rcs[PATH_MAX];
+ char *rcs;
int inattic = 0;
+ rcs = xmalloc (strlen (repository) + strlen (vfile) + sizeof (RCSEXT)
+ + 5);
(void) sprintf (rcs, "%s/%s%s", repository, vfile, RCSEXT);
if (!isfile (rcs))
{
+ char *attic_name;
+
+ attic_name = xmalloc (strlen (repository) + strlen (vfile) +
+ sizeof (CVSATTIC) + sizeof (RCSEXT) + 10);
(void) sprintf (attic_name, "%s/%s/%s%s", repository, CVSATTIC,
vfile, RCSEXT);
if (!isfile (attic_name))
{
+ int retval;
+ free (attic_name);
/*
* A new import source file; it doesn't exist as a ,v within the
* repository nor in the Attic -- create it anew.
*/
add_log ('N', vfile);
- return (add_rcs_file (message, rcs, vfile, vtag, targc, targv));
+ retval = add_rcs_file (message, rcs, vfile, vtag, targc, targv);
+ free (rcs);
+ return retval;
}
+ free (attic_name);
inattic = 1;
}
+ free (rcs);
/*
* an rcs file exists. have to do things the official, slow, way.
*/
@@ -470,24 +505,23 @@ update_rcs_file (message, vfile, vtag, targc, targv, inattic)
{
Vers_TS *vers;
int letter;
- int ierrno;
- char *tmpdir;
char *tocvsPath;
-
- vers = Version_TS (repository, (char *) NULL, vbranch, (char *) NULL, vfile,
- 1, 0, (List *) NULL, (RCSNode *) NULL);
+ struct file_info finfo;
+
+ memset (&finfo, 0, sizeof finfo);
+ finfo.file = vfile;
+ /* Not used, so don't worry about it. */
+ finfo.update_dir = NULL;
+ finfo.fullname = finfo.file;
+ finfo.repository = repository;
+ finfo.entries = NULL;
+ finfo.rcs = NULL;
+ vers = Version_TS (&finfo, (char *) NULL, vbranch, (char *) NULL,
+ 1, 0);
if (vers->vn_rcs != NULL
&& !RCS_isdead(vers->srcfile, vers->vn_rcs))
{
- char xtmpfile[PATH_MAX];
int different;
- int retcode = 0;
-
- tmpdir = getenv ("TMPDIR");
- if (tmpdir == NULL || tmpdir[0] == '\0')
- tmpdir = "/tmp";
-
- (void) sprintf (xtmpfile, "%s/cvs-imp%ld", tmpdir, (long) getpid());
/*
* The rcs file does have a revision on the vendor branch. Compare
@@ -498,35 +532,14 @@ update_rcs_file (message, vfile, vtag, targc, targv, inattic)
* This is to try to cut down the number of "C" conflict messages for
* locally modified import source files.
*/
- /* Why is RCS_FLAGS_FORCE here? I wouldn't think that it would have any
- effect in conjunction with passing NULL for workfile (i.e. to stdout). */
- retcode = RCS_checkout (vers->srcfile->path, NULL, vers->vn_rcs,
-#ifdef HAVE_RCS5
- "-ko",
-#else
- NULL,
-#endif
- xtmpfile, RCS_FLAGS_FORCE, 0);
- if (retcode != 0)
- {
- ierrno = errno;
- fperror (logfp, 0, retcode == -1 ? ierrno : 0,
- "ERROR: cannot co revision %s of file %s", vers->vn_rcs,
- vers->srcfile->path);
- error (0, retcode == -1 ? ierrno : 0,
- "ERROR: cannot co revision %s of file %s", vers->vn_rcs,
- vers->srcfile->path);
- (void) unlink_file (xtmpfile);
- return (1);
- }
-
tocvsPath = wrap_tocvs_process_file (vfile);
- different = xcmp (xtmpfile, vfile);
+ /* FIXME: Why don't we pass tocvsPath to RCS_cmp_file if it is
+ not NULL? */
+ different = RCS_cmp_file (vers->srcfile, vers->vn_rcs, "-ko", vfile);
if (tocvsPath)
if (unlink_file_dir (tocvsPath) < 0)
error (0, errno, "cannot remove %s", tocvsPath);
- (void) unlink_file (xtmpfile);
if (!different)
{
int retval = 0;
@@ -536,7 +549,7 @@ update_rcs_file (message, vfile, vtag, targc, targv, inattic)
* "U", signifying that the file has changed, but needs no
* attention, and we're done.
*/
- if (add_tags (vers->srcfile->path, vfile, vtag, targc, targv))
+ if (add_tags (vers->srcfile, vfile, vtag, targc, targv))
retval = 1;
add_log ('U', vfile);
freevers_ts (&vers);
@@ -546,8 +559,8 @@ update_rcs_file (message, vfile, vtag, targc, targv, inattic)
/* We may have failed to parse the RCS file; check just in case */
if (vers->srcfile == NULL ||
- add_rev (message, vers->srcfile->path, vfile, vers->vn_rcs) ||
- add_tags (vers->srcfile->path, vfile, vtag, targc, targv))
+ add_rev (message, vers->srcfile, vfile, vers->vn_rcs) ||
+ add_tags (vers->srcfile, vfile, vtag, targc, targv))
{
freevers_ts (&vers);
return (1);
@@ -573,7 +586,7 @@ update_rcs_file (message, vfile, vtag, targc, targv, inattic)
static int
add_rev (message, rcs, vfile, vers)
char *message;
- char *rcs;
+ RCSNode *rcs;
char *vfile;
char *vers;
{
@@ -619,11 +632,10 @@ add_rev (message, rcs, vfile, vers)
}
}
- status = RCS_checkin (rcs, tocvsPath == NULL ? vfile : tocvsPath,
+ status = RCS_checkin (rcs->path, tocvsPath == NULL ? vfile : tocvsPath,
message, vbranch,
(RCS_FLAGS_QUIET
- | (use_file_modtime ? RCS_FLAGS_MODTIME : 0)),
- 0);
+ | (use_file_modtime ? RCS_FLAGS_MODTIME : 0)));
ierrno = errno;
if (tocvsPath == NULL)
@@ -636,8 +648,10 @@ add_rev (message, rcs, vfile, vers)
{
if (!noexec)
{
- fperror (logfp, 0, status == -1 ? ierrno : 0, "ERROR: Check-in of %s failed", rcs);
- error (0, status == -1 ? ierrno : 0, "ERROR: Check-in of %s failed", rcs);
+ fperror (logfp, 0, status == -1 ? ierrno : 0,
+ "ERROR: Check-in of %s failed", rcs->path);
+ error (0, status == -1 ? ierrno : 0,
+ "ERROR: Check-in of %s failed", rcs->path);
}
if (locked)
{
@@ -656,7 +670,7 @@ add_rev (message, rcs, vfile, vers)
*/
static int
add_tags (rcs, vfile, vtag, targc, targv)
- char *rcs;
+ RCSNode *rcs;
char *vfile;
char *vtag;
int targc;
@@ -665,6 +679,7 @@ add_tags (rcs, vfile, vtag, targc, targv)
int i, ierrno;
Vers_TS *vers;
int retcode = 0;
+ struct file_info finfo;
if (noexec)
return (0);
@@ -672,23 +687,33 @@ add_tags (rcs, vfile, vtag, targc, targv)
if ((retcode = RCS_settag(rcs, vtag, vbranch)) != 0)
{
ierrno = errno;
- fperror (logfp, 0, retcode == -1 ? ierrno : 0,
- "ERROR: Failed to set tag %s in %s", vtag, rcs);
+ fperror (logfp, 0, retcode == -1 ? ierrno : 0,
+ "ERROR: Failed to set tag %s in %s", vtag, rcs->path);
error (0, retcode == -1 ? ierrno : 0,
- "ERROR: Failed to set tag %s in %s", vtag, rcs);
+ "ERROR: Failed to set tag %s in %s", vtag, rcs->path);
return (1);
}
- vers = Version_TS (repository, (char *) NULL, vtag, (char *) NULL, vfile,
- 1, 0, (List *) NULL, (RCSNode *) NULL);
+
+ memset (&finfo, 0, sizeof finfo);
+ finfo.file = vfile;
+ /* Not used, so don't worry about it. */
+ finfo.update_dir = NULL;
+ finfo.fullname = finfo.file;
+ finfo.repository = repository;
+ finfo.entries = NULL;
+ finfo.rcs = NULL;
+ vers = Version_TS (&finfo, NULL, vtag, NULL, 1, 0);
for (i = 0; i < targc; i++)
{
if ((retcode = RCS_settag (rcs, targv[i], vers->vn_rcs)) != 0)
{
ierrno = errno;
- fperror (logfp, 0, retcode == -1 ? ierrno : 0,
- "WARNING: Couldn't add tag %s to %s", targv[i], rcs);
+ fperror (logfp, 0, retcode == -1 ? ierrno : 0,
+ "WARNING: Couldn't add tag %s to %s", targv[i],
+ rcs->path);
error (0, retcode == -1 ? ierrno : 0,
- "WARNING: Couldn't add tag %s to %s", targv[i], rcs);
+ "WARNING: Couldn't add tag %s to %s", targv[i],
+ rcs->path);
}
}
freevers_ts (&vers);
@@ -712,6 +737,10 @@ static const struct compair comtable[] =
* table is used to guess the proper comment leader from the working file's
* suffix during initial ci (see InitAdmin()). Comment leaders are needed for
* languages without multiline comments; for others they are optional.
+ *
+ * I believe that the comment leader is unused if you are using RCS 5.7, which
+ * decides what leader to use based on the text surrounding the $Log keyword
+ * rather than a specified comment leader.
*/
{"a", "-- "}, /* Ada */
{"ada", "-- "},
@@ -806,9 +835,11 @@ get_comment (user)
char *user;
{
char *cp, *suffix;
- char suffix_path[PATH_MAX];
+ char *suffix_path;
int i;
+ char *retval;
+ suffix_path = xmalloc (strlen (user) + 5);
cp = strrchr (user, '.');
if (cp != NULL)
{
@@ -828,11 +859,21 @@ get_comment (user)
suffix = ""; /* will use the default */
for (i = 0;; i++)
{
- if (comtable[i].suffix == NULL) /* default */
- return (comtable[i].comlead);
+ if (comtable[i].suffix == NULL)
+ {
+ /* Default. Note we'll always hit this case before we
+ ever return NULL. */
+ retval = comtable[i].comlead;
+ break;
+ }
if (strcmp (suffix, comtable[i].suffix) == 0)
- return (comtable[i].comlead);
+ {
+ retval = comtable[i].comlead;
+ break;
+ }
}
+ free (suffix_path);
+ return retval;
}
static int
@@ -848,26 +889,32 @@ add_rcs_file (message, rcs, user, vtag, targc, targv)
struct stat sb;
struct tm *ftm;
time_t now;
- char altdate1[50];
+ char altdate1[MAXDATELEN];
#ifndef HAVE_RCS5
- char altdate2[50];
+ char altdate2[MAXDATELEN];
#endif
char *author;
int i, ierrno, err = 0;
mode_t mode;
char *tocvsPath;
char *userfile;
+ char *local_opt = keyword_opt;
+ char *free_opt = NULL;
if (noexec)
return (0);
- /* FIXME? We always import files as text files (note that means
- that files get stored with straight linefeeds). There isn't an
- obvious, clean, way to let people specify which files are binary.
- Maybe based on the file name.... */
+ if (local_opt == NULL)
+ {
+ if (wrap_name_has (user, WRAP_RCSOPTION))
+ {
+ local_opt = free_opt = wrap_rcsoption (user, 0);
+ }
+ }
+
tocvsPath = wrap_tocvs_process_file (user);
userfile = (tocvsPath == NULL ? user : tocvsPath);
- fpuser = fopen (userfile, "r");
+ fpuser = CVS_FOPEN (userfile, "r");
if (fpuser == NULL)
{
/* not fatal, continue import */
@@ -875,7 +922,7 @@ add_rcs_file (message, rcs, user, vtag, targc, targv)
error (0, errno, "ERROR: cannot read file %s", userfile);
goto read_error;
}
- fprcs = fopen (rcs, "w+b");
+ fprcs = CVS_FOPEN (rcs, "w+b");
if (fprcs == NULL)
{
ierrno = errno;
@@ -905,11 +952,13 @@ add_rcs_file (message, rcs, user, vtag, targc, targv)
goto write_error;
}
- if (keyword_opt != NULL)
- if (fprintf (fprcs, "expand @%s@;\012", keyword_opt) < 0)
+ if (local_opt != NULL)
+ {
+ if (fprintf (fprcs, "expand @%s@;\012", local_opt) < 0)
{
- goto write_error;
+ goto write_error;
}
+ }
if (fprintf (fprcs, "\012") < 0)
goto write_error;
@@ -976,7 +1025,7 @@ add_rcs_file (message, rcs, user, vtag, targc, targv)
/* Now copy over the contents of the file, expanding at signs. */
{
- unsigned char buf[8192];
+ char buf[8192];
unsigned int len;
while (1)
@@ -1030,6 +1079,8 @@ add_rcs_file (message, rcs, user, vtag, targc, targv)
if (tocvsPath)
if (unlink_file_dir (tocvsPath) < 0)
error (0, errno, "cannot remove %s", tocvsPath);
+ if (free_opt != NULL)
+ free (free_opt);
return (err);
write_error:
@@ -1041,7 +1092,7 @@ write_error_noclose:
error (0, ierrno, "ERROR: cannot write file %s", rcs);
if (ierrno == ENOSPC)
{
- (void) unlink (rcs);
+ (void) CVS_UNLINK (rcs);
fperror (logfp, 0, 0, "ERROR: out of space - aborting");
error (1, 0, "ERROR: out of space - aborting");
}
@@ -1050,6 +1101,9 @@ read_error:
if (unlink_file_dir (tocvsPath) < 0)
error (0, errno, "cannot remove %s", tocvsPath);
+ if (free_opt != NULL)
+ free (free_opt);
+
return (err + 1);
}
@@ -1135,6 +1189,7 @@ import_descend_dir (message, dir, vtag, targc, targv)
struct saved_cwd cwd;
char *cp;
int ierrno, err;
+ char *rcs = NULL;
if (islink (dir))
return (0);
@@ -1143,13 +1198,24 @@ import_descend_dir (message, dir, vtag, targc, targv)
fperror (logfp, 0, 0, "ERROR: cannot get working directory");
return (1);
}
+
+ /* Concatenate DIR to the end of REPOSITORY. */
if (repository[0] == '\0')
- (void) strcpy (repository, dir);
+ {
+ char *new = xstrdup (dir);
+ free (repository);
+ repository = new;
+ }
else
{
- (void) strcat (repository, "/");
- (void) strcat (repository, dir);
+ char *new = xmalloc (strlen (repository) + strlen (dir) + 10);
+ strcpy (new, repository);
+ (void) strcat (new, "/");
+ (void) strcat (new, dir);
+ free (repository);
+ repository = new;
}
+
#ifdef CLIENT_SUPPORT
if (!quiet && !client_active)
#else
@@ -1157,7 +1223,7 @@ import_descend_dir (message, dir, vtag, targc, targv)
#endif
error (0, 0, "Importing %s", repository);
- if (chdir (dir) < 0)
+ if ( CVS_CHDIR (dir) < 0)
{
ierrno = errno;
fperror (logfp, 0, ierrno, "ERROR: cannot chdir to %s", repository);
@@ -1171,12 +1237,12 @@ import_descend_dir (message, dir, vtag, targc, targv)
if (!isdir (repository))
#endif
{
- char rcs[PATH_MAX];
-
+ rcs = xmalloc (strlen (repository) + sizeof (RCSEXT) + 5);
(void) sprintf (rcs, "%s%s", repository, RCSEXT);
if (isfile (repository) || isfile(rcs))
{
- fperror (logfp, 0, 0, "ERROR: %s is a file, should be a directory!",
+ fperror (logfp, 0, 0,
+ "ERROR: %s is a file, should be a directory!",
repository);
error (0, 0, "ERROR: %s is a file, should be a directory!",
repository);
@@ -1196,12 +1262,14 @@ import_descend_dir (message, dir, vtag, targc, targv)
}
err = import_descend (message, vtag, targc, targv);
out:
+ if (rcs != NULL)
+ free (rcs);
if ((cp = strrchr (repository, '/')) != NULL)
*cp = '\0';
else
repository[0] = '\0';
if (restore_cwd (&cwd, NULL))
- exit (EXIT_FAILURE);
+ error_exit ();
free_cwd (&cwd);
return (err);
}
diff --git a/contrib/cvs/src/lock.c b/contrib/cvs/src/lock.c
index 7e35aed..f84eccf 100644
--- a/contrib/cvs/src/lock.c
+++ b/contrib/cvs/src/lock.c
@@ -10,40 +10,160 @@
* Lock file support for CVS.
*/
+/* The node Concurrency in doc/cvs.texinfo has a brief introduction to
+ how CVS locks function, and some of the user-visible consequences of
+ their existence. Here is a summary of why they exist (and therefore,
+ the consequences of hacking CVS to read a repository without creating
+ locks):
+
+ There are two uses. One is the ability to prevent there from being
+ two writers at the same time. This is necessary for any number of
+ reasons (fileattr code, probably others). Commit needs to lock the
+ whole tree so that nothing happens between the up-to-date check and
+ the actual checkin.
+
+ The second use is the ability to ensure that there is not a writer
+ and a reader at the same time (several readers are allowed). Reasons
+ for this are:
+
+ * Readlocks ensure that once CVS has found a collection of rcs
+ files using Find_Names, the files will still exist when it reads
+ them (they may have moved in or out of the attic).
+
+ * Readlocks provide some modicum of consistency, although this is
+ kind of limited--see the node Concurrency in cvs.texinfo.
+
+ * Readlocks ensure that the RCS file does not change between
+ RCS_parse and RCS_reparsercsfile time. This one strikes me as
+ important, although I haven't thought up what bad scenarios might
+ be.
+
+ * Readlocks ensure that we won't find the file in the state in
+ which it is in between the "rcs -i" and the RCS_checkin in commit.c
+ (when a file is being added). This state is a state in which the
+ RCS file parsing routines in rcs.c cannot parse the file.
+
+ * Readlocks ensure that a reader won't try to look at a
+ half-written fileattr file (fileattr is not updated atomically).
+
+ (see also the description of anonymous read-only access in
+ "Password authentication security" node in doc/cvs.texinfo).
+
+ While I'm here, I'll try to summarize a few random suggestions
+ which periodically get made about how locks might be different:
+
+ 1. Check for EROFS. Maybe useful, although in the presence of NFS
+ EROFS does *not* mean that the file system is unchanging.
+
+ 2. Provide a means to put the cvs locks in some directory apart from
+ the repository (CVSROOT/locks; a -l option in modules; etc.).
+
+ 3. Provide an option to disable locks for operations which only
+ read (see above for some of the consequences).
+
+ 4. Have a server internally do the locking. Probably a good
+ long-term solution, and many people have been working hard on code
+ changes which would eventually make it possible to have a server
+ which can handle various connections in one process, but there is
+ much, much work still to be done before this is feasible.
+
+ 5. Like #4 but use shared memory or something so that the servers
+ merely need to all be on the same machine. This is a much smaller
+ change to CVS (it functions much like #2; shared memory might be an
+ unneeded complication although it presumably would be faster). */
+
#include "cvs.h"
+struct lock {
+ /* This is the directory in which we may have a lock named by the
+ readlock variable, a lock named by the writelock variable, and/or
+ a lock named CVSLCK. The storage is not allocated along with the
+ struct lock; it is allocated by the Reader_Lock caller or in the
+ case of writelocks, it is just a pointer to the storage allocated
+ for the ->key field. */
+ char *repository;
+ /* Do we have a lock named CVSLCK? */
+ int have_lckdir;
+ /* Note there is no way of knowing whether the readlock and writelock
+ exist. The code which sets the locks doesn't use SIG_beginCrSect
+ to set a flag like we do for CVSLCK. */
+};
+
+static void remove_locks PROTO((void));
static int readers_exist PROTO((char *repository));
-static int set_lock PROTO((char *repository, int will_wait));
-static void clear_lock PROTO((void));
+static int set_lock PROTO ((struct lock *lock, int will_wait));
+static void clear_lock PROTO ((struct lock *lock));
static void set_lockers_name PROTO((struct stat *statp));
static int set_writelock_proc PROTO((Node * p, void *closure));
static int unlock_proc PROTO((Node * p, void *closure));
-static int write_lock PROTO((char *repository));
-static void lock_simple_remove PROTO((char *repository));
+static int write_lock PROTO ((struct lock *lock));
+static void lock_simple_remove PROTO ((struct lock *lock));
static void lock_wait PROTO((char *repository));
-static int Check_Owner PROTO((char *lockdir));
-
-static char lockers_name[20];
-static char *repository;
-static char readlock[PATH_MAX], writelock[PATH_MAX], masterlock[PATH_MAX];
-static int cleanup_lckdir;
+static void lock_obtained PROTO((char *repository));
+
+/* Malloc'd array containing the username of the whoever has the lock.
+ Will always be non-NULL in the cases where it is needed. */
+static char *lockers_name;
+/* Malloc'd array specifying name of a readlock within a directory.
+ Or NULL if none. */
+static char *readlock;
+/* Malloc'd array specifying name of a writelock within a directory.
+ Or NULL if none. */
+static char *writelock;
+/* Malloc'd array specifying the name of a CVSLCK file (absolute pathname).
+ Will always be non-NULL in the cases where it is used. */
+static char *masterlock;
static List *locklist;
#define L_OK 0 /* success */
#define L_ERROR 1 /* error condition */
#define L_LOCKED 2 /* lock owned by someone else */
+/* This is the (single) readlock which is set by Reader_Lock. The
+ repository field is NULL if there is no such lock. */
+static struct lock global_readlock;
+
+/* List of locks set by lock_tree_for_write. This is redundant
+ with locklist, sort of. */
+static List *lock_tree_list;
+
+/* If we set locks with lock_dir_for_write, then locked_dir contains
+ the malloc'd name of the repository directory which we have locked.
+ locked_list is the same thing packaged into a list and is redundant
+ with locklist the same way that lock_tree_list is. */
+static char *locked_dir;
+static List *locked_list;
+
/*
* Clean up all outstanding locks
*/
void
Lock_Cleanup ()
{
+ remove_locks ();
+
+ dellist (&lock_tree_list);
+
+ if (locked_dir != NULL)
+ {
+ dellist (&locked_list);
+ free (locked_dir);
+ locked_dir = NULL;
+ locked_list = NULL;
+ }
+}
+
+/*
+ * Remove locks without discarding the lock information
+ */
+static void
+remove_locks ()
+{
/* clean up simple locks (if any) */
- if (repository != NULL)
+ if (global_readlock.repository != NULL)
{
- lock_simple_remove (repository);
- repository = (char *) NULL;
+ lock_simple_remove (&global_readlock);
+ global_readlock.repository = NULL;
}
/* clean up multiple locks (if any) */
@@ -62,87 +182,57 @@ unlock_proc (p, closure)
Node *p;
void *closure;
{
- lock_simple_remove (p->key);
+ lock_simple_remove ((struct lock *)p->data);
return (0);
}
-/*
- * Remove the lock files (without complaining if they are not there),
- */
+/* Remove the lock files. */
static void
-lock_simple_remove (repository)
- char *repository;
+lock_simple_remove (lock)
+ struct lock *lock;
{
- char tmp[PATH_MAX];
+ char *tmp;
- if (readlock[0] != '\0')
+ /* If readlock is set, the lock directory *might* have been created, but
+ since Reader_Lock doesn't use SIG_beginCrSect the way that set_lock
+ does, we don't know that. That is why we need to check for
+ existence_error here. */
+ if (readlock != NULL)
{
- (void) sprintf (tmp, "%s/%s", repository, readlock);
- if (unlink (tmp) < 0 && ! existence_error (errno))
+ tmp = xmalloc (strlen (lock->repository) + strlen (readlock) + 10);
+ (void) sprintf (tmp, "%s/%s", lock->repository, readlock);
+ if ( CVS_UNLINK (tmp) < 0 && ! existence_error (errno))
error (0, errno, "failed to remove lock %s", tmp);
+ free (tmp);
}
- if (writelock[0] != '\0')
+ /* If writelock is set, the lock directory *might* have been created, but
+ since write_lock doesn't use SIG_beginCrSect the way that set_lock
+ does, we don't know that. That is why we need to check for
+ existence_error here. */
+ if (writelock != NULL)
{
- (void) sprintf (tmp, "%s/%s", repository, writelock);
- if (unlink (tmp) < 0 && ! existence_error (errno))
+ tmp = xmalloc (strlen (lock->repository) + strlen (writelock) + 10);
+ (void) sprintf (tmp, "%s/%s", lock->repository, writelock);
+ if ( CVS_UNLINK (tmp) < 0 && ! existence_error (errno))
error (0, errno, "failed to remove lock %s", tmp);
+ free (tmp);
}
- /*
- * Only remove the lock directory if it is ours, note that this does
- * lead to the limitation that one user ID should not be committing
- * files into the same Repository directory at the same time. Oh well.
- */
- if (writelock[0] != '\0' || (readlock[0] != '\0' && cleanup_lckdir))
+ if (lock->have_lckdir)
{
- (void) sprintf (tmp, "%s/%s", repository, CVSLCK);
- if (Check_Owner(tmp))
- {
-#ifdef AFSCVS
- char rmuidlock[PATH_MAX];
- sprintf(rmuidlock, "rm -f %s/uidlock%d", tmp, geteuid() );
- system(rmuidlock);
-#endif
- (void) rmdir (tmp);
- }
+ tmp = xmalloc (strlen (lock->repository) + sizeof (CVSLCK) + 10);
+ (void) sprintf (tmp, "%s/%s", lock->repository, CVSLCK);
+ SIG_beginCrSect ();
+ if (CVS_RMDIR (tmp) < 0)
+ error (0, errno, "failed to remove lock dir %s", tmp);
+ lock->have_lckdir = 0;
+ SIG_endCrSect ();
+ free (tmp);
}
- cleanup_lckdir = 0;
}
/*
- * Check the owner of a lock. Returns 1 if we own it, 0 otherwise.
- */
-static int
-Check_Owner(lockdir)
- char *lockdir;
-{
- struct stat sb;
-
-#ifdef AFSCVS
- /* In the Andrew File System (AFS), user ids from stat don't match
- those from geteuid(). The AFSCVS code can deal with either AFS or
- non-AFS repositories; the non-AFSCVS code is faster. */
- char uidlock[PATH_MAX];
-
- /* Check if the uidlock is in the lock directory */
- sprintf(uidlock, "%s/uidlock%d", lockdir, geteuid() );
- if( stat(uidlock, &sb) != -1)
- return 1; /* The file exists, therefore we own the lock */
- else
- return 0; /* The file didn't exist or some other error.
- * Assume that we don't own it.
- */
-#else
- if (stat (lockdir, &sb) != -1 && sb.st_uid == geteuid ())
- return 1;
- else
- return 0;
-#endif
-} /* end Check_Owner() */
-
-
-/*
* Create a lock file for readers
*/
int
@@ -151,51 +241,63 @@ Reader_Lock (xrepository)
{
int err = 0;
FILE *fp;
- char tmp[PATH_MAX];
+ char *tmp;
if (noexec)
return (0);
/* we only do one directory at a time for read locks! */
- if (repository != NULL)
+ if (global_readlock.repository != NULL)
{
error (0, 0, "Reader_Lock called while read locks set - Help!");
return (1);
}
- if (readlock[0] == '\0')
- (void) sprintf (readlock,
+ if (readlock == NULL)
+ {
+ readlock = xmalloc (strlen (hostname) + sizeof (CVSRFL) + 40);
+ (void) sprintf (readlock,
#ifdef HAVE_LONG_FILE_NAMES
- "%s.%s.%ld", CVSRFL, hostname,
+ "%s.%s.%ld", CVSRFL, hostname,
#else
- "%s.%ld", CVSRFL,
+ "%s.%ld", CVSRFL,
#endif
- (long) getpid ());
+ (long) getpid ());
+ }
- /* remember what we're locking (for lock_cleanup) */
- repository = xrepository;
+ /* remember what we're locking (for Lock_Cleanup) */
+ global_readlock.repository = xrepository;
/* get the lock dir for our own */
- if (set_lock (xrepository, 1) != L_OK)
+ if (set_lock (&global_readlock, 1) != L_OK)
{
error (0, 0, "failed to obtain dir lock in repository `%s'",
xrepository);
- readlock[0] = '\0';
+ if (readlock != NULL)
+ free (readlock);
+ readlock = NULL;
+ /* We don't set global_readlock.repository to NULL. I think this
+ only works because recurse.c will give a fatal error if we return
+ a nonzero value. */
return (1);
}
/* write a read-lock */
+ tmp = xmalloc (strlen (xrepository) + strlen (readlock) + 10);
(void) sprintf (tmp, "%s/%s", xrepository, readlock);
- if ((fp = fopen (tmp, "w+")) == NULL || fclose (fp) == EOF)
+ if ((fp = CVS_FOPEN (tmp, "w+")) == NULL || fclose (fp) == EOF)
{
error (0, errno, "cannot create read lock in repository `%s'",
xrepository);
- readlock[0] = '\0';
+ if (readlock != NULL)
+ free (readlock);
+ readlock = NULL;
err = 1;
}
+ free (tmp);
/* free the lock dir */
- clear_lock();
+ clear_lock (&global_readlock);
return (err);
}
@@ -205,10 +307,15 @@ Reader_Lock (xrepository)
*/
static char *lock_error_repos;
static int lock_error;
-int
+
+static int Writer_Lock PROTO ((List * list));
+
+static int
Writer_Lock (list)
List *list;
{
+ char *wait_repos;
+
if (noexec)
return (0);
@@ -219,32 +326,45 @@ Writer_Lock (list)
return (1);
}
+ wait_repos = NULL;
for (;;)
{
/* try to lock everything on the list */
lock_error = L_OK; /* init for set_writelock_proc */
lock_error_repos = (char *) NULL; /* init for set_writelock_proc */
locklist = list; /* init for Lock_Cleanup */
- (void) strcpy (lockers_name, "unknown");
+ if (lockers_name != NULL)
+ free (lockers_name);
+ lockers_name = xstrdup ("unknown");
(void) walklist (list, set_writelock_proc, NULL);
switch (lock_error)
{
case L_ERROR: /* Real Error */
+ if (wait_repos != NULL)
+ free (wait_repos);
Lock_Cleanup (); /* clean up any locks we set */
error (0, 0, "lock failed - giving up");
return (1);
case L_LOCKED: /* Someone already had a lock */
- Lock_Cleanup (); /* clean up any locks we set */
+ remove_locks (); /* clean up any locks we set */
lock_wait (lock_error_repos); /* sleep a while and try again */
+ wait_repos = xstrdup (lock_error_repos);
continue;
case L_OK: /* we got the locks set */
+ if (wait_repos != NULL)
+ {
+ lock_obtained (wait_repos);
+ free (wait_repos);
+ }
return (0);
default:
+ if (wait_repos != NULL)
+ free (wait_repos);
error (0, 0, "unknown lock status %d in Writer_Lock",
lock_error);
return (1);
@@ -266,7 +386,7 @@ set_writelock_proc (p, closure)
/* apply the write lock */
lock_error_repos = p->key;
- lock_error = write_lock (p->key);
+ lock_error = write_lock ((struct lock *)p->data);
return (0);
}
@@ -275,33 +395,36 @@ set_writelock_proc (p, closure)
* lock held by someone else or L_ERROR if an error occurred
*/
static int
-write_lock (repository)
- char *repository;
+write_lock (lock)
+ struct lock *lock;
{
int status;
FILE *fp;
- char tmp[PATH_MAX];
+ char *tmp;
- if (writelock[0] == '\0')
+ if (writelock == NULL)
+ {
+ writelock = xmalloc (strlen (hostname) + sizeof (CVSWFL) + 40);
(void) sprintf (writelock,
#ifdef HAVE_LONG_FILE_NAMES
- "%s.%s.%ld", CVSWFL, hostname,
+ "%s.%s.%ld", CVSWFL, hostname,
#else
- "%s.%ld", CVSWFL,
+ "%s.%ld", CVSWFL,
#endif
- (long) getpid());
+ (long) getpid());
+ }
/* make sure the lock dir is ours (not necessarily unique to us!) */
- status = set_lock (repository, 0);
+ status = set_lock (lock, 0);
if (status == L_OK)
{
/* we now own a writer - make sure there are no readers */
- if (readers_exist (repository))
+ if (readers_exist (lock->repository))
{
/* clean up the lock dir if we created it */
if (status == L_OK)
{
- clear_lock();
+ clear_lock (lock);
}
/* indicate we failed due to read locks instead of error */
@@ -309,25 +432,28 @@ write_lock (repository)
}
/* write the write-lock file */
- (void) sprintf (tmp, "%s/%s", repository, writelock);
- if ((fp = fopen (tmp, "w+")) == NULL || fclose (fp) == EOF)
+ tmp = xmalloc (strlen (lock->repository) + strlen (writelock) + 10);
+ (void) sprintf (tmp, "%s/%s", lock->repository, writelock);
+ if ((fp = CVS_FOPEN (tmp, "w+")) == NULL || fclose (fp) == EOF)
{
int xerrno = errno;
- if (unlink (tmp) < 0 && ! existence_error (errno))
+ if ( CVS_UNLINK (tmp) < 0 && ! existence_error (errno))
error (0, errno, "failed to remove lock %s", tmp);
/* free the lock dir if we created it */
if (status == L_OK)
{
- clear_lock();
+ clear_lock (lock);
}
/* return the error */
error (0, xerrno, "cannot create write lock in repository `%s'",
- repository);
+ lock->repository);
+ free (tmp);
return (L_ERROR);
}
+ free (tmp);
return (L_OK);
}
else
@@ -353,7 +479,7 @@ readers_exist (repository)
again:
#endif
- if ((dirp = opendir (repository)) == NULL)
+ if ((dirp = CVS_OPENDIR (repository)) == NULL)
error (1, 0, "cannot open directory %s", repository);
errno = 0;
@@ -368,7 +494,7 @@ again:
line = xmalloc (strlen (repository) + strlen (dp->d_name) + 5);
(void) sprintf (line, "%s/%s", repository, dp->d_name);
- if (stat (line, &sb) != -1)
+ if ( CVS_STAT (line, &sb) != -1)
{
#ifdef CVS_FUDGELOCKS
/*
@@ -376,7 +502,7 @@ again:
* seconds ago, try to clean-up the lock file, and if
* successful, re-open the directory and try again.
*/
- if (now >= (sb.st_ctime + CVSLCKAGE) && unlink (line) != -1)
+ if (now >= (sb.st_ctime + CVSLCKAGE) && CVS_UNLINK (line) != -1)
{
(void) closedir (dirp);
free (line);
@@ -418,13 +544,18 @@ set_lockers_name (statp)
{
struct passwd *pw;
+ if (lockers_name != NULL)
+ free (lockers_name);
if ((pw = (struct passwd *) getpwuid (statp->st_uid)) !=
(struct passwd *) NULL)
{
- (void) strcpy (lockers_name, pw->pw_name);
+ lockers_name = xstrdup (pw->pw_name);
}
else
+ {
+ lockers_name = xmalloc (20);
(void) sprintf (lockers_name, "uid%lu", (unsigned long) statp->st_uid);
+ }
}
/*
@@ -433,24 +564,29 @@ set_lockers_name (statp)
* seconds old, just try to remove the directory.
*/
static int
-set_lock (repository, will_wait)
- char *repository;
+set_lock (lock, will_wait)
+ struct lock *lock;
int will_wait;
{
+ int waited;
struct stat sb;
mode_t omask;
#ifdef CVS_FUDGELOCKS
time_t now;
#endif
- (void) sprintf (masterlock, "%s/%s", repository, CVSLCK);
+ if (masterlock != NULL)
+ free (masterlock);
+ masterlock = xmalloc (strlen (lock->repository) + sizeof (CVSLCK) + 10);
+ (void) sprintf (masterlock, "%s/%s", lock->repository, CVSLCK);
/*
* Note that it is up to the callers of set_lock() to arrange for signal
* handlers that do the appropriate things, like remove the lock
* directory before they exit.
*/
- cleanup_lckdir = 0;
+ waited = 0;
+ lock->have_lckdir = 0;
for (;;)
{
int status = -1;
@@ -458,27 +594,11 @@ set_lock (repository, will_wait)
SIG_beginCrSect ();
if (CVS_MKDIR (masterlock, 0777) == 0)
{
-#ifdef AFSCVS
- char uidlock[PATH_MAX];
- FILE *fp;
-
- sprintf(uidlock, "%s/uidlock%d", masterlock, geteuid() );
- if ((fp = fopen(uidlock, "w+")) == NULL)
- {
- /* We failed to create the uidlock,
- so rm masterlock and leave */
- rmdir(masterlock);
- SIG_endCrSect ();
- status = L_ERROR;
- goto out;
- }
-
- /* We successfully created the uid lock, so close the file */
- fclose(fp);
-#endif
- cleanup_lckdir = 1;
+ lock->have_lckdir = 1;
SIG_endCrSect ();
status = L_OK;
+ if (waited)
+ lock_obtained (lock->repository);
goto out;
}
SIG_endCrSect ();
@@ -491,15 +611,14 @@ set_lock (repository, will_wait)
{
error (0, errno,
"failed to create lock directory in repository `%s'",
- repository);
+ lock->repository);
return (L_ERROR);
}
- /*
- * stat the dir - if it is non-existent, re-try the loop since
- * someone probably just removed it (thus releasing the lock)
- */
- if (stat (masterlock, &sb) < 0)
+ /* Find out who owns the lock. If the lock directory is
+ non-existent, re-try the loop since someone probably just
+ removed it (thus releasing the lock). */
+ if (CVS_STAT (masterlock, &sb) < 0)
{
if (existence_error (errno))
continue;
@@ -517,13 +636,7 @@ set_lock (repository, will_wait)
(void) time (&now);
if (now >= (sb.st_ctime + CVSLCKAGE))
{
-#ifdef AFSCVS
- /* Remove the uidlock first */
- char rmuidlock[PATH_MAX];
- sprintf(rmuidlock, "rm -f %s/uidlock%d", masterlock, geteuid() );
- system(rmuidlock);
-#endif
- if (rmdir (masterlock) >= 0)
+ if (CVS_RMDIR (masterlock) >= 0)
continue;
}
#endif
@@ -534,7 +647,8 @@ set_lock (repository, will_wait)
/* if he wasn't willing to wait, return an error */
if (!will_wait)
return (L_LOCKED);
- lock_wait (repository);
+ lock_wait (lock->repository);
+ waited = 1;
}
}
@@ -543,17 +657,14 @@ set_lock (repository, will_wait)
* clear_lock is never called except after a successful set_lock().
*/
static void
-clear_lock()
+clear_lock (lock)
+ struct lock *lock;
{
-#ifdef AFSCVS
- /* Remove the uidlock first */
- char rmuidlock[PATH_MAX];
- sprintf(rmuidlock, "rm -f %s/uidlock%d", masterlock, geteuid() );
- system(rmuidlock);
-#endif
- if (rmdir (masterlock) < 0)
+ SIG_beginCrSect ();
+ if (CVS_RMDIR (masterlock) < 0)
error (0, errno, "failed to remove lock dir `%s'", masterlock);
- cleanup_lckdir = 0;
+ lock->have_lckdir = 0;
+ SIG_endCrSect ();
}
/*
@@ -568,30 +679,54 @@ lock_wait (repos)
(void) time (&now);
error (0, 0, "[%8.8s] waiting for %s's lock in %s", ctime (&now) + 11,
lockers_name, repos);
+ /* Call cvs_flusherr to ensure that the user sees this message as
+ soon as possible. */
+ cvs_flusherr ();
(void) sleep (CVSLCKSLEEP);
}
+
+/*
+ * Print out a message when we obtain a lock.
+ */
+static void
+lock_obtained (repos)
+ char *repos;
+{
+ time_t now;
+
+ (void) time (&now);
+ error (0, 0, "[%8.8s] obtained lock in %s", ctime (&now) + 11, repos);
+ /* Call cvs_flusherr to ensure that the user sees this message as
+ soon as possible. */
+ cvs_flusherr ();
+}
-static int lock_filesdoneproc PROTO ((int err, char *repository,
- char *update_dir));
+static int lock_filesdoneproc PROTO ((void *callerdat, int err,
+ char *repository, char *update_dir,
+ List *entries));
static int fsortcmp PROTO((const Node * p, const Node * q));
-static List *lock_tree_list;
-
/*
* Create a list of repositories to lock
*/
/* ARGSUSED */
static int
-lock_filesdoneproc (err, repository, update_dir)
+lock_filesdoneproc (callerdat, err, repository, update_dir, entries)
+ void *callerdat;
int err;
char *repository;
char *update_dir;
+ List *entries;
{
Node *p;
p = getnode ();
p->type = LOCK;
p->key = xstrdup (repository);
+ p->data = xmalloc (sizeof (struct lock));
+ ((struct lock *)p->data)->repository = p->key;
+ ((struct lock *)p->data)->have_lckdir = 0;
+
/* FIXME-KRP: this error condition should not simply be passed by. */
if (p->key == NULL || addnode (lock_tree_list, p) != 0)
freenode (p);
@@ -623,17 +758,39 @@ lock_tree_for_write (argc, argv, local, aflag)
*/
lock_tree_list = getlist ();
err = start_recursion ((FILEPROC) NULL, lock_filesdoneproc,
- (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL, argc,
- argv, local, W_LOCAL, aflag, 0, (char *) NULL, 0,
- 0);
+ (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL, NULL, argc,
+ argv, local, W_LOCAL, aflag, 0, (char *) NULL, 0);
sortlist (lock_tree_list, fsortcmp);
if (Writer_Lock (lock_tree_list) != 0)
error (1, 0, "lock failed - giving up");
}
-
+
+/* Lock a single directory in REPOSITORY. It is OK to call this if
+ a lock has been set with lock_dir_for_write; the new lock will replace
+ the old one. If REPOSITORY is NULL, don't do anything. */
void
-lock_tree_cleanup ()
+lock_dir_for_write (repository)
+ char *repository;
{
- Lock_Cleanup ();
- dellist (&lock_tree_list);
+ if (repository != NULL
+ && (locked_dir == NULL
+ || strcmp (locked_dir, repository) != 0))
+ {
+ Node *node;
+
+ if (locked_dir != NULL)
+ Lock_Cleanup ();
+
+ locked_dir = xstrdup (repository);
+ locked_list = getlist ();
+ node = getnode ();
+ node->type = LOCK;
+ node->key = xstrdup (repository);
+ node->data = xmalloc (sizeof (struct lock));
+ ((struct lock *)node->data)->repository = node->key;
+ ((struct lock *)node->data)->have_lckdir = 0;
+
+ (void) addnode (locked_list, node);
+ Writer_Lock (locked_list);
+ }
}
diff --git a/contrib/cvs/src/log.c b/contrib/cvs/src/log.c
index f167d92..8fb6910 100644
--- a/contrib/cvs/src/log.c
+++ b/contrib/cvs/src/log.c
@@ -17,42 +17,213 @@
#include "cvs.h"
-static Dtype log_dirproc PROTO((char *dir, char *repository, char *update_dir));
-static int log_fileproc PROTO((struct file_info *finfo));
+/* This structure holds information parsed from the -r option. */
+
+struct option_revlist
+{
+ /* The next -r option. */
+ struct option_revlist *next;
+ /* The first revision to print. This is NULL if the range is
+ :rev, or if no revision is given. */
+ char *first;
+ /* The last revision to print. This is NULL if the range is rev:,
+ or if no revision is given. If there is no colon, first and
+ last are the same. */
+ char *last;
+ /* Nonzero if there was a trailing `.', which means to print only
+ the head revision of a branch. */
+ int branchhead;
+};
+
+/* This structure holds information derived from option_revlist given
+ a particular RCS file. */
+
+struct revlist
+{
+ /* The next pair. */
+ struct revlist *next;
+ /* The first numeric revision to print. */
+ char *first;
+ /* The last numeric revision to print. */
+ char *last;
+ /* The number of fields in these revisions (one more than
+ numdots). */
+ int fields;
+};
+
+/* This structure holds information parsed from the -d option. */
+
+struct datelist
+{
+ /* The next date. */
+ struct datelist *next;
+ /* The starting date. */
+ char *start;
+ /* The ending date. */
+ char *end;
+ /* Nonzero if the range is inclusive rather than exclusive. */
+ int inclusive;
+};
+
+/* This structure is used to pass information through start_recursion. */
+struct log_data
+{
+ /* Nonzero if the -R option was given, meaning that only the name
+ of the RCS file should be printed. */
+ int nameonly;
+ /* Nonzero if the -h option was given, meaning that only header
+ information should be printed. */
+ int header;
+ /* Nonzero if the -t option was given, meaning that only the
+ header and the descriptive text should be printed. */
+ int long_header;
+ /* Nonzero if the -N option was seen, meaning that tag information
+ should not be printed. */
+ int notags;
+ /* Nonzero if the -b option was seen, meaning that only revisions
+ on the default branch should be printed. */
+ int default_branch;
+ /* If not NULL, the value given for the -r option, which lists
+ sets of revisions to be printed. */
+ struct option_revlist *revlist;
+ /* If not NULL, the date pairs given for the -d option, which
+ select date ranges to print. */
+ struct datelist *datelist;
+ /* If not NULL, the single dates given for the -d option, which
+ select specific revisions to print based on a date. */
+ struct datelist *singledatelist;
+ /* If not NULL, the list of states given for the -s option, which
+ only prints revisions of given states. */
+ List *statelist;
+ /* If not NULL, the list of login names given for the -w option,
+ which only prints revisions checked in by given users. */
+ List *authorlist;
+};
+
+/* This structure is used to pass information through walklist. */
+struct log_data_and_rcs
+{
+ struct log_data *log_data;
+ struct revlist *revlist;
+ RCSNode *rcs;
+};
+
+static Dtype log_dirproc PROTO ((void *callerdat, char *dir,
+ char *repository, char *update_dir,
+ List *entries));
+static int log_fileproc PROTO ((void *callerdat, struct file_info *finfo));
+static struct option_revlist *log_parse_revlist PROTO ((const char *));
+static void log_parse_date PROTO ((struct log_data *, const char *));
+static void log_parse_list PROTO ((List **, const char *));
+static struct revlist *log_expand_revlist PROTO ((RCSNode *,
+ struct option_revlist *,
+ int));
+static void log_free_revlist PROTO ((struct revlist *));
+static int log_version_requested PROTO ((struct log_data *, struct revlist *,
+ RCSNode *, RCSVers *));
+static int log_symbol PROTO ((Node *, void *));
+static int log_count PROTO ((Node *, void *));
+static int log_fix_singledate PROTO ((Node *, void *));
+static int log_count_print PROTO ((Node *, void *));
+static void log_tree PROTO ((struct log_data *, struct revlist *,
+ RCSNode *, const char *));
+static void log_abranch PROTO ((struct log_data *, struct revlist *,
+ RCSNode *, const char *));
+static void log_version PROTO ((struct log_data *, struct revlist *,
+ RCSNode *, RCSVers *, int));
+static int log_branch PROTO ((Node *, void *));
+static int version_compare PROTO ((const char *, const char *, int));
static const char *const log_usage[] =
{
- "Usage: %s %s [-l] [rlog-options] [files...]\n",
+ "Usage: %s %s [-lRhtNb] [-r[revisions]] [-d dates] [-s states]\n",
+ " [-w[logins]] [files...]\n",
"\t-l\tLocal directory only, no recursion.\n",
+ "\t-R\tOnly print name of RCS file.\n",
+ "\t-h\tOnly print header.\n",
+ "\t-t\tOnly print header and descriptive text.\n",
+ "\t-N\tDo not list tags.\n",
+ "\t-b\tOnly list revisions on the default branch.\n",
+ "\t-r[revisions]\tSpecify revision(s)s to list.\n",
+ "\t-d dates\tSpecify dates (D1<D2 for range, D for latest before).\n",
+ "\t-s states\tOnly list revisions with specified states.\n",
+ "\t-w[logins]\tOnly list revisions checked in by specified logins.\n",
NULL
};
-static int ac;
-static char **av;
-
int
cvslog (argc, argv)
int argc;
char **argv;
{
- int i;
+ int c;
int err = 0;
int local = 0;
+ struct log_data log_data;
+ struct option_revlist *rl, **prl;
if (argc == -1)
usage (log_usage);
- /*
- * All 'log' command options except -l are passed directly on to 'rlog'
- */
- for (i = 1; i < argc && argv[i][0] == '-'; i++)
- if (argv[i][1] == 'l')
- local = 1;
+ memset (&log_data, 0, sizeof log_data);
+
+ optind = 1;
+ while ((c = getopt (argc, argv, "+bd:hlNRr::s:tw::")) != -1)
+ {
+ switch (c)
+ {
+ case 'b':
+ log_data.default_branch = 1;
+ break;
+ case 'd':
+ log_parse_date (&log_data, optarg);
+ break;
+ case 'h':
+ log_data.header = 1;
+ break;
+ case 'l':
+ local = 1;
+ break;
+ case 'N':
+ log_data.notags = 1;
+ break;
+ case 'R':
+ log_data.nameonly = 1;
+ break;
+ case 'r':
+ rl = log_parse_revlist (optarg);
+ for (prl = &log_data.revlist;
+ *prl != NULL;
+ prl = &(*prl)->next)
+ ;
+ *prl = rl;
+ break;
+ case 's':
+ log_parse_list (&log_data.statelist, optarg);
+ break;
+ case 't':
+ log_data.long_header = 1;
+ break;
+ case 'w':
+ if (optarg != NULL)
+ log_parse_list (&log_data.authorlist, optarg);
+ else
+ log_parse_list (&log_data.authorlist, getcaller ());
+ break;
+ case '?':
+ default:
+ usage (log_usage);
+ break;
+ }
+ }
wrap_setup ();
#ifdef CLIENT_SUPPORT
- if (client_active) {
+ if (client_active)
+ {
+ int i;
+
/* We're the local client. Fire up the remote server. */
start_server ();
@@ -62,39 +233,256 @@ cvslog (argc, argv)
send_arg (argv[i]);
send_file_names (argc - i, argv + i, SEND_EXPAND_WILD);
-/* FIXME: We shouldn't have to send current files to get log entries, but it
- doesn't work yet and I haven't debugged it. So send the files --
- it's slower but it works. gnu@cygnus.com Apr94 */
- send_files (argc - i, argv + i, local, 0);
+ send_files (argc - i, argv + i, local, 0, SEND_NO_CONTENTS);
send_to_server ("log\012", 0);
err = get_responses_and_close ();
return err;
}
-
- ac = argc;
- av = argv;
#endif
err = start_recursion (log_fileproc, (FILESDONEPROC) NULL, log_dirproc,
- (DIRLEAVEPROC) NULL, argc - i, argv + i, local,
+ (DIRLEAVEPROC) NULL, (void *) &log_data,
+ argc - optind, argv + optind, local,
W_LOCAL | W_REPOS | W_ATTIC, 0, 1,
- (char *) NULL, 1, 0);
+ (char *) NULL, 1);
return (err);
}
+/*
+ * Parse a revision list specification.
+ */
+
+static struct option_revlist *
+log_parse_revlist (argstring)
+ const char *argstring;
+{
+ char *copy;
+ struct option_revlist *ret, **pr;
+
+ /* Unfortunately, rlog accepts -r without an argument to mean that
+ latest revision on the default branch, so we must support that
+ for compatibility. */
+ if (argstring == NULL)
+ {
+ ret = (struct option_revlist *) xmalloc (sizeof *ret);
+ ret->first = NULL;
+ ret->last = NULL;
+ ret->next = NULL;
+ ret->branchhead = 0;
+ return ret;
+ }
+
+ ret = NULL;
+ pr = &ret;
+
+ /* Copy the argument into memory so that we can change it. We
+ don't want to change the argument because, at least as of this
+ writing, we will use it if we send the arguments to the server.
+ We never bother to free up our copy. */
+ copy = xstrdup (argstring);
+ while (copy != NULL)
+ {
+ char *comma;
+ char *cp;
+ char *first, *last;
+ struct option_revlist *r;
+
+ comma = strchr (copy, ',');
+ if (comma != NULL)
+ *comma++ = '\0';
+
+ first = copy;
+ cp = strchr (copy, ':');
+ if (cp == NULL)
+ last = copy;
+ else
+ {
+ *cp++ = '\0';
+ last = cp;
+ }
+
+ if (*first == '\0')
+ first = NULL;
+ if (*last == '\0')
+ last = NULL;
+
+ r = (struct option_revlist *) xmalloc (sizeof *r);
+ r->next = NULL;
+ r->first = first;
+ r->last = last;
+ if (first != last
+ || first[strlen (first) - 1] != '.')
+ {
+ r->branchhead = 0;
+ }
+ else
+ {
+ r->branchhead = 1;
+ first[strlen (first) - 1] = '\0';
+ }
+
+ *pr = r;
+ pr = &r->next;
+
+ copy = comma;
+ }
+
+ return ret;
+}
+
+/*
+ * Parse a date specification.
+ */
+static void
+log_parse_date (log_data, argstring)
+ struct log_data *log_data;
+ const char *argstring;
+{
+ char *orig_copy, *copy;
+
+ /* Copy the argument into memory so that we can change it. We
+ don't want to change the argument because, at least as of this
+ writing, we will use it if we send the arguments to the server. */
+ copy = xstrdup (argstring);
+ orig_copy = copy;
+ while (copy != NULL)
+ {
+ struct datelist *nd, **pd;
+ char *cpend, *cp, *ds, *de;
+
+ nd = (struct datelist *) xmalloc (sizeof *nd);
+
+ cpend = strchr (copy, ';');
+ if (cpend != NULL)
+ *cpend++ = '\0';
+
+ pd = &log_data->datelist;
+ nd->inclusive = 0;
+
+ if ((cp = strchr (copy, '>')) != NULL)
+ {
+ *cp++ = '\0';
+ if (*cp == '=')
+ {
+ ++cp;
+ nd->inclusive = 1;
+ }
+ ds = cp;
+ de = copy;
+ }
+ else if ((cp = strchr (copy, '<')) != NULL)
+ {
+ *cp++ = '\0';
+ if (*cp == '=')
+ {
+ ++cp;
+ nd->inclusive = 1;
+ }
+ ds = copy;
+ de = cp;
+ }
+ else
+ {
+ ds = NULL;
+ de = copy;
+ pd = &log_data->singledatelist;
+ }
+
+ if (ds == NULL)
+ nd->start = NULL;
+ else if (*ds != '\0')
+ nd->start = Make_Date (ds);
+ else
+ {
+ /* 1970 was the beginning of time, as far as get_date and
+ Make_Date are concerned. FIXME: That is true only if time_t
+ is a POSIX-style time and there is nothing in ANSI that
+ mandates that. It would be cleaner to set a flag saying
+ whether or not there is a start date. */
+ nd->start = Make_Date ("1/1/1970 UTC");
+ }
+
+ if (*de != '\0')
+ nd->end = Make_Date (de);
+ else
+ {
+ /* We want to set the end date to some time sufficiently far
+ in the future to pick up all revisions that have been
+ created since the specified date and the time `cvs log'
+ completes. FIXME: The date in question only makes sense
+ if time_t is a POSIX-style time and it is 32 bits
+ and signed. We should instead be setting a flag saying
+ whether or not there is an end date. Note that using
+ something like "next week" would break the testsuite (and,
+ perhaps less importantly, loses if the clock is set grossly
+ wrong). */
+ nd->end = Make_Date ("2038-01-01");
+ }
+
+ nd->next = *pd;
+ *pd = nd;
+
+ copy = cpend;
+ }
+
+ free (orig_copy);
+}
+
+/*
+ * Parse a comma separated list of items, and add each one to *PLIST.
+ */
+static void
+log_parse_list (plist, argstring)
+ List **plist;
+ const char *argstring;
+{
+ while (1)
+ {
+ Node *p;
+ char *cp;
+
+ p = getnode ();
+
+ cp = strchr (argstring, ',');
+ if (cp == NULL)
+ p->key = xstrdup (argstring);
+ else
+ {
+ size_t len;
+
+ len = cp - argstring;
+ p->key = xmalloc (len + 1);
+ strncpy (p->key, argstring, len);
+ p->key[len + 1] = '\0';
+ }
+
+ if (*plist == NULL)
+ *plist = getlist ();
+ if (addnode (*plist, p) != 0)
+ freenode (p);
+
+ if (cp == NULL)
+ break;
+
+ argstring = cp + 1;
+ }
+}
/*
* Do an rlog on a file
*/
-/* ARGSUSED */
static int
-log_fileproc (finfo)
+log_fileproc (callerdat, finfo)
+ void *callerdat;
struct file_info *finfo;
{
+ struct log_data *log_data = (struct log_data *) callerdat;
Node *p;
RCSNode *rcsfile;
- int retcode = 0;
+ char buf[50];
+ struct revlist *revlist;
+ struct log_data_and_rcs log_data_and_rcs;
if ((rcsfile = finfo->rcs) == NULL)
{
@@ -120,28 +508,875 @@ log_fileproc (finfo)
return (1);
}
- run_setup ("%s%s -x,v/", Rcsbin, RCS_RLOG);
+ if (log_data->nameonly)
+ {
+ cvs_output (rcsfile->path, 0);
+ cvs_output ("\n", 1);
+ return 0;
+ }
+
+ /* We will need all the information in the RCS file. */
+ RCS_fully_parse (rcsfile);
+
+ /* Turn any symbolic revisions in the revision list into numeric
+ revisions. */
+ revlist = log_expand_revlist (rcsfile, log_data->revlist,
+ log_data->default_branch);
+
+ /* The output here is intended to be exactly compatible with the
+ output of rlog. I'm not sure whether this code should be here
+ or in rcs.c; I put it here because it is specific to the log
+ function, even though it uses information gathered by the
+ functions in rcs.c. */
+
+ cvs_output ("\n", 1);
+
+ cvs_output ("RCS file: ", 0);
+ cvs_output (rcsfile->path, 0);
+
+ cvs_output ("\nWorking file: ", 0);
+ if (finfo->update_dir[0] == '\0')
+ cvs_output (finfo->file, 0);
+ else
+ {
+ cvs_output (finfo->update_dir, 0);
+ cvs_output ("/", 0);
+ cvs_output (finfo->file, 0);
+
+ }
+
+ cvs_output ("\nhead:", 0);
+ if (rcsfile->head != NULL)
+ {
+ cvs_output (" ", 1);
+ cvs_output (rcsfile->head, 0);
+ }
+
+ cvs_output ("\nbranch:", 0);
+ if (rcsfile->branch != NULL)
+ {
+ cvs_output (" ", 1);
+ cvs_output (rcsfile->branch, 0);
+ }
+
+ cvs_output ("\nlocks:", 0);
+ if (rcsfile->other != NULL)
+ {
+ p = findnode (rcsfile->other, "strict");
+ if (p != NULL)
+ cvs_output (" strict", 0);
+ p = findnode (rcsfile->other, "locks");
+ if (p != NULL && p->data != NULL)
+ {
+ char *f, *cp;
+
+ f = xstrdup (p->data);
+ cp = f;
+ while (*cp != '\0')
+ {
+ char *cp2, *locker, *version;
+ RCSVers *vnode;
+
+ locker = cp;
+
+ cp2 = strchr (cp, ':');
+ if (cp2 == NULL)
+ {
+ error (0, 0, "warning: bad locks field in RCS file `%s'",
+ finfo->fullname);
+ break;
+ }
+
+ *cp2 = '\0';
+
+ cvs_output ("\n\t", 2);
+ cvs_output (cp, cp2 - cp);
+ cvs_output (": ", 2);
+
+ cp = cp2 + 1;
+ while (isspace (*cp) && *cp != '\0')
+ ++cp;
+
+ version = cp;
+
+ cp2 = cp;
+ while (! isspace (*cp2) && *cp2 != '\0')
+ ++cp2;
+
+ cvs_output (cp, cp2 - cp);
+
+ if (*cp2 == '\0')
+ cp = cp2;
+ else
+ {
+ *cp2 = '\0';
+ cp = cp2 + 1;
+ while (isspace (*cp) && *cp != '\0')
+ ++cp;
+ }
+
+ p = findnode (rcsfile->versions, version);
+ if (p == NULL)
+ error (0, 0,
+ "warning: lock for missing version `%s' in `%s'",
+ version, finfo->fullname);
+ else
+ {
+ vnode = (RCSVers *) p->data;
+ p = getnode ();
+ p->type = RCSFIELD;
+ p->key = xstrdup (";locker");
+ p->data = xstrdup (locker);
+ if (addnode (vnode->other, p) != 0)
+ {
+ error (0, 0,
+ "warning: duplicate lock for `%s' in `%s'",
+ version, finfo->fullname);
+ freenode (p);
+ }
+ }
+ }
+
+ free (f);
+ }
+ }
+
+ cvs_output ("\naccess list:", 0);
+ if (rcsfile->other != NULL)
+ {
+ p = findnode (rcsfile->other, "access");
+ if (p != NULL && p->data != NULL)
+ {
+ const char *cp;
+
+ cp = p->data;
+ while (*cp != '\0')
+ {
+ const char *cp2;
+
+ cvs_output ("\n\t", 2);
+ cp2 = cp;
+ while (! isspace (*cp2) && *cp2 != '\0')
+ ++cp2;
+ cvs_output (cp, cp2 - cp);
+ cp = cp2;
+ while (isspace (*cp) && *cp != '\0')
+ ++cp;
+ }
+ }
+ }
+
+ if (! log_data->notags)
+ {
+ List *syms;
+
+ cvs_output ("\nsymbolic names:", 0);
+ syms = RCS_symbols (rcsfile);
+ walklist (syms, log_symbol, NULL);
+ }
+
+ cvs_output ("\nkeyword substitution: ", 0);
+ if (rcsfile->expand == NULL)
+ cvs_output ("kv", 2);
+ else
+ cvs_output (rcsfile->expand, 0);
+
+ cvs_output ("\ntotal revisions: ", 0);
+ sprintf (buf, "%d", walklist (rcsfile->versions, log_count, NULL));
+ cvs_output (buf, 0);
+
+ if (! log_data->header && ! log_data->long_header)
+ {
+ cvs_output (";\tselected revisions: ", 0);
+
+ log_data_and_rcs.log_data = log_data;
+ log_data_and_rcs.revlist = revlist;
+ log_data_and_rcs.rcs = rcsfile;
+
+ /* If any single dates were specified, we need to identify the
+ revisions they select. Each one selects the single
+ revision, which is otherwise selected, of that date or
+ earlier. The log_fix_singledate routine will fill in the
+ start date for each specific revision. */
+ if (log_data->singledatelist != NULL)
+ walklist (rcsfile->versions, log_fix_singledate,
+ (void *) &log_data_and_rcs);
+
+ sprintf (buf, "%d", walklist (rcsfile->versions, log_count_print,
+ (void *) &log_data_and_rcs));
+ cvs_output (buf, 0);
+ }
+
+ cvs_output ("\n", 1);
+
+ if (! log_data->header || log_data->long_header)
+ {
+ cvs_output ("description:\n", 0);
+ if (rcsfile->other != NULL)
+ {
+ p = findnode (rcsfile->other, "desc");
+ if (p != NULL && p->data != NULL)
+ cvs_output (p->data, 0);
+ }
+ }
+
+ if (! log_data->header && ! log_data->long_header && rcsfile->head != NULL)
+ {
+ p = findnode (rcsfile->versions, rcsfile->head);
+ if (p == NULL)
+ error (1, 0, "can not find head revision in `%s'",
+ finfo->fullname);
+ while (p != NULL)
+ {
+ RCSVers *vers;
+
+ vers = (RCSVers *) p->data;
+ log_version (log_data, revlist, rcsfile, vers, 1);
+ if (vers->next == NULL)
+ p = NULL;
+ else
+ {
+ p = findnode (rcsfile->versions, vers->next);
+ if (p == NULL)
+ error (1, 0, "can not find next revision `%s' in `%s'",
+ vers->next, finfo->fullname);
+ }
+ }
+
+ log_tree (log_data, revlist, rcsfile, rcsfile->head);
+ }
+
+ cvs_output("\
+=============================================================================\n",
+ 0);
+
+ /* Free up the new revlist and restore the old one. */
+ log_free_revlist (revlist);
+
+ /* If singledatelist is not NULL, free up the start dates we added
+ to it. */
+ if (log_data->singledatelist != NULL)
+ {
+ struct datelist *d;
+
+ for (d = log_data->singledatelist; d != NULL; d = d->next)
+ {
+ if (d->start != NULL)
+ free (d->start);
+ d->start = NULL;
+ }
+ }
+
+ return 0;
+}
+
+/*
+ * Fix up a revision list in order to compare it against versions.
+ * Expand any symbolic revisions.
+ */
+static struct revlist *
+log_expand_revlist (rcs, revlist, default_branch)
+ RCSNode *rcs;
+ struct option_revlist *revlist;
+ int default_branch;
+{
+ struct option_revlist *r;
+ struct revlist *ret, **pr;
+
+ ret = NULL;
+ pr = &ret;
+ for (r = revlist; r != NULL; r = r->next)
+ {
+ struct revlist *nr;
+
+ nr = (struct revlist *) xmalloc (sizeof *nr);
+
+ if (r->first == NULL && r->last == NULL)
+ {
+ /* If both first and last are NULL, it means that we want
+ just the head of the default branch, which is RCS_head. */
+ nr->first = RCS_head (rcs);
+ nr->last = xstrdup (nr->first);
+ nr->fields = numdots (nr->first) + 1;
+ }
+ else if (r->branchhead)
+ {
+ char *branch;
+
+ /* Print just the head of the branch. */
+ if (isdigit (r->first[0]))
+ nr->first = RCS_getbranch (rcs, r->first, 1);
+ else
+ {
+ branch = RCS_whatbranch (rcs, r->first);
+ if (branch == NULL)
+ {
+ error (0, 0, "warning: `%s' is not a branch in `%s'",
+ r->first, rcs->path);
+ free (nr);
+ continue;
+ }
+ nr->first = RCS_getbranch (rcs, branch, 1);
+ free (branch);
+ }
+ if (nr->first == NULL)
+ {
+ error (0, 0, "warning: no revision `%s' in `%s'",
+ r->first, rcs->path);
+ free (nr);
+ continue;
+ }
+ nr->last = xstrdup (nr->first);
+ nr->fields = numdots (nr->first) + 1;
+ }
+ else
+ {
+ if (r->first == NULL || isdigit (r->first[0]))
+ nr->first = xstrdup (r->first);
+ else
+ {
+ if (RCS_nodeisbranch (rcs, r->first))
+ nr->first = RCS_whatbranch (rcs, r->first);
+ else
+ nr->first = RCS_gettag (rcs, r->first, 1, (int *) NULL);
+ if (nr->first == NULL)
+ {
+ error (0, 0, "warning: no revision `%s' in `%s'",
+ r->first, rcs->path);
+ free (nr);
+ continue;
+ }
+ }
+
+ if (r->last == r->first)
+ nr->last = xstrdup (nr->first);
+ else if (r->last == NULL || isdigit (r->last[0]))
+ nr->last = xstrdup (r->last);
+ else
+ {
+ if (RCS_nodeisbranch (rcs, r->last))
+ nr->last = RCS_whatbranch (rcs, r->last);
+ else
+ nr->last = RCS_gettag (rcs, r->last, 1, (int *) NULL);
+ if (nr->last == NULL)
+ {
+ error (0, 0, "warning: no revision `%s' in `%s'",
+ r->last, rcs->path);
+ if (nr->first != NULL)
+ free (nr->first);
+ free (nr);
+ continue;
+ }
+ }
+
+ /* Process the revision numbers the same way that rlog
+ does. This code is a bit cryptic for my tastes, but
+ keeping the same implementation as rlog ensures a
+ certain degree of compatibility. */
+ if (r->first == NULL)
+ {
+ nr->fields = numdots (nr->last) + 1;
+ if (nr->fields < 2)
+ nr->first = xstrdup (".0");
+ else
+ {
+ char *cp;
+
+ nr->first = xstrdup (nr->last);
+ cp = strrchr (nr->first, '.');
+ strcpy (cp, ".0");
+ }
+ }
+ else if (r->last == NULL)
+ {
+ nr->fields = numdots (nr->first) + 1;
+ nr->last = xstrdup (nr->first);
+ if (nr->fields < 2)
+ nr->last[0] = '\0';
+ else
+ {
+ char *cp;
+
+ cp = strrchr (nr->last, '.');
+ *cp = '\0';
+ }
+ }
+ else
+ {
+ nr->fields = numdots (nr->first) + 1;
+ if (nr->fields != numdots (nr->last) + 1
+ || (nr->fields > 2
+ && version_compare (nr->first, nr->last,
+ nr->fields - 1) != 0))
+ {
+ error (0, 0,
+ "invalid branch or revision pair %s:%s in `%s'",
+ r->first, r->last, rcs->path);
+ free (nr->first);
+ free (nr->last);
+ free (nr);
+ continue;
+ }
+ if (version_compare (nr->first, nr->last, nr->fields) > 0)
+ {
+ char *tmp;
+
+ tmp = nr->first;
+ nr->first = nr->last;
+ nr->last = tmp;
+ }
+ }
+ }
+
+ nr->next = NULL;
+ *pr = nr;
+ pr = &nr->next;
+ }
+
+ /* If the default branch was requested, add a revlist entry for
+ it. This is how rlog handles this option. */
+ if (default_branch
+ && (rcs->head != NULL || rcs->branch != NULL))
+ {
+ struct revlist *nr;
+
+ nr = (struct revlist *) xmalloc (sizeof *nr);
+ if (rcs->branch != NULL)
+ nr->first = xstrdup (rcs->branch);
+ else
+ {
+ char *cp;
+
+ nr->first = xstrdup (rcs->head);
+ cp = strrchr (nr->first, '.');
+ *cp = '\0';
+ }
+ nr->last = xstrdup (nr->first);
+ nr->fields = numdots (nr->first) + 1;
+
+ nr->next = NULL;
+ *pr = nr;
+ }
+
+ return ret;
+}
+
+/*
+ * Free a revlist created by log_expand_revlist.
+ */
+static void
+log_free_revlist (revlist)
+ struct revlist *revlist;
+{
+ struct revlist *r;
+
+ r = revlist;
+ while (r != NULL)
+ {
+ struct revlist *next;
+
+ if (r->first != NULL)
+ free (r->first);
+ if (r->last != NULL)
+ free (r->last);
+ next = r->next;
+ free (r);
+ r = next;
+ }
+}
+
+/*
+ * Return nonzero if a revision should be printed, based on the
+ * options provided.
+ */
+static int
+log_version_requested (log_data, revlist, rcs, vnode)
+ struct log_data *log_data;
+ struct revlist *revlist;
+ RCSNode *rcs;
+ RCSVers *vnode;
+{
+ /* Handle the list of states from the -s option. */
+ if (log_data->statelist != NULL
+ && findnode (log_data->statelist, vnode->state) == NULL)
+ {
+ return 0;
+ }
+
+ /* Handle the list of authors from the -w option. */
+ if (log_data->authorlist != NULL)
+ {
+ if (vnode->author != NULL
+ && findnode (log_data->authorlist, vnode->author) == NULL)
+ {
+ return 0;
+ }
+ }
+
+ /* rlog considers all the -d options together when it decides
+ whether to print a revision, so we must be compatible. */
+ if (log_data->datelist != NULL || log_data->singledatelist != NULL)
+ {
+ struct datelist *d;
+
+ for (d = log_data->datelist; d != NULL; d = d->next)
+ {
+ int cmp;
+
+ cmp = RCS_datecmp (vnode->date, d->start);
+ if (cmp > 0 || (cmp == 0 && d->inclusive))
+ {
+ cmp = RCS_datecmp (vnode->date, d->end);
+ if (cmp < 0 || (cmp == 0 && d->inclusive))
+ break;
+ }
+ }
+
+ if (d == NULL)
+ {
+ /* Look through the list of specific dates. We want to
+ select the revision with the exact date found in the
+ start field. The commit code ensures that it is
+ impossible to check in multiple revisions of a single
+ file in a single second, so checking the date this way
+ should never select more than one revision. */
+ for (d = log_data->singledatelist; d != NULL; d = d->next)
+ {
+ if (d->start != NULL
+ && RCS_datecmp (vnode->date, d->start) == 0)
+ {
+ break;
+ }
+ }
+
+ if (d == NULL)
+ return 0;
+ }
+ }
+
+ /* If the -r or -b options were used, REVLIST will be non NULL,
+ and we print the union of the specified revisions. */
+ if (revlist != NULL)
+ {
+ char *v;
+ int vfields;
+ struct revlist *r;
+
+ /* This code is taken from rlog. */
+ v = vnode->version;
+ vfields = numdots (v) + 1;
+ for (r = revlist; r != NULL; r = r->next)
+ {
+ if (vfields == r->fields + (r->fields & 1)
+ && version_compare (v, r->first, r->fields) >= 0
+ && version_compare (v, r->last, r->fields) <= 0)
+ {
+ return 1;
+ }
+ }
+
+ /* If we get here, then the -b and/or the -r option was used,
+ but did not match this revision, so we reject it. */
+
+ return 0;
+ }
+
+ /* By default, we print all revisions. */
+ return 1;
+}
+
+/*
+ * Output a single symbol. This is called via walklist.
+ */
+/*ARGSUSED*/
+static int
+log_symbol (p, closure)
+ Node *p;
+ void *closure;
+{
+ cvs_output ("\n\t", 2);
+ cvs_output (p->key, 0);
+ cvs_output (": ", 2);
+ cvs_output (p->data, 0);
+ return 0;
+}
+
+/*
+ * Count the number of entries on a list. This is called via walklist.
+ */
+/*ARGSUSED*/
+static int
+log_count (p, closure)
+ Node *p;
+ void *closure;
+{
+ return 1;
+}
+
+/*
+ * Sort out a single date specification by narrowing down the date
+ * until we find the specific selected revision.
+ */
+static int
+log_fix_singledate (p, closure)
+ Node *p;
+ void *closure;
+{
+ struct log_data_and_rcs *data = (struct log_data_and_rcs *) closure;
+ Node *pv;
+ RCSVers *vnode;
+ struct datelist *holdsingle, *holddate;
+ int requested;
+
+ pv = findnode (data->rcs->versions, p->key);
+ if (pv == NULL)
+ error (1, 0, "missing version `%s' in RCS file `%s'",
+ p->key, data->rcs->path);
+ vnode = (RCSVers *) pv->data;
+
+ /* We are only interested if this revision passes any other tests.
+ Temporarily clear log_data->singledatelist to avoid confusing
+ log_version_requested. We also clear log_data->datelist,
+ because rlog considers all the -d options together. We don't
+ want to reject a revision because it does not match a date pair
+ if we are going to select it on the basis of the singledate. */
+ holdsingle = data->log_data->singledatelist;
+ data->log_data->singledatelist = NULL;
+ holddate = data->log_data->datelist;
+ data->log_data->datelist = NULL;
+ requested = log_version_requested (data->log_data, data->revlist,
+ data->rcs, vnode);
+ data->log_data->singledatelist = holdsingle;
+ data->log_data->datelist = holddate;
+
+ if (requested)
+ {
+ struct datelist *d;
+
+ /* For each single date, if this revision is before the
+ specified date, but is closer than the previously selected
+ revision, select it instead. */
+ for (d = data->log_data->singledatelist; d != NULL; d = d->next)
+ {
+ if (RCS_datecmp (vnode->date, d->end) <= 0
+ && (d->start == NULL
+ || RCS_datecmp (vnode->date, d->start) > 0))
+ {
+ if (d->start != NULL)
+ free (d->start);
+ d->start = xstrdup (vnode->date);
+ }
+ }
+ }
+
+ return 0;
+}
+
+/*
+ * Count the number of revisions we are going to print.
+ */
+static int
+log_count_print (p, closure)
+ Node *p;
+ void *closure;
+{
+ struct log_data_and_rcs *data = (struct log_data_and_rcs *) closure;
+ Node *pv;
+
+ pv = findnode (data->rcs->versions, p->key);
+ if (pv == NULL)
+ error (1, 0, "missing version `%s' in RCS file `%s'",
+ p->key, data->rcs->path);
+ if (log_version_requested (data->log_data, data->revlist, data->rcs,
+ (RCSVers *) pv->data))
+ return 1;
+ else
+ return 0;
+}
+
+/*
+ * Print the list of changes, not including the trunk, in reverse
+ * order for each branch.
+ */
+static void
+log_tree (log_data, revlist, rcs, ver)
+ struct log_data *log_data;
+ struct revlist *revlist;
+ RCSNode *rcs;
+ const char *ver;
+{
+ Node *p;
+ RCSVers *vnode;
+
+ p = findnode (rcs->versions, ver);
+ if (p == NULL)
+ error (1, 0, "missing version `%s' in RCS file `%s'",
+ ver, rcs->path);
+ vnode = (RCSVers *) p->data;
+ if (vnode->next != NULL)
+ log_tree (log_data, revlist, rcs, vnode->next);
+ if (vnode->branches != NULL)
+ {
+ Node *head, *branch;
+
+ /* We need to do the branches in reverse order. This breaks
+ the List abstraction, but so does most of the branch
+ manipulation in rcs.c. */
+ head = vnode->branches->list;
+ for (branch = head->prev; branch != head; branch = branch->prev)
+ {
+ log_abranch (log_data, revlist, rcs, branch->key);
+ log_tree (log_data, revlist, rcs, branch->key);
+ }
+ }
+}
+
+/*
+ * Log the changes for a branch, in reverse order.
+ */
+static void
+log_abranch (log_data, revlist, rcs, ver)
+ struct log_data *log_data;
+ struct revlist *revlist;
+ RCSNode *rcs;
+ const char *ver;
+{
+ Node *p;
+ RCSVers *vnode;
+
+ p = findnode (rcs->versions, ver);
+ if (p == NULL)
+ error (1, 0, "missing version `%s' in RCS file `%s'",
+ ver, rcs->path);
+ vnode = (RCSVers *) p->data;
+ if (vnode->next != NULL)
+ log_abranch (log_data, revlist, rcs, vnode->next);
+ log_version (log_data, revlist, rcs, vnode, 0);
+}
+
+/*
+ * Print the log output for a single version.
+ */
+static void
+log_version (log_data, revlist, rcs, ver, trunk)
+ struct log_data *log_data;
+ struct revlist *revlist;
+ RCSNode *rcs;
+ RCSVers *ver;
+ int trunk;
+{
+ Node *p;
+ int year, mon, mday, hour, min, sec;
+ char buf[100];
+ Node *padd, *pdel;
+
+ if (! log_version_requested (log_data, revlist, rcs, ver))
+ return;
+
+ cvs_output ("----------------------------\nrevision ", 0);
+ cvs_output (ver->version, 0);
+
+ p = findnode (ver->other, ";locker");
+ if (p != NULL)
+ {
+ cvs_output ("\tlocked by: ", 0);
+ cvs_output (p->data, 0);
+ cvs_output (";", 1);
+ }
+
+ cvs_output ("\ndate: ", 0);
+ (void) sscanf (ver->date, SDATEFORM, &year, &mon, &mday, &hour, &min,
+ &sec);
+ if (year < 1900)
+ year += 1900;
+ sprintf (buf, "%04d/%02d/%02d %02d:%02d:%02d", year, mon, mday,
+ hour, min, sec);
+ cvs_output (buf, 0);
+
+ cvs_output ("; author: ", 0);
+ cvs_output (ver->author, 0);
+
+ cvs_output ("; state: ", 0);
+ cvs_output (ver->state, 0);
+ cvs_output (";", 1);
+
+ if (! trunk)
+ {
+ padd = findnode (ver->other, ";add");
+ pdel = findnode (ver->other, ";delete");
+ }
+ else if (ver->next == NULL)
+ {
+ padd = NULL;
+ pdel = NULL;
+ }
+ else
+ {
+ Node *nextp;
+ RCSVers *nextver;
+
+ nextp = findnode (rcs->versions, ver->next);
+ if (nextp == NULL)
+ error (1, 0, "missing version `%s' in `%s'", ver->next,
+ rcs->path);
+ nextver = (RCSVers *) nextp->data;
+ pdel = findnode (nextver->other, ";add");
+ padd = findnode (nextver->other, ";delete");
+ }
+
+ if (padd != NULL)
+ {
+ cvs_output (" lines: +", 0);
+ cvs_output (padd->data, 0);
+ cvs_output (" -", 2);
+ cvs_output (pdel->data, 0);
+ }
+
+ if (ver->branches != NULL)
{
- int i;
- for (i = 1; i < ac && av[i][0] == '-'; i++)
- if (av[i][1] != 'l')
- run_arg (av[i]);
+ cvs_output ("\nbranches:", 0);
+ walklist (ver->branches, log_branch, (void *) NULL);
}
- run_arg (rcsfile->path);
- if (*finfo->update_dir)
+ cvs_output ("\n", 1);
+
+ p = findnode (ver->other, "log");
+ if (p == NULL || p->data[0] == '\0')
+ cvs_output ("*** empty log message ***\n", 0);
+ else
{
- char *workfile = xmalloc (strlen (finfo->update_dir) + strlen (finfo->file) + 2);
- sprintf (workfile, "%s/%s", finfo->update_dir, finfo->file);
- run_arg (workfile);
- free (workfile);
+ /* FIXME: Technically, the log message could contain a null
+ byte. */
+ cvs_output (p->data, 0);
+ if (p->data[strlen (p->data) - 1] != '\n')
+ cvs_output ("\n", 1);
}
+}
- if ((retcode = run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_REALLY)) == -1)
+/*
+ * Output a branch version. This is called via walklist.
+ */
+/*ARGSUSED*/
+static int
+log_branch (p, closure)
+ Node *p;
+ void *closure;
+{
+ cvs_output (" ", 2);
+ if ((numdots (p->key) & 1) == 0)
+ cvs_output (p->key, 0);
+ else
{
- error (1, errno, "fork failed for rlog on %s", finfo->file);
+ char *f, *cp;
+
+ f = xstrdup (p->key);
+ cp = strrchr (f, '.');
+ *cp = '\0';
+ cvs_output (f, 0);
+ free (f);
}
- return (retcode);
+ cvs_output (";", 1);
+ return 0;
}
/*
@@ -149,10 +1384,12 @@ log_fileproc (finfo)
*/
/* ARGSUSED */
static Dtype
-log_dirproc (dir, repository, update_dir)
+log_dirproc (callerdat, dir, repository, update_dir, entries)
+ void *callerdat;
char *dir;
char *repository;
char *update_dir;
+ List *entries;
{
if (!isdir (dir))
return (R_SKIP_ALL);
@@ -161,3 +1398,52 @@ log_dirproc (dir, repository, update_dir)
error (0, 0, "Logging %s", update_dir);
return (R_PROCESS);
}
+
+/*
+ * Compare versions. This is taken from RCS compartial.
+ */
+static int
+version_compare (v1, v2, len)
+ const char *v1;
+ const char *v2;
+ int len;
+{
+ while (1)
+ {
+ int d1, d2, r;
+
+ if (*v1 == '\0')
+ return 1;
+ if (*v2 == '\0')
+ return -1;
+
+ while (*v1 == '0')
+ ++v1;
+ for (d1 = 0; isdigit (v1[d1]); ++d1)
+ ;
+
+ while (*v2 == '0')
+ ++v2;
+ for (d2 = 0; isdigit (v2[d2]); ++d2)
+ ;
+
+ if (d1 != d2)
+ return d1 < d2 ? -1 : 1;
+
+ r = memcmp (v1, v2, d1);
+ if (r != 0)
+ return r;
+
+ --len;
+ if (len == 0)
+ return 0;
+
+ v1 += d1;
+ v2 += d1;
+
+ if (*v1 == '.')
+ ++v1;
+ if (*v2 == '.')
+ ++v2;
+ }
+}
diff --git a/contrib/cvs/src/login.c b/contrib/cvs/src/login.c
index fc3a178..cc277a6 100644
--- a/contrib/cvs/src/login.c
+++ b/contrib/cvs/src/login.c
@@ -12,7 +12,16 @@
#ifdef AUTH_CLIENT_SUPPORT /* This covers the rest of the file. */
+/* There seems to be very little agreement on which system header
+ getpass is declared in. With a lot of fancy autoconfiscation,
+ we could perhaps detect this, but for now we'll just rely on
+ _CRAY, since Cray is perhaps the only system on which our own
+ declaration won't work (some Crays declare the 2#$@% thing as
+ varadic, believe it or not). On Cray, getpass will be declared
+ in either stdlib.h or unistd.h. */
+#ifndef _CRAY
extern char *getpass ();
+#endif
#ifndef CVS_PASSWORD_FILE
#define CVS_PASSWORD_FILE ".cvspass"
@@ -21,40 +30,53 @@ extern char *getpass ();
/* If non-NULL, get_cvs_password() will just return this. */
static char *cvs_password = NULL;
+static char *construct_cvspass_filename PROTO ((void));
+
/* The return value will need to be freed. */
-char *
+static char *
construct_cvspass_filename ()
{
- char *homedir;
- char *passfile;
+ char *homedir;
+ char *passfile;
- /* Environment should override file. */
- if ((passfile = getenv ("CVS_PASSFILE")) != NULL)
- return xstrdup (passfile);
+ /* Environment should override file. */
+ if ((passfile = getenv ("CVS_PASSFILE")) != NULL)
+ return xstrdup (passfile);
- /* Construct absolute pathname to user's password file. */
- /* todo: does this work under OS/2 ? */
- homedir = get_homedir ();
- if (! homedir)
+ /* Construct absolute pathname to user's password file. */
+ /* todo: does this work under OS/2 ? */
+ homedir = get_homedir ();
+ if (! homedir)
{
- error (1, errno, "could not find out home directory");
- return (char *) NULL;
+ error (1, errno, "could not find out home directory");
+ return (char *) NULL;
}
-
- passfile =
- (char *) xmalloc (strlen (homedir) + strlen (CVS_PASSWORD_FILE) + 3);
- strcpy (passfile, homedir);
- strcat (passfile, "/");
- strcat (passfile, CVS_PASSWORD_FILE);
-
- /* Safety first and last, Scouts. */
- if (isfile (passfile))
- /* xchmod() is too polite. */
- chmod (passfile, 0600);
- return passfile;
+ passfile =
+ (char *) xmalloc (strlen (homedir) + strlen (CVS_PASSWORD_FILE) + 3);
+ strcpy (passfile, homedir);
+#ifndef NO_SLASH_AFTER_HOME
+ /* NO_SLASH_AFTER_HOME is defined for VMS, where foo:[bar]/.cvspass is not
+ a legal filename but foo:[bar].cvspass is. A more clean solution would
+ be something more along the lines of a "join a directory to a filename"
+ kind of thing.... */
+ strcat (passfile, "/");
+#endif
+ strcat (passfile, CVS_PASSWORD_FILE);
+
+ /* Safety first and last, Scouts. */
+ if (isfile (passfile))
+ /* xchmod() is too polite. */
+ chmod (passfile, 0600);
+
+ return passfile;
}
+static const char *const login_usage[] =
+{
+ "Usage: %s %s\n",
+ NULL
+};
/* Prompt for a password, and store it in the file "CVS/.cvspass".
*
@@ -84,309 +106,354 @@ login (argc, argv)
int argc;
char **argv;
{
- char *passfile;
- FILE *fp;
- char *typed_password, *found_password;
- char *linebuf = (char *) NULL;
- size_t linebuf_len;
- int root_len, already_entered = 0;
-
- /* Make this a "fully-qualified" CVSroot if necessary. */
- if (! strchr (CVSroot, '@'))
- {
- /* We need to prepend "user@host:". */
- char *tmp;
+ char *passfile;
+ FILE *fp;
+ char *typed_password, *found_password;
+ char *linebuf = (char *) NULL;
+ size_t linebuf_len;
+ int root_len, already_entered = 0;
- printf ("Repository \"%s\" not fully-qualified.\n", CVSroot);
- printf ("Please enter \"user@host:/path\": ");
- fflush (stdout);
- getline (&linebuf, &linebuf_len, stdin);
+ if (argc < 0)
+ usage (login_usage);
- tmp = xmalloc (strlen (linebuf) + 1);
-
- /* Give it some permanent storage. */
- strcpy (tmp, linebuf);
- tmp[strlen (linebuf) - 1] = '\0';
- CVSroot = tmp;
-
- /* Reset. */
- free (linebuf);
- linebuf = (char *) NULL;
+ if (CVSroot_method != pserver_method)
+ {
+ error (0, 0, "can only use pserver method with `login' command");
+ error (1, 0, "CVSROOT: %s", CVSroot_original);
}
-
- if (CVSroot[0] != ':')
+
+ if (! CVSroot_username)
{
- /* Then we need to prepend ":pserver:". */
- char *tmp;
-
- tmp = xmalloc (strlen (":pserver:") + strlen (CVSroot) + 1);
- strcpy (tmp, ":pserver:");
- strcat (tmp, CVSroot);
- CVSroot = tmp;
+ error (0, 0, "CVSROOT \"%s\" is not fully-qualified.",
+ CVSroot_original);
+ error (1, 0, "Please make sure to specify \"user@host\"!");
}
- /* Check to make sure it's fully-qualified before going on.
- * Fully qualified in this context means it has both a user and a
- * host:repos portion.
- */
- {
- char *r;
-
- /* After confirming that CVSroot is non-NULL, we skip past the
- initial ":pserver:" to test the rest of it. */
-
- if (! CVSroot)
- error (1, 0, "CVSroot is NULL");
- else if (! strchr ((r = (CVSroot + strlen (":pserver:"))), '@'))
- goto not_fqrn;
- else if (! strchr (r, ':'))
- goto not_fqrn;
-
- if (0) /* Lovely. */
- {
- not_fqrn:
- error (0, 0, "CVSroot not fully-qualified: %s", CVSroot);
- error (1, 0, "should be format user@host:/path/to/repository");
- }
- }
-
- /* CVSroot is now fully qualified and has ":pserver:" prepended.
- We'll print out most of it so user knows exactly what is being
- dealt with here. */
- {
- char *s;
- s = strchr (CVSroot, ':');
- s++;
- s = strchr (s, ':');
- s++;
-
- if (s == NULL)
- error (1, 0, "NULL CVSroot");
-
- printf ("(Logging in to %s)\n", s);
+ printf ("(Logging in to %s@%s)\n", CVSroot_username, CVSroot_hostname);
fflush (stdout);
- }
- passfile = construct_cvspass_filename ();
- typed_password = getpass ("CVS password: ");
- typed_password = scramble (typed_password);
+ passfile = construct_cvspass_filename ();
+ typed_password = getpass ("CVS password: ");
+ typed_password = scramble (typed_password);
- /* Force get_cvs_password() to use this one (when the client
- * confirms the new password with the server), instead of consulting
- * the file. We make a new copy because cvs_password will get
- * zeroed by connect_to_server().
- */
- cvs_password = xstrdup (typed_password);
+ /* Force get_cvs_password() to use this one (when the client
+ * confirms the new password with the server), instead of
+ * consulting the file. We make a new copy because cvs_password
+ * will get zeroed by connect_to_server(). */
- if (connect_to_pserver (NULL, NULL, 1) == 0)
+ cvs_password = xstrdup (typed_password);
+
+ if (connect_to_pserver (NULL, NULL, 1) == 0)
{
- /* The password is wrong, according to the server. */
- error (1, 0, "incorrect password");
+ /* The password is wrong, according to the server. */
+ error (1, 0, "incorrect password");
}
- /* IF we have a password for this "[user@]host:/path" already
- * THEN
- * IF it's the same as the password we read from the prompt
- * THEN
- * do nothing
- * ELSE
- * replace the old password with the new one
- * ELSE
- * append new entry to the end of the file.
- */
-
- root_len = strlen (CVSroot);
-
- /* Yes, the method below reads the user's password file twice. It's
- inefficient, but we're not talking about a gig of data here. */
-
- fp = fopen (passfile, "r");
- /* FIXME: should be printing a message if fp == NULL and not
- existence_error (errno). */
- if (fp != NULL)
+ /* IF we have a password for this "[user@]host:/path" already
+ * THEN
+ * IF it's the same as the password we read from the prompt
+ * THEN
+ * do nothing
+ * ELSE
+ * replace the old password with the new one
+ * ELSE
+ * append new entry to the end of the file.
+ */
+
+ root_len = strlen (CVSroot_original);
+
+ /* Yes, the method below reads the user's password file twice. It's
+ inefficient, but we're not talking about a gig of data here. */
+
+ fp = CVS_FOPEN (passfile, "r");
+ /* FIXME: should be printing a message if fp == NULL and not
+ existence_error (errno). */
+ if (fp != NULL)
{
- /* Check each line to see if we have this entry already. */
- while (getline (&linebuf, &linebuf_len, fp) >= 0)
+ /* Check each line to see if we have this entry already. */
+ while (getline (&linebuf, &linebuf_len, fp) >= 0)
{
- if (strncmp (CVSroot, linebuf, root_len) == 0)
- {
- already_entered = 1;
- break;
- }
- else
+ if (strncmp (CVSroot_original, linebuf, root_len) == 0)
{
- free (linebuf);
- linebuf = (char *) NULL;
+ already_entered = 1;
+ break;
}
}
- fclose (fp);
+ fclose (fp);
}
-
- if (already_entered)
+
+ if (already_entered)
{
- /* This user/host has a password in the file already. */
+ /* This user/host has a password in the file already. */
- strtok (linebuf, " ");
- found_password = strtok (NULL, "\n");
- if (strcmp (found_password, typed_password))
+ strtok (linebuf, " ");
+ found_password = strtok (NULL, "\n");
+ if (strcmp (found_password, typed_password))
{
- /* typed_password and found_password don't match, so we'll
- * have to update passfile. We replace the old password
- * with the new one by writing a tmp file whose contents are
- * exactly the same as passfile except that this one entry
- * gets typed_password instead of found_password. Then we
- * rename the tmp file on top of passfile.
- */
- char *tmp_name;
- FILE *tmp_fp;
-
- tmp_name = tmpnam (NULL);
- if ((tmp_fp = fopen (tmp_name, "w")) == NULL)
+ /* typed_password and found_password don't match, so we'll
+ * have to update passfile. We replace the old password
+ * with the new one by writing a tmp file whose contents are
+ * exactly the same as passfile except that this one entry
+ * gets typed_password instead of found_password. Then we
+ * rename the tmp file on top of passfile.
+ */
+ char *tmp_name;
+ FILE *tmp_fp;
+
+ tmp_name = cvs_temp_name ();
+ if ((tmp_fp = CVS_FOPEN (tmp_name, "w")) == NULL)
{
- error (1, errno, "unable to open temp file %s", tmp_name);
- return 1;
+ error (1, errno, "unable to open temp file %s", tmp_name);
+ return 1;
}
- chmod (tmp_name, 0600);
+ chmod (tmp_name, 0600);
- fp = fopen (passfile, "r");
- if (fp == NULL)
+ fp = CVS_FOPEN (passfile, "r");
+ if (fp == NULL)
{
- error (1, errno, "unable to open %s", passfile);
- return 1;
+ error (1, errno, "unable to open %s", passfile);
+ if (linebuf)
+ free (linebuf);
+ return 1;
}
- /* I'm not paranoid, they really ARE out to get me: */
- chmod (passfile, 0600);
+ /* I'm not paranoid, they really ARE out to get me: */
+ chmod (passfile, 0600);
- free (linebuf);
- linebuf = (char *) NULL;
- while (getline (&linebuf, &linebuf_len, fp) >= 0)
+ while (getline (&linebuf, &linebuf_len, fp) >= 0)
{
- if (strncmp (CVSroot, linebuf, root_len))
- fprintf (tmp_fp, "%s", linebuf);
- else
- fprintf (tmp_fp, "%s %s\n", CVSroot, typed_password);
+ if (strncmp (CVSroot_original, linebuf, root_len))
+ fprintf (tmp_fp, "%s", linebuf);
+ else
+ fprintf (tmp_fp, "%s %s\n", CVSroot_original,
+ typed_password);
- free (linebuf);
- linebuf = (char *) NULL;
}
- fclose (tmp_fp);
- fclose (fp);
- rename_file (tmp_name, passfile);
- chmod (passfile, 0600);
+ if (linebuf)
+ free (linebuf);
+ fclose (tmp_fp);
+ fclose (fp);
+ copy_file (tmp_name, passfile);
+ unlink_file (tmp_name);
+ chmod (passfile, 0600);
+ free (tmp_name);
}
}
- else
+ else
{
- if ((fp = fopen (passfile, "a")) == NULL)
+ if (linebuf)
+ free (linebuf);
+ if ((fp = CVS_FOPEN (passfile, "a")) == NULL)
{
- error (1, errno, "could not open %s", passfile);
- free (passfile);
- return 1;
+ error (1, errno, "could not open %s", passfile);
+ free (passfile);
+ return 1;
}
- fprintf (fp, "%s %s\n", CVSroot, typed_password);
- fclose (fp);
+ fprintf (fp, "%s %s\n", CVSroot_original, typed_password);
+ fclose (fp);
}
- /* Utter, total, raving paranoia, I know. */
- chmod (passfile, 0600);
- memset (typed_password, 0, strlen (typed_password));
- free (typed_password);
+ /* Utter, total, raving paranoia, I know. */
+ chmod (passfile, 0600);
+ memset (typed_password, 0, strlen (typed_password));
+ free (typed_password);
- free (passfile);
- free (cvs_password);
- cvs_password = NULL;
- return 0;
+ free (passfile);
+ free (cvs_password);
+ cvs_password = NULL;
+ return 0;
}
-/* todo: "cvs logout" could erase an entry from the file.
- * But to what purpose?
- */
-
/* Returns the _scrambled_ password. The server must descramble
before hashing and comparing. */
char *
get_cvs_password ()
{
- int found_it = 0;
- int root_len;
- char *password;
- char *linebuf = (char *) NULL;
- size_t linebuf_len;
- FILE *fp;
- char *passfile;
-
- /* If someone (i.e., login()) is calling connect_to_pserver() out of
- context, then assume they have supplied the correct, scrambled
- password. */
- if (cvs_password)
- return cvs_password;
-
- /* Environment should override file. */
- if ((password = getenv ("CVS_PASSWORD")) != NULL)
+ int found_it = 0;
+ int root_len;
+ char *password;
+ char *linebuf = (char *) NULL;
+ size_t linebuf_len;
+ FILE *fp;
+ char *passfile;
+
+ /* If someone (i.e., login()) is calling connect_to_pserver() out of
+ context, then assume they have supplied the correct, scrambled
+ password. */
+ if (cvs_password)
+ return cvs_password;
+
+ if (getenv ("CVS_PASSWORD") != NULL)
+ {
+ /* In previous versions of CVS one could specify a password in
+ CVS_PASSWORD. This is a bad idea, because in BSD variants
+ of unix anyone can see the environment variable with 'ps'.
+ But for users who were using that feature we want to at
+ least let them know what is going on. After printing this
+ warning, we should fall through to the regular error where
+ we tell them to run "cvs login" (unless they already ran
+ it, of course). */
+ error (0, 0, "CVS_PASSWORD is no longer supported; ignored");
+ }
+
+ /* Else get it from the file. First make sure that the CVSROOT
+ variable has the appropriate fields filled in. */
+
+ if (CVSroot_method != pserver_method)
+ {
+ error (0, 0, "can only call GET_CVS_PASSWORD with pserver method");
+ error (1, 0, "CVSROOT: %s", CVSroot_original);
+ }
+
+ if (! CVSroot_username)
{
- char *p;
- p = xstrdup (password);
- /* If we got it from the environment, then it wasn't properly
- scrambled. Since unscrambling is done on the server side, we
- need to transmit it scrambled. */
- p = scramble (p);
- return p;
+ error (0, 0, "CVSROOT \"%s\" is not fully-qualified.",
+ CVSroot_original);
+ error (1, 0, "Please make sure to specify \"user@host\"!");
}
- /* Else get it from the file. */
- passfile = construct_cvspass_filename ();
- fp = fopen (passfile, "r");
- if (fp == NULL)
+ passfile = construct_cvspass_filename ();
+ fp = CVS_FOPEN (passfile, "r");
+ if (fp == NULL)
{
- error (0, errno, "could not open %s", passfile);
- free (passfile);
- error (1, 0, "use \"cvs login\" to log in first");
+ error (0, errno, "could not open %s", passfile);
+ free (passfile);
+ error (1, 0, "use \"cvs login\" to log in first");
}
- root_len = strlen (CVSroot);
+ root_len = strlen (CVSroot_original);
- /* Check each line to see if we have this entry already. */
- while (getline (&linebuf, &linebuf_len, fp) >= 0)
+ /* Check each line to see if we have this entry already. */
+ while (getline (&linebuf, &linebuf_len, fp) >= 0)
{
- if (strncmp (CVSroot, linebuf, root_len) == 0)
- {
- /* This is it! So break out and deal with linebuf. */
- found_it = 1;
- break;
- }
- else
+ if (strncmp (CVSroot_original, linebuf, root_len) == 0)
{
- free (linebuf);
- linebuf = (char *) NULL;
+ /* This is it! So break out and deal with linebuf. */
+ found_it = 1;
+ break;
}
}
- if (found_it)
+ if (found_it)
{
- /* linebuf now contains the line with the password. */
- char *tmp;
-
- strtok (linebuf, " ");
- password = strtok (NULL, "\n");
-
- /* Give it permanent storage. */
- tmp = xmalloc (strlen (password) + 1);
- strcpy (tmp, password);
- tmp[strlen (password)] = '\0';
- memset (password, 0, strlen (password));
- free (linebuf);
- return tmp;
+ /* linebuf now contains the line with the password. */
+ char *tmp;
+
+ strtok (linebuf, " ");
+ password = strtok (NULL, "\n");
+
+ /* Give it permanent storage. */
+ tmp = xstrdup (password);
+ memset (password, 0, strlen (password));
+ free (linebuf);
+ return tmp;
}
- else
+ else
{
- error (0, 0, "cannot find password");
- error (0, 0, "use \"cvs login\" to log in first");
- error (1, 0, "or set the CVS_PASSWORD environment variable");
+ if (linebuf)
+ free (linebuf);
+ error (0, 0, "cannot find password");
+ error (1, 0, "use \"cvs login\" to log in first");
}
- /* NOTREACHED */
- return NULL;
+ /* NOTREACHED */
+ return NULL;
}
-#endif /* AUTH_CLIENT_SUPPORT from beginning of file. */
+static const char *const logout_usage[] =
+{
+ "Usage: %s %s\n",
+ NULL
+};
+
+/* Remove any entry for the CVSRoot repository found in "CVS/.cvspass". */
+int
+logout (argc, argv)
+ int argc;
+ char **argv;
+{
+ char *passfile;
+ FILE *fp;
+ char *tmp_name;
+ FILE *tmp_fp;
+ char *linebuf = (char *) NULL;
+ size_t linebuf_len;
+ int root_len, found = 0;
+
+ if (argc < 0)
+ usage (logout_usage);
+
+ if (CVSroot_method != pserver_method)
+ {
+ error (0, 0, "can only use pserver method with `logout' command");
+ error (1, 0, "CVSROOT: %s", CVSroot_original);
+ }
+
+ if (! CVSroot_username)
+ {
+ error (0, 0, "CVSROOT \"%s\" is not fully-qualified.",
+ CVSroot_original);
+ error (1, 0, "Please make sure to specify \"user@host\"!");
+ }
+
+ /* Hmm. Do we want a variant of this command which deletes _all_
+ the entries from the current .cvspass? Might be easier to
+ remember than "rm ~/.cvspass" but then again if people are
+ mucking with HOME (common in Win95 as the system doesn't set
+ it), then this variant of "cvs logout" might give a false sense
+ of security, in that it wouldn't delete entries from any
+ .cvspass files but the current one. */
+
+ printf ("(Logging out of %s@%s)\n", CVSroot_username, CVSroot_hostname);
+ fflush (stdout);
+ /* IF we have a password for this "[user@]host:/path" already
+ * THEN
+ * drop the entry
+ * ELSE
+ * do nothing
+ */
+
+ passfile = construct_cvspass_filename ();
+ tmp_name = cvs_temp_name ();
+ if ((tmp_fp = CVS_FOPEN (tmp_name, "w")) == NULL)
+ {
+ error (1, errno, "unable to open temp file %s", tmp_name);
+ return 1;
+ }
+ chmod (tmp_name, 0600);
+
+ root_len = strlen (CVSroot_original);
+
+ fp = CVS_FOPEN (passfile, "r");
+ if (fp == NULL)
+ error (1, errno, "Error opening %s", passfile);
+
+ /* Check each line to see if we have this entry. */
+ /* Copy only those lines that do not match this entry */
+ while (getline (&linebuf, &linebuf_len, fp) >= 0)
+ {
+ if (strncmp (CVSroot_original, linebuf, root_len))
+ fprintf (tmp_fp, "%s", linebuf);
+ else
+ found = TRUE;
+ }
+ if (linebuf)
+ free (linebuf);
+ fclose (fp);
+ fclose (tmp_fp);
+
+ if (! found)
+ {
+ printf ("Entry not found for %s\n", CVSroot_original);
+ unlink_file (tmp_name);
+ }
+ else
+ {
+ copy_file (tmp_name, passfile);
+ unlink_file (tmp_name);
+ chmod (passfile, 0600);
+ }
+ return 0;
+}
+
+#endif /* AUTH_CLIENT_SUPPORT from beginning of file. */
diff --git a/contrib/cvs/src/logmsg.c b/contrib/cvs/src/logmsg.c
index 370ceab..98e4ae1 100644
--- a/contrib/cvs/src/logmsg.c
+++ b/contrib/cvs/src/logmsg.c
@@ -11,18 +11,20 @@
static int find_type PROTO((Node * p, void *closure));
static int fmt_proc PROTO((Node * p, void *closure));
-static int logfile_write PROTO((char *repository, char *filter, char *title,
- char *message, char *revision, FILE * logfp,
- List * changes));
+static int logfile_write PROTO((char *repository, char *filter,
+ char *message, FILE * logfp, List * changes));
static int rcsinfo_proc PROTO((char *repository, char *template));
static int title_proc PROTO((Node * p, void *closure));
static int update_logfile_proc PROTO((char *repository, char *filter));
static void setup_tmpfile PROTO((FILE * xfp, char *xprefix, List * changes));
static int editinfo_proc PROTO((char *repository, char *template));
+static int verifymsg_proc PROTO((char *repository, char *script));
static FILE *fp;
static char *str_list;
+static char *str_list_format; /* The format for str_list's contents. */
static char *editinfo_editor;
+static char *verifymsg_script;
static Ctype type;
/*
@@ -31,6 +33,7 @@ static Ctype type;
* and removed files are included (if any) and formatted to look pretty. */
static char *prefix;
static int col;
+static char *tag;
static void
setup_tmpfile (xfp, xprefix, changes)
FILE *xfp;
@@ -45,28 +48,40 @@ setup_tmpfile (xfp, xprefix, changes)
if (walklist (changes, find_type, NULL) != 0)
{
(void) fprintf (fp, "%sModified Files:\n", prefix);
- (void) fprintf (fp, "%s\t", prefix);
- col = 8;
+ col = 0;
(void) walklist (changes, fmt_proc, NULL);
(void) fprintf (fp, "\n");
+ if (tag != NULL)
+ {
+ free (tag);
+ tag = NULL;
+ }
}
type = T_ADDED;
if (walklist (changes, find_type, NULL) != 0)
{
(void) fprintf (fp, "%sAdded Files:\n", prefix);
- (void) fprintf (fp, "%s\t", prefix);
- col = 8;
+ col = 0;
(void) walklist (changes, fmt_proc, NULL);
(void) fprintf (fp, "\n");
+ if (tag != NULL)
+ {
+ free (tag);
+ tag = NULL;
+ }
}
type = T_REMOVED;
if (walklist (changes, find_type, NULL) != 0)
{
(void) fprintf (fp, "%sRemoved Files:\n", prefix);
- (void) fprintf (fp, "%s\t", prefix);
- col = 8;
+ col = 0;
(void) walklist (changes, fmt_proc, NULL);
(void) fprintf (fp, "\n");
+ if (tag != NULL)
+ {
+ free (tag);
+ tag = NULL;
+ }
}
}
@@ -78,7 +93,10 @@ find_type (p, closure)
Node *p;
void *closure;
{
- if (p->data == (char *) type)
+ struct logfile_info *li;
+
+ li = (struct logfile_info *) p->data;
+ if (li->type == type)
return (1);
else
return (0);
@@ -94,9 +112,44 @@ fmt_proc (p, closure)
Node *p;
void *closure;
{
- if (p->data == (char *) type)
+ struct logfile_info *li;
+
+ li = (struct logfile_info *) p->data;
+ if (li->type == type)
{
- if ((col + (int) strlen (p->key)) > 70)
+ if (li->tag == NULL
+ ? tag != NULL
+ : tag == NULL || strcmp (tag, li->tag) != 0)
+ {
+ if (col > 0)
+ (void) fprintf (fp, "\n");
+ (void) fprintf (fp, "%s", prefix);
+ col = strlen (prefix);
+ while (col < 6)
+ {
+ (void) fprintf (fp, " ");
+ ++col;
+ }
+
+ if (li->tag == NULL)
+ (void) fprintf (fp, "No tag");
+ else
+ (void) fprintf (fp, "Tag: %s", li->tag);
+
+ if (tag != NULL)
+ free (tag);
+ tag = xstrdup (li->tag);
+
+ /* Force a new line. */
+ col = 70;
+ }
+
+ if (col == 0)
+ {
+ (void) fprintf (fp, "%s\t", prefix);
+ col = 8;
+ }
+ else if (col > 8 && (col + (int) strlen (p->key)) > 70)
{
(void) fprintf (fp, "\n%s\t", prefix);
col = 8;
@@ -126,7 +179,7 @@ do_editor (dir, messagep, repository, changes)
char *line;
int line_length;
size_t line_chars_allocated;
- char fname[L_tmpnam+1];
+ char *fname;
struct stat pre_stbuf, post_stbuf;
int retcode = 0;
char *p;
@@ -138,17 +191,19 @@ do_editor (dir, messagep, repository, changes)
if (strcmp (Editor, "") == 0 && !editinfo_editor)
error(1, 0, "no editor defined, must use -e or -m");
+
/* Create a temporary file */
- (void) tmpnam (fname);
+ fname = cvs_temp_name ();
again:
- if ((fp = fopen (fname, "w+")) == NULL)
+ if ((fp = CVS_FOPEN (fname, "w+")) == NULL)
error (1, 0, "cannot create temporary file %s", fname);
if (*messagep)
{
(void) fprintf (fp, "%s", *messagep);
- if ((*messagep)[strlen (*messagep) - 1] != '\n')
+ if ((*messagep)[0] == '\0' ||
+ (*messagep)[strlen (*messagep) - 1] != '\n')
(void) fprintf (fp, "\n");
}
else
@@ -166,7 +221,7 @@ do_editor (dir, messagep, repository, changes)
size_t nwrite;
/* Why "b"? */
- tfp = fopen (CVSADM_TEMPLATE, "rb");
+ tfp = CVS_FOPEN (CVSADM_TEMPLATE, "rb");
if (tfp == NULL)
{
if (!existence_error (errno))
@@ -197,8 +252,9 @@ do_editor (dir, messagep, repository, changes)
"%s----------------------------------------------------------------------\n",
CVSEDITPREFIX);
(void) fprintf (fp,
- "%sEnter Log. Lines beginning with `%s' are removed automatically\n%s\n",
- CVSEDITPREFIX, CVSEDITPREFIX, CVSEDITPREFIX);
+ "%sEnter Log. Lines beginning with `%.*s' are removed automatically\n%s\n",
+ CVSEDITPREFIX, CVSEDITPREFIXLEN, CVSEDITPREFIX,
+ CVSEDITPREFIX);
if (dir != NULL && *dir)
(void) fprintf (fp, "%sCommitting in %s\n%s\n", CVSEDITPREFIX,
dir, CVSEDITPREFIX);
@@ -211,12 +267,17 @@ do_editor (dir, messagep, repository, changes)
/* finish off the temp file */
if (fclose (fp) == EOF)
error (1, errno, "%s", fname);
- if (stat (fname, &pre_stbuf) == -1)
+ if ( CVS_STAT (fname, &pre_stbuf) == -1)
pre_stbuf.st_mtime = 0;
if (editinfo_editor)
free (editinfo_editor);
editinfo_editor = (char *) NULL;
+#ifdef CLIENT_SUPPORT
+ if (client_active)
+ ; /* nothing, leave editinfo_editor NULL */
+ else
+#endif
if (repository != NULL)
(void) Parse_Info (CVSROOTADM_EDITINFO, repository, editinfo_proc, 0);
@@ -236,7 +297,7 @@ do_editor (dir, messagep, repository, changes)
if (*messagep)
free (*messagep);
- if (stat (fname, &post_stbuf) != 0)
+ if ( CVS_STAT (fname, &post_stbuf) != 0)
error (1, errno, "cannot find size of temp file %s", fname);
if (post_stbuf.st_size == 0)
@@ -264,7 +325,7 @@ do_editor (dir, messagep, repository, changes)
error (0, errno, "warning: cannot read %s", fname);
break;
}
- if (strncmp (line, CVSEDITPREFIX, sizeof (CVSEDITPREFIX) - 1) == 0)
+ if (strncmp (line, CVSEDITPREFIX, CVSEDITPREFIXLEN) == 0)
continue;
(void) strcpy (p, line);
p += line_length;
@@ -288,7 +349,11 @@ do_editor (dir, messagep, repository, changes)
|| *line == '\n' || *line == 'c' || *line == 'C')
break;
if (*line == 'a' || *line == 'A')
- error (1, 0, "aborted by user");
+ {
+ if (unlink_file (fname) < 0)
+ error (0, errno, "warning: cannot remove temp file %s", fname);
+ error (1, 0, "aborted by user");
+ }
if (*line == 'e' || *line == 'E')
goto again;
if (*line == '!')
@@ -303,6 +368,85 @@ do_editor (dir, messagep, repository, changes)
free (line);
if (unlink_file (fname) < 0)
error (0, errno, "warning: cannot remove temp file %s", fname);
+ free (fname);
+}
+
+/* Runs the user-defined verification script as part of the commit or import
+ process. This verification is meant to be run whether or not the user
+ included the -m atribute. unlike the do_editor function, this is
+ independant of the running of an editor for getting a message.
+ */
+void
+do_verify (message, repository)
+ char *message;
+ char *repository;
+{
+ FILE *fp;
+ char *fname;
+ int retcode = 0;
+
+#ifdef CLIENT_SUPPORT
+ if (client_active)
+ /* The verification will happen on the server. */
+ return;
+#endif
+
+ /* FIXME? Do we really want to skip this on noexec? What do we do
+ for the other administrative files? */
+ if (noexec)
+ return;
+
+ /* If there's no message, then we have nothing to verify. Can this
+ case happen? And if so why would we print a message? */
+ if (message == NULL)
+ {
+ cvs_output ("No message to verify\n", 0);
+ return;
+ }
+
+ /* Get a temp filename, open a temporary file, write the message to the
+ temp file, and close the file. */
+
+ fname = cvs_temp_name ();
+
+ fp = fopen (fname, "w");
+ if (fp == NULL)
+ {
+ error (1, errno, "cannot create temporary file %s", fname);
+ return;
+ }
+ else
+ {
+ fprintf (fp, "%s", message);
+ if ((message)[0] == '\0' ||
+ (message)[strlen (message) - 1] != '\n')
+ (void) fprintf (fp, "%s", "\n");
+ if (fclose (fp) == EOF)
+ error (1, errno, "%s", fname);
+
+ /* Get the name of the verification script to run */
+
+ if (repository != NULL)
+ (void) Parse_Info (CVSROOTADM_VERIFYMSG, repository,
+ verifymsg_proc, 0);
+
+ /* Run the verification script */
+
+ if (verifymsg_script)
+ {
+ run_setup ("%s", verifymsg_script);
+ run_arg (fname);
+ if ((retcode = run_exec (RUN_TTY, RUN_TTY, RUN_TTY,
+ RUN_NORMAL | RUN_SIGIGNORE)) != 0)
+ error (1, retcode == -1 ? errno : 0,
+ "Message verification failed");
+ }
+
+ /* Close and delete the temp file */
+
+ unlink_file (fname);
+ free (fname);
+ }
}
/*
@@ -326,7 +470,7 @@ rcsinfo_proc (repository, template)
free (last_template);
last_template = xstrdup (template);
- if ((tfp = fopen (template, "r")) != NULL)
+ if ((tfp = CVS_FOPEN (template, "r")) != NULL)
{
char *line = NULL;
size_t line_chars_allocated = 0;
@@ -354,60 +498,28 @@ rcsinfo_proc (repository, template)
* directory in the source repository. The log information is fed into the
* specified program as standard input.
*/
-static char *title;
static FILE *logfp;
static char *message;
-static char *revision;
static List *changes;
void
-Update_Logfile (repository, xmessage, xrevision, xlogfp, xchanges)
+Update_Logfile (repository, xmessage, xlogfp, xchanges)
char *repository;
char *xmessage;
- char *xrevision;
FILE *xlogfp;
List *xchanges;
{
- char *srepos;
-
/* nothing to do if the list is empty */
if (xchanges == NULL || xchanges->list->next == xchanges->list)
return;
/* set up static vars for update_logfile_proc */
message = xmessage;
- revision = xrevision;
logfp = xlogfp;
changes = xchanges;
- /* figure out a good title string */
- srepos = Short_Repository (repository);
-
- /* allocate a chunk of memory to hold the title string */
- if (!str_list)
- str_list = xmalloc (MAXLISTLEN);
- str_list[0] = '\0';
-
- type = T_TITLE;
- (void) walklist (changes, title_proc, NULL);
- type = T_ADDED;
- (void) walklist (changes, title_proc, NULL);
- type = T_MODIFIED;
- (void) walklist (changes, title_proc, NULL);
- type = T_REMOVED;
- (void) walklist (changes, title_proc, NULL);
- title = xmalloc (strlen (srepos) + strlen (str_list) + 1 + 2); /* for 's */
- (void) sprintf (title, "'%s%s'", srepos, str_list);
-
- /* to be nice, free up this chunk of memory */
- free (str_list);
- str_list = (char *) NULL;
-
/* call Parse_Info to do the actual logfile updates */
(void) Parse_Info (CVSROOTADM_LOGINFO, repository, update_logfile_proc, 1);
-
- /* clean up */
- free (title);
}
/*
@@ -418,58 +530,273 @@ update_logfile_proc (repository, filter)
char *repository;
char *filter;
{
- return (logfile_write (repository, filter, title, message, revision,
- logfp, changes));
+ return (logfile_write (repository, filter, message, logfp, changes));
}
/*
- * concatenate each name onto str_list
+ * concatenate each filename/version onto str_list
*/
static int
title_proc (p, closure)
Node *p;
void *closure;
{
- if (p->data == (char *) type)
+ struct logfile_info *li;
+ char *c;
+
+ li = (struct logfile_info *) p->data;
+ if (li->type == type)
{
+ /* Until we decide on the correct logging solution when we add
+ directories or perform imports, T_TITLE nodes will only
+ tack on the name provided, regardless of the format string.
+ You can verify that this assumption is safe by checking the
+ code in add.c (add_directory) and import.c (import). */
+
+ str_list = xrealloc (str_list, strlen (str_list) + 5);
(void) strcat (str_list, " ");
- (void) strcat (str_list, p->key);
+
+ if (li->type == T_TITLE)
+ {
+ str_list = xrealloc (str_list,
+ strlen (str_list) + strlen (p->key) + 5);
+ (void) strcat (str_list, p->key);
+ }
+ else
+ {
+ /* All other nodes use the format string. */
+
+ for (c = str_list_format; *c != '\0'; c++)
+ {
+ switch (*c)
+ {
+ case 's':
+ str_list =
+ xrealloc (str_list,
+ strlen (str_list) + strlen (p->key) + 5);
+ (void) strcat (str_list, p->key);
+ break;
+ case 'V':
+ str_list =
+ xrealloc (str_list,
+ (strlen (str_list)
+ + (li->rev_old ? strlen (li->rev_old) : 0)
+ + 10)
+ );
+ (void) strcat (str_list, (li->rev_old
+ ? li->rev_old : "NONE"));
+ break;
+ case 'v':
+ str_list =
+ xrealloc (str_list,
+ (strlen (str_list)
+ + (li->rev_new ? strlen (li->rev_new) : 0)
+ + 10)
+ );
+ (void) strcat (str_list, (li->rev_new
+ ? li->rev_new : "NONE"));
+ break;
+ /* All other characters, we insert an empty field (but
+ we do put in the comma separating it from other
+ fields). This way if future CVS versions add formatting
+ characters, one can write a loginfo file which at least
+ won't blow up on an old CVS. */
+ }
+ if (*(c + 1) != '\0')
+ {
+ str_list = xrealloc (str_list, strlen (str_list) + 5);
+ (void) strcat (str_list, ",");
+ }
+ }
+ }
}
return (0);
}
/*
- * Since some systems don't define this...
- */
-#ifndef MAXHOSTNAMELEN
-#define MAXHOSTNAMELEN 256
-#endif
-
-/*
* Writes some stuff to the logfile "filter" and returns the status of the
* filter program.
*/
static int
-logfile_write (repository, filter, title, message, revision, logfp, changes)
+logfile_write (repository, filter, message, logfp, changes)
char *repository;
char *filter;
- char *title;
char *message;
- char *revision;
FILE *logfp;
List *changes;
{
- char cwd[PATH_MAX];
FILE *pipefp;
- char *prog = xmalloc (MAXPROGLEN);
+ char *prog;
char *cp;
int c;
int pipestatus;
+ char *fmt_percent; /* the location of the percent sign
+ that starts the format string. */
+
+ /* The user may specify a format string as part of the filter.
+ Originally, `%s' was the only valid string. The string that
+ was substituted for it was:
+
+ <repository-name> <file1> <file2> <file3> ...
+
+ Each file was either a new directory/import (T_TITLE), or a
+ added (T_ADDED), modified (T_MODIFIED), or removed (T_REMOVED)
+ file.
+
+ It is desirable to preserve that behavior so lots of commitlog
+ scripts won't die when they get this new code. At the same
+ time, we'd like to pass other information about the files (like
+ version numbers, statuses, or checkin times).
+
+ The solution is to allow a format string that allows us to
+ specify those other pieces of information. The format string
+ will be composed of `%' followed by a single format character,
+ or followed by a set of format characters surrounded by `{' and
+ `}' as separators. The format characters are:
+
+ s = file name
+ V = old version number (pre-checkin)
+ v = new version number (post-checkin)
+
+ For example, valid format strings are:
+
+ %{}
+ %s
+ %{s}
+ %{sVv}
+
+ There's no reason that more items couldn't be added (like
+ modification date or file status [added, modified, updated,
+ etc.]) -- the code modifications would be minimal (logmsg.c
+ (title_proc) and commit.c (check_fileproc)).
+
+ The output will be a string of tokens separated by spaces. For
+ backwards compatibility, the the first token will be the
+ repository name. The rest of the tokens will be
+ comma-delimited lists of the information requested in the
+ format string. For example, if `/u/src/master' is the
+ repository, `%{sVv}' is the format string, and three files
+ (ChangeLog, Makefile, foo.c) were modified, the output might
+ be:
+
+ /u/src/master ChangeLog,1.1,1.2 Makefile,1.3,1.4 foo.c,1.12,1.13
+
+ Why this duplicates the old behavior when the format string is
+ `%s' is left as an exercise for the reader. */
+
+ fmt_percent = strchr (filter, '%');
+ if (fmt_percent)
+ {
+ int len;
+ char *srepos;
+ char *fmt_begin, *fmt_end; /* beginning and end of the
+ format string specified in
+ filter. */
+ char *fmt_continue; /* where the string continues
+ after the format string (we
+ might skip a '}') somewhere
+ in there... */
+
+ /* Grab the format string. */
+
+ if ((*(fmt_percent + 1) == ' ') || (*(fmt_percent + 1) == '\0'))
+ {
+ /* The percent stands alone. This is an error. We could
+ be treating ' ' like any other formatting character, but
+ using it as a formatting character seems like it would be
+ a mistake. */
+
+ /* Would be nice to also be giving the line number. */
+ error (0, 0, "loginfo: '%%' not followed by formatting character");
+ fmt_begin = fmt_percent + 1;
+ fmt_end = fmt_begin;
+ fmt_continue = fmt_begin;
+ }
+ else if (*(fmt_percent + 1) == '{')
+ {
+ /* The percent has a set of characters following it. */
+
+ fmt_begin = fmt_percent + 2;
+ fmt_end = strchr (fmt_begin, '}');
+ if (fmt_end)
+ {
+ /* Skip over the '}' character. */
+
+ fmt_continue = fmt_end + 1;
+ }
+ else
+ {
+ /* There was no close brace -- assume that format
+ string continues to the end of the line. */
+
+ /* Would be nice to also be giving the line number. */
+ error (0, 0, "loginfo: '}' missing");
+ fmt_end = fmt_begin + strlen (fmt_begin);
+ fmt_continue = fmt_end;
+ }
+ }
+ else
+ {
+ /* The percent has a single character following it. FIXME:
+ %% should expand to a regular percent sign. */
+
+ fmt_begin = fmt_percent + 1;
+ fmt_end = fmt_begin + 1;
+ fmt_continue = fmt_end;
+ }
+
+ len = fmt_end - fmt_begin;
+ str_list_format = xmalloc (sizeof (char) * (len + 1));
+ strncpy (str_list_format, fmt_begin, len);
+ str_list_format[len] = '\0';
+
+ /* Allocate an initial chunk of memory. As we build up the string
+ we will realloc it. */
+ if (!str_list)
+ str_list = xmalloc (1);
+ str_list[0] = '\0';
+
+ /* Add entries to the string. Don't bother looking for
+ entries if the format string is empty. */
+
+ if (str_list_format[0] != '\0')
+ {
+ type = T_TITLE;
+ (void) walklist (changes, title_proc, NULL);
+ type = T_ADDED;
+ (void) walklist (changes, title_proc, NULL);
+ type = T_MODIFIED;
+ (void) walklist (changes, title_proc, NULL);
+ type = T_REMOVED;
+ (void) walklist (changes, title_proc, NULL);
+ }
+
+ /* Construct the final string. */
+
+ srepos = Short_Repository (repository);
+
+ prog = xmalloc ((fmt_percent - filter) + strlen (srepos)
+ + strlen (str_list) + strlen (fmt_continue)
+ + 10);
+ (void) strncpy (prog, filter, fmt_percent - filter);
+ prog[fmt_percent - filter] = '\0';
+ (void) strcat (prog, "'");
+ (void) strcat (prog, srepos);
+ (void) strcat (prog, str_list);
+ (void) strcat (prog, "'");
+ (void) strcat (prog, fmt_continue);
+
+ /* To be nice, free up some memory. */
+
+ free (str_list);
+ str_list = (char *) NULL;
+ }
+ else
+ {
+ /* There's no format string. */
+ prog = xstrdup (filter);
+ }
- /*
- * Only 1 %s argument is supported in the filter
- */
- (void) sprintf (prog, filter, title);
if ((pipefp = run_popen (prog, "w")) == NULL)
{
if (!noexec)
@@ -478,10 +805,17 @@ logfile_write (repository, filter, title, message, revision, logfp, changes)
return (1);
}
(void) fprintf (pipefp, "Update of %s\n", repository);
- (void) fprintf (pipefp, "In directory %s:%s\n\n", hostname,
- ((cp = getwd (cwd)) != NULL) ? cp : cwd);
- if (revision && *revision)
- (void) fprintf (pipefp, "Revision/Branch: %s\n\n", revision);
+ (void) fprintf (pipefp, "In directory %s:", hostname);
+ cp = xgetwd ();
+ if (cp == NULL)
+ fprintf (pipefp, "<cannot get working directory: %s>\n\n",
+ strerror (errno));
+ else
+ {
+ fprintf (pipefp, "%s\n\n", cp);
+ free (cp);
+ }
+
setup_tmpfile (pipefp, "", changes);
(void) fprintf (pipefp, "Log Message:\n%s\n", message);
if (logfp != (FILE *) 0)
@@ -519,3 +853,19 @@ editinfo_proc(repository, editor)
editinfo_editor = xstrdup (editor);
return (0);
}
+
+/* This routine is calld by Parse_Info. it asigns the name of the
+ * message verification script to the global variable verify_script
+ */
+static int
+verifymsg_proc (repository, script)
+ char *repository;
+ char *script;
+{
+ if (verifymsg_script && strcmp (verifymsg_script, script) == 0)
+ return (0);
+ if (verifymsg_script)
+ free (verifymsg_script);
+ verifymsg_script = xstrdup (script);
+ return (0);
+}
diff --git a/contrib/cvs/src/main.c b/contrib/cvs/src/main.c
index daa0230..21400ea 100644
--- a/contrib/cvs/src/main.c
+++ b/contrib/cvs/src/main.c
@@ -10,27 +10,6 @@
* Credit to Dick Grune, Vrije Universiteit, Amsterdam, for writing
* the shell-script CVS system that this is based on.
*
- * Usage:
- * cvs [options] command [options] [files/modules...]
- *
- * Where "command" is composed of:
- * admin RCS command
- * checkout Check out a module/dir/file
- * export Like checkout, but used for exporting sources
- * update Brings work tree in sync with repository
- * commit Checks files into the repository
- * diff Runs diffs between revisions
- * log Prints "rlog" information for files
- * login Record user, host, repos, password
- * add Adds an entry to the repository
- * remove Removes an entry from the repository
- * status Status info on the revisions
- * rdiff "patch" format diff listing between releases
- * tag Add/delete a symbolic tag to the RCS file
- * rtag Add/delete a symbolic tag to the RCS file
- * import Import sources into CVS, using vendor branches
- * release Indicate that Module is no longer in use.
- * history Display history of Users and Modules.
*/
#include "cvs.h"
@@ -41,35 +20,19 @@
extern int gethostname ();
#endif
-#if HAVE_KERBEROS
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <krb.h>
-#ifndef HAVE_KRB_GET_ERR_TEXT
-#define krb_get_err_text(status) krb_err_txt[status]
-#endif
-#endif
-
char *program_name;
char *program_path;
-/*
- * Initialize comamnd_name to "cvs" so that the first call to
- * read_cvsrc tries to find global cvs options.
- */
-char *command_name = "";
+char *command_name;
-/*
- * Since some systems don't define this...
- */
+/* I'd dynamically allocate this, but it seems like gethostname
+ requires a fixed size array. If I'm remembering the RFCs right,
+ 256 should be enough. */
#ifndef MAXHOSTNAMELEN
#define MAXHOSTNAMELEN 256
#endif
char hostname[MAXHOSTNAMELEN];
-#ifdef AUTH_CLIENT_SUPPORT
-int use_authenticating_server = FALSE;
-#endif /* AUTH_CLIENT_SUPPORT */
int use_editor = TRUE;
int use_cvsrc = TRUE;
int cvswrite = !CVSREAD_DFLT;
@@ -86,87 +49,77 @@ char *CurDir;
* Defaults, for the environment variables that are not set
*/
char *Rcsbin = RCSBIN_DFLT;
+char *Tmpdir = TMPDIR_DFLT;
char *Editor = EDITOR_DFLT;
-char *CVSroot = CVSROOT_DFLT;
-/*
- * The path found in CVS/Root must match $CVSROOT and/or 'cvs -d root'
- */
-char *CVSADM_Root = CVSROOT_DFLT;
-
-int add PROTO((int argc, char **argv));
-int admin PROTO((int argc, char **argv));
-int checkout PROTO((int argc, char **argv));
-int commit PROTO((int argc, char **argv));
-int diff PROTO((int argc, char **argv));
-int history PROTO((int argc, char **argv));
-int import PROTO((int argc, char **argv));
-int cvslog PROTO((int argc, char **argv));
-#ifdef AUTH_CLIENT_SUPPORT
-int login PROTO((int argc, char **argv));
-#endif /* AUTH_CLIENT_SUPPORT */
-int patch PROTO((int argc, char **argv));
-int release PROTO((int argc, char **argv));
-int cvsremove PROTO((int argc, char **argv));
-int rtag PROTO((int argc, char **argv));
-int status PROTO((int argc, char **argv));
-int tag PROTO((int argc, char **argv));
-int update PROTO((int argc, char **argv));
-
-const struct cmd
+
+static const struct cmd
{
char *fullname; /* Full name of the function (e.g. "commit") */
- char *nick1; /* alternate name (e.g. "ci") */
- char *nick2; /* another alternate names (e.g. "ci") */
+
+ /* Synonyms for the command, nick1 and nick2. We supply them
+ mostly for two reasons: (1) CVS has always supported them, and
+ we need to maintain compatibility, (2) if there is a need for a
+ version which is shorter than the fullname, for ease in typing.
+ Synonyms have the disadvantage that people will see "new" and
+ then have to think about it, or look it up, to realize that is
+ the operation they know as "add". Also, this means that one
+ cannot create a command "cvs new" with a different meaning. So
+ new synonyms are probably best used sparingly, and where used
+ should be abbreviations of the fullname (preferably consisting
+ of the first 2 or 3 or so letters).
+
+ One thing that some systems do is to recognize any unique
+ abbreviation, for example "annotat" "annota", etc., for
+ "annotate". The problem with this is that scripts and user
+ habits will expect a certain abbreviation to be unique, and in
+ a future release of CVS it may not be. So it is better to
+ accept only an explicit list of abbreviations and plan on
+ supporting them in the future as well as now. */
+
+ char *nick1;
+ char *nick2;
+
int (*func) (); /* Function takes (argc, argv) arguments. */
-#ifdef CLIENT_SUPPORT
- int (*client_func) (); /* Function to do it via the protocol. */
-#endif
} cmds[] =
{
-#ifdef CLIENT_SUPPORT
-#define CMD_ENTRY(n1, n2, n3, f1, f2) { n1, n2, n3, f1, f2 }
-#else
-#define CMD_ENTRY(n1, n2, n3, f1, f2) { n1, n2, n3, f1 }
+ { "add", "ad", "new", add },
+ { "admin", "adm", "rcs", admin },
+ { "annotate", "ann", NULL, annotate },
+ { "checkout", "co", "get", checkout },
+ { "commit", "ci", "com", commit },
+ { "diff", "di", "dif", diff },
+ { "edit", NULL, NULL, edit },
+ { "editors", NULL, NULL, editors },
+ { "export", "exp", "ex", checkout },
+ { "history", "hi", "his", history },
+ { "import", "im", "imp", import },
+ { "init", NULL, NULL, init },
+#ifdef SERVER_SUPPORT
+ { "kserver", NULL, NULL, server }, /* placeholder */
#endif
-
- CMD_ENTRY("add", "ad", "new", add, client_add),
- CMD_ENTRY("admin", "adm", "rcs", admin, client_admin),
- CMD_ENTRY("annotate", NULL, NULL, annotate, client_annotate),
- CMD_ENTRY("checkout", "co", "get", checkout, client_checkout),
- CMD_ENTRY("commit", "ci", "com", commit, client_commit),
- CMD_ENTRY("diff", "di", "dif", diff, client_diff),
- CMD_ENTRY("edit", "edit", "edit", edit, client_edit),
- CMD_ENTRY("editors", "editors","editors",editors, client_editors),
- CMD_ENTRY("export", "exp", "ex", checkout, client_export),
- CMD_ENTRY("history", "hi", "his", history, client_history),
- CMD_ENTRY("import", "im", "imp", import, client_import),
- CMD_ENTRY("init", NULL, NULL, init, client_init),
- CMD_ENTRY("log", "lo", "rlog", cvslog, client_log),
+ { "log", "lo", "rlog", cvslog },
#ifdef AUTH_CLIENT_SUPPORT
- CMD_ENTRY("login", "logon", "lgn", login, login),
+ { "login", "logon", "lgn", login },
+ { "logout", NULL, NULL, logout },
+#ifdef SERVER_SUPPORT
+ { "pserver", NULL, NULL, server }, /* placeholder */
+#endif
#endif /* AUTH_CLIENT_SUPPORT */
- CMD_ENTRY("rdiff", "patch", "pa", patch, client_rdiff),
- CMD_ENTRY("release", "re", "rel", release, client_release),
- CMD_ENTRY("remove", "rm", "delete", cvsremove, client_remove),
- CMD_ENTRY("status", "st", "stat", status, client_status),
- CMD_ENTRY("rtag", "rt", "rfreeze", rtag, client_rtag),
- CMD_ENTRY("tag", "ta", "freeze", tag, client_tag),
- CMD_ENTRY("unedit", "unedit","unedit", unedit, client_unedit),
- CMD_ENTRY("update", "up", "upd", update, client_update),
- CMD_ENTRY("watch", "watch", "watch", watch, client_watch),
- CMD_ENTRY("watchers", "watchers","watchers",watchers,client_watchers),
+ { "rdiff", "patch", "pa", patch },
+ { "release", "re", "rel", release },
+ { "remove", "rm", "delete", cvsremove },
+ { "status", "st", "stat", status },
+ { "rtag", "rt", "rfreeze", rtag },
+ { "tag", "ta", "freeze", cvstag },
+ { "unedit", NULL, NULL, unedit },
+ { "update", "up", "upd", update },
+ { "watch", NULL, NULL, watch },
+ { "watchers", NULL, NULL, watchers },
#ifdef SERVER_SUPPORT
- /*
- * The client_func is also server because we might have picked up a
- * CVSROOT environment variable containing a colon. The client will send
- * the real root later.
- */
- CMD_ENTRY("server", "server", "server", server, server),
+ { "server", NULL, NULL, server },
#endif
- CMD_ENTRY(NULL, NULL, NULL, NULL, NULL),
-
-#undef CMD_ENTRY
+ { NULL, NULL, NULL, NULL },
};
static const char *const usg[] =
@@ -183,11 +136,15 @@ static const char *const usg[] =
" -t Show trace of program execution -- Try with -n\n",
" -v CVS version and copyright\n",
" -b bindir Find RCS programs in 'bindir'\n",
+ " -T tmpdir Use 'tmpdir' for temporary files\n",
" -e editor Use 'editor' for editing log information\n",
" -d CVS_root Overrides $CVSROOT as the root of the CVS tree\n",
" -f Do not use the ~/.cvsrc file\n",
#ifdef CLIENT_SUPPORT
- " -z # Use 'gzip -#' for net traffic if possible.\n",
+ " -z # Use compression level '#' for net traffic.\n",
+#ifdef ENCRYPTION
+ " -x Encrypt all net traffic.\n",
+#endif
#endif
" -s VAR=VAL Set CVS user variable.\n",
"\n",
@@ -199,48 +156,165 @@ static const char *const usg[] =
static const char *const cmd_usage[] =
{
"CVS commands are:\n",
- " add Adds a new file/directory to the repository\n",
+ " add Add a new file/directory to the repository\n",
" admin Administration front end for rcs\n",
- " annotate Show revision where each line was modified\n",
+ " annotate Show last revision where each line was modified\n",
" checkout Checkout sources for editing\n",
- " commit Checks files into the repository\n",
- " diff Runs diffs between revisions\n",
+ " commit Check files into the repository\n",
+ " diff Show differences between revisions\n",
" edit Get ready to edit a watched file\n",
" editors See who is editing a watched file\n",
- " history Shows status of files and users\n",
- " import Import sources into CVS, using vendor branches\n",
" export Export sources from CVS, similar to checkout\n",
- " log Prints out 'rlog' information for files\n",
+ " history Show repository access history\n",
+ " import Import sources into CVS, using vendor branches\n",
+ " init Create a CVS repository if it doesn't exist\n",
+ " log Print out history information for files\n",
#ifdef AUTH_CLIENT_SUPPORT
" login Prompt for password for authenticating server.\n",
+ " logout Removes entry in .cvspass for remote repository.\n",
#endif /* AUTH_CLIENT_SUPPORT */
- " rdiff 'patch' format diffs between releases\n",
+ " rdiff Create 'patch' format diffs between releases\n",
" release Indicate that a Module is no longer in use\n",
- " remove Removes an entry from the repository\n",
- " status Status info on the revisions\n",
- " tag Add a symbolic tag to checked out version of RCS file\n",
+ " remove Remove an entry from the repository\n",
+ " rtag Add a symbolic tag to a module\n",
+ " status Display status information on checked out files\n",
+ " tag Add a symbolic tag to checked out version of files\n",
" unedit Undo an edit command\n",
- " rtag Add a symbolic tag to the RCS file\n",
- " update Brings work tree in sync with repository\n",
+ " update Bring work tree in sync with repository\n",
" watch Set watches\n",
" watchers See who is watching a file\n",
+ "(Use the --help-synonyms option for a list of alternate command names)\n",
NULL,
};
-static RETSIGTYPE
-main_cleanup ()
+static const char * const*
+cmd_synonyms ()
{
- exit (EXIT_FAILURE);
+ char ** synonyms;
+ char ** line;
+ const struct cmd *c = &cmds[0];
+ int numcmds = 2; /* two more for title and end */
+
+ while (c->fullname != NULL)
+ {
+ numcmds++;
+ c++;
+ }
+
+ synonyms = (char **) xmalloc(numcmds * sizeof(char *));
+ line = synonyms;
+ *line++ = "CVS command synonyms are:\n";
+ for (c = &cmds[0]; c->fullname != NULL; c++)
+ {
+ if (c->nick1 || c->nick2)
+ {
+ *line = xmalloc (strlen (c->fullname)
+ + (c->nick1 != NULL ? strlen (c->nick1) : 0)
+ + (c->nick2 != NULL ? strlen (c->nick2) : 0)
+ + 40);
+ sprintf(*line, " %-12s %s %s\n", c->fullname,
+ c->nick1 ? c->nick1 : "",
+ c->nick2 ? c->nick2 : "");
+ line++;
+ }
+ }
+ *line = NULL;
+
+ return (const char * const*) synonyms; /* will never be freed */
}
-static void
-error_cleanup PROTO((void))
+
+unsigned long int
+lookup_command_attribute (cmd_name)
+ char *cmd_name;
{
- Lock_Cleanup();
-#ifdef SERVER_SUPPORT
- if (server_active)
- server_cleanup (0);
+ unsigned long int ret = 0;
+
+ if (strcmp (cmd_name, "import") != 0)
+ {
+ ret |= CVS_CMD_IGNORE_ADMROOT;
+ }
+
+
+ if ((strcmp (cmd_name, "checkout") != 0) &&
+ (strcmp (cmd_name, "init") != 0) &&
+ (strcmp (cmd_name, "login") != 0) &&
+ (strcmp (cmd_name, "logout") != 0) &&
+ (strcmp (cmd_name, "rdiff") != 0) &&
+ (strcmp (cmd_name, "release") != 0) &&
+ (strcmp (cmd_name, "rtag") != 0))
+ {
+ ret |= CVS_CMD_USES_WORK_DIR;
+ }
+
+
+ /* The following commands do not modify the repository; we
+ conservatively assume that everything else does. Feel free to
+ add to this list if you are _certain_ something is safe. */
+ if ((strcmp (cmd_name, "checkout") != 0) &&
+ (strcmp (cmd_name, "diff") != 0) &&
+ (strcmp (cmd_name, "update") != 0) &&
+ (strcmp (cmd_name, "history") != 0) &&
+ (strcmp (cmd_name, "editors") != 0) &&
+ (strcmp (cmd_name, "export") != 0) &&
+ (strcmp (cmd_name, "history") != 0) &&
+ (strcmp (cmd_name, "log") != 0) &&
+ (strcmp (cmd_name, "noop") != 0) &&
+ (strcmp (cmd_name, "watchers") != 0) &&
+ (strcmp (cmd_name, "status") != 0))
+ {
+ ret |= CVS_CMD_MODIFIES_REPOSITORY;
+ }
+
+ return ret;
+}
+
+
+static RETSIGTYPE
+main_cleanup (sig)
+ int sig;
+{
+#ifndef DONT_USE_SIGNALS
+ const char *name;
+ char temp[10];
+
+ switch (sig)
+ {
+#ifdef SIGHUP
+ case SIGHUP:
+ name = "hangup";
+ break;
+#endif
+#ifdef SIGINT
+ case SIGINT:
+ name = "interrupt";
+ break;
#endif
+#ifdef SIGQUIT
+ case SIGQUIT:
+ name = "quit";
+ break;
+#endif
+#ifdef SIGPIPE
+ case SIGPIPE:
+ name = "broken pipe";
+ break;
+#endif
+#ifdef SIGTERM
+ case SIGTERM:
+ name = "termination";
+ break;
+#endif
+ default:
+ /* This case should never be reached, because we list above all
+ the signals for which we actually establish a signal handler. */
+ sprintf (temp, "%d", sig);
+ name = temp;
+ break;
+ }
+
+ error (1, 0, "received %s signal", name);
+#endif /* !DONT_USE_SIGNALS */
}
int
@@ -248,56 +322,70 @@ main (argc, argv)
int argc;
char **argv;
{
+ char *CVSroot = CVSROOT_DFLT;
extern char *version_string;
extern char *config_string;
char *cp, *end;
const struct cmd *cm;
int c, err = 0;
- static int help = FALSE;
- static int version_flag = FALSE;
- static int help_commands = FALSE;
- int rcsbin_update_env, cvs_update_env = 0;
+ int rcsbin_update_env, tmpdir_update_env, cvs_update_env;
+ int help = 0; /* Has the user asked for help? This
+ lets us support the `cvs -H cmd'
+ convention to give help for cmd. */
static struct option long_options[] =
{
- {"help", 0, &help, TRUE},
- {"version", 0, &version_flag, TRUE},
- {"help-commands", 0, &help_commands, TRUE},
+ {"help", 0, NULL, 'H'},
+ {"version", 0, NULL, 'v'},
+ {"help-commands", 0, NULL, 1},
+ {"help-synonyms", 0, NULL, 2},
{0, 0, 0, 0}
};
/* `getopt_long' stores the option index here, but right now we
don't use it. */
int option_index = 0;
+ int need_to_create_root = 0;
- error_set_cleanup (error_cleanup);
+#ifdef SYSTEM_INITIALIZE
+ /* Hook for OS-specific behavior, for example socket subsystems on
+ NT and OS2 or dealing with windows and arguments on Mac. */
+ SYSTEM_INITIALIZE (&argc, &argv);
+#endif
-/* The socket subsystems on NT and OS2 must be initialized before use */
-#ifdef INITIALIZE_SOCKET_SUBSYSTEM
- INITIALIZE_SOCKET_SUBSYSTEM();
-#endif /* INITIALIZE_SOCKET_SUBSYSTEM */
+#ifdef HAVE_TZSET
+ /* On systems that have tzset (which is almost all the ones I know
+ of), it's a good idea to call it. */
+ tzset ();
+#endif
/*
* Just save the last component of the path for error messages
*/
program_path = xstrdup (argv[0]);
+#ifdef ARGV0_NOT_PROGRAM_NAME
+ /* On some systems, e.g. VMS, argv[0] is not the name of the command
+ which the user types to invoke the program. */
+ program_name = "cvs";
+#else
program_name = last_component (argv[0]);
-
- CurDir = xmalloc (PATH_MAX);
-#ifndef SERVER_SUPPORT
- if (!getwd (CurDir))
- error (1, 0, "cannot get working directory: %s", CurDir);
#endif
/*
* Query the environment variables up-front, so that
* they can be overridden by command line arguments
*/
- rcsbin_update_env = *Rcsbin; /* RCSBIN_DFLT must be set */
cvs_update_env = 0;
+ rcsbin_update_env = *Rcsbin; /* RCSBIN_DFLT must be set */
if ((cp = getenv (RCSBIN_ENV)) != NULL)
{
Rcsbin = cp;
rcsbin_update_env = 0; /* it's already there */
}
+ tmpdir_update_env = *Tmpdir; /* TMPDIR_DFLT must be set */
+ if ((cp = getenv (TMPDIR_ENV)) != NULL)
+ {
+ Tmpdir = cp;
+ tmpdir_update_env = 0; /* it's already there */
+ }
if ((cp = getenv (EDITOR1_ENV)) != NULL)
Editor = cp;
else if ((cp = getenv (EDITOR2_ENV)) != NULL)
@@ -311,20 +399,10 @@ main (argc, argv)
}
if (getenv (CVSREAD_ENV) != NULL)
cvswrite = FALSE;
- if ((cp = getenv (CVSUMASK_ENV)) != NULL)
- {
- /* FIXME: Should be accepting symbolic as well as numeric mask. */
- cvsumask = strtol (cp, &end, 8) & 0777;
- if (*end != '\0')
- error (1, errno, "invalid umask value in %s (%s)",
- CVSUMASK_ENV, cp);
- }
- /* This has the effect of setting getopt's ordering to REQUIRE_ORDER,
- which is what we need to distinguish between global options and
- command options. FIXME: It would appear to be possible to do this
- much less kludgily by passing "+" as the first character to the
- option string we pass to getopt_long. */
+ /* I'm not sure whether this needs to be 1 instead of 0 anymore. Using
+ 1 used to accomplish what passing "+" as the first character to
+ the option string does, but that reason doesn't exist anymore. */
optind = 1;
@@ -335,13 +413,13 @@ main (argc, argv)
opterr = 0;
while ((c = getopt_long
- (argc, argv, "f", NULL, NULL))
+ (argc, argv, "+f", NULL, NULL))
!= EOF)
- {
+ {
if (c == 'f')
use_cvsrc = FALSE;
- }
-
+ }
+
/*
* Scan cvsrc file for global options.
*/
@@ -352,13 +430,18 @@ main (argc, argv)
opterr = 1;
while ((c = getopt_long
- (argc, argv, "Qqrwtnlvb:e:d:Hfz:s:", long_options, &option_index))
+ (argc, argv, "+Qqrwtnlvb:T:e:d:Hfz:s:x", long_options, &option_index))
!= EOF)
{
switch (c)
{
- case 0:
- /* getopt_long took care of setting the flag. */
+ case 1:
+ /* --help-commands */
+ usage (cmd_usage);
+ break;
+ case 2:
+ /* --help-synonyms */
+ usage (cmd_synonyms());
break;
case 'Q':
really_quiet = TRUE;
@@ -381,12 +464,26 @@ main (argc, argv)
logoff = TRUE;
break;
case 'v':
- version_flag = TRUE;
+ (void) fputs (version_string, stdout);
+ (void) fputs (config_string, stdout);
+ (void) fputs ("\n", stdout);
+ (void) fputs ("Copyright (c) 1993-1994 Brian Berliner\n", stdout);
+ (void) fputs ("Copyright (c) 1993-1994 david d `zoo' zuhn\n", stdout);
+ (void) fputs ("Copyright (c) 1992, Brian Berliner and Jeff Polk\n", stdout);
+ (void) fputs ("Copyright (c) 1989-1992, Brian Berliner\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);
+ exit (0);
break;
case 'b':
Rcsbin = optarg;
rcsbin_update_env = 1; /* need to update environment */
break;
+ case 'T':
+ Tmpdir = optarg;
+ tmpdir_update_env = 1; /* need to update environment */
+ break;
case 'e':
Editor = optarg;
break;
@@ -395,11 +492,10 @@ main (argc, argv)
cvs_update_env = 1; /* need to update environment */
break;
case 'H':
- use_cvsrc = FALSE; /* this ensure that cvs -H works */
- help = TRUE;
+ help = 1;
break;
case 'f':
- use_cvsrc = FALSE;
+ use_cvsrc = FALSE; /* unnecessary, since we've done it above */
break;
case 'z':
#ifdef CLIENT_SUPPORT
@@ -415,313 +511,307 @@ main (argc, argv)
case 's':
variable_set (optarg);
break;
+ case 'x':
+#ifdef CLIENT_SUPPORT
+ cvsencrypt = 1;
+#endif /* CLIENT_SUPPORT */
+ /* If no CLIENT_SUPPORT, ignore -x, so that users can
+ have it in their .cvsrc and not cause any trouble.
+ If no ENCRYPTION, we still accept -x, but issue an
+ error if we are being run as a client. */
+ break;
case '?':
default:
usage (usg);
}
}
- if (version_flag == TRUE)
- {
- (void) fputs (version_string, stdout);
- (void) fputs (config_string, stdout);
- (void) fputs ("\n", stdout);
- (void) fputs ("Copyright (c) 1993-1994 Brian Berliner\n", stdout);
- (void) fputs ("Copyright (c) 1993-1994 david d `zoo' zuhn\n", stdout);
- (void) fputs ("Copyright (c) 1992, Brian Berliner and Jeff Polk\n", stdout);
- (void) fputs ("Copyright (c) 1989-1992, Brian Berliner\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);
- exit (0);
- }
- else if (help_commands)
- usage (cmd_usage);
-
argc -= optind;
argv += optind;
if (argc < 1)
usage (usg);
-#ifdef HAVE_KERBEROS
- /* If we are invoked with a single argument "kserver", then we are
- running as Kerberos server as root. Do the authentication as
- the very first thing, to minimize the amount of time we are
- running as root. */
- if (strcmp (argv[0], "kserver") == 0)
+
+ /* Look up the command name. */
+
+ command_name = argv[0];
+ for (cm = cmds; cm->fullname; cm++)
{
- int status;
- char instance[INST_SZ];
- struct sockaddr_in peer;
- struct sockaddr_in laddr;
- int len;
- KTEXT_ST ticket;
- AUTH_DAT auth;
- char version[KRB_SENDAUTH_VLEN];
- Key_schedule sched;
- char user[ANAME_SZ];
- struct passwd *pw;
-
- strcpy (instance, "*");
- len = sizeof peer;
- if (getpeername (STDIN_FILENO, (struct sockaddr *) &peer, &len) < 0
- || getsockname (STDIN_FILENO, (struct sockaddr *) &laddr,
- &len) < 0)
- {
- printf ("E Fatal error, aborting.\n\
-error %s getpeername or getsockname failed\n", strerror (errno));
- exit (EXIT_FAILURE);
- }
+ if (cm->nick1 && !strcmp (command_name, cm->nick1))
+ break;
+ if (cm->nick2 && !strcmp (command_name, cm->nick2))
+ break;
+ if (!strcmp (command_name, cm->fullname))
+ break;
+ }
- status = krb_recvauth (KOPT_DO_MUTUAL, STDIN_FILENO, &ticket, "rcmd",
- instance, &peer, &laddr, &auth, "", sched,
- version);
- if (status != KSUCCESS)
- {
- printf ("E Fatal error, aborting.\n\
-error 0 kerberos: %s\n", krb_get_err_text(status));
- exit (EXIT_FAILURE);
- }
+ if (!cm->fullname)
+ usage (cmd_usage); /* no match */
+ else
+ command_name = cm->fullname; /* Global pointer for later use */
- /* Get the local name. */
- status = krb_kntoln (&auth, user);
- if (status != KSUCCESS)
- {
- printf ("E Fatal error, aborting.\n\
-error 0 kerberos: can't get local name: %s\n", krb_get_err_text(status));
- exit (EXIT_FAILURE);
- }
+ if (strcmp (argv[0], "rlog") == 0)
+ {
+ error (0, 0, "warning: the rlog command is deprecated");
+ error (0, 0, "use the synonymous log command instead");
+ }
- pw = getpwnam (user);
- if (pw == NULL)
- {
- printf ("E Fatal error, aborting.\n\
-error 0 %s: no such user\n", user);
- exit (EXIT_FAILURE);
- }
+ if (help)
+ argc = -1; /* some functions only check for this */
+ else
+ {
+ /* The user didn't ask for help, so go ahead and authenticate,
+ set up CVSROOT, and the rest of it. */
- initgroups (pw->pw_name, pw->pw_gid);
- setgid (pw->pw_gid);
- setuid (pw->pw_uid);
- /* Inhibit access by randoms. Don't want people randomly
- changing our temporary tree before we check things in. */
- umask (077);
+ /* The UMASK environment variable isn't handled with the
+ others above, since we don't want to signal errors if the
+ user has asked for help. This won't work if somebody adds
+ a command-line flag to set the umask, since we'll have to
+ parse it before we get here. */
-#if HAVE_PUTENV
- /* Set LOGNAME and USER in the environment, in case they are
- already set to something else. */
+ if ((cp = getenv (CVSUMASK_ENV)) != NULL)
{
- char *env;
+ /* FIXME: Should be accepting symbolic as well as numeric mask. */
+ cvsumask = strtol (cp, &end, 8) & 0777;
+ if (*end != '\0')
+ error (1, errno, "invalid umask value in %s (%s)",
+ CVSUMASK_ENV, cp);
+ }
- env = xmalloc (sizeof "LOGNAME=" + strlen (user));
- (void) sprintf (env, "LOGNAME=%s", user);
- (void) putenv (env);
+#if defined (HAVE_KERBEROS) && defined (SERVER_SUPPORT)
+ /* If we are invoked with a single argument "kserver", then we are
+ running as Kerberos server as root. Do the authentication as
+ the very first thing, to minimize the amount of time we are
+ running as root. */
+ if (strcmp (command_name, "kserver") == 0)
+ {
+ kserver_authenticate_connection ();
- env = xmalloc (sizeof "USER=" + strlen (user));
- (void) sprintf (env, "USER=%s", user);
- (void) putenv (env);
+ /* Pretend we were invoked as a plain server. */
+ command_name = "server";
}
-#endif
-
- /* Pretend we were invoked as a plain server. */
- argv[0] = "server";
- }
#endif /* HAVE_KERBEROS */
#if defined(AUTH_SERVER_SUPPORT) && defined(SERVER_SUPPORT)
- if (strcmp (argv[0], "pserver") == 0)
- {
- /* Gets username and password from client, authenticates, then
- switches to run as that user and sends an ACK back to the
- client. */
- authenticate_connection ();
+ if (strcmp (command_name, "pserver") == 0)
+ {
+ /* Gets username and password from client, authenticates, then
+ switches to run as that user and sends an ACK back to the
+ client. */
+ pserver_authenticate_connection ();
- /* Pretend we were invoked as a plain server. */
- argv[0] = "server";
- }
+ /* Pretend we were invoked as a plain server. */
+ command_name = "server";
+ }
#endif /* AUTH_SERVER_SUPPORT && SERVER_SUPPORT */
- /*
- * See if we are able to find a 'better' value for CVSroot in the
- * CVSADM_ROOT directory.
- */
-#ifdef SERVER_SUPPORT
- if (strcmp (argv[0], "server") == 0 && CVSroot == NULL)
- CVSADM_Root = NULL;
- else
- CVSADM_Root = Name_Root((char *) NULL, (char *) NULL);
-#else /* No SERVER_SUPPORT */
- CVSADM_Root = Name_Root((char *) NULL, (char *) NULL);
-#endif /* No SERVER_SUPPORT */
- if (CVSADM_Root != NULL)
- {
- if (CVSroot == NULL || !cvs_update_env)
- {
- CVSroot = CVSADM_Root;
- cvs_update_env = 1; /* need to update environment */
- }
-#ifdef CLIENT_SUPPORT
- else if (!getenv ("CVS_IGNORE_REMOTE_ROOT"))
-#else /* ! CLIENT_SUPPORT */
- else
-#endif /* CLIENT_SUPPORT */
- {
- /*
- * Now for the hard part, compare the two directories. If they
- * are not identical, then abort this command.
- */
- if ((fncmp (CVSroot, CVSADM_Root) != 0) &&
- !same_directories(CVSroot, CVSADM_Root))
- {
- error (0, 0, "%s value for CVS Root found in %s",
- CVSADM_Root, CVSADM_ROOT);
- error (0, 0, "does not match command line -d %s setting",
- CVSroot);
- error (1, 0,
- "you may wish to try the cvs command again without the -d option ");
- }
- }
- }
-
- /* CVSroot may need fixing up, if an access-method was specified,
- * but not a user. Later code assumes that if CVSroot contains an
- * access-method, then it also has a user. We print a warning and
- * die if we can't guarantee that.
- */
- if (CVSroot
- && *CVSroot
- && (CVSroot[0] == ':')
- && (strchr (CVSroot, '@') == NULL))
- {
- error (1, 0,
- "must also give a username if specifying access method");
- }
+ /* 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. */
- /*
- * Specifying just the '-H' flag to the sub-command causes a Usage
- * message to be displayed.
- */
- command_name = cp = argv[0];
- if (help == TRUE || (argc > 1 && strcmp (argv[1], "-H") == 0))
- argc = -1;
- else
- {
- /*
- * Check to see if we can write into the history file. If not,
- * we assume that we can't work in the repository.
- * BUT, only if the history file exists.
- */
#ifdef SERVER_SUPPORT
- if (strcmp (command_name, "server") != 0 || CVSroot != NULL)
+ if (strcmp (command_name, "server") != 0)
#endif
{
- char path[PATH_MAX];
- int save_errno;
+ char *CVSADM_Root;
+
+ /* See if we are able to find a 'better' value for CVSroot
+ in the CVSADM_ROOT directory. */
- if (!CVSroot || !*CVSroot)
- error (1, 0, "You don't have a %s environment variable",
- CVSROOT_ENV);
- (void) sprintf (path, "%s/%s", CVSroot, CVSROOTADM);
- if (!isaccessible (path, R_OK | X_OK))
+ 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 (lookup_command_attribute (command_name)
+ & CVS_CMD_IGNORE_ADMROOT)
+ {
+ CVSADM_Root = Name_Root((char *) NULL, (char *) NULL);
+ }
+
+ if (CVSADM_Root != NULL)
{
- save_errno = errno;
- /* If this is "cvs init", the root need not exist yet. */
- if (strcmp (command_name, "init") != 0
+ if (CVSroot == NULL || !cvs_update_env)
+ {
+ CVSroot = CVSADM_Root;
+ cvs_update_env = 1; /* need to update environment */
+ }
+ /* Let -d override CVS/Root file. The user might want
+ to change the access method, use a different server
+ (if there are two server machines which share the
+ repository using a networked file system), etc. */
+ else if (
#ifdef CLIENT_SUPPORT
- /* If we are a remote client, the root need not exist
- on the client machine (FIXME: we should also skip
- the check for CVSROOTADM_HISTORY being writable;
- it shouldn't matter if there is a read-only file
- which happens to have the same name on the client
- machine). */
- && strchr (CVSroot, ':') == NULL)
+ !getenv ("CVS_IGNORE_REMOTE_ROOT") &&
#endif
+ strcmp (CVSroot, CVSADM_Root) != 0)
{
- error (0, 0,
- "Sorry, you don't have sufficient access to %s", CVSroot);
- error (1, save_errno, "%s", path);
+ /* Once we have verified that this root is usable,
+ we will want to write it into CVS/Root.
+
+ Don't do it for the "login" command, however.
+ Consider: if the user executes "cvs login" with
+ the working directory inside an already checked
+ out module, we'd incorrectly change the
+ CVS/Root file to reflect the CVSROOT of the
+ "cvs login" command. Ahh, the things one
+ discovers. */
+
+ if (lookup_command_attribute (command_name)
+ & CVS_CMD_USES_WORK_DIR)
+ {
+ need_to_create_root = 1;
+ }
+
}
}
- (void) strcat (path, "/");
- (void) strcat (path, CVSROOTADM_HISTORY);
- if (isfile (path) && !isaccessible (path, R_OK | W_OK))
+
+ /* 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)
{
- save_errno = errno;
error (0, 0,
- "Sorry, you don't have read/write access to the history file");
- error (1, save_errno, "%s", path);
+ "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 legal, either via the");
+ error (0, 0,
+ "`-d' option, the %s environment variable, or the",
+ CVSROOT_ENV);
+ error (1, 0,
+ "CVS/Root file (if any).");
}
- }
- }
-#ifdef SERVER_SUPPORT
- if (strcmp (command_name, "server") == 0)
- /* This is only used for writing into the history file. Might
- be nice to have hostname and/or remote path, on the other hand
- I'm not sure whether it is worth the trouble. */
- strcpy (CurDir, "<remote>");
- else if (!getwd (CurDir))
- error (1, 0, "cannot get working directory: %s", CurDir);
-#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 (parse_cvsroot (CVSroot))
+ error (1, 0, "Bad CVSROOT.");
+
+ /*
+ * Check to see if we can write into the history file. If not,
+ * we assume that we can't work in the repository.
+ * BUT, only if the history file exists.
+ */
+
+ if (!client_active)
+ {
+ char *path;
+ int save_errno;
+
+ path = xmalloc (strlen (CVSroot_directory)
+ + sizeof (CVSROOTADM)
+ + 20
+ + sizeof (CVSROOTADM_HISTORY));
+ (void) sprintf (path, "%s/%s", CVSroot_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 (command_name, "init") != 0)
+ {
+ error (1, save_errno, "%s", path);
+ }
+ }
+ (void) strcat (path, "/");
+ (void) strcat (path, CVSROOTADM_HISTORY);
+ if (isfile (path) && !isaccessible (path, R_OK | W_OK))
+ {
+ save_errno = errno;
+ error (0, 0, "Sorry, you don't have read/write access to the history file");
+ error (1, save_errno, "%s", path);
+ }
+ free (path);
+ }
#ifdef HAVE_PUTENV
- /* Now, see if we should update the environment with the Rcsbin value */
- if (cvs_update_env)
- {
- char *env;
+ /* Update the CVSROOT environment variable if necessary. */
- env = xmalloc (strlen (CVSROOT_ENV) + strlen (CVSroot) + 1 + 1);
- (void) sprintf (env, "%s=%s", CVSROOT_ENV, CVSroot);
- (void) putenv (env);
- /* do not free env, as putenv has control of it */
- }
- if (rcsbin_update_env)
- {
- char *env;
+ if (cvs_update_env)
+ {
+ char *env;
+ env = xmalloc (strlen (CVSROOT_ENV) + strlen (CVSroot)
+ + 1 + 1);
+ (void) sprintf (env, "%s=%s", CVSROOT_ENV, CVSroot);
+ (void) putenv (env);
+ /* do not free env, as putenv has control of it */
+ }
+#endif
+ }
+
+ /* 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. */
- env = xmalloc (strlen (RCSBIN_ENV) + strlen (Rcsbin) + 1 + 1);
- (void) sprintf (env, "%s=%s", RCSBIN_ENV, Rcsbin);
- (void) putenv (env);
- /* do not free env, as putenv has control of it */
- }
+#ifdef SERVER_SUPPORT
+ if (strcmp (command_name, "server") == 0)
+ CurDir = xstrdup ("<remote>");
+ else
#endif
+ {
+ CurDir = xgetwd ();
+ if (CurDir == NULL)
+ error (1, errno, "cannot get working directory");
+ }
- /*
- * If Rcsbin is set to something, make sure it is terminated with
- * a slash character. If not, add one.
- */
- if (*Rcsbin)
- {
- int len = strlen (Rcsbin);
- char *rcsbin;
+ if (Tmpdir == NULL || Tmpdir[0] == '\0')
+ Tmpdir = "/tmp";
- if (Rcsbin[len - 1] != '/')
+#ifdef HAVE_PUTENV
+ /* Now, see if we should update the environment with the
+ Rcsbin value */
+ if (rcsbin_update_env)
{
- rcsbin = Rcsbin;
- Rcsbin = xmalloc (len + 2); /* one for '/', one for NULL */
- (void) strcpy (Rcsbin, rcsbin);
- (void) strcat (Rcsbin, "/");
+ char *env;
+ env = xmalloc (strlen (RCSBIN_ENV) + strlen (Rcsbin) + 1 + 1);
+ (void) sprintf (env, "%s=%s", RCSBIN_ENV, Rcsbin);
+ (void) putenv (env);
+ /* do not free env, as putenv has control of it */
}
- }
+ if (tmpdir_update_env)
+ {
+ char *env;
+ env = xmalloc (strlen (TMPDIR_ENV) + strlen (Tmpdir) + 1 + 1);
+ (void) sprintf (env, "%s=%s", TMPDIR_ENV, Tmpdir);
+ (void) putenv (env);
+ /* do not free env, as putenv has control of it */
+ }
+#endif
- for (cm = cmds; cm->fullname; cm++)
- {
- if (cm->nick1 && !strcmp (cp, cm->nick1))
- break;
- if (cm->nick2 && !strcmp (cp, cm->nick2))
- break;
- if (!strcmp (cp, cm->fullname))
- break;
- }
+ /*
+ * If Rcsbin is set to something, make sure it is terminated with
+ * a slash character. If not, add one.
+ */
+ if (*Rcsbin)
+ {
+ int len = strlen (Rcsbin);
+ char *rcsbin;
- if (!cm->fullname)
- usage (usg); /* no match */
- else
- {
- command_name = cm->fullname; /* Global pointer for later use */
+ if (Rcsbin[len - 1] != '/')
+ {
+ rcsbin = Rcsbin;
+ Rcsbin = xmalloc (len + 2); /* one for '/', one for NULL */
+ (void) strcpy (Rcsbin, rcsbin);
+ (void) strcat (Rcsbin, "/");
+ }
+ }
+#ifndef DONT_USE_SIGNALS
/* make sure we clean up on error */
#ifdef SIGHUP
(void) SIG_register (SIGHUP, main_cleanup);
@@ -743,39 +833,44 @@ error 0 %s: no such user\n", user);
(void) SIG_register (SIGTERM, main_cleanup);
(void) SIG_register (SIGTERM, Lock_Cleanup);
#endif
+#endif /* !DONT_USE_SIGNALS */
gethostname(hostname, sizeof (hostname));
-#ifdef HAVE_SETVBUF
- /*
- * Make stdout line buffered, so 'tail -f' can monitor progress.
- * Patch creates too much output to monitor and it runs slowly.
- */
- if (strcmp (cm->fullname, "patch"))
- (void) setvbuf (stdout, (char *) NULL, _IOLBF, 0);
-#endif
+#ifdef KLUDGE_FOR_WNT_TESTSUITE
+ /* Probably the need for this will go away at some point once
+ we call fflush enough places (e.g. fflush (stdout) in
+ cvs_outerr). */
+ (void) setvbuf (stdout, (char *) NULL, _IONBF, 0);
+ (void) setvbuf (stderr, (char *) NULL, _IONBF, 0);
+#endif /* KLUDGE_FOR_WNT_TESTSUITE */
if (use_cvsrc)
- read_cvsrc (&argc, &argv, command_name);
+ read_cvsrc (&argc, &argv, command_name);
-#ifdef CLIENT_SUPPORT
- /* If cvsroot contains a colon, try to do it via the protocol. */
- {
- char *p = CVSroot == NULL ? NULL : strchr (CVSroot, ':');
- if (p)
- err = (*(cm->client_func)) (argc, argv);
- else
- err = (*(cm->func)) (argc, argv);
- }
-#else /* No CLIENT_SUPPORT */
- err = (*(cm->func)) (argc, argv);
+ } /* end of stuff that gets done if the user DOESN'T ask for help */
+
+ err = (*(cm->func)) (argc, argv);
-#endif /* No CLIENT_SUPPORT */
+ if (need_to_create_root)
+ {
+ /* Update the CVS/Root file. We might want to do this in
+ all directories that we recurse into, but currently we
+ don't. */
+ Create_Root (NULL, CVSroot);
}
+
Lock_Cleanup ();
- if (err)
- return (EXIT_FAILURE);
- return 0;
+
+#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
+
+ /* This is exit rather than return because apparently that keeps
+ some tools which check for memory leaks happier. */
+ exit (err ? EXIT_FAILURE : 0);
}
char *
@@ -784,7 +879,7 @@ Make_Date (rawdate)
{
struct tm *ftm;
time_t unixtime;
- char date[256]; /* XXX bigger than we'll ever need? */
+ char date[MAXDATELEN];
char *ret;
unixtime = get_date (rawdate, (struct timeb *) NULL);
@@ -810,5 +905,5 @@ usage (cpp)
(void) fprintf (stderr, *cpp++, program_name, command_name);
for (; *cpp; cpp++)
(void) fprintf (stderr, *cpp);
- exit (EXIT_FAILURE);
+ error_exit ();
}
diff --git a/contrib/cvs/src/mkmodules.c b/contrib/cvs/src/mkmodules.c
index bdd27eb..cff993a 100644
--- a/contrib/cvs/src/mkmodules.c
+++ b/contrib/cvs/src/mkmodules.c
@@ -7,13 +7,14 @@
#include "cvs.h"
#include "savecwd.h"
+#include "getline.h"
#ifndef DBLKSIZ
#define DBLKSIZ 4096 /* since GNU ndbm doesn't define it */
#endif
static int checkout_file PROTO((char *file, char *temp));
-static void make_tempfile PROTO((char *temp));
+static char *make_tempfile PROTO((void));
static void rename_rcsfile PROTO((char *temp, char *real));
#ifndef MY_NDBM
@@ -28,38 +29,50 @@ struct admin_file {
/* This is a one line description of what the file is for. It is not
currently used, although one wonders whether it should be, somehow.
- If NULL, then don't process this file in mkmodules (FIXME: a bit of
+ If NULL, then don't process this file in mkmodules (FIXME?: a bit of
a kludge; probably should replace this with a flags field). */
char *errormsg;
/* Contents which the file should have in a new repository. To avoid
problems with brain-dead compilers which choke on long string constants,
this is a pointer to an array of char * terminated by NULL--each of
- the strings is concatenated. */
+ the strings is concatenated.
+
+ If this field is NULL, the file is not created in a new
+ repository, but it can be added with "cvs add" (just as if one
+ had created the repository with a version of CVS which didn't
+ know about the file) and the checked-out copy will be updated
+ without having to add it to checkoutlist. */
const char * const *contents;
};
static const char *const loginfo_contents[] = {
- "# The \"loginfo\" file is used to control where \"cvs commit\" log information\n",
- "# is sent. The first entry on a line is a regular expression which is tested\n",
- "# against the directory that the change is being made to, relative to the\n",
- "# $CVSROOT. For the first match that is found, then the remainder of the\n",
- "# line is a filter program that should expect log information on its standard\n",
- "# input.\n",
+ "# The \"loginfo\" file controls where \"cvs commit\" log information\n",
+ "# is sent. The first entry on a line is a regular expression which must match\n",
+ "# the directory that the change is being made to, relative to the\n",
+ "# $CVSROOT. If a match is found, then the remainder of the line is a filter\n",
+ "# program that should expect log information on its standard input.\n",
"#\n",
- "# If the repository name does not match any of the regular expressions in the\n",
- "# first field of this file, the \"DEFAULT\" line is used, if it is specified.\n",
+ "# If the repository name does not match any of the regular expressions in this\n",
+ "# file, the \"DEFAULT\" line is used, if it is specified.\n",
"#\n",
- "# If the name \"ALL\" appears as a regular expression it is always used\n",
- "# in addition to the first matching regex or \"DEFAULT\".\n",
+ "# If the name ALL appears as a regular expression it is always used\n",
+ "# in addition to the first matching regex or DEFAULT.\n",
"#\n",
- "# The filter program may use one and only one \"%s\" modifier (ala printf). If\n",
- "# such a \"%s\" is specified in the filter program, a brief title is included\n",
- "# (as one argument, enclosed in single quotes) showing the relative directory\n",
- "# name and listing the modified file names.\n",
+ "# You may specify a format string as part of the\n",
+ "# filter. The string is composed of a `%' followed\n",
+ "# by a single format character, or followed by a set of format\n",
+ "# characters surrounded by `{' and `}' as separators. The format\n",
+ "# characters are:\n",
+ "#\n",
+ "# s = file name\n",
+ "# V = old version number (pre-checkin)\n",
+ "# v = new version number (post-checkin)\n",
"#\n",
"# For example:\n",
- "#DEFAULT (echo \"\"; who am i; date; cat) >> $CVSROOT/CVSROOT/commitlog\n",
+ "#DEFAULT (echo \"\"; id; echo %s; date; cat) >> $CVSROOT/CVSROOT/commitlog\n",
+ "# or\n",
+ "#DEFAULT (echo \"\"; id; echo %{sVv}; date; cat) >> $CVSROOT/CVSROOT/commitlog\n",
NULL
};
@@ -99,8 +112,33 @@ static const char *const editinfo_contents[] = {
"# Actions such as mailing a copy of the report to each reviewer are\n",
"# better handled by an entry in the loginfo file.\n",
"#\n",
- "# One thing that should be noted is the the ALL keyword is not\n",
- "# supported. There can be only one entry that matches a given\n",
+ "# One thing that should be noted is the the ALL keyword is not\n",
+ "# supported. There can be only one entry that matches a given\n",
+ "# repository.\n",
+ NULL
+};
+
+static const char *const verifymsg_contents[] = {
+ "# The \"verifymsg\" file is used to allow verification of logging\n",
+ "# information. It works best when a template (as specified in the\n",
+ "# rcsinfo file) is provided for the logging procedure. Given a\n",
+ "# template with locations for, a bug-id number, a list of people who\n",
+ "# reviewed the code before it can be checked in, and an external\n",
+ "# process to catalog the differences that were code reviewed, the\n",
+ "# following test can be applied to the code:\n",
+ "#\n",
+ "# Making sure that the entered bug-id number is correct.\n",
+ "# Validating that the code that was reviewed is indeed the code being\n",
+ "# checked in (using the bug-id number or a seperate review\n",
+ "# number to identify this particular code set.).\n",
+ "#\n",
+ "# If any of the above test failed, then the commit would be aborted.\n",
+ "#\n",
+ "# Actions such as mailing a copy of the report to each reviewer are\n",
+ "# better handled by an entry in the loginfo file.\n",
+ "#\n",
+ "# One thing that should be noted is the the ALL keyword is not\n",
+ "# supported. There can be only one entry that matches a given\n",
"# repository.\n",
NULL
};
@@ -222,6 +260,9 @@ static const char *const modules_contents[] = {
"# -d dir Place module in directory \"dir\" instead of module name.\n",
"# -l Top-level directory only -- do not recurse.\n",
"#\n",
+ "# NOTE: If you change any of the \"Run\" options above, you'll have to\n",
+ "# release and re-checkout any working directories of these modules.\n",
+ "#\n",
"# And \"directory\" is a path to a directory relative to $CVSROOT.\n",
"#\n",
"# The \"-a\" option specifies an alias. An alias is interpreted as if\n",
@@ -244,6 +285,9 @@ static const struct admin_file filelist[] = {
{CVSROOTADM_EDITINFO,
"a %s file can be used to validate log messages",
editinfo_contents},
+ {CVSROOTADM_VERIFYMSG,
+ "a %s file can be used to validate log messages",
+ verifymsg_contents},
{CVSROOTADM_COMMITINFO,
"a %s file can be used to configure 'cvs commit' checking",
commitinfo_contents},
@@ -266,6 +310,20 @@ static const struct admin_file filelist[] = {
/* modules is special-cased in mkmodules. */
NULL,
modules_contents},
+ {CVSROOTADM_READERS,
+ "a %s file specifies read-only users",
+ NULL},
+ {CVSROOTADM_WRITERS,
+ "a %s file specifies read/write users",
+ NULL},
+ /* Some have suggested listing CVSROOTADM_PASSWD here too. The
+ security implications of transmitting hashed passwords over the
+ net are no worse than transmitting cleartext passwords which pserver
+ does, so this isn't a problem. But I'm worried about the implications
+ of storing old passwords--if someone used a password in the past
+ they might be using it elsewhere, using a similar password, etc,
+ and so it doesn't seem to me like we should be saving old passwords,
+ even hashed. */
{NULL, NULL}
};
@@ -275,27 +333,26 @@ mkmodules (dir)
char *dir;
{
struct saved_cwd cwd;
- /* FIXME: arbitrary limit */
- char temp[PATH_MAX];
+ char *temp;
char *cp, *last, *fname;
#ifdef MY_NDBM
DBM *db;
#endif
FILE *fp;
- /* FIXME: arbitrary limit */
- char line[512];
+ char *line = NULL;
+ size_t line_allocated = 0;
const struct admin_file *fileptr;
if (save_cwd (&cwd))
- exit (EXIT_FAILURE);
+ error_exit ();
- if (chdir (dir) < 0)
+ if ( CVS_CHDIR (dir) < 0)
error (1, errno, "cannot chdir to %s", dir);
/*
* First, do the work necessary to update the "modules" database.
*/
- make_tempfile (temp);
+ temp = make_tempfile ();
switch (checkout_file (CVSROOTADM_MODULES, temp))
{
@@ -313,7 +370,7 @@ mkmodules (dir)
case -1: /* fork failed */
(void) unlink_file (temp);
- exit (EXIT_FAILURE);
+ error (1, errno, "cannot check out %s", CVSROOTADM_MODULES);
/* NOTREACHED */
default:
@@ -324,12 +381,13 @@ mkmodules (dir)
} /* switch on checkout_file() */
(void) unlink_file (temp);
+ free (temp);
/* Checkout the files that need it in CVSROOT dir */
for (fileptr = filelist; fileptr && fileptr->filename; fileptr++) {
if (fileptr->errormsg == NULL)
continue;
- make_tempfile (temp);
+ temp = make_tempfile ();
if (checkout_file (fileptr->filename, temp) == 0)
rename_rcsfile (temp, fileptr->filename);
#if 0
@@ -344,10 +402,10 @@ mkmodules (dir)
error (0, 0, fileptr->errormsg, fileptr->filename);
#endif
(void) unlink_file (temp);
+ free (temp);
}
- /* Use 'fopen' instead of 'open_file' because we want to ignore error */
- fp = fopen (CVSROOTADM_CHECKOUTLIST, "r");
+ fp = CVS_FOPEN (CVSROOTADM_CHECKOUTLIST, "r");
if (fp)
{
/*
@@ -356,7 +414,7 @@ mkmodules (dir)
*
* comment lines begin with '#'
*/
- while (fgets (line, sizeof (line), fp) != NULL)
+ while (getline (&line, &line_allocated, fp) >= 0)
{
/* skip lines starting with # */
if (line[0] == '#')
@@ -374,7 +432,7 @@ mkmodules (dir)
;
*cp = '\0';
- make_tempfile (temp);
+ temp = make_tempfile ();
if (checkout_file (fname, temp) == 0)
{
rename_rcsfile (temp, fname);
@@ -386,12 +444,24 @@ mkmodules (dir)
if (cp < last && *cp)
error (0, 0, cp, fname);
}
+ free (temp);
}
- (void) fclose (fp);
+ if (line)
+ free (line);
+ if (ferror (fp))
+ error (0, errno, "cannot read %s", CVSROOTADM_CHECKOUTLIST);
+ if (fclose (fp) < 0)
+ error (0, errno, "cannot close %s", CVSROOTADM_CHECKOUTLIST);
+ }
+ else
+ {
+ /* Error from CVS_FOPEN. */
+ if (!existence_error (errno))
+ error (0, errno, "cannot open %s", CVSROOTADM_CHECKOUTLIST);
}
if (restore_cwd (&cwd, NULL))
- exit (EXIT_FAILURE);
+ error_exit ();
free_cwd (&cwd);
return (0);
@@ -400,25 +470,27 @@ mkmodules (dir)
/*
* Yeah, I know, there are NFS race conditions here.
*/
-static void
-make_tempfile (temp)
- char *temp;
+static char *
+make_tempfile ()
{
static int seed = 0;
int fd;
+ char *temp;
if (seed == 0)
seed = getpid ();
+ temp = xmalloc (sizeof (BAKPREFIX) + 40);
while (1)
{
(void) sprintf (temp, "%s%d", BAKPREFIX, seed++);
- if ((fd = open (temp, O_CREAT|O_EXCL|O_RDWR, 0666)) != -1)
+ if ((fd = CVS_OPEN (temp, O_CREAT|O_EXCL|O_RDWR, 0666)) != -1)
break;
if (errno != EEXIST)
error (1, errno, "cannot create temporary file %s", temp);
}
if (close(fd) < 0)
error(1, errno, "cannot close temporary file %s", temp);
+ return temp;
}
static int
@@ -426,18 +498,31 @@ checkout_file (file, temp)
char *file;
char *temp;
{
- char rcs[PATH_MAX];
+ char *rcs;
+ RCSNode *rcsnode;
int retcode = 0;
- (void) sprintf (rcs, "%s%s", file, RCSEXT);
+ if (noexec)
+ return 0;
+
+ rcs = xmalloc (strlen (file) + 5);
+ strcpy (rcs, file);
+ strcat (rcs, RCSEXT);
if (!isfile (rcs))
+ {
+ free (rcs);
return (1);
- run_setup ("%s%s -x,v/ -q -p", Rcsbin, RCS_CO);
- run_arg (rcs);
- if ((retcode = run_exec (RUN_TTY, temp, RUN_TTY, RUN_NORMAL)) != 0)
+ }
+ rcsnode = RCS_parsercsfile (rcs);
+ retcode = RCS_checkout (rcsnode, NULL, NULL, NULL, NULL, temp,
+ (RCSCHECKOUTPROC) NULL, (void *) NULL);
+ if (retcode != 0)
{
- error (0, retcode == -1 ? errno : 0, "failed to check out %s file", file);
+ error (0, retcode == -1 ? errno : 0, "failed to check out %s file",
+ file);
}
+ freercsnode (&rcsnode);
+ free (rcs);
return (retcode);
}
@@ -568,12 +653,12 @@ rename_dbmfile (temp)
(void) unlink_file (bakdir); /* rm .#modules.dir .#modules.pag */
(void) unlink_file (bakpag);
(void) unlink_file (bakdb);
- (void) rename (dotdir, bakdir); /* mv modules.dir .#modules.dir */
- (void) rename (dotpag, bakpag); /* mv modules.pag .#modules.pag */
- (void) rename (dotdb, bakdb); /* mv modules.db .#modules.db */
- (void) rename (newdir, dotdir); /* mv "temp".dir modules.dir */
- (void) rename (newpag, dotpag); /* mv "temp".pag modules.pag */
- (void) rename (newdb, dotdb); /* mv "temp".db modules.db */
+ (void) CVS_RENAME (dotdir, bakdir); /* mv modules.dir .#modules.dir */
+ (void) CVS_RENAME (dotpag, bakpag); /* mv modules.pag .#modules.pag */
+ (void) CVS_RENAME (dotdb, bakdb); /* mv modules.db .#modules.db */
+ (void) CVS_RENAME (newdir, dotdir); /* mv "temp".dir modules.dir */
+ (void) CVS_RENAME (newpag, dotpag); /* mv "temp".pag modules.pag */
+ (void) CVS_RENAME (newdb, dotdb); /* mv "temp".db modules.db */
/* OK -- make my day */
SIG_endCrSect ();
@@ -586,21 +671,25 @@ rename_rcsfile (temp, real)
char *temp;
char *real;
{
- char bak[50];
+ char *bak;
struct stat statbuf;
- char rcs[PATH_MAX];
-
+ char *rcs;
+
/* Set "x" bits if set in original. */
+ rcs = xmalloc (strlen (real) + sizeof (RCSEXT) + 10);
(void) sprintf (rcs, "%s%s", real, RCSEXT);
statbuf.st_mode = 0; /* in case rcs file doesn't exist, but it should... */
- (void) stat (rcs, &statbuf);
+ (void) CVS_STAT (rcs, &statbuf);
+ free (rcs);
if (chmod (temp, 0444 | (statbuf.st_mode & 0111)) < 0)
error (0, errno, "warning: cannot chmod %s", temp);
+ bak = xmalloc (strlen (real) + sizeof (BAKPREFIX) + 10);
(void) sprintf (bak, "%s%s", BAKPREFIX, real);
(void) unlink_file (bak); /* rm .#loginfo */
- (void) rename (real, bak); /* mv loginfo .#loginfo */
- (void) rename (temp, real); /* mv "temp" loginfo */
+ (void) CVS_RENAME (real, bak); /* mv loginfo .#loginfo */
+ (void) CVS_RENAME (temp, real); /* mv "temp" loginfo */
+ free (bak);
}
const char *const init_usage[] = {
@@ -608,26 +697,6 @@ const char *const init_usage[] = {
NULL
};
-/* Create directory NAME if it does not already exist; fatal error for
- other errors. FIXME: This should be in filesubr.c or thereabouts,
- probably. Perhaps it should be further abstracted, though (for example
- to handle CVSUMASK where appropriate?). */
-static void
-mkdir_if_needed (name)
- char *name;
-{
- if (CVS_MKDIR (name, 0777) < 0)
- {
- if (errno != EEXIST
-#ifdef EACCESS
- /* OS/2; see longer comment in client.c. */
- && errno != EACCESS
-#endif
- )
- error (1, errno, "cannot mkdir %s", name);
- }
-}
-
int
init (argc, argv)
int argc;
@@ -644,9 +713,10 @@ init (argc, argv)
umask (cvsumask);
- if (argc > 1)
+ if (argc == -1 || argc > 1)
usage (init_usage);
+#ifdef CLIENT_SUPPORT
if (client_active)
{
start_server ();
@@ -655,21 +725,22 @@ init (argc, argv)
send_init_command ();
return get_responses_and_close ();
}
+#endif /* CLIENT_SUPPORT */
/* 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
which needs to be created. */
- mkdir_if_needed (CVSroot);
+ mkdir_if_needed (CVSroot_directory);
- adm = xmalloc (strlen (CVSroot) + sizeof (CVSROOTADM) + 10);
- strcpy (adm, CVSroot);
+ adm = xmalloc (strlen (CVSroot_directory) + sizeof (CVSROOTADM) + 10);
+ strcpy (adm, CVSroot_directory);
strcat (adm, "/");
strcat (adm, CVSROOTADM);
mkdir_if_needed (adm);
/* This is needed by the call to "ci" below. */
- if (chdir (adm) < 0)
+ if ( CVS_CHDIR (adm) < 0)
error (1, errno, "cannot change to directory %s", adm);
/* 80 is long enough for all the administrative file names, plus
diff --git a/contrib/cvs/src/modules.c b/contrib/cvs/src/modules.c
index 0e07c0b..7c3d495 100644
--- a/contrib/cvs/src/modules.c
+++ b/contrib/cvs/src/modules.c
@@ -54,17 +54,21 @@ static void save_d PROTO((char *k, int ks, char *d, int ds));
DBM *
open_module ()
{
- char mfile[PATH_MAX];
+ char *mfile;
+ DBM *retval;
- if (CVSroot == NULL)
+ if (CVSroot_original == NULL)
{
- (void) fprintf (stderr,
- "%s: must set the CVSROOT environment variable\n",
- program_name);
- error (1, 0, "or specify the '-d' option to %s", program_name);
+ error (0, 0, "must set the CVSROOT environment variable");
+ error (1, 0, "or specify the '-d' global option");
}
- (void) sprintf (mfile, "%s/%s/%s", CVSroot, CVSROOTADM, CVSROOTADM_MODULES);
- return (dbm_open (mfile, O_RDONLY, 0666));
+ mfile = xmalloc (strlen (CVSroot_directory) + sizeof (CVSROOTADM)
+ + sizeof (CVSROOTADM_MODULES) + 20);
+ (void) sprintf (mfile, "%s/%s/%s", CVSroot_directory,
+ CVSROOTADM, CVSROOTADM_MODULES);
+ retval = dbm_open (mfile, O_RDONLY, 0666);
+ free (mfile);
+ return retval;
}
/*
@@ -103,42 +107,57 @@ do_module (db, mname, m_type, msg, callback_proc, where,
char *tag_prog = NULL;
char *update_prog = NULL;
struct saved_cwd cwd;
+ int cwd_saved = 0;
char *line;
int modargc;
int xmodargc;
char **modargv;
- char *xmodargv[MAXFILEPERDIR];
+ char **xmodargv;
char *value;
- char *zvalue;
+ char *zvalue = NULL;
char *mwhere = NULL;
char *mfile = NULL;
char *spec_opt = NULL;
- char xvalue[PATH_MAX];
+ char *xvalue = NULL;
int alias = 0;
datum key, val;
char *cp;
int c, err = 0;
+ int nonalias_opt = 0;
#ifdef SERVER_SUPPORT
+ int restore_server_dir = 0;
+ char *server_dir_to_restore;
if (trace)
- {
- fprintf (stderr, "%s%c-> do_module (%s, %s, %s, %s)\n",
- error_use_protocol ? "E " : "",
+ {
+ char *buf;
+
+ /* We use cvs_outerr, rather than fprintf to stderr, because
+ this may be called by server code with error_use_protocol
+ set. */
+ buf = xmalloc (100
+ + strlen (mname)
+ + strlen (msg)
+ + (where ? strlen (where) : 0)
+ + (extra_arg ? strlen (extra_arg) : 0));
+ sprintf (buf, "%c-> do_module (%s, %s, %s, %s)\n",
(server_active) ? 'S' : ' ',
mname, msg, where ? where : "",
extra_arg ? extra_arg : "");
- }
+ cvs_outerr (buf, 0);
+ free (buf);
+ }
#endif
/* if this is a directory to ignore, add it to that list */
if (mname[0] == '!' && mname[1] != '\0')
{
ign_dir_add (mname+1);
- return(err);
+ goto do_module_return;
}
/* strip extra stuff from the module name */
- strip_path (mname);
+ strip_trailing_slashes (mname);
/*
* Look up the module using the following scheme:
@@ -182,28 +201,31 @@ do_module (db, mname, m_type, msg, callback_proc, where,
}
else
{
- char file[PATH_MAX];
- char attic_file[PATH_MAX];
+ char *file;
+ char *attic_file;
char *acp;
+ int is_found = 0;
/* check to see if mname is a directory or file */
-
- (void) sprintf (file, "%s/%s", CVSroot, mname);
+ file = xmalloc (strlen (CVSroot_directory) + strlen (mname) + 10);
+ (void) sprintf (file, "%s/%s", CVSroot_directory, mname);
+ attic_file = xmalloc (strlen (CVSroot_directory) + strlen (mname)
+ + sizeof (CVSATTIC) + sizeof (RCSEXT) + 15);
if ((acp = strrchr (mname, '/')) != NULL)
{
*acp = '\0';
- (void) sprintf (attic_file, "%s/%s/%s/%s%s", CVSroot, mname,
- CVSATTIC, acp + 1, RCSEXT);
+ (void) sprintf (attic_file, "%s/%s/%s/%s%s", CVSroot_directory,
+ mname, CVSATTIC, acp + 1, RCSEXT);
*acp = '/';
}
else
- (void) sprintf (attic_file, "%s/%s/%s%s", CVSroot, CVSATTIC,
- mname, RCSEXT);
+ (void) sprintf (attic_file, "%s/%s/%s%s", CVSroot_directory,
+ CVSATTIC, mname, RCSEXT);
if (isdir (file))
{
value = mname;
- goto found;
+ is_found = 1;
}
else
{
@@ -215,7 +237,9 @@ do_module (db, mname, m_type, msg, callback_proc, where,
{
char *slashp;
- /* put the ' ' in a copy so we don't mess up the original */
+ /* put the ' ' in a copy so we don't mess up the
+ original */
+ xvalue = xmalloc (strlen (mname) + 2);
value = strcpy (xvalue, mname);
slashp = strrchr (value, '/');
*slashp = ' ';
@@ -230,19 +254,26 @@ do_module (db, mname, m_type, msg, callback_proc, where,
if (cp == mname)
{
/* drop the leading / if specified */
+ xvalue = xmalloc (strlen (mname) + 10);
value = strcpy (xvalue, ". ");
(void) strcat (xvalue, mname + 1);
}
else
{
/* otherwise just copy it */
+ xvalue = xmalloc (strlen (mname) + 10);
value = strcpy (xvalue, ". ");
(void) strcat (xvalue, mname);
}
}
- goto found;
+ is_found = 1;
}
}
+ free (attic_file);
+ free (file);
+
+ if (is_found)
+ goto found;
}
/* look up everything to the first / as a module */
@@ -293,9 +324,7 @@ do_module (db, mname, m_type, msg, callback_proc, where,
/* if we got here, we couldn't find it using our search, so give up */
error (0, 0, "cannot find module `%s' - ignored", mname);
err++;
- if (mwhere)
- free (mwhere);
- return (err);
+ goto do_module_return;
/*
@@ -306,7 +335,8 @@ do_module (db, mname, m_type, msg, callback_proc, where,
/* remember where we start */
if (save_cwd (&cwd))
- exit (EXIT_FAILURE);
+ error_exit ();
+ cwd_saved = 1;
/* copy value to our own string since if we go recursive we'll be
really screwed if we do another dbm lookup */
@@ -343,7 +373,7 @@ do_module (db, mname, m_type, msg, callback_proc, where,
/* XXX - think about making null repositories at each dir here
instead of just at the bottom */
make_directories (dir);
- if (chdir (dir) < 0)
+ if ( CVS_CHDIR (dir) < 0)
{
error (0, errno, "cannot chdir to %s", dir);
spec_opt = NULL;
@@ -352,9 +382,13 @@ do_module (db, mname, m_type, msg, callback_proc, where,
}
if (!isfile (CVSADM))
{
- char nullrepos[PATH_MAX];
+ char *nullrepos;
- (void) sprintf (nullrepos, "%s/%s/%s", CVSroot,
+ nullrepos = xmalloc (strlen (CVSroot_directory)
+ + sizeof (CVSROOTADM)
+ + sizeof (CVSNULLREPOS)
+ + 10);
+ (void) sprintf (nullrepos, "%s/%s/%s", CVSroot_directory,
CVSROOTADM, CVSNULLREPOS);
if (!isfile (nullrepos))
{
@@ -367,7 +401,7 @@ do_module (db, mname, m_type, msg, callback_proc, where,
error (1, 0, "there is no repository %s", nullrepos);
Create_Admin (".", dir,
- nullrepos, (char *) NULL, (char *) NULL);
+ nullrepos, (char *) NULL, (char *) NULL, 0);
if (!noexec)
{
FILE *fp;
@@ -380,6 +414,7 @@ do_module (db, mname, m_type, msg, callback_proc, where,
server_set_entstat (dir, nullrepos);
#endif
}
+ free (nullrepos);
}
out:
goto do_special;
@@ -404,7 +439,7 @@ do_module (db, mname, m_type, msg, callback_proc, where,
(void) sprintf (line, "%s %s", "XXX", value);
/* turn the line into an argv[] array */
- line2argv (&xmodargc, xmodargv, line);
+ line2argv (&xmodargc, &xmodargv, line);
free (line);
modargc = xmodargc;
modargv = xmodargv;
@@ -419,26 +454,33 @@ do_module (db, mname, m_type, msg, callback_proc, where,
alias = 1;
break;
case 'd':
+ nonalias_opt = 1;
if (mwhere)
free (mwhere);
mwhere = xstrdup (optarg);
break;
case 'i':
+ nonalias_opt = 1;
checkin_prog = optarg;
break;
case 'l':
+ nonalias_opt = 1;
local_specified = 1;
break;
case 'o':
+ nonalias_opt = 1;
checkout_prog = optarg;
break;
case 'e':
+ nonalias_opt = 1;
export_prog = optarg;
break;
case 't':
+ nonalias_opt = 1;
tag_prog = optarg;
break;
case 'u':
+ nonalias_opt = 1;
update_prog = optarg;
break;
case '?':
@@ -446,11 +488,7 @@ do_module (db, mname, m_type, msg, callback_proc, where,
"modules file has invalid option for key %s value %s",
key.dptr, val.dptr);
err++;
- if (mwhere)
- free (mwhere);
- free (zvalue);
- free_cwd (&cwd);
- return (err);
+ goto do_module_return;
}
}
modargc -= optind;
@@ -458,11 +496,20 @@ do_module (db, mname, m_type, msg, callback_proc, where,
if (modargc == 0)
{
error (0, 0, "modules file missing directory for module %s", mname);
- if (mwhere)
- free (mwhere);
- free (zvalue);
- free_cwd (&cwd);
- return (++err);
+ ++err;
+ goto do_module_return;
+ }
+
+ if (alias && nonalias_opt)
+ {
+ /* The documentation has never said it is legal to specify
+ -a along with another option. And I believe that in the past
+ CVS has ignored the options other than -a, more or less, in this
+ situation. */
+ error (0, 0, "\
+-a cannot be specified in the modules file along with other options");
+ ++err;
+ goto do_module_return;
}
/* if this was an alias, call ourselves recursively for each module */
@@ -481,11 +528,7 @@ do_module (db, mname, m_type, msg, callback_proc, where,
where, shorten, local_specified,
run_module_prog, extra_arg);
}
- if (mwhere)
- free (mwhere);
- free (zvalue);
- free_cwd (&cwd);
- return (err);
+ goto do_module_return;
}
/* otherwise, process this module */
@@ -507,6 +550,40 @@ do_module (db, mname, m_type, msg, callback_proc, where,
if (local_specified)
spec_opt = NULL;
+#ifdef SERVER_SUPPORT
+ /* We want to check out into the directory named by the module.
+ So we set a global variable which tells the server to glom that
+ directory name onto the front. A cleaner approach would be some
+ way of passing it down to the recursive call, through the
+ callback_proc, to start_recursion, and then into the update_dir in
+ the struct file_info. That way the "Updating foo" message could
+ print the actual directory we are checking out into.
+
+ For local CVS, this is handled by the chdir call above
+ (directly or via the callback_proc). */
+ if (server_active && spec_opt != NULL)
+ {
+ char *change_to;
+
+ change_to = where ? where : (mwhere ? mwhere : mname);
+ server_dir_to_restore = server_dir;
+ restore_server_dir = 1;
+ server_dir =
+ xmalloc ((server_dir_to_restore != NULL
+ ? strlen (server_dir_to_restore)
+ : 0)
+ + strlen (change_to)
+ + 5);
+ server_dir[0] = '\0';
+ if (server_dir_to_restore != NULL)
+ {
+ strcat (server_dir, server_dir_to_restore);
+ strcat (server_dir, "/");
+ }
+ strcat (server_dir, change_to);
+ }
+#endif
+
while (spec_opt != NULL)
{
char *next_opt;
@@ -539,6 +616,14 @@ do_module (db, mname, m_type, msg, callback_proc, where,
spec_opt = next_opt;
}
+#ifdef SERVER_SUPPORT
+ if (server_active && restore_server_dir)
+ {
+ free (server_dir);
+ server_dir = server_dir_to_restore;
+ }
+#endif
+
/* write out the checkin/update prog files if necessary */
#ifdef SERVER_SUPPORT
if (err == 0 && !noexec && m_type == CHECKOUT && server_expanding)
@@ -572,8 +657,9 @@ do_module (db, mname, m_type, msg, callback_proc, where,
/* cd back to where we started */
if (restore_cwd (&cwd, NULL))
- exit (EXIT_FAILURE);
+ error_exit ();
free_cwd (&cwd);
+ cwd_saved = 0;
/* run checkout or tag prog if appropriate */
if (err == 0 && run_module_prog)
@@ -588,38 +674,57 @@ do_module (db, mname, m_type, msg, callback_proc, where,
* if we can't find a matching program, just punt and use
* whatever is specified in the modules file.
*/
- char real_prog[PATH_MAX];
+ char *real_prog = NULL;
char *prog = (m_type == TAG ? tag_prog :
(m_type == CHECKOUT ? checkout_prog : export_prog));
char *real_where = (where != NULL ? where : mwhere);
+ char *expanded_path;
if ((*prog != '/') && (*prog != '.'))
{
+ real_prog = xmalloc (strlen (real_where) + strlen (prog)
+ + 10);
(void) sprintf (real_prog, "%s/%s", real_where, prog);
if (isfile (real_prog))
prog = real_prog;
}
- run_setup ("%s %s", prog, real_where);
- if (extra_arg)
- run_arg (extra_arg);
-
- if (!quiet)
+ /* XXX can we determine the line number for this entry??? */
+ expanded_path = expand_path (prog, "modules", 0);
+ if (expanded_path != NULL)
{
- (void) printf ("%s %s: Executing '", program_name,
- command_name);
- run_print (stdout);
- (void) printf ("'\n");
+ run_setup ("%s %s", expanded_path, real_where);
+
+ if (extra_arg)
+ run_arg (extra_arg);
+
+ if (!quiet)
+ {
+ cvs_output (program_name, 0);
+ cvs_output (" ", 1);
+ cvs_output (command_name, 0);
+ cvs_output (": Executing '", 0);
+ run_print (stdout);
+ cvs_output ("'\n", 0);
+ }
+ err += run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL);
+ free (expanded_path);
}
- err += run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL);
+ free (real_prog);
}
}
+ do_module_return:
/* clean up */
if (mwhere)
free (mwhere);
- free (zvalue);
+ if (cwd_saved)
+ free_cwd (&cwd);
+ if (zvalue != NULL)
+ free (zvalue);
+ if (xvalue != NULL)
+ free (xvalue);
return (err);
}
@@ -774,24 +879,7 @@ cat_module (status)
int moduleargc;
struct sortrec *s_h;
char *cp, *cp2, **argv;
- char *line;
- char *moduleargv[MAXFILEPERDIR];
-
-#ifdef sun
-#ifdef TIOCGSIZE
- struct ttysize ts;
-
- (void) ioctl (0, TIOCGSIZE, &ts);
- cols = ts.ts_cols;
-#endif
-#else
-#ifdef TIOCGWINSZ
- struct winsize ws;
-
- (void) ioctl (0, TIOCGWINSZ, &ws);
- cols = ws.ws_col;
-#endif
-#endif
+ char **moduleargv;
Status = status;
@@ -806,6 +894,8 @@ cat_module (status)
save_d (key.dptr, key.dsize, val.dptr, val.dsize);
}
+ close_module (db);
+
/* Sort the list as requested */
qsort ((PTR) s_head, s_count, sizeof (struct sortrec), sort_order);
@@ -817,19 +907,27 @@ cat_module (status)
fill = cols - (indent + 2);
for (s_h = s_head, i = 0; i < s_count; i++, s_h++)
{
+ char *line;
+
/* Print module name (and status, if wanted) */
- (void) printf ("%-12s", s_h->modname);
+ line = xmalloc (strlen (s_h->modname) + 15);
+ sprintf (line, "%-12s", s_h->modname);
+ cvs_output (line, 0);
+ free (line);
if (status)
{
- (void) printf (" %-11s", s_h->status);
+ line = xmalloc (strlen (s_h->status) + 15);
+ sprintf (line, " %-11s", s_h->status);
+ cvs_output (line, 0);
if (s_h->status != def_status)
*(s_h->status + strlen (s_h->status)) = ' ';
+ free (line);
}
+ line = xmalloc (strlen (s_h->modname) + strlen (s_h->rest) + 15);
/* Parse module file entry as command line and print options */
- line = xmalloc (strlen (s_h->modname) + strlen (s_h->rest) + 10);
(void) sprintf (line, "%s %s", s_h->modname, s_h->rest);
- line2argv (&moduleargc, moduleargv, line);
+ line2argv (&moduleargc, &moduleargv, line);
free (line);
argc = moduleargc;
argv = moduleargv;
@@ -842,17 +940,28 @@ cat_module (status)
{
if (c == 'a' || c == 'l')
{
- (void) printf (" -%c", c);
+ char buf[5];
+
+ sprintf (buf, " -%c", c);
+ cvs_output (buf, 0);
wid += 3; /* Could just set it to 3 */
}
else
{
+ char buf[10];
+
if (strlen (optarg) + 4 + wid > (unsigned) fill)
{
- (void) printf ("\n%*s", indent, "");
+ int j;
+
+ cvs_output ("\n", 1);
+ for (j = 0; j < indent; ++j)
+ cvs_output (" ", 1);
wid = 0;
}
- (void) printf (" -%c %s", c, optarg);
+ sprintf (buf, " -%c ", c);
+ cvs_output (buf, 0);
+ cvs_output (optarg, 0);
wid += strlen (optarg) + 4;
}
}
@@ -865,21 +974,31 @@ cat_module (status)
{
if (strlen (*argv) + wid > (unsigned) fill)
{
- (void) printf ("\n%*s", indent, "");
+ int j;
+
+ cvs_output ("\n", 1);
+ for (j = 0; j < indent; ++j)
+ cvs_output (" ", 1);
wid = 0;
}
- (void) printf (" %s", *argv);
+ cvs_output (" ", 1);
+ cvs_output (*argv, 0);
wid += strlen (*argv) + 1;
}
- (void) printf ("\n");
+ cvs_output ("\n", 1);
/* Format the comment field -- save_d (), compressed spaces */
for (cp2 = cp = s_h->comment; *cp; cp2 = cp)
{
- (void) printf ("%*s # ", indent, "");
+ int j;
+
+ for (j = 0; j < indent; ++j)
+ cvs_output (" ", 1);
+ cvs_output (" # ", 0);
if (strlen (cp2) < (unsigned) (fill - 2))
{
- (void) printf ("%s\n", cp2);
+ cvs_output (cp2, 0);
+ cvs_output ("\n", 1);
break;
}
cp += fill - 2;
@@ -887,12 +1006,14 @@ cat_module (status)
cp--;
if (cp == cp2)
{
- (void) printf ("%s\n", cp2);
+ cvs_output (cp2, 0);
+ cvs_output ("\n", 1);
break;
}
*cp++ = '\0';
- (void) printf ("%s\n", cp2);
+ cvs_output (cp2, 0);
+ cvs_output ("\n", 1);
}
free_names(&moduleargc, moduleargv);
diff --git a/contrib/cvs/src/myndbm.c b/contrib/cvs/src/myndbm.c
index 527f7ee..1a3fcae 100644
--- a/contrib/cvs/src/myndbm.c
+++ b/contrib/cvs/src/myndbm.c
@@ -19,7 +19,7 @@
#ifdef MY_NDBM
-static void mydbm_load_file ();
+static void mydbm_load_file PROTO ((FILE *, List *));
/* ARGSUSED */
DBM *
@@ -31,7 +31,7 @@ mydbm_open (file, flags, mode)
FILE *fp;
DBM *db;
- fp = fopen (file, FOPEN_BINARY_READ);
+ fp = CVS_FOPEN (file, FOPEN_BINARY_READ);
if (fp == NULL && !(existence_error (errno) && (flags & O_CREAT)))
return ((DBM *) 0);
@@ -71,7 +71,7 @@ mydbm_close (db)
if (db->modified)
{
FILE *fp;
- fp = fopen (db->name, FOPEN_BINARY_WRITE);
+ fp = CVS_FOPEN (db->name, FOPEN_BINARY_WRITE);
if (fp == NULL)
error (1, errno, "cannot write %s", db->name);
walklist (db->dbm_list, write_item, (void *)fp);
@@ -199,11 +199,14 @@ mydbm_load_file (fp, list)
{
char *line = NULL;
size_t line_len;
- /* FIXME: arbitrary limit. */
- char value[MAXLINELEN];
+ char *value;
+ size_t value_allocated;
char *cp, *vp;
int len, cont;
+ value_allocated = 1;
+ value = xmalloc (value_allocated);
+
for (cont = 0; getline (&line, &line_len, fp) >= 0;)
{
if ((cp = strrchr (line, '\012')) != NULL)
@@ -221,9 +224,8 @@ mydbm_load_file (fp, list)
* line; otherwise at the beginning, but only after any trailing
* backslash is removed.
*/
- vp = value;
- if (cont)
- vp += strlen (value);
+ if (!cont)
+ value[0] = '\0';
/*
* See if the line we read is a continuation line, and strip the
@@ -243,7 +245,11 @@ mydbm_load_file (fp, list)
{
cont = 0;
}
- (void) strcpy (vp, line);
+ expand_string (&value,
+ &value_allocated,
+ strlen (value) + strlen (line) + 5);
+ strcat (value, line);
+
if (value[0] == '#')
continue; /* comment line */
vp = value;
@@ -283,6 +289,7 @@ mydbm_load_file (fp, list)
}
}
free (line);
+ free (value);
}
#endif /* MY_NDBM */
diff --git a/contrib/cvs/src/myndbm.h b/contrib/cvs/src/myndbm.h
index 0431e15..2bce739 100644
--- a/contrib/cvs/src/myndbm.h
+++ b/contrib/cvs/src/myndbm.h
@@ -1,5 +1,3 @@
-/* $CVSid: @(#)myndbm.h 1.4 94/09/21 $ */
-
#ifdef MY_NDBM
#define DBLKSIZ 4096
diff --git a/contrib/cvs/src/no_diff.c b/contrib/cvs/src/no_diff.c
index a0d00f5..384800f 100644
--- a/contrib/cvs/src/no_diff.c
+++ b/contrib/cvs/src/no_diff.c
@@ -17,20 +17,22 @@
#include "cvs.h"
int
-No_Difference (file, vers, entries, repository, update_dir)
- char *file;
+No_Difference (finfo, vers)
+ struct file_info *finfo;
Vers_TS *vers;
- List *entries;
- char *repository;
- char *update_dir;
{
Node *p;
- char tmp[L_tmpnam+1];
int ret;
char *ts, *options;
int retcode = 0;
char *tocvsPath;
+ /* If ts_user is "Is-modified", we can only conclude the files are
+ different (since we don't have the file's contents). */
+ if (vers->ts_user != NULL
+ && strcmp (vers->ts_user, "Is-modified") == 0)
+ return -1;
+
if (!vers->srcfile || !vers->srcfile->path)
return (-1); /* different since we couldn't tell */
@@ -39,91 +41,51 @@ No_Difference (file, vers, entries, repository, update_dir)
else
options = xstrdup ("");
- retcode = RCS_checkout (vers->srcfile->path, NULL, vers->vn_user, options,
- tmpnam (tmp), 0, 0);
+ tocvsPath = wrap_tocvs_process_file (finfo->file);
+ retcode = RCS_cmp_file (vers->srcfile, vers->vn_user, options,
+ tocvsPath == NULL ? finfo->file : tocvsPath);
if (retcode == 0)
{
-#if 0
- /* Why would we want to munge the modes? And only if the timestamps
- are different? And even for commands like "cvs status"???? */
- if (!iswritable (file)) /* fix the modes as a side effect */
- xchmod (file, 1);
-#endif
-
- tocvsPath = wrap_tocvs_process_file (file);
-
- /* do the byte by byte compare */
- if (xcmp (tocvsPath == NULL ? file : tocvsPath, tmp) == 0)
- {
-#if 0
- /* Why would we want to munge the modes? And only if the
- timestamps are different? And even for commands like
- "cvs status"???? */
- if (cvswrite == FALSE) /* fix the modes as a side effect */
- xchmod (file, 0);
-#endif
-
- /* no difference was found, so fix the entries file */
- ts = time_stamp (file);
- Register (entries, file,
- vers->vn_user ? vers->vn_user : vers->vn_rcs, ts,
- options, vers->tag, vers->date, (char *) 0);
+ /* no difference was found, so fix the entries file */
+ ts = time_stamp (finfo->file);
+ Register (finfo->entries, finfo->file,
+ vers->vn_user ? vers->vn_user : vers->vn_rcs, ts,
+ options, vers->tag, vers->date, (char *) 0);
#ifdef SERVER_SUPPORT
- if (server_active)
- {
- /* We need to update the entries line on the client side. */
- server_update_entries
- (file, update_dir, repository, SERVER_UPDATED);
- }
+ if (server_active)
+ {
+ /* We need to update the entries line on the client side. */
+ server_update_entries
+ (finfo->file, finfo->update_dir, finfo->repository, SERVER_UPDATED);
+ }
#endif
- free (ts);
+ free (ts);
- /* update the entdata pointer in the vers_ts structure */
- p = findnode (entries, file);
- vers->entdata = (Entnode *) p->data;
+ /* update the entdata pointer in the vers_ts structure */
+ p = findnode (finfo->entries, finfo->file);
+ vers->entdata = (Entnode *) p->data;
- ret = 0;
- }
- else
- ret = 1; /* files were really different */
- if (tocvsPath)
- {
- /* Need to call unlink myself because the noexec variable
- * has been set to 1. */
- if (trace)
- (void) fprintf (stderr, "%c-> unlink (%s)\n",
-#ifdef SERVER_SUPPORT
- (server_active) ? 'S' : ' ',
-#else
- ' ',
-#endif
- tocvsPath);
- if (unlink (tocvsPath) < 0)
- error (0, errno, "could not remove %s", tocvsPath);
- }
+ ret = 0;
}
else
- {
- if (update_dir[0] == '\0')
- error (0, retcode == -1 ? errno : 0,
- "could not check out revision %s of %s",
- vers->vn_user, file);
- else
- error (0, retcode == -1 ? errno : 0,
- "could not check out revision %s of %s/%s",
- vers->vn_user, update_dir, file);
- ret = -1; /* different since we couldn't tell */
- }
+ ret = 1; /* files were really different */
- if (trace)
+ if (tocvsPath)
+ {
+ /* Need to call unlink myself because the noexec variable
+ * has been set to 1. */
+ if (trace)
+ (void) fprintf (stderr, "%c-> unlink (%s)\n",
#ifdef SERVER_SUPPORT
- (void) fprintf (stderr, "%c-> unlink2 (%s)\n",
- (server_active) ? 'S' : ' ', tmp);
+ (server_active) ? 'S' : ' ',
#else
- (void) fprintf (stderr, "-> unlink (%s)\n", tmp);
+ ' ',
#endif
- if (unlink (tmp) < 0)
- error (0, errno, "could not remove %s", tmp);
+ tocvsPath);
+ if ( CVS_UNLINK (tocvsPath) < 0)
+ error (0, errno, "could not remove %s", tocvsPath);
+ }
+
free (options);
return (ret);
}
diff --git a/contrib/cvs/src/options.h.in b/contrib/cvs/src/options.h.in
index 7cb58dc..476d747 100644
--- a/contrib/cvs/src/options.h.in
+++ b/contrib/cvs/src/options.h.in
@@ -16,70 +16,47 @@
*/
/*
- * CVS provides the most features when used in conjunction with the Version-5
- * release of RCS. Thus, it is the default. This also assumes that GNU diff
- * Version-1.15 is being used as well -- you will have to configure your RCS
- * V5 release separately to make this the case. If you do not have RCS V5 and
- * GNU diff V1.15, comment out this define. You should not try mixing and
- * matching other combinations of these tools.
+ * CVS provides the most features when used in conjunction with the
+ * Version-5 release of RCS. Thus, it is the default. This also
+ * assumes that GNU diff Version-1.15 is being used as well -- you
+ * will have to configure your RCS V5 release separately to make this
+ * the case. If you do not have RCS V5 and GNU diff V1.15, comment out
+ * this define. You should not try mixing and matching other
+ * combinations of these tools.
*/
#ifndef HAVE_RCS5
#define HAVE_RCS5
#endif
/*
- * If, before installing this version of CVS, you were running RCS V4 AND you
- * are installing this CVS and RCS V5 and GNU diff 1.15 all at the same time,
- * you should turn on the following define. It only exists to try to do
- * reasonable things with your existing checked out files when you upgrade to
- * RCS V5, since the keyword expansion formats have changed with RCS V5.
- *
- * If you already have been running with RCS5, or haven't been running with CVS
- * yet at all, or are sticking with RCS V4 for now, leave the commented out.
- */
-#ifndef HAD_RCS4
-/* #define HAD_RCS4 */
-#endif
-
-/*
- * For portability and heterogeneity reasons, CVS is shipped by default using
- * my own text-file version of the ndbm database library in the src/myndbm.c
- * file. If you want better performance and are not concerned about
- * heterogeneous hosts accessing your modules file, turn this option off.
+ * For portability and heterogeneity reasons, CVS is shipped by
+ * default using my own text-file version of the ndbm database library
+ * in the src/myndbm.c file. If you want better performance and are
+ * not concerned about heterogeneous hosts accessing your modules
+ * file, turn this option off.
*/
#ifndef MY_NDBM
#define MY_NDBM
#endif
/*
- * The "diff" program to execute when creating patch output. This "diff"
- * must support the "-c" option for context diffing. Specify a full
- * pathname if your site wants to use a particular diff. Note that unlike
- * the diff used with RCS, you *must not* supply -a here (doing so will cause
- * the server to generate patches which patch cannot handle in some cases).
+ * The "diff" program to execute when creating patch output. This
+ * "diff" must support the "-c" option for context diffing. Specify a
+ * full pathname if your site wants to use a particular diff. Note
+ * that unlike the diff used with RCS, you *must not* supply -a here
+ * (doing so will cause the server to generate patches which patch
+ * cannot handle in some cases).
*
* NOTE: this program is only used for the ``patch'' sub-command (and
* for ``update'' if you are using the server). The other commands
* use rcsdiff which will use whatever version of diff was specified
* when rcsdiff was built on your system.
*/
-
#ifndef DIFF
#define DIFF "diff"
#endif
/*
- * The "grep" program to execute when checking to see if a merged file had
- * any conflicts. This "grep" must support a standard basic
- * regular expression as an argument. Specify a full pathname if your site
- * wants to use a particular grep.
- */
-
-#ifndef GREP
-#define GREP "grep"
-#endif
-
-/*
* The "patch" program to run when using the CVS server and accepting
* patches across the network. Specify a full pathname if your site
* wants to use a particular patch.
@@ -89,13 +66,13 @@
#endif
/*
- * By default, RCS programs are executed with the shell or through execlp(),
- * so the user's PATH environment variable is searched. If you'd like to
- * bind all RCS programs to a certain directory (perhaps one not in most
- * people's PATH) then set the default in RCSBIN_DFLT. Note that setting
- * this here will cause all RCS programs to be executed from this directory,
- * unless the user overrides the default with the RCSBIN environment variable
- * or the "-b" option to CVS.
+ * By default, RCS programs are executed with the shell or through
+ * execlp(), so the user's PATH environment variable is searched. If
+ * you'd like to bind all RCS programs to a certain directory (perhaps
+ * one not in most people's PATH) then set the default in RCSBIN_DFLT.
+ * Note that setting this here will cause all RCS programs to be
+ * executed from this directory, unless the user overrides the default
+ * with the RCSBIN environment variable or the "-b" option to CVS.
*
* If you use the password-authenticating server, then you need to
* make sure that the server can find the RCS programs to invoke them.
@@ -104,12 +81,16 @@
* complete. But no actual shell is ever started by that user, so the
* PATH environment variable may not contain the directory with the
* RCS binaries, even though if that user logged in normally, PATH
- * would include the directory.
+ * would include the directory.
*
* One way to solve this problem is to set RCSBIN_DFLT here. An
* alternative is to make sure that root has the right directory in
* its path already. Another, probably better alternative is to
- * specify -b in /etc/inetd.conf.
+ * specify -b in /etc/inetd.conf.
+ *
+ * You may also have to set RCSBIN_DFLT here if there's no global
+ * start-up script run for users by rshd and your RCS programs are not
+ * in a directory in the default PATH assigned by rshd.
*
* This define should be either the empty string ("") or a full
* pathname to the directory containing all the installed programs
@@ -119,12 +100,20 @@
#define RCSBIN_DFLT ""
#endif
+/* Directory used for storing temporary files, if not overridden by
+ environment variables or the -T global option. There should be little
+ need to change this (-T is a better mechanism if you need to use a
+ different directory for temporary files). */
+#ifndef TMPDIR_DFLT
+#define TMPDIR_DFLT "/tmp"
+#endif
+
/*
- * The default editor to use, if one does not specify the "-e" option to cvs,
- * or does not have an EDITOR environment variable. I set this to just "vi",
- * and use the shell to find where "vi" actually is. This allows sites with
- * /usr/bin/vi or /usr/ucb/vi to work equally well (assuming that your PATH
- * is reasonable).
+ * The default editor to use, if one does not specify the "-e" option
+ * to cvs, or does not have an EDITOR environment variable. I set
+ * this to just "vi", and use the shell to find where "vi" actually
+ * is. This allows sites with /usr/bin/vi or /usr/ucb/vi to work
+ * equally well (assuming that your PATH is reasonable).
*/
#ifndef EDITOR_DFLT
#define EDITOR_DFLT "vi"
@@ -147,22 +136,23 @@
* The cvs admin command is restricted to the members of the group
* CVS_ADMIN_GROUP. If this group does not exist, all users are
* allowed to run cvs admin. To disable the cvs admin for all users,
- * create an empty group CVS_ADMIN_GROUP. To disable access control for
- * cvs admin, comment out the define below.
+ * create an empty group CVS_ADMIN_GROUP. To disable access control
+ * for cvs admin, comment out the define below.
*/
#ifndef CVS_ADMIN_GROUP
#define CVS_ADMIN_GROUP "cvsadmin"
#endif
/*
- * The Repository file holds the path to the directory within the source
- * repository that contains the RCS ,v files for each CVS working directory.
- * This path is either a full-path or a path relative to CVSROOT.
+ * The Repository file holds the path to the directory within the
+ * source repository that contains the RCS ,v files for each CVS
+ * working directory. This path is either a full-path or a path
+ * relative to CVSROOT.
*
- * The only advantage that I can see to having a relative path is that One can
- * change the physical location of the master source repository, change one's
- * CVSROOT environment variable, and CVS will work without problems. I
- * recommend using full-paths.
+ * The only advantage that I can see to having a relative path is that
+ * one can change the physical location of the master source
+ * repository, change one's CVSROOT environment variable, and CVS will
+ * work without problems. I recommend using full-paths.
*/
#ifndef RELATIVE_REPOS
/* #define RELATIVE_REPOS */
@@ -170,25 +160,28 @@
/*
* When committing or importing files, you must enter a log message.
- * Normally, you can do this either via the -m flag on the command line or an
- * editor will be started for you. If you like to use logging templates (the
- * rcsinfo file within the $CVSROOT/CVSROOT directory), you might want to
- * force people to use the editor even if they specify a message with -m.
- * Enabling FORCE_USE_EDITOR will cause the -m message to be appended to the
- * temp file when the editor is started.
+ * Normally, you can do this either via the -m flag on the command
+ * line or an editor will be started for you. If you like to use
+ * logging templates (the rcsinfo file within the $CVSROOT/CVSROOT
+ * directory), you might want to force people to use the editor even
+ * if they specify a message with -m. Enabling FORCE_USE_EDITOR will
+ * cause the -m message to be appended to the temp file when the
+ * editor is started.
*/
#ifndef FORCE_USE_EDITOR
/* #define FORCE_USE_EDITOR */
#endif
/*
- * When locking the repository, some sites like to remove locks and assume
- * the program that created them went away if the lock has existed for a long
- * time. This used to be the default for previous versions of CVS. CVS now
- * attempts to be much more robust, so lock files should not be left around
- * by mistake. The new behaviour will never remove old locks (they must now
- * be removed by hand). Enabling CVS_FUDGELOCKS will cause CVS to remove
- * locks that are older than CVSLCKAGE seconds.
+ * When locking the repository, some sites like to remove locks and
+ * assume the program that created them went away if the lock has
+ * existed for a long time. This used to be the default for previous
+ * versions of CVS. CVS now attempts to be much more robust, so lock
+ * files should not be left around by mistake. The new behaviour will
+ * never remove old locks (they must now be removed by hand).
+ * Enabling CVS_FUDGELOCKS will cause CVS to remove locks that are
+ * older than CVSLCKAGE seconds.
+ *
* Use of this option is NOT recommended.
*/
#ifndef CVS_FUDGELOCKS
@@ -197,30 +190,18 @@
/*
* When committing a permanent change, CVS and RCS make a log entry of
- * who committed the change. If you are committing the change logged in
- * as "root" (not under "su" or other root-priv giving program), CVS/RCS
- * cannot determine who is actually making the change.
+ * who committed the change. If you are committing the change logged
+ * in as "root" (not under "su" or other root-priv giving program),
+ * CVS/RCS cannot determine who is actually making the change.
*
* As such, by default, CVS disallows changes to be committed by users
- * logged in as "root". You can disable this option by commenting
- * out the lines below.
+ * logged in as "root". You can disable this option by commenting out
+ * the lines below.
*/
#ifndef CVS_BADROOT
#define CVS_BADROOT
#endif
-/*
- * The "cvs diff" command accepts all the single-character options that GNU
- * diff (1.15) accepts. Except -D. GNU diff uses -D as a way to put
- * cpp-style #define's around the output differences. CVS, by default, uses
- * -D to specify a free-form date (like "cvs diff -D '1 week ago'"). If
- * you would prefer that the -D option of "cvs diff" work like the GNU diff
- * option, then comment out this define.
- */
-#ifndef CVS_DIFFDATE
-#define CVS_DIFFDATE
-#endif
-
/* Define this to enable the SETXID support. The way to use this is
to create a group with no users in it (except perhaps cvs
administrators), set the cvs executable to setgid that group, chown
@@ -228,42 +209,54 @@
permissions in the repository to 770. The last person to modify a
file will own it, but as long as directory permissions are set
right that won't matter. You'll need a system which inherits file
- groups from the parent directory. I don't know how carefully this
- has been inspected for security holes. */
+ groups from the parent directory (WARNING: using the wrong kind of
+ system (I think Solaris 2.4 is the wrong kind, for example) will
+ create a security hole! You will receive no warning other than the
+ fact that files in the working directory are owned by the group
+ which cvs is setgid to).
+ One security hole which has been reported is that setgid is not
+ turned off when the editor is invoked--most editors provide a way
+ to execute a shell, or the user can specify an editor (this one is
+ large enough to drive a truck through). Don't assume that the
+ holes described here are the only ones; I don't know how carefully
+ SETXID has been inspected for security holes. */
#ifndef SETXID_SUPPORT
/* #define SETXID_SUPPORT */
#endif
-/* Should we build the password-authenticating client? Whether to
- include the password-authenticating _server_, on the other hand, is
- set in config.h. */
+/*
+ * Should we build the password-authenticating client? Whether to
+ * include the password-authenticating _server_, on the other hand, is
+ * set in config.h.
+ */
+#ifdef CLIENT_SUPPORT
#define AUTH_CLIENT_SUPPORT 1
+#endif
/*
- * If you are working with a large remote repository and a 'cvs checkout' is
- * swamping your network and memory, define these to enable flow control.
- * You will end up with even less guarantees of a consistant checkout,
- * but that may be better than no checkout at all. The master server process
- * will monitor how far it is getting behind, if it reaches the high water
- * mark, it will signal the child process to stop generating data when
- * convenient (ie: no locks are held, currently at the beginning of a
- * new directory). Once the buffer has drained sufficiently to reach the
- * low water mark, it will be signalled to start again.
- * -- EXPERIMENTAL! -- A better solution may be in the works.
- * You may override the default hi/low watermarks here too.
+ * If you are working with a large remote repository and a 'cvs
+ * checkout' is swamping your network and memory, define these to
+ * enable flow control. You will end up with even less probability of
+ * a consistent checkout (see Concurrency in cvs.texinfo), but CVS
+ * doesn't try to guarantee that anyway. The master server process
+ * will monitor how far it is getting behind, if it reaches the high
+ * water mark, it will signal the child process to stop generating
+ * data when convenient (ie: no locks are held, currently at the
+ * beginning of a new directory). Once the buffer has drained
+ * sufficiently to reach the low water mark, it will be signalled to
+ * start again. You may override the default hi/low watermarks here
+ * too.
*/
-#ifndef SERVER_FLOWCONTROL
-/* #define SERVER_FLOWCONTROL */
-/* #define SERVER_HI_WATER (2 * 1024 * 1024) */
-/* #define SERVER_LO_WATER (1 * 1024 * 1024) */
-#endif
+#define SERVER_FLOWCONTROL
+#define SERVER_HI_WATER (2 * 1024 * 1024)
+#define SERVER_LO_WATER (1 * 1024 * 1024)
/* End of CVS configuration section */
/*
- * Externs that are included in libc, but are used frequently enough to
- * warrant defining here.
+ * Externs that are included in libc, but are used frequently enough
+ * to warrant defining here.
*/
#ifndef STDC_HEADERS
extern void exit ();
diff --git a/contrib/cvs/src/parseinfo.c b/contrib/cvs/src/parseinfo.c
index c567ef8..1011965 100644
--- a/contrib/cvs/src/parseinfo.c
+++ b/contrib/cvs/src/parseinfo.c
@@ -7,6 +7,7 @@
*/
#include "cvs.h"
+#include "getline.h"
/*
* Parse the INFOFILE file for the specified REPOSITORY. Invoke CALLPROC for
@@ -24,15 +25,16 @@ Parse_Info (infofile, repository, callproc, all)
{
int err = 0;
FILE *fp_info;
- char infopath[PATH_MAX];
- char line[MAXLINELEN];
+ char *infopath;
+ char *line = NULL;
+ size_t line_allocated = 0;
char *default_value = NULL;
char *expanded_value= NULL;
int callback_done, line_number;
char *cp, *exp, *value, *srepos;
const char *regex_err;
- if (CVSroot == NULL)
+ if (CVSroot_original == NULL)
{
/* XXX - should be error maybe? */
error (0, 0, "CVSROOT variable not set");
@@ -40,10 +42,20 @@ Parse_Info (infofile, repository, callproc, all)
}
/* find the info file and open it */
- (void) sprintf (infopath, "%s/%s/%s", CVSroot,
+ infopath = xmalloc (strlen (CVSroot_directory)
+ + strlen (infofile)
+ + sizeof (CVSROOTADM)
+ + 10);
+ (void) sprintf (infopath, "%s/%s/%s", CVSroot_directory,
CVSROOTADM, infofile);
- if ((fp_info = fopen (infopath, "r")) == NULL)
- return (0); /* no file -> nothing special done */
+ fp_info = CVS_FOPEN (infopath, "r");
+ if (fp_info == NULL)
+ {
+ /* If no file, don't do anything special. */
+ if (!existence_error (errno))
+ error (0, errno, "cannot open %s", infopath);
+ return 0;
+ }
/* strip off the CVSROOT if repository was absolute */
srepos = Short_Repository (repository);
@@ -54,7 +66,7 @@ Parse_Info (infofile, repository, callproc, all)
/* search the info file for lines that match */
callback_done = line_number = 0;
- while (fgets (line, sizeof (line), fp_info) != NULL)
+ while (getline (&line, &line_allocated, fp_info) >= 0)
{
line_number++;
@@ -146,7 +158,10 @@ Parse_Info (infofile, repository, callproc, all)
err += callproc (repository, expanded_value);
callback_done = 1;
}
- (void) fclose (fp_info);
+ if (ferror (fp_info))
+ error (0, errno, "cannot read %s", infopath);
+ if (fclose (fp_info) < 0)
+ error (0, errno, "cannot close %s", infopath);
/* if we fell through and didn't callback at all, do the default */
if (callback_done == 0 && default_value != NULL)
@@ -157,6 +172,9 @@ Parse_Info (infofile, repository, callproc, all)
free (default_value);
if (expanded_value != NULL)
free (expanded_value);
+ free (infopath);
+ if (line != NULL)
+ free (line);
return (err);
}
diff --git a/contrib/cvs/src/patch.c b/contrib/cvs/src/patch.c
index 39b4e64..4c21943 100644
--- a/contrib/cvs/src/patch.c
+++ b/contrib/cvs/src/patch.c
@@ -16,8 +16,10 @@
#include "getline.h"
static RETSIGTYPE patch_cleanup PROTO((void));
-static Dtype patch_dirproc PROTO((char *dir, char *repos, char *update_dir));
-static int patch_fileproc PROTO((struct file_info *finfo));
+static Dtype patch_dirproc PROTO ((void *callerdat, char *dir,
+ char *repos, char *update_dir,
+ List *entries));
+static int patch_fileproc PROTO ((void *callerdat, struct file_info *finfo));
static int patch_proc PROTO((int *pargc, char **argv, char *xwhere,
char *mwhere, char *mfile, int shorten,
int local_specified, char *mname, char *msg));
@@ -28,20 +30,23 @@ static int toptwo_diffs = 0;
static int local = 0;
static char *options = NULL;
static char *rev1 = NULL;
-static int rev1_validated = 1;
+static int rev1_validated = 0;
static char *rev2 = NULL;
-static int rev2_validated = 1;
+static int rev2_validated = 0;
static char *date1 = NULL;
static char *date2 = NULL;
-static char tmpfile1[L_tmpnam+1], tmpfile2[L_tmpnam+1], tmpfile3[L_tmpnam+1];
+static char *tmpfile1 = NULL;
+static char *tmpfile2 = NULL;
+static char *tmpfile3 = NULL;
static int unidiff = 0;
static const char *const patch_usage[] =
{
- "Usage: %s %s [-fl] [-c|-u] [-s|-t] [-V %%d]\n",
+ "Usage: %s %s [-flR] [-c|-u] [-s|-t] [-V %%d]\n",
" -r rev|-D date [-r rev2 | -D date2] modules...\n",
"\t-f\tForce a head revision match if tag/date not found.\n",
"\t-l\tLocal directory only, not recursive\n",
+ "\t-R\tProcess directories recursively.\n",
"\t-c\tContext diffs (default)\n",
"\t-u\tUnidiff format.\n",
"\t-s\tShort patch - one liner per file.\n",
@@ -66,7 +71,7 @@ patch (argc, argv)
usage (patch_usage);
optind = 1;
- while ((c = getopt (argc, argv, "V:k:cuftsQqlRD:r:")) != -1)
+ while ((c = getopt (argc, argv, "+V:k:cuftsQqlRD:r:")) != -1)
{
switch (c)
{
@@ -120,12 +125,31 @@ patch (argc, argv)
options = RCS_check_kflag (optarg);
break;
case 'V':
+ /* This option is pretty seriously broken:
+ 1. It is not clear what it does (does it change keyword
+ expansion behavior? If so, how? Or does it have
+ something to do with what version of RCS we are using?
+ Or the format we write RCS files in?).
+ 2. Because both it and -k use the options variable,
+ specifying both -V and -k doesn't work.
+ 3. At least as of CVS 1.9, it doesn't work (failed
+ assertion in RCS_checkout where it asserts that options
+ starts with -k). Few people seem to be complaining.
+ In the future (perhaps the near future), I have in mind
+ removing it entirely, and updating NEWS and cvs.texinfo,
+ but in case it is a good idea to give people more time
+ to complain if they would miss it, I'll just add this
+ quick and dirty error message for now. */
+ error (1, 0,
+ "the -V option is obsolete and should not be used");
+#if 0
if (atoi (optarg) <= 0)
error (1, 0, "must specify a version number to -V");
if (options)
free (options);
options = xmalloc (strlen (optarg) + 1 + 2); /* for the -V */
(void) sprintf (options, "-V%s", optarg);
+#endif
break;
case 'u':
unidiff = 1; /* Unidiff */
@@ -173,7 +197,7 @@ patch (argc, argv)
if (local)
send_arg("-l");
- if (force_tag_match)
+ if (!force_tag_match)
send_arg("-f");
if (toptwo_diffs)
send_arg("-t");
@@ -235,7 +259,6 @@ patch (argc, argv)
* callback proc for doing the real work of patching
*/
/* ARGSUSED */
-static char where[PATH_MAX];
static int
patch_proc (pargc, argv, xwhere, mwhere, mfile, shorten, local_specified,
mname, msg)
@@ -251,16 +274,21 @@ patch_proc (pargc, argv, xwhere, mwhere, mfile, shorten, local_specified,
{
int err = 0;
int which;
- char repository[PATH_MAX];
-
- (void) sprintf (repository, "%s/%s", CVSroot, argv[0]);
+ char *repository;
+ char *where;
+
+ repository = xmalloc (strlen (CVSroot_directory) + strlen (argv[0])
+ + (mfile == NULL ? 0 : strlen (mfile)) + 30);
+ (void) sprintf (repository, "%s/%s", CVSroot_directory, argv[0]);
+ where = xmalloc (strlen (argv[0]) + (mfile == NULL ? 0 : strlen (mfile))
+ + 10);
(void) strcpy (where, argv[0]);
/* if mfile isn't null, we need to set up to do only part of the module */
if (mfile != NULL)
{
char *cp;
- char path[PATH_MAX];
+ char *path;
/* if the portion of the module is a path, put the dir part on repos */
if ((cp = strrchr (mfile, '/')) != NULL)
@@ -274,6 +302,7 @@ patch_proc (pargc, argv, xwhere, mwhere, mfile, shorten, local_specified,
}
/* take care of the rest */
+ path = xmalloc (strlen (repository) + strlen (mfile) + 5);
(void) sprintf (path, "%s/%s", repository, mfile);
if (isdir (path))
{
@@ -292,14 +321,17 @@ patch_proc (pargc, argv, xwhere, mwhere, mfile, shorten, local_specified,
argv[1] = xstrdup (mfile);
(*pargc) = 2;
}
+ free (path);
}
/* cd to the starting repository */
- if (chdir (repository) < 0)
+ if ( CVS_CHDIR (repository) < 0)
{
error (0, errno, "cannot chdir to %s", repository);
+ free (repository);
return (1);
}
+ free (repository);
if (force_tag_match)
which = W_REPOS | W_ATTIC;
@@ -319,8 +351,10 @@ patch_proc (pargc, argv, xwhere, mwhere, mfile, shorten, local_specified,
/* start the recursion processor */
err = start_recursion (patch_fileproc, (FILESDONEPROC) NULL, patch_dirproc,
- (DIRLEAVEPROC) NULL, *pargc - 1, argv + 1, local,
- which, 0, 1, where, 1, 1);
+ (DIRLEAVEPROC) NULL, NULL,
+ *pargc - 1, argv + 1, local,
+ which, 0, 1, where, 1);
+ free (where);
return (err);
}
@@ -331,62 +365,99 @@ patch_proc (pargc, argv, xwhere, mwhere, mfile, shorten, local_specified,
*/
/* ARGSUSED */
static int
-patch_fileproc (finfo)
+patch_fileproc (callerdat, finfo)
+ void *callerdat;
struct file_info *finfo;
{
struct utimbuf t;
char *vers_tag, *vers_head;
- char rcsspace[1][PATH_MAX];
- char *rcs = rcsspace[0];
+ char *rcs = NULL;
RCSNode *rcsfile;
FILE *fp1, *fp2, *fp3;
int ret = 0;
int isattic = 0;
int retcode = 0;
- char file1[PATH_MAX], file2[PATH_MAX], strippath[PATH_MAX];
+ char *file1;
+ char *file2;
+ char *strippath;
char *line1, *line2;
size_t line1_chars_allocated;
size_t line2_chars_allocated;
char *cp1, *cp2;
FILE *fp;
+ line1 = NULL;
+ line1_chars_allocated = 0;
+ line2 = NULL;
+ line2_chars_allocated = 0;
+
/* find the parsed rcs file */
if ((rcsfile = finfo->rcs) == NULL)
- return (1);
+ {
+ ret = 1;
+ goto out2;
+ }
if ((rcsfile->flags & VALID) && (rcsfile->flags & INATTIC))
isattic = 1;
+ rcs = xmalloc (strlen (finfo->file) + sizeof (RCSEXT) + 5);
(void) sprintf (rcs, "%s%s", finfo->file, RCSEXT);
/* if vers_head is NULL, may have been removed from the release */
if (isattic && rev2 == NULL && date2 == NULL)
vers_head = NULL;
else
- vers_head = RCS_getversion (rcsfile, rev2, date2, force_tag_match, 0);
+ {
+ vers_head = RCS_getversion (rcsfile, rev2, date2, force_tag_match,
+ (int *) NULL);
+ if (vers_head != NULL && RCS_isdead (rcsfile, vers_head))
+ {
+ free (vers_head);
+ vers_head = NULL;
+ }
+ }
if (toptwo_diffs)
{
if (vers_head == NULL)
- return (1);
+ {
+ ret = 1;
+ goto out2;
+ }
if (!date1)
- date1 = xmalloc (50); /* plenty big :-) */
+ date1 = xmalloc (MAXDATELEN);
*date1 = '\0';
if (RCS_getrevtime (rcsfile, vers_head, date1, 1) == -1)
{
if (!really_quiet)
error (0, 0, "cannot find date in rcs file %s revision %s",
rcs, vers_head);
- return (1);
+ ret = 1;
+ goto out2;
}
}
- vers_tag = RCS_getversion (rcsfile, rev1, date1, force_tag_match, 0);
+ vers_tag = RCS_getversion (rcsfile, rev1, date1, force_tag_match,
+ (int *) NULL);
+ if (vers_tag != NULL && RCS_isdead (rcsfile, vers_tag))
+ {
+ free (vers_tag);
+ vers_tag = NULL;
+ }
- if (vers_tag == NULL && (vers_head == NULL || isattic))
- return (0); /* nothing known about specified revs */
+ if (vers_tag == NULL && vers_head == NULL)
+ {
+ /* Nothing known about specified revs. */
+ ret = 0;
+ goto out2;
+ }
if (vers_tag && vers_head && strcmp (vers_head, vers_tag) == 0)
- return (0); /* not changed between releases */
+ {
+ /* Not changed between releases. */
+ ret = 0;
+ goto out2;
+ }
if (patch_short)
{
@@ -407,24 +478,31 @@ patch_fileproc (finfo)
else
(void) printf ("changed from revision %s to %s\n",
vers_tag, vers_head);
- return (0);
+ ret = 0;
+ goto out2;
}
- if ((fp1 = fopen (tmpnam (tmpfile1), "w+")) != NULL)
+ tmpfile1 = cvs_temp_name ();
+ if ((fp1 = CVS_FOPEN (tmpfile1, "w+")) != NULL)
(void) fclose (fp1);
- if ((fp2 = fopen (tmpnam (tmpfile2), "w+")) != NULL)
+ tmpfile2 = cvs_temp_name ();
+ if ((fp2 = CVS_FOPEN (tmpfile2, "w+")) != NULL)
(void) fclose (fp2);
- if ((fp3 = fopen (tmpnam (tmpfile3), "w+")) != NULL)
+ tmpfile3 = cvs_temp_name ();
+ if ((fp3 = CVS_FOPEN (tmpfile3, "w+")) != NULL)
(void) fclose (fp3);
if (fp1 == NULL || fp2 == NULL || fp3 == NULL)
{
+ /* FIXME: should be printing a proper error message, with errno-based
+ message, and the filename which we could not create. */
error (0, 0, "cannot create temporary files");
ret = 1;
goto out;
}
if (vers_tag != NULL)
{
- retcode = RCS_checkout (rcsfile->path, NULL, vers_tag, options, tmpfile1,
- 0, 0);
+ retcode = RCS_checkout (rcsfile, (char *) NULL, vers_tag,
+ rev1, options, tmpfile1,
+ (RCSCHECKOUTPROC) NULL, (void *) NULL);
if (retcode != 0)
{
if (!really_quiet)
@@ -445,7 +523,9 @@ patch_fileproc (finfo)
}
if (vers_head != NULL)
{
- retcode = RCS_checkout (rcsfile->path, NULL, vers_head, options, tmpfile2, 0, 0);
+ retcode = RCS_checkout (rcsfile, (char *) NULL, vers_head,
+ rev2, options, tmpfile2,
+ (RCSCHECKOUTPROC) NULL, (void *) NULL);
if (retcode != 0)
{
if (!really_quiet)
@@ -462,11 +542,6 @@ patch_fileproc (finfo)
run_arg (tmpfile1);
run_arg (tmpfile2);
- line1 = NULL;
- line1_chars_allocated = 0;
- line2 = NULL;
- line2_chars_allocated = 0;
-
switch (run_exec (RUN_TTY, tmpfile3, RUN_TTY, RUN_REALLY))
{
case -1: /* fork/wait failure */
@@ -522,20 +597,30 @@ patch_fileproc (finfo)
goto out;
}
}
- if (CVSroot != NULL)
- (void) sprintf (strippath, "%s/", CVSroot);
+ if (CVSroot_directory != NULL)
+ {
+ strippath = xmalloc (strlen (CVSroot_directory) + 10);
+ (void) sprintf (strippath, "%s/", CVSroot_directory);
+ }
else
- (void) strcpy (strippath, REPOS_STRIP);
+ strippath = xstrdup (REPOS_STRIP);
if (strncmp (rcs, strippath, strlen (strippath)) == 0)
rcs += strlen (strippath);
+ free (strippath);
if (vers_tag != NULL)
{
+ file1 = xmalloc (strlen (finfo->fullname)
+ + strlen (vers_tag)
+ + 10);
(void) sprintf (file1, "%s:%s", finfo->fullname, vers_tag);
}
else
{
- (void) strcpy (file1, DEVNULL);
+ file1 = xstrdup (DEVNULL);
}
+ file2 = xmalloc (strlen (finfo->fullname)
+ + (vers_head != NULL ? strlen (vers_head) : 10)
+ + 10);
(void) sprintf (file2, "%s:%s", finfo->fullname,
vers_head ? vers_head : "removed");
@@ -558,6 +643,8 @@ patch_fileproc (finfo)
while (getline (&line1, &line1_chars_allocated, fp) >= 0)
(void) fputs (line1, stdout);
(void) fclose (fp);
+ free (file1);
+ free (file2);
break;
default:
error (0, 0, "diff failed for %s", finfo->fullname);
@@ -568,9 +655,17 @@ patch_fileproc (finfo)
if (line2)
free (line2);
/* FIXME: should be checking for errors. */
- (void) unlink (tmpfile1);
- (void) unlink (tmpfile2);
- (void) unlink (tmpfile3);
+ (void) CVS_UNLINK (tmpfile1);
+ (void) CVS_UNLINK (tmpfile2);
+ (void) CVS_UNLINK (tmpfile3);
+ free (tmpfile1);
+ free (tmpfile2);
+ free (tmpfile3);
+ tmpfile1 = tmpfile2 = tmpfile3 = NULL;
+
+ out2:
+ if (rcs != NULL)
+ free (rcs);
return (ret);
}
@@ -579,10 +674,12 @@ patch_fileproc (finfo)
*/
/* ARGSUSED */
static Dtype
-patch_dirproc (dir, repos, update_dir)
+patch_dirproc (callerdat, dir, repos, update_dir, entries)
+ void *callerdat;
char *dir;
char *repos;
char *update_dir;
+ List *entries;
{
if (!quiet)
error (0, 0, "Diffing %s", update_dir);
@@ -595,10 +692,20 @@ patch_dirproc (dir, repos, update_dir)
static RETSIGTYPE
patch_cleanup ()
{
- if (tmpfile1[0] != '\0')
+ if (tmpfile1 != NULL)
+ {
(void) unlink_file (tmpfile1);
- if (tmpfile2[0] != '\0')
+ free (tmpfile1);
+ }
+ if (tmpfile2 != NULL)
+ {
(void) unlink_file (tmpfile2);
- if (tmpfile3[0] != '\0')
+ free (tmpfile2);
+ }
+ if (tmpfile3 != NULL)
+ {
(void) unlink_file (tmpfile3);
+ free (tmpfile3);
+ }
+ tmpfile1 = tmpfile2 = tmpfile3 = NULL;
}
diff --git a/contrib/cvs/src/rcs.c b/contrib/cvs/src/rcs.c
index c68c255..15d303e 100644
--- a/contrib/cvs/src/rcs.c
+++ b/contrib/cvs/src/rcs.c
@@ -11,13 +11,35 @@
#include <assert.h>
#include "cvs.h"
+/* The RCS -k options, and a set of enums that must match the array.
+ These come first so that we can use enum kflag in function
+ prototypes. */
+static const char *const kflags[] =
+ {"kv", "kvl", "k", "v", "o", "b", (char *) NULL};
+enum kflag { KFLAG_KV = 0, KFLAG_KVL, KFLAG_K, KFLAG_V, KFLAG_O, KFLAG_B };
+
static RCSNode *RCS_parsercsfile_i PROTO((FILE * fp, const char *rcsfile));
+static void RCS_reparsercsfile PROTO((RCSNode *, int, FILE **));
static char *RCS_getdatebranch PROTO((RCSNode * rcs, char *date, char *branch));
-static int getrcskey PROTO((FILE * fp, char **keyp, char **valp));
+static int getrcskey PROTO((FILE * fp, char **keyp, char **valp,
+ size_t *lenp));
+static void getrcsrev PROTO ((FILE *fp, char **revp));
static int checkmagic_proc PROTO((Node *p, void *closure));
static void do_branches PROTO((List * list, char *val));
static void do_symbols PROTO((List * list, char *val));
+static void free_rcsnode_contents PROTO((RCSNode *));
static void rcsvers_delproc PROTO((Node * p));
+static char *translate_symtag PROTO((RCSNode *, const char *));
+static char *printable_date PROTO((const char *));
+static char *escape_keyword_value PROTO ((const char *, int *));
+static void expand_keywords PROTO((RCSNode *, RCSVers *, const char *,
+ const char *, size_t, enum kflag, char *,
+ size_t, char **, size_t *));
+static void cmp_file_buffer PROTO((void *, const char *, size_t));
+
+enum rcs_delta_op {RCS_ANNOTATE, RCS_FETCH};
+static void RCS_deltas PROTO ((RCSNode *, FILE *, char *, enum rcs_delta_op,
+ char **, size_t *, char **, size_t *));
/*
* We don't want to use isspace() from the C library because:
@@ -49,9 +71,11 @@ static const char spacetab[] = {
#define whitespace(c) (spacetab[(unsigned char)c] != 0)
-/*
- * Parse an rcsfile given a user file name and a repository
- */
+/* Parse an rcsfile given a user file name and a repository. If there is
+ an error, we print an error message and return NULL. If the file
+ does not exist, we return NULL without printing anything (I'm not
+ sure this allows the caller to do anything reasonable, but it is
+ the current behavior). */
RCSNode *
RCS_parse (file, repos)
const char *file;
@@ -59,26 +83,31 @@ RCS_parse (file, repos)
{
RCSNode *rcs;
FILE *fp;
- char rcsfile[PATH_MAX];
+ RCSNode *retval;
+ char *rcsfile;
+ rcsfile = xmalloc (strlen (repos) + strlen (file)
+ + sizeof (RCSEXT) + sizeof (CVSATTIC) + 10);
(void) sprintf (rcsfile, "%s/%s%s", repos, file, RCSEXT);
- if ((fp = fopen (rcsfile, FOPEN_BINARY_READ)) != NULL)
+ if ((fp = CVS_FOPEN (rcsfile, FOPEN_BINARY_READ)) != NULL)
{
rcs = RCS_parsercsfile_i(fp, rcsfile);
if (rcs != NULL)
rcs->flags |= VALID;
fclose (fp);
- return (rcs);
+ retval = rcs;
+ goto out;
}
else if (! existence_error (errno))
{
error (0, errno, "cannot open %s", rcsfile);
- return NULL;
+ retval = NULL;
+ goto out;
}
(void) sprintf (rcsfile, "%s/%s/%s%s", repos, CVSATTIC, file, RCSEXT);
- if ((fp = fopen (rcsfile, FOPEN_BINARY_READ)) != NULL)
+ if ((fp = CVS_FOPEN (rcsfile, FOPEN_BINARY_READ)) != NULL)
{
rcs = RCS_parsercsfile_i(fp, rcsfile);
if (rcs != NULL)
@@ -88,15 +117,78 @@ RCS_parse (file, repos)
}
fclose (fp);
- return (rcs);
+ retval = rcs;
+ goto out;
}
else if (! existence_error (errno))
{
error (0, errno, "cannot open %s", rcsfile);
- return NULL;
+ retval = NULL;
+ goto out;
}
+#if defined (SERVER_SUPPORT) && !defined (FILENAMES_CASE_INSENSITIVE)
+ else if (ign_case)
+ {
+ int status;
+ char *found_path;
+
+ /* The client might be asking for a file which we do have
+ (which the client doesn't know about), but for which the
+ filename case differs. We only consider this case if the
+ regular CVS_FOPENs fail, because fopen_case is such an
+ expensive call. */
+ (void) sprintf (rcsfile, "%s/%s%s", repos, file, RCSEXT);
+ status = fopen_case (rcsfile, "rb", &fp, &found_path);
+ if (status == 0)
+ {
+ rcs = RCS_parsercsfile_i (fp, rcsfile);
+ if (rcs != NULL)
+ rcs->flags |= VALID;
+
+ fclose (fp);
+ free (rcs->path);
+ rcs->path = found_path;
+ retval = rcs;
+ goto out;
+ }
+ else if (! existence_error (status))
+ {
+ error (0, status, "cannot open %s", rcsfile);
+ retval = NULL;
+ goto out;
+ }
- return (NULL);
+ (void) sprintf (rcsfile, "%s/%s/%s%s", repos, CVSATTIC, file, RCSEXT);
+ status = fopen_case (rcsfile, "rb", &fp, &found_path);
+ if (status == 0)
+ {
+ rcs = RCS_parsercsfile_i (fp, rcsfile);
+ if (rcs != NULL)
+ {
+ rcs->flags |= INATTIC;
+ rcs->flags |= VALID;
+ }
+
+ fclose (fp);
+ free (rcs->path);
+ rcs->path = found_path;
+ retval = rcs;
+ goto out;
+ }
+ else if (! existence_error (status))
+ {
+ error (0, status, "cannot open %s", rcsfile);
+ retval = NULL;
+ goto out;
+ }
+ }
+#endif
+ retval = NULL;
+
+ out:
+ free (rcsfile);
+
+ return retval;
}
/*
@@ -110,7 +202,7 @@ RCS_parsercsfile (rcsfile)
RCSNode *rcs;
/* open the rcsfile */
- if ((fp = fopen (rcsfile, FOPEN_BINARY_READ)) == NULL)
+ if ((fp = CVS_FOPEN (rcsfile, FOPEN_BINARY_READ)) == NULL)
{
error (0, errno, "Couldn't open rcs file `%s'", rcsfile);
return (NULL);
@@ -145,7 +237,7 @@ RCS_parsercsfile_i (fp, rcsfile)
* information. Those that do call XXX to completely parse the
* RCS file. */
- if (getrcskey (fp, &key, &value) == -1 || key == NULL)
+ if (getrcskey (fp, &key, &value, NULL) == -1 || key == NULL)
goto l_error;
if (strcmp (key, RCSDESC) == 0)
goto l_error;
@@ -153,7 +245,7 @@ RCS_parsercsfile_i (fp, rcsfile)
if (strcmp (RCSHEAD, key) == 0 && value != NULL)
rdata->head = xstrdup (value);
- if (getrcskey (fp, &key, &value) == -1 || key == NULL)
+ if (getrcskey (fp, &key, &value, NULL) == -1 || key == NULL)
goto l_error;
if (strcmp (key, RCSDESC) == 0)
goto l_error;
@@ -196,11 +288,15 @@ l_error:
On error, die with a fatal error; if it returns at all it was successful.
+ If ALL is nonzero, remember all keywords and values. Otherwise
+ only keep the ones we will need.
+
If PFP is NULL, close the file when done. Otherwise, leave it open
and store the FILE * in *PFP. */
static void
-RCS_reparsercsfile (rdata, pfp)
+RCS_reparsercsfile (rdata, all, pfp)
RCSNode *rdata;
+ int all;
FILE **pfp;
{
FILE *fp;
@@ -215,7 +311,7 @@ RCS_reparsercsfile (rdata, pfp)
assert (rdata != NULL);
rcsfile = rdata->path;
- fp = fopen(rcsfile, FOPEN_BINARY_READ);
+ fp = CVS_FOPEN (rcsfile, FOPEN_BINARY_READ);
if (fp == NULL)
error (1, 0, "unable to reopen `%s'", rcsfile);
@@ -232,7 +328,7 @@ RCS_reparsercsfile (rdata, pfp)
/* if key is NULL here, then the file is missing some headers
or we had trouble reading the file. */
- if (getrcskey (fp, &key, &value) == -1 || key == NULL
+ if (getrcskey (fp, &key, &value, NULL) == -1 || key == NULL
|| strcmp (key, RCSDESC) == 0)
{
if (ferror(fp))
@@ -249,10 +345,8 @@ RCS_reparsercsfile (rdata, pfp)
if (strcmp (RCSSYMBOLS, key) == 0)
{
if (value != NULL)
- {
rdata->symbols_data = xstrdup(value);
- continue;
- }
+ continue;
}
if (strcmp (RCSEXPAND, key) == 0)
@@ -271,6 +365,28 @@ RCS_reparsercsfile (rdata, pfp)
if (*cp == '\0' && strncmp (RCSDATE, value, strlen (RCSDATE)) == 0)
break;
+ /* We always save lock information, so that we can handle
+ -kkvl correctly when checking out a file. We don't use a
+ special field for this information, since it will normally
+ not be set for a CVS file. */
+ if (all || strcmp (key, "locks") == 0)
+ {
+ Node *kv;
+
+ if (rdata->other == NULL)
+ rdata->other = getlist ();
+ kv = getnode ();
+ kv->type = RCSFIELD;
+ kv->key = xstrdup (key);
+ kv->data = xstrdup (value);
+ if (addnode (rdata->other, kv) != 0)
+ {
+ error (0, 0, "warning: duplicate key `%s' in RCS file `%s'",
+ key, rcsfile);
+ freenode (kv);
+ }
+ }
+
/* if we haven't grabbed it yet, we didn't want it */
}
@@ -297,7 +413,7 @@ RCS_reparsercsfile (rdata, pfp)
vnode->date = xstrdup (valp);
/* Get author field. */
- (void) getrcskey (fp, &key, &value);
+ (void) getrcskey (fp, &key, &value, NULL);
/* FIXME: should be using errno in case of ferror. */
if (key == NULL || strcmp (key, "author") != 0)
error (1, 0, "\
@@ -305,18 +421,19 @@ unable to parse rcs file; `author' not in the expected place");
vnode->author = xstrdup (value);
/* Get state field. */
- (void) getrcskey (fp, &key, &value);
+ (void) getrcskey (fp, &key, &value, NULL);
/* FIXME: should be using errno in case of ferror. */
if (key == NULL || strcmp (key, "state") != 0)
error (1, 0, "\
unable to parse rcs file; `state' not in the expected place");
+ vnode->state = xstrdup (value);
if (strcmp (value, "dead") == 0)
{
vnode->dead = 1;
}
/* fill in the branch list (if any branches exist) */
- (void) getrcskey (fp, &key, &value);
+ (void) getrcskey (fp, &key, &value, NULL);
/* FIXME: should be handling various error conditions better. */
if (key != NULL && strcmp (key, RCSDESC) == 0)
value = NULL;
@@ -327,7 +444,7 @@ unable to parse rcs file; `state' not in the expected place");
}
/* fill in the next field if there is a next revision */
- (void) getrcskey (fp, &key, &value);
+ (void) getrcskey (fp, &key, &value, NULL);
/* FIXME: should be handling various error conditions better. */
if (key != NULL && strcmp (key, RCSDESC) == 0)
value = NULL;
@@ -339,7 +456,7 @@ unable to parse rcs file; `state' not in the expected place");
* we put the symbolic link stuff???
*/
/* FIXME: Does not correctly handle errors, e.g. from stdio. */
- while ((n = getrcskey (fp, &key, &value)) >= 0)
+ while ((n = getrcskey (fp, &key, &value, NULL)) >= 0)
{
assert (key != NULL);
@@ -356,6 +473,9 @@ unable to parse rcs file; `state' not in the expected place");
if (strcmp(key, RCSDEAD) == 0)
{
vnode->dead = 1;
+ if (vnode->state != NULL)
+ free (vnode->state);
+ vnode->state = xstrdup ("dead");
continue;
}
/* if we have a revision, break and do it */
@@ -363,6 +483,26 @@ unable to parse rcs file; `state' not in the expected place");
/* do nothing */ ;
if (*cp == '\0' && strncmp (RCSDATE, value, strlen (RCSDATE)) == 0)
break;
+
+ if (all)
+ {
+ Node *kv;
+
+ if (vnode->other == NULL)
+ vnode->other = getlist ();
+ kv = getnode ();
+ kv->type = RCSFIELD;
+ kv->key = xstrdup (key);
+ kv->data = xstrdup (value);
+ if (addnode (vnode->other, kv) != 0)
+ {
+ error (0, 0,
+ "\
+warning: duplicate key `%s' in version `%s' of RCS file `%s'",
+ key, vnode->version, rcsfile);
+ freenode (kv);
+ }
+ }
}
/* get the node */
@@ -390,6 +530,28 @@ unable to parse rcs file; `state' not in the expected place");
break;
}
+ if (all && key != NULL && strcmp (key, RCSDESC) == 0)
+ {
+ Node *kv;
+
+ if (rdata->other == NULL)
+ rdata->other = getlist ();
+ kv = getnode ();
+ kv->type = RCSFIELD;
+ kv->key = xstrdup (key);
+ kv->data = xstrdup (value);
+ if (addnode (rdata->other, kv) != 0)
+ {
+ error (0, 0,
+ "warning: duplicate key `%s' in RCS file `%s'",
+ key, rcsfile);
+ freenode (kv);
+ }
+ }
+
+ rdata->delta_pos = ftell (fp);
+ rdata->flags &= ~NODELTA;
+
if (pfp == NULL)
{
if (fclose (fp) < 0)
@@ -403,6 +565,177 @@ unable to parse rcs file; `state' not in the expected place");
}
/*
+ * Fully parse the RCS file. Store all keyword/value pairs, fetch the
+ * log messages for each revision, and fetch add and delete counts for
+ * each revision (we could fetch the entire text for each revision,
+ * but the only caller, log_fileproc, doesn't need that information,
+ * so we don't waste the memory required to store it). The add and
+ * delete counts are stored on the OTHER field of the RCSVERSNODE
+ * structure, under the names ";add" and ";delete", so that we don't
+ * waste the memory space of extra fields in RCSVERSNODE for code
+ * which doesn't need this information.
+ */
+
+void
+RCS_fully_parse (rcs)
+ RCSNode *rcs;
+{
+ FILE *fp;
+
+ RCS_reparsercsfile (rcs, 1, &fp);
+
+ while (1)
+ {
+ int c;
+ char *key, *value;
+ size_t vallen;
+ Node *vers;
+ RCSVers *vnode;
+
+ /* Rather than try to keep track of how much information we
+ have read, just read to the end of the file. */
+ do
+ {
+ c = getc (fp);
+ if (c == EOF)
+ break;
+ } while (whitespace (c));
+ if (c == EOF)
+ break;
+ if (ungetc (c, fp) == EOF)
+ error (1, errno, "ungetc failed");
+
+ getrcsrev (fp, &key);
+ vers = findnode (rcs->versions, key);
+ if (vers == NULL)
+ error (1, 0,
+ "mismatch in rcs file %s between deltas and deltatexts",
+ rcs->path);
+
+ vnode = (RCSVers *) vers->data;
+
+ while (getrcskey (fp, &key, &value, &vallen) >= 0)
+ {
+ if (strcmp (key, "text") != 0)
+ {
+ Node *kv;
+
+ if (vnode->other == NULL)
+ vnode->other = getlist ();
+ kv = getnode ();
+ kv->type = RCSFIELD;
+ kv->key = xstrdup (key);
+ kv->data = xstrdup (value);
+ if (addnode (vnode->other, kv) != 0)
+ {
+ error (0, 0,
+ "\
+warning: duplicate key `%s' in version `%s' of RCS file `%s'",
+ key, vnode->version, rcs->path);
+ freenode (kv);
+ }
+
+ continue;
+ }
+
+ if (strcmp (vnode->version, rcs->head) != 0)
+ {
+ unsigned long add, del;
+ char buf[50];
+ Node *kv;
+
+ /* This is a change text. Store the add and delete
+ counts. */
+ add = 0;
+ del = 0;
+ if (value != NULL)
+ {
+ const char *cp;
+
+ cp = value;
+ while (cp < value + vallen)
+ {
+ char op;
+ unsigned long count;
+
+ op = *cp++;
+ if (op != 'a' && op != 'd')
+ error (1, 0, "unrecognized operation '%c' in %s",
+ op, rcs->path);
+ (void) strtoul (cp, (char **) &cp, 10);
+ if (*cp++ != ' ')
+ error (1, 0, "space expected in %s",
+ rcs->path);
+ count = strtoul (cp, (char **) &cp, 10);
+ if (*cp++ != '\012')
+ error (1, 0, "linefeed expected in %s",
+ rcs->path);
+
+ if (op == 'd')
+ del += count;
+ else
+ {
+ add += count;
+ while (count != 0)
+ {
+ if (*cp == '\012')
+ --count;
+ else if (cp == value + vallen)
+ {
+ if (count != 1)
+ error (1, 0, "\
+invalid rcs file %s: premature end of value",
+ rcs->path);
+ else
+ break;
+ }
+ ++cp;
+ }
+ }
+ }
+ }
+
+ sprintf (buf, "%lu", add);
+ kv = getnode ();
+ kv->type = RCSFIELD;
+ kv->key = xstrdup (";add");
+ kv->data = xstrdup (buf);
+ if (addnode (vnode->other, kv) != 0)
+ {
+ error (0, 0,
+ "\
+warning: duplicate key `%s' in version `%s' of RCS file `%s'",
+ key, vnode->version, rcs->path);
+ freenode (kv);
+ }
+
+ sprintf (buf, "%lu", del);
+ kv = getnode ();
+ kv->type = RCSFIELD;
+ kv->key = xstrdup (";delete");
+ kv->data = xstrdup (buf);
+ if (addnode (vnode->other, kv) != 0)
+ {
+ error (0, 0,
+ "\
+warning: duplicate key `%s' in version `%s' of RCS file `%s'",
+ key, vnode->version, rcs->path);
+ freenode (kv);
+ }
+ }
+
+ /* We have found the "text" key which ends the data for
+ this revision. Break out of the loop and go on to the
+ next revision. */
+ break;
+ }
+ }
+
+ if (fclose (fp) < 0)
+ error (0, errno, "cannot close %s", rcs->path);
+}
+
+/*
* freercsnode - free up the info for an RCSNode
*/
void
@@ -419,22 +752,37 @@ freercsnode (rnodep)
return;
}
free ((*rnodep)->path);
- dellist (&(*rnodep)->versions);
- if ((*rnodep)->symbols != (List *) NULL)
- dellist (&(*rnodep)->symbols);
- if ((*rnodep)->symbols_data != (char *) NULL)
- free ((*rnodep)->symbols_data);
- if ((*rnodep)->expand != NULL)
- free ((*rnodep)->expand);
if ((*rnodep)->head != (char *) NULL)
free ((*rnodep)->head);
if ((*rnodep)->branch != (char *) NULL)
free ((*rnodep)->branch);
+ free_rcsnode_contents (*rnodep);
free ((char *) *rnodep);
*rnodep = (RCSNode *) NULL;
}
/*
+ * free_rcsnode_contents - free up the contents of an RCSNode without
+ * freeing the node itself, or the file name, or the head, or the
+ * path. This returns the RCSNode to the state it is in immediately
+ * after a call to RCS_parse.
+ */
+static void
+free_rcsnode_contents (rnode)
+ RCSNode *rnode;
+{
+ dellist (&rnode->versions);
+ if (rnode->symbols != (List *) NULL)
+ dellist (&rnode->symbols);
+ if (rnode->symbols_data != (char *) NULL)
+ free (rnode->symbols_data);
+ if (rnode->expand != NULL)
+ free (rnode->expand);
+ if (rnode->other != (List *) NULL)
+ dellist (&rnode->other);
+}
+
+/*
* rcsvers_delproc - free up an RCSVers type node
*/
static void
@@ -451,6 +799,12 @@ rcsvers_delproc (p)
free (rnode->date);
if (rnode->next != (char *) NULL)
free (rnode->next);
+ if (rnode->author != (char *) NULL)
+ free (rnode->author);
+ if (rnode->state != (char *) NULL)
+ free (rnode->state);
+ if (rnode->other != (List *) NULL)
+ dellist (&rnode->other);
free ((char *) rnode);
}
@@ -469,8 +823,10 @@ rcsvers_delproc (p)
* o return 0 since we found something besides "desc"
*
* Sets *KEYP and *VALUEP to point to storage managed by the getrcskey
- * function; the contents are only valid until the next call to getrcskey
- * or getrcsrev.
+ * function; the contents are only valid until the next call to
+ * getrcskey or getrcsrev. If LENP is not NULL, this sets *LENP to
+ * the length of *VALUEP; this is needed if the string might contain
+ * binary data.
*/
static char *key = NULL;
@@ -478,16 +834,19 @@ static char *value = NULL;
static size_t keysize = 0;
static size_t valsize = 0;
-#define ALLOCINCR 1024
-
static int
-getrcskey (fp, keyp, valp)
+getrcskey (fp, keyp, valp, lenp)
FILE *fp;
char **keyp;
char **valp;
+ size_t *lenp;
{
char *cur, *max;
int c;
+ int just_string;
+
+ if (lenp != NULL)
+ *lenp = 0;
/* skip leading whitespace */
do
@@ -508,9 +867,9 @@ getrcskey (fp, keyp, valp)
{
if (cur >= max)
{
- key = xrealloc (key, keysize + ALLOCINCR);
- cur = key + keysize;
- keysize += ALLOCINCR;
+ size_t curoff = cur - key;
+ expand_string (&key, &keysize, keysize + 1);
+ cur = key + curoff;
max = key + keysize;
}
*cur++ = c;
@@ -525,9 +884,9 @@ getrcskey (fp, keyp, valp)
}
if (cur >= max)
{
- key = xrealloc (key, keysize + ALLOCINCR);
- cur = key + keysize;
- keysize += ALLOCINCR;
+ size_t curoff = cur - key;
+ expand_string (&key, &keysize, keysize + 1);
+ cur = key + curoff;
max = key + keysize;
}
*cur = '\0';
@@ -556,6 +915,10 @@ getrcskey (fp, keyp, valp)
cur = value;
max = value + valsize;
+ just_string = (strcmp (key, RCSDESC) == 0
+ || strcmp (key, "text") == 0
+ || strcmp (key, "log") == 0);
+
/* process the value */
for (;;)
{
@@ -588,9 +951,9 @@ getrcskey (fp, keyp, valp)
if (cur >= max)
{
- value = xrealloc (value, valsize + ALLOCINCR);
- cur = value + valsize;
- valsize += ALLOCINCR;
+ size_t curoff = cur - value;
+ expand_string (&value, &valsize, valsize + 1);
+ cur = value + curoff;
max = value + valsize;
}
*cur++ = c;
@@ -599,9 +962,7 @@ getrcskey (fp, keyp, valp)
/* The syntax for some key-value pairs is different; they
don't end with a semicolon. */
- if (strcmp (key, RCSDESC) == 0
- || strcmp (key, "text") == 0
- || strcmp (key, "log") == 0)
+ if (just_string)
break;
/* compress whitespace down to a single space */
@@ -619,9 +980,9 @@ getrcskey (fp, keyp, valp)
if (cur >= max)
{
- value = xrealloc (value, valsize + ALLOCINCR);
- cur = value + valsize;
- valsize += ALLOCINCR;
+ size_t curoff = cur - value;
+ expand_string (&value, &valsize, valsize + 1);
+ cur = value + curoff;
max = value + valsize;
}
*cur++ = ' ';
@@ -633,9 +994,9 @@ getrcskey (fp, keyp, valp)
if (cur >= max)
{
- value = xrealloc (value, valsize + ALLOCINCR);
- cur = value + valsize;
- valsize += ALLOCINCR;
+ size_t curoff = cur - value;
+ expand_string (&value, &valsize, valsize + 1);
+ cur = value + curoff;
max = value + valsize;
}
*cur++ = c;
@@ -652,24 +1013,26 @@ getrcskey (fp, keyp, valp)
/* terminate the string */
if (cur >= max)
{
- value = xrealloc (value, valsize + ALLOCINCR);
- cur = value + valsize;
- valsize += ALLOCINCR;
+ size_t curoff = cur - value;
+ expand_string (&value, &valsize, valsize + 1);
+ cur = value + curoff;
max = value + valsize;
}
*cur = '\0';
/* if the string is empty, make it null */
- if (value && *value != '\0')
+ if (value && cur != value)
+ {
*valp = value;
+ if (lenp != NULL)
+ *lenp = cur - value;
+ }
else
*valp = NULL;
*keyp = key;
return (0);
}
-static void getrcsrev PROTO ((FILE *fp, char **revp));
-
/* Read an RCS revision number from FP. Put a pointer to it in *REVP;
it points to space managed by getrcsrev which is only good until
the next call to getrcskey or getrcsrev. */
@@ -699,9 +1062,9 @@ getrcsrev (fp, revp)
{
if (cur >= max)
{
- key = xrealloc (key, keysize + ALLOCINCR);
- cur = key + keysize;
- keysize += ALLOCINCR;
+ size_t curoff = cur - key;
+ expand_string (&key, &keysize, keysize + 1);
+ cur = key + curoff;
max = key + keysize;
}
*cur++ = c;
@@ -716,9 +1079,9 @@ getrcsrev (fp, revp)
if (cur >= max)
{
- key = xrealloc (key, keysize + ALLOCINCR);
- cur = key + keysize;
- keysize += ALLOCINCR;
+ size_t curoff = cur - key;
+ expand_string (&key, &keysize, keysize + 1);
+ cur = key + curoff;
max = key + keysize;
}
*cur = '\0';
@@ -810,36 +1173,43 @@ do_branches (list, val)
* The result is returned; null-string if error.
*/
char *
-RCS_getversion (rcs, tag, date, force_tag_match, return_both)
+RCS_getversion (rcs, tag, date, force_tag_match, simple_tag)
RCSNode *rcs;
char *tag;
char *date;
int force_tag_match;
- int return_both;
+ int *simple_tag;
{
+ if (simple_tag != NULL)
+ *simple_tag = 0;
+
/* make sure we have something to look at... */
assert (rcs != NULL);
if (tag && date)
{
- char *cp, *rev, *tagrev;
+ char *branch, *rev;
- /*
- * first lookup the tag; if that works, turn the revision into
- * a branch and lookup the date.
- */
- tagrev = RCS_gettag (rcs, tag, force_tag_match, 0);
- if (tagrev == NULL)
- return ((char *) NULL);
+ if (! RCS_isbranch (rcs, tag))
+ {
+ /* We can't get a particular date if the tag is not a
+ branch. */
+ return NULL;
+ }
- if ((cp = strrchr (tagrev, '.')) != NULL)
- *cp = '\0';
- rev = RCS_getdatebranch (rcs, date, tagrev);
- free (tagrev);
+ /* Work out the branch. */
+ if (! isdigit (tag[0]))
+ branch = RCS_whatbranch (rcs, tag);
+ else
+ branch = xstrdup (tag);
+
+ /* Fetch the revision of branch as of date. */
+ rev = RCS_getdatebranch (rcs, date, branch);
+ free (branch);
return (rev);
}
else if (tag)
- return (RCS_gettag (rcs, tag, force_tag_match, return_both));
+ return (RCS_gettag (rcs, tag, force_tag_match, simple_tag));
else if (date)
return (RCS_getdate (rcs, date, force_tag_match));
else
@@ -856,21 +1226,24 @@ RCS_getversion (rcs, tag, date, force_tag_match, return_both)
* If the matched tag is a branch tag, find the head of the branch.
*/
char *
-RCS_gettag (rcs, symtag, force_tag_match, return_both)
+RCS_gettag (rcs, symtag, force_tag_match, simple_tag)
RCSNode *rcs;
char *symtag;
int force_tag_match;
- int return_both;
+ int *simple_tag;
{
- Node *p;
char *tag = symtag;
+ int tag_allocated = 0;
+
+ if (simple_tag != NULL)
+ *simple_tag = 0;
/* make sure we have something to look at... */
assert (rcs != NULL);
/* XXX this is probably not necessary, --jtc */
if (rcs->flags & PARTIAL)
- RCS_reparsercsfile (rcs, NULL);
+ RCS_reparsercsfile (rcs, 0, NULL);
/* If tag is "HEAD", special case to get head RCS revision */
if (tag && (strcmp (tag, TAG_HEAD) == 0 || *tag == '\0'))
@@ -883,18 +1256,17 @@ RCS_gettag (rcs, symtag, force_tag_match, return_both)
if (!isdigit (tag[0]))
{
+ char *version;
+
/* If we got a symbolic tag, resolve it to a numeric */
- if (rcs == NULL)
- p = NULL;
- else {
- p = findnode (RCS_symbols(rcs), tag);
- }
- if (p != NULL)
+ version = translate_symtag (rcs, tag);
+ if (version != NULL)
{
int dots;
char *magic, *branch, *cp;
- tag = p->data;
+ tag = version;
+ tag_allocated = 1;
/*
* If this is a magic revision, we turn it into either its
@@ -914,21 +1286,17 @@ RCS_gettag (rcs, symtag, force_tag_match, return_both)
(void) sprintf (magic, ".%d.", RCS_MAGIC_BRANCH);
if (strncmp (magic, cp, strlen (magic)) == 0)
{
- char *xtag;
-
/* it's magic. See if the branch exists */
*cp = '\0'; /* turn it into a revision */
- xtag = xstrdup (tag);
- *cp = '.'; /* and back again */
- (void) sprintf (magic, "%s.%s", xtag, branch);
+ (void) sprintf (magic, "%s.%s", tag, branch);
branch = RCS_getbranch (rcs, magic, 1);
free (magic);
if (branch != NULL)
{
- free (xtag);
+ free (tag);
return (branch);
}
- return (xtag);
+ return (tag);
}
free (magic);
}
@@ -955,39 +1323,40 @@ RCS_gettag (rcs, symtag, force_tag_match, return_both)
if ((numdots (tag) & 1) == 0)
{
+ char *branch;
+
/* we have a branch tag, so we need to walk the branch */
- return (RCS_getbranch (rcs, tag, force_tag_match));
+ branch = RCS_getbranch (rcs, tag, force_tag_match);
+ if (tag_allocated)
+ free (tag);
+ return branch;
}
else
{
+ Node *p;
+
/* we have a revision tag, so make sure it exists */
- if (rcs == NULL)
- p = NULL;
- else
- p = findnode (rcs->versions, tag);
+ p = findnode (rcs->versions, tag);
if (p != NULL)
{
- /*
- * we have found a numeric revision for the revision tag.
- * To support expanding the RCS keyword Name, return both
- * the numeric tag and the supplied tag (which might be
- * symbolic). They are separated with a ':' which is not
- * a valid tag char. The variable return_both is only set
- * if this function is called through Version_TS ->
- * RCS_getversion.
- */
- if (return_both)
- {
- char *both = xmalloc(strlen(tag) + 2 + strlen(symtag));
- sprintf(both, "%s:%s", tag, symtag);
- return both;
- }
- else
- return (xstrdup (tag));
+ /* We have found a numeric revision for the revision tag.
+ To support expanding the RCS keyword Name, if
+ SIMPLE_TAG is not NULL, tell the the caller that this
+ is a simple tag which co will recognize. FIXME: Are
+ there other cases in which we should set this? In
+ particular, what if we expand RCS keywords internally
+ without calling co? */
+ if (simple_tag != NULL)
+ *simple_tag = 1;
+ if (! tag_allocated)
+ tag = xstrdup (tag);
+ return (tag);
}
else
{
/* The revision wasn't there, so return the head or NULL */
+ if (tag_allocated)
+ free (tag);
if (force_tag_match)
return (NULL);
else
@@ -1104,37 +1473,42 @@ RCS_nodeisbranch (rcs, rev)
const char *rev;
{
int dots;
- Node *p;
+ char *version;
/* numeric revisions are easy -- even number of dots is a branch */
if (isdigit (*rev))
return ((numdots (rev) & 1) == 0);
- p = findnode (RCS_symbols(rcs), rev);
- if (p == NULL)
+ version = translate_symtag (rcs, rev);
+ if (version == NULL)
return (0);
- dots = numdots (p->data);
+ dots = numdots (version);
if ((dots & 1) == 0)
+ {
+ free (version);
return (1);
+ }
/* got a symbolic tag match, but it's not a branch; see if it's magic */
if (dots > 2)
{
char *magic;
- char *branch = strrchr (p->data, '.');
+ char *branch = strrchr (version, '.');
char *cp = branch - 1;
while (*cp != '.')
cp--;
/* see if we have .magic-branch. (".0.") */
- magic = xmalloc (strlen (p->data) + 1);
+ magic = xmalloc (strlen (version) + 1);
(void) sprintf (magic, ".%d.", RCS_MAGIC_BRANCH);
if (strncmp (magic, cp, strlen (magic)) == 0)
{
free (magic);
+ free (version);
return (1);
}
free (magic);
+ free (version);
}
return (0);
}
@@ -1148,7 +1522,7 @@ RCS_whatbranch (rcs, rev)
RCSNode *rcs;
const char *rev;
{
- Node *p;
+ char *version;
int dots;
/* assume no branch if you can't find the RCS info */
@@ -1156,34 +1530,35 @@ RCS_whatbranch (rcs, rev)
return ((char *) NULL);
/* now, look for a match in the symbols list */
- p = findnode (RCS_symbols(rcs), rev);
- if (p == NULL)
+ version = translate_symtag (rcs, rev);
+ if (version == NULL)
return ((char *) NULL);
- dots = numdots (p->data);
+ dots = numdots (version);
if ((dots & 1) == 0)
- return (xstrdup (p->data));
+ return (version);
/* got a symbolic tag match, but it's not a branch; see if it's magic */
if (dots > 2)
{
char *magic;
- char *branch = strrchr (p->data, '.');
+ char *branch = strrchr (version, '.');
char *cp = branch++ - 1;
while (*cp != '.')
cp--;
/* see if we have .magic-branch. (".0.") */
- magic = xmalloc (strlen (p->data) + 1);
+ magic = xmalloc (strlen (version) + 1);
(void) sprintf (magic, ".%d.", RCS_MAGIC_BRANCH);
if (strncmp (magic, cp, strlen (magic)) == 0)
{
/* yep. it's magic. now, construct the real branch */
*cp = '\0'; /* turn it into a revision */
- (void) sprintf (magic, "%s.%s", p->data, branch);
- *cp = '.'; /* and turn it back */
+ (void) sprintf (magic, "%s.%s", version, branch);
+ free (version);
return (magic);
}
free (magic);
+ free (version);
}
return ((char *) NULL);
}
@@ -1208,7 +1583,7 @@ RCS_getbranch (rcs, tag, force_tag_match)
assert (rcs != NULL);
if (rcs->flags & PARTIAL)
- RCS_reparsercsfile (rcs, NULL);
+ RCS_reparsercsfile (rcs, 0, NULL);
/* find out if the tag contains a dot, or is on the trunk */
cp = strrchr (tag, '.');
@@ -1347,7 +1722,7 @@ RCS_getdate (rcs, date, force_tag_match)
assert (rcs != NULL);
if (rcs->flags & PARTIAL)
- RCS_reparsercsfile (rcs, NULL);
+ RCS_reparsercsfile (rcs, 0, NULL);
/* if the head is on a branch, try the branch first */
if (rcs->branch != NULL)
@@ -1434,7 +1809,7 @@ RCS_getdatebranch (rcs, date, branch)
assert (rcs != NULL);
if (rcs->flags & PARTIAL)
- RCS_reparsercsfile (rcs, NULL);
+ RCS_reparsercsfile (rcs, 0, NULL);
p = findnode (rcs->versions, xrev);
free (xrev);
@@ -1442,9 +1817,13 @@ RCS_getdatebranch (rcs, date, branch)
return (NULL);
vers = (RCSVers *) p->data;
- /* if no branches list, return NULL */
+ /* Tentatively use this revision, if it is early enough. */
+ if (RCS_datecmp (vers->date, date) <= 0)
+ cur_rev = vers->version;
+
+ /* if no branches list, return now */
if (vers->branches == NULL)
- return (NULL);
+ return xstrdup (cur_rev);
/* walk the branches list looking for the branch number */
xbranch = xmalloc (strlen (branch) + 1 + 1); /* +1 for the extra dot */
@@ -1455,7 +1834,11 @@ RCS_getdatebranch (rcs, date, branch)
break;
free (xbranch);
if (p == vers->branches->list)
+ {
+ /* FIXME: This case would seem to imply that the RCS file is
+ somehow invalid. Should we give an error message? */
return (NULL);
+ }
p = findnode (rcs->versions, p->key);
@@ -1475,11 +1858,8 @@ RCS_getdatebranch (rcs, date, branch)
p = (Node *) NULL;
}
- /* if we found something acceptable, return it - otherwise NULL */
- if (cur_rev != NULL)
- return (xstrdup (cur_rev));
- else
- return (NULL);
+ /* Return whatever we found, which may be NULL. */
+ return xstrdup (cur_rev);
}
/*
@@ -1495,13 +1875,17 @@ RCS_datecmp (date1, date2)
return (length_diff ? length_diff : strcmp (date1, date2));
}
-/*
- * Lookup the specified revision in the ,v file and return, in the date
- * argument, the date specified for the revision *minus one second*, so that
- * the logically previous revision will be found later.
- *
- * Returns zero on failure, RCS revision time as a Unix "time_t" on success.
- */
+/* Look up revision REV in RCS and return the date specified for the
+ revision minus FUDGE seconds (FUDGE will generally be one, so that the
+ logically previous revision will be found later, or zero, if we want
+ the exact date).
+
+ The return value is the date being returned as a time_t, or (time_t)-1
+ on error (previously was documented as zero on error; I haven't checked
+ the callers to make sure that they really check for (time_t)-1, but
+ the latter is what this function really returns). If DATE is non-NULL,
+ then it must point to MAXDATELEN characters, and we store the same
+ return value there in DATEFORM format. */
time_t
RCS_getrevtime (rcs, rev, date, fudge)
RCSNode *rcs;
@@ -1519,7 +1903,7 @@ RCS_getrevtime (rcs, rev, date, fudge)
assert (rcs != NULL);
if (rcs->flags & PARTIAL)
- RCS_reparsercsfile (rcs, NULL);
+ RCS_reparsercsfile (rcs, 0, NULL);
/* look up the revision */
p = findnode (rcs->versions, rev);
@@ -1544,11 +1928,11 @@ RCS_getrevtime (rcs, rev, date, fudge)
/* put the date in a form getdate can grok */
#ifdef HAVE_RCS5
(void) sprintf (tdate, "%d/%d/%d GMT %d:%d:%d", ftm->tm_mon,
- ftm->tm_mday, ftm->tm_year, ftm->tm_hour,
+ ftm->tm_mday, ftm->tm_year + 1900, ftm->tm_hour,
ftm->tm_min, ftm->tm_sec);
#else
(void) sprintf (tdate, "%d/%d/%d %d:%d:%d", ftm->tm_mon,
- ftm->tm_mday, ftm->tm_year, ftm->tm_hour,
+ ftm->tm_mday, ftm->tm_year + 1900, ftm->tm_hour,
ftm->tm_min, ftm->tm_sec);
#endif
@@ -1581,7 +1965,7 @@ RCS_symbols(rcs)
assert(rcs != NULL);
if (rcs->flags & PARTIAL)
- RCS_reparsercsfile (rcs, NULL);
+ RCS_reparsercsfile (rcs, 0, NULL);
if (rcs->symbols_data) {
rcs->symbols = getlist ();
@@ -1594,6 +1978,69 @@ RCS_symbols(rcs)
}
/*
+ * Return the version associated with a particular symbolic tag.
+ */
+static char *
+translate_symtag (rcs, tag)
+ RCSNode *rcs;
+ const char *tag;
+{
+ if (rcs->flags & PARTIAL)
+ RCS_reparsercsfile (rcs, 0, NULL);
+
+ if (rcs->symbols != NULL)
+ {
+ Node *p;
+
+ /* The symbols have already been converted into a list. */
+ p = findnode (rcs->symbols, tag);
+ if (p == NULL)
+ return NULL;
+
+ return xstrdup (p->data);
+ }
+
+ if (rcs->symbols_data != NULL)
+ {
+ size_t len;
+ char *cp;
+
+ /* Look through the RCS symbols information. This is like
+ do_symbols, but we don't add the information to a list. In
+ most cases, we will only be called once for this file, so
+ generating the list is unnecessary overhead. */
+
+ len = strlen (tag);
+ cp = rcs->symbols_data;
+ while ((cp = strchr (cp, tag[0])) != NULL)
+ {
+ if ((cp == rcs->symbols_data || whitespace (cp[-1]))
+ && strncmp (cp, tag, len) == 0
+ && cp[len] == ':')
+ {
+ char *v, *r;
+
+ /* We found the tag. Return the version number. */
+
+ cp += len + 1;
+ v = cp;
+ while (! whitespace (*cp) && *cp != '\0')
+ ++cp;
+ r = xmalloc (cp - v + 1);
+ strncpy (r, v, cp - v);
+ r[cp - v] = '\0';
+ return r;
+ }
+
+ while (! whitespace (*cp) && *cp != '\0')
+ ++cp;
+ }
+ }
+
+ return NULL;
+}
+
+/*
* The argument ARG is the getopt remainder of the -k option specified on the
* command line. This function returns malloc'ed space that can be used
* directly in calls to RCS V5, with the -k flag munged correctly.
@@ -1602,8 +2049,6 @@ char *
RCS_check_kflag (arg)
const char *arg;
{
- static const char *const kflags[] =
- {"kv", "kvl", "k", "v", "o", "b", (char *) NULL};
static const char *const keyword_usage[] =
{
"%s %s: invalid RCS keyword expansion mode\n",
@@ -1616,6 +2061,7 @@ RCS_check_kflag (arg)
" -kb\tGenerate binary file unmodified (merges not allowed) (RCS 5.7).\n",
NULL,
};
+ /* Big enough to hold any of the strings from kflags. */
char karg[10];
char const *const *cpp = NULL;
@@ -1686,7 +2132,7 @@ RCS_isdead (rcs, tag)
RCSVers *version;
if (rcs->flags & PARTIAL)
- RCS_reparsercsfile (rcs, NULL);
+ RCS_reparsercsfile (rcs, 0, NULL);
p = findnode (rcs->versions, tag);
if (p == NULL)
@@ -1707,13 +2153,1200 @@ RCS_getexpand (rcs)
{
assert (rcs != NULL);
if (rcs->flags & PARTIAL)
- RCS_reparsercsfile (rcs, NULL);
+ RCS_reparsercsfile (rcs, 0, NULL);
return rcs->expand;
}
+
+/* RCS keywords, and a matching enum. */
+struct rcs_keyword
+{
+ const char *string;
+ size_t len;
+};
+#define KEYWORD_INIT(s) (s), sizeof (s) - 1
+static const struct rcs_keyword keywords[] =
+{
+ { KEYWORD_INIT ("Author") },
+ { KEYWORD_INIT ("Date") },
+ { KEYWORD_INIT ("Header") },
+ { KEYWORD_INIT ("Id") },
+ { KEYWORD_INIT ("Locker") },
+ { KEYWORD_INIT ("Log") },
+ { KEYWORD_INIT ("Name") },
+ { KEYWORD_INIT ("RCSfile") },
+ { KEYWORD_INIT ("Revision") },
+ { KEYWORD_INIT ("Source") },
+ { KEYWORD_INIT ("State") },
+ { NULL, 0 }
+};
+enum keyword
+{
+ KEYWORD_AUTHOR = 0,
+ KEYWORD_DATE,
+ KEYWORD_HEADER,
+ KEYWORD_ID,
+ KEYWORD_LOCKER,
+ KEYWORD_LOG,
+ KEYWORD_NAME,
+ KEYWORD_RCSFILE,
+ KEYWORD_REVISION,
+ KEYWORD_SOURCE,
+ KEYWORD_STATE
+};
+
+/* Convert an RCS date string into a readable string. This is like
+ the RCS date2str function. */
+
+static char *
+printable_date (rcs_date)
+ const char *rcs_date;
+{
+ int year, mon, mday, hour, min, sec;
+ char buf[100];
+
+ (void) sscanf (rcs_date, SDATEFORM, &year, &mon, &mday, &hour, &min,
+ &sec);
+ if (year < 1900)
+ year += 1900;
+ sprintf (buf, "%04d/%02d/%02d %02d:%02d:%02d", year, mon, mday,
+ hour, min, sec);
+ return xstrdup (buf);
+}
+
+/* Escape the characters in a string so that it can be included in an
+ RCS value. */
+
+static char *
+escape_keyword_value (value, free_value)
+ const char *value;
+ int *free_value;
+{
+ char *ret, *t;
+ const char *s;
+
+ for (s = value; *s != '\0'; s++)
+ {
+ char c;
+
+ c = *s;
+ if (c == '\t'
+ || c == '\n'
+ || c == '\\'
+ || c == ' '
+ || c == '$')
+ {
+ break;
+ }
+ }
+
+ if (*s == '\0')
+ {
+ *free_value = 0;
+ return (char *) value;
+ }
+
+ ret = xmalloc (strlen (value) * 4 + 1);
+ *free_value = 1;
+
+ for (s = value, t = ret; *s != '\0'; s++, t++)
+ {
+ switch (*s)
+ {
+ default:
+ *t = *s;
+ break;
+ case '\t':
+ *t++ = '\\';
+ *t = 't';
+ break;
+ case '\n':
+ *t++ = '\\';
+ *t = 'n';
+ break;
+ case '\\':
+ *t++ = '\\';
+ *t = '\\';
+ break;
+ case ' ':
+ *t++ = '\\';
+ *t++ = '0';
+ *t++ = '4';
+ *t = '0';
+ break;
+ case '$':
+ *t++ = '\\';
+ *t++ = '0';
+ *t++ = '4';
+ *t = '4';
+ break;
+ }
+ }
+
+ *t = '\0';
+
+ return ret;
+}
+
+/* Expand RCS keywords in the memory buffer BUF of length LEN. This
+ applies to file RCS and version VERS. If NAME is not NULL, and is
+ not a numeric revision, then it is the symbolic tag used for the
+ checkout. EXPAND indicates how to expand the keywords. This
+ function sets *RETBUF and *RETLEN to the new buffer and length.
+ This function may modify the buffer BUF. If BUF != *RETBUF, then
+ RETBUF is a newly allocated buffer. */
+
+static void
+expand_keywords (rcs, ver, name, log, loglen, expand, buf, len, retbuf, retlen)
+ RCSNode *rcs;
+ RCSVers *ver;
+ const char *name;
+ const char *log;
+ size_t loglen;
+ enum kflag expand;
+ char *buf;
+ size_t len;
+ char **retbuf;
+ size_t *retlen;
+{
+ struct expand_buffer
+ {
+ struct expand_buffer *next;
+ char *data;
+ size_t len;
+ int free_data;
+ } *ebufs = NULL;
+ struct expand_buffer *ebuf_last = NULL;
+ size_t ebuf_len = 0;
+ char *locker;
+ char *srch, *srch_next;
+ size_t srch_len;
+
+ if (expand == KFLAG_O || expand == KFLAG_B)
+ {
+ *retbuf = buf;
+ *retlen = len;
+ return;
+ }
+
+ /* If we are using -kkvl, dig out the locker information if any. */
+ locker = NULL;
+ if (expand == KFLAG_KVL && rcs->other != NULL)
+ {
+ Node *p;
+
+ p = findnode (rcs->other, "locks");
+ if (p != NULL)
+ {
+ char *cp;
+ size_t verlen;
+
+ /* The format of the locking information is
+ USER:VERSION USER:VERSION ...
+ If we find our version on the list, we set LOCKER to
+ the corresponding user name. */
+
+ verlen = strlen (ver->version);
+ cp = p->data;
+ while ((cp = strstr (cp, ver->version)) != NULL)
+ {
+ if (cp > p->data
+ && cp[-1] == ':'
+ && (cp[verlen] == '\0'
+ || whitespace (cp[verlen])))
+ {
+ char *cpend;
+
+ --cp;
+ cpend = cp;
+ while (cp > p->data && ! whitespace (*cp))
+ --cp;
+ locker = xmalloc (cpend - cp + 1);
+ memcpy (locker, cp, cpend - cp);
+ locker[cpend - cp] = '\0';
+ break;
+ }
+
+ ++cp;
+ }
+ }
+ }
+
+ /* RCS keywords look like $STRING$ or $STRING: VALUE$. */
+ srch = buf;
+ srch_len = len;
+ while ((srch_next = memchr (srch, '$', srch_len)) != NULL)
+ {
+ char *s, *send;
+ size_t slen;
+ const struct rcs_keyword *keyword;
+ enum keyword kw;
+ char *value;
+ int free_value;
+ char *sub;
+ size_t sublen;
+
+ srch_len -= (srch_next + 1) - srch;
+ srch = srch_next + 1;
+
+ /* Look for the first non alphabetic character after the '$'. */
+ send = srch + srch_len;
+ for (s = srch; s < send; s++)
+ if (! isalpha (*s))
+ break;
+
+ /* If the first non alphabetic character is not '$' or ':',
+ then this is not an RCS keyword. */
+ if (s == send || (*s != '$' && *s != ':'))
+ continue;
+
+ /* See if this is one of the keywords. */
+ slen = s - srch;
+ for (keyword = keywords; keyword->string != NULL; keyword++)
+ {
+ if (keyword->len == slen
+ && strncmp (keyword->string, srch, slen) == 0)
+ {
+ break;
+ }
+ }
+ if (keyword->string == NULL)
+ continue;
+
+ kw = (enum keyword) (keyword - keywords);
+
+ /* If the keyword ends with a ':', then the old value consists
+ of the characters up to the next '$'. If there is no '$'
+ before the end of the line, though, then this wasn't an RCS
+ keyword after all. */
+ if (*s == ':')
+ {
+ for (; s < send; s++)
+ if (*s == '$' || *s == '\n')
+ break;
+ if (s == send || *s != '$')
+ continue;
+ }
+
+ /* At this point we must replace the string from SRCH to S
+ with the expansion of the keyword KW. */
+
+ /* Get the value to use. */
+ free_value = 0;
+ if (expand == KFLAG_K)
+ value = NULL;
+ else
+ {
+ switch (kw)
+ {
+ default:
+ abort ();
+
+ case KEYWORD_AUTHOR:
+ value = ver->author;
+ break;
+
+ case KEYWORD_DATE:
+ value = printable_date (ver->date);
+ free_value = 1;
+ break;
+
+ case KEYWORD_HEADER:
+ case KEYWORD_ID:
+ {
+ char *path;
+ int free_path;
+ char *date;
+
+ if (kw == KEYWORD_HEADER)
+ path = rcs->path;
+ else
+ path = last_component (rcs->path);
+ path = escape_keyword_value (path, &free_path);
+ date = printable_date (ver->date);
+ value = xmalloc (strlen (path)
+ + strlen (ver->version)
+ + strlen (date)
+ + strlen (ver->author)
+ + strlen (ver->state)
+ + (locker == NULL ? 0 : strlen (locker))
+ + 20);
+
+ sprintf (value, "%s %s %s %s %s%s%s",
+ path, ver->version, date, ver->author,
+ ver->state,
+ locker != NULL ? " " : "",
+ locker != NULL ? locker : "");
+ if (free_path)
+ free (path);
+ free (date);
+ free_value = 1;
+ }
+ break;
+
+ case KEYWORD_LOCKER:
+ value = locker;
+ break;
+
+ case KEYWORD_LOG:
+ case KEYWORD_RCSFILE:
+ value = escape_keyword_value (last_component (rcs->path),
+ &free_value);
+ break;
+
+ case KEYWORD_NAME:
+ if (name != NULL && ! isdigit (*name))
+ value = (char *) name;
+ else
+ value = NULL;
+ break;
+
+ case KEYWORD_REVISION:
+ value = ver->version;
+ break;
+
+ case KEYWORD_SOURCE:
+ value = escape_keyword_value (rcs->path, &free_value);
+ break;
+
+ case KEYWORD_STATE:
+ value = ver->state;
+ break;
+ }
+ }
+
+ sub = xmalloc (keyword->len
+ + (value == NULL ? 0 : strlen (value))
+ + 10);
+ if (expand == KFLAG_V)
+ {
+ /* Decrement SRCH and increment S to remove the $
+ characters. */
+ --srch;
+ ++srch_len;
+ ++s;
+ sublen = 0;
+ }
+ else
+ {
+ strcpy (sub, keyword->string);
+ sublen = strlen (keyword->string);
+ if (expand != KFLAG_K)
+ {
+ sub[sublen] = ':';
+ sub[sublen + 1] = ' ';
+ sublen += 2;
+ }
+ }
+ if (value != NULL)
+ {
+ strcpy (sub + sublen, value);
+ sublen += strlen (value);
+ }
+ if (expand != KFLAG_V && expand != KFLAG_K)
+ {
+ sub[sublen] = ' ';
+ ++sublen;
+ sub[sublen] = '\0';
+ }
+
+ if (free_value)
+ free (value);
+
+ /* The Log keyword requires special handling. This behaviour
+ is taken from RCS 5.7. The special log message is what RCS
+ uses for ci -k. */
+ if (kw == KEYWORD_LOG
+ && (sizeof "checked in with -k by " <= loglen
+ || strncmp (log, "checked in with -k by ",
+ sizeof "checked in with -k by " - 1) != 0))
+ {
+ char *start;
+ char *leader;
+ size_t leader_len, leader_sp_len;
+ const char *logend;
+ const char *snl;
+ int cnl;
+ char *date;
+ const char *sl;
+
+ /* We are going to insert the trailing $ ourselves, before
+ the log message, so we must remove it from S, if we
+ haven't done so already. */
+ if (expand != KFLAG_V)
+ ++s;
+
+ /* Find the start of the line. */
+ start = srch;
+ while (start > buf && start[-1] != '\n')
+ --start;
+
+ /* Copy the start of the line to use as a comment leader. */
+ leader_len = srch - start;
+ if (expand != KFLAG_V)
+ --leader_len;
+ leader = xmalloc (leader_len);
+ memcpy (leader, start, leader_len);
+ leader_sp_len = leader_len;
+ while (leader_sp_len > 0 && leader[leader_sp_len - 1] == ' ')
+ --leader_sp_len;
+
+ /* RCS does some checking for an old style of Log here,
+ but we don't bother. RCS issues a warning if it
+ changes anything. */
+
+ /* Count the number of newlines in the log message so that
+ we know how many copies of the leader we will need. */
+ cnl = 0;
+ logend = log + loglen;
+ for (snl = log; snl < logend; snl++)
+ if (*snl == '\n')
+ ++cnl;
+
+ date = printable_date (ver->date);
+ sub = xrealloc (sub,
+ (sublen
+ + sizeof "Revision"
+ + strlen (ver->version)
+ + strlen (date)
+ + strlen (ver->author)
+ + loglen
+ + (cnl + 2) * leader_len
+ + 20));
+ if (expand != KFLAG_V)
+ {
+ sub[sublen] = '$';
+ ++sublen;
+ }
+ sub[sublen] = '\n';
+ ++sublen;
+ memcpy (sub + sublen, leader, leader_len);
+ sublen += leader_len;
+ sprintf (sub + sublen, "Revision %s %s %s\n",
+ ver->version, date, ver->author);
+ sublen += strlen (sub + sublen);
+ free (date);
+
+ sl = log;
+ while (sl < logend)
+ {
+ if (*sl == '\n')
+ {
+ memcpy (sub + sublen, leader, leader_sp_len);
+ sublen += leader_sp_len;
+ sub[sublen] = '\n';
+ ++sublen;
+ ++sl;
+ }
+ else
+ {
+ const char *slnl;
+
+ memcpy (sub + sublen, leader, leader_len);
+ sublen += leader_len;
+ for (slnl = sl; slnl < logend && *slnl != '\n'; ++slnl)
+ ;
+ if (slnl < logend)
+ ++slnl;
+ memcpy (sub + sublen, sl, slnl - sl);
+ sublen += slnl - sl;
+ sl = slnl;
+ }
+ }
+
+ memcpy (sub + sublen, leader, leader_sp_len);
+ sublen += leader_sp_len;
+
+ free (leader);
+ }
+
+ /* Now SUB contains a string which is to replace the string
+ from SRCH to S. SUBLEN is the length of SUB. */
+
+ if (srch + sublen == s)
+ {
+ memcpy (srch, sub, sublen);
+ free (sub);
+ }
+ else
+ {
+ struct expand_buffer *ebuf;
+
+ /* We need to change the size of the buffer. We build a
+ list of expand_buffer structures. Each expand_buffer
+ structure represents a portion of the final output. We
+ concatenate them back into a single buffer when we are
+ done. This minimizes the number of potentially large
+ buffer copies we must do. */
+
+ if (ebufs == NULL)
+ {
+ ebufs = (struct expand_buffer *) xmalloc (sizeof *ebuf);
+ ebufs->next = NULL;
+ ebufs->data = buf;
+ ebufs->free_data = 0;
+ ebuf_len = srch - buf;
+ ebufs->len = ebuf_len;
+ ebuf_last = ebufs;
+ }
+ else
+ {
+ assert (srch >= ebuf_last->data);
+ assert (srch <= ebuf_last->data + ebuf_last->len);
+ ebuf_len -= ebuf_last->len - (srch - ebuf_last->data);
+ ebuf_last->len = srch - ebuf_last->data;
+ }
+
+ ebuf = (struct expand_buffer *) xmalloc (sizeof *ebuf);
+ ebuf->data = sub;
+ ebuf->len = sublen;
+ ebuf->free_data = 1;
+ ebuf->next = NULL;
+ ebuf_last->next = ebuf;
+ ebuf_last = ebuf;
+ ebuf_len += sublen;
+
+ ebuf = (struct expand_buffer *) xmalloc (sizeof *ebuf);
+ ebuf->data = s;
+ ebuf->len = srch_len - (s - srch);
+ ebuf->free_data = 0;
+ ebuf->next = NULL;
+ ebuf_last->next = ebuf;
+ ebuf_last = ebuf;
+ ebuf_len += srch_len - (s - srch);
+ }
+
+ srch_len -= (s - srch);
+ srch = s;
+ }
+
+ if (locker != NULL)
+ free (locker);
+
+ if (ebufs == NULL)
+ {
+ *retbuf = buf;
+ *retlen = len;
+ }
+ else
+ {
+ char *ret;
+
+ ret = xmalloc (ebuf_len);
+ *retbuf = ret;
+ *retlen = ebuf_len;
+ while (ebufs != NULL)
+ {
+ struct expand_buffer *next;
+
+ memcpy (ret, ebufs->data, ebufs->len);
+ ret += ebufs->len;
+ if (ebufs->free_data)
+ free (ebufs->data);
+ next = ebufs->next;
+ free (ebufs);
+ ebufs = next;
+ }
+ }
+}
+
+/* Check out a revision from an RCS file.
+
+ If PFN is not NULL, then ignore WORKFILE and SOUT. Call PFN zero
+ or more times with the contents of the file. CALLERDAT is passed,
+ uninterpreted, to PFN. (The current code will always call PFN
+ exactly once for a non empty file; however, the current code
+ assumes that it can hold the entire file contents in memory, which
+ is not a good assumption, and might change in the future).
+
+ Otherwise, if WORKFILE is not NULL, check out the revision to
+ WORKFILE. However, if WORKFILE is not NULL, and noexec is set,
+ then don't do anything.
+
+ Otherwise, if WORKFILE is NULL, check out the revision to SOUT. If
+ SOUT is RUN_TTY, then write the contents of the revision to
+ standard output. When using SOUT, the output is generally a
+ temporary file; don't bother to get the file modes correct.
+
+ REV is the numeric revision to check out. It may be NULL, which
+ means to check out the head of the default branch.
+
+ If NAMETAG is not NULL, and is not a numeric revision, then it is
+ the tag that should be used when expanding the RCS Name keyword.
+
+ OPTIONS is a string such as "-kb" or "-kv" for keyword expansion
+ options. It may be NULL to use the default expansion mode of the
+ file, typically "-kkv". */
+
+int
+RCS_checkout (rcs, workfile, rev, nametag, options, sout, pfn, callerdat)
+ RCSNode *rcs;
+ char *workfile;
+ char *rev;
+ char *nametag;
+ char *options;
+ char *sout;
+ RCSCHECKOUTPROC pfn;
+ void *callerdat;
+{
+ int free_rev = 0;
+ enum kflag expand;
+ FILE *fp;
+ struct stat sb;
+ char *key;
+ char *value;
+ size_t len;
+ int free_value = 0;
+ char *log = NULL;
+ size_t loglen;
+ FILE *ofp;
+
+ if (trace)
+ {
+ (void) fprintf (stderr, "%s-> checkout (%s, %s, %s, %s)\n",
+#ifdef SERVER_SUPPORT
+ server_active ? "S" : " ",
+#else
+ "",
+#endif
+ rcs->path,
+ rev != NULL ? rev : "",
+ options != NULL ? options : "",
+ (pfn != NULL ? "(function)"
+ : (workfile != NULL
+ ? workfile
+ : (sout != RUN_TTY ? sout : "(stdout)"))));
+ }
+
+ assert (rev == NULL || isdigit (*rev));
+
+ if (noexec && workfile != NULL)
+ return 0;
+
+ assert (sout == RUN_TTY || workfile == NULL);
+ assert (pfn == NULL || (sout == RUN_TTY && workfile == NULL));
+
+ /* Some callers, such as Checkin or remove_file, will pass us a
+ branch. */
+ if (rev != NULL && (numdots (rev) & 1) == 0)
+ {
+ rev = RCS_getbranch (rcs, rev, 1);
+ if (rev == NULL)
+ error (1, 0, "internal error: bad branch tag in checkout");
+ free_rev = 1;
+ }
+
+ if (rev == NULL || strcmp (rev, rcs->head) == 0)
+ {
+ int gothead;
+
+ /* We want the head revision. Try to read it directly. */
+
+ if (rcs->flags & NODELTA)
+ {
+ free_rcsnode_contents (rcs);
+ rcs->flags |= PARTIAL;
+ }
+
+ if (rcs->flags & PARTIAL)
+ RCS_reparsercsfile (rcs, 0, &fp);
+ else
+ {
+ fp = CVS_FOPEN (rcs->path, FOPEN_BINARY_READ);
+ if (fp == NULL)
+ error (1, 0, "unable to reopen `%s'", rcs->path);
+ if (fseek (fp, rcs->delta_pos, SEEK_SET) != 0)
+ error (1, 0, "cannot fseek RCS file");
+ }
+
+ gothead = 0;
+ getrcsrev (fp, &key);
+ while (getrcskey (fp, &key, &value, &len) >= 0)
+ {
+ if (strcmp (key, "log") == 0)
+ {
+ log = xmalloc (len);
+ memcpy (log, value, len);
+ loglen = len;
+ }
+ if (strcmp (key, "text") == 0)
+ {
+ gothead = 1;
+ break;
+ }
+ }
+
+ if (! gothead)
+ {
+ error (0, 0, "internal error: cannot find head text");
+ if (free_rev)
+ free (rev);
+ return 1;
+ }
+
+ if (fstat (fileno (fp), &sb) < 0)
+ error (1, errno, "cannot fstat %s", rcs->path);
+
+ if (fclose (fp) < 0)
+ error (0, errno, "cannot close %s", rcs->path);
+ }
+ else
+ {
+ /* It isn't the head revision of the trunk. We'll need to
+ walk through the deltas. */
+
+ fp = NULL;
+ if (rcs->flags & PARTIAL)
+ RCS_reparsercsfile (rcs, 0, &fp);
+
+ if (fp == NULL)
+ {
+ /* If RCS_deltas didn't close the file, we could use fstat
+ here too. Probably should change it thusly.... */
+ if (stat (rcs->path, &sb) < 0)
+ error (1, errno, "cannot stat %s", rcs->path);
+ }
+ else
+ {
+ if (fstat (fileno (fp), &sb) < 0)
+ error (1, errno, "cannot fstat %s", rcs->path);
+ }
+
+ RCS_deltas (rcs, fp, rev, RCS_FETCH, &value, &len, &log, &loglen);
+ free_value = 1;
+ }
+
+ /* If OPTIONS is NULL or the empty string, then the old code would
+ invoke the RCS co program with no -k option, which means that
+ co would use the string we have stored in rcs->expand. */
+ if ((options == NULL || options[0] == '\0') && rcs->expand == NULL)
+ expand = KFLAG_KV;
+ else
+ {
+ const char *ouroptions;
+ const char * const *cpp;
+
+ if (options != NULL && options[0] != '\0')
+ {
+ assert (options[0] == '-' && options[1] == 'k');
+ ouroptions = options + 2;
+ }
+ else
+ ouroptions = rcs->expand;
+
+ for (cpp = kflags; *cpp != NULL; cpp++)
+ if (strcmp (*cpp, ouroptions) == 0)
+ break;
+
+ if (*cpp != NULL)
+ expand = (enum kflag) (cpp - kflags);
+ else
+ {
+ error (0, 0,
+ "internal error: unsupported substitution string -k%s",
+ ouroptions);
+ expand = KFLAG_KV;
+ }
+ }
+
+ if (expand != KFLAG_O && expand != KFLAG_B)
+ {
+ Node *p;
+ char *newvalue;
+
+ p = findnode (rcs->versions, rev == NULL ? rcs->head : rev);
+ if (p == NULL)
+ error (1, 0, "internal error: no revision information for %s",
+ rev == NULL ? rcs->head : rev);
+
+ expand_keywords (rcs, (RCSVers *) p->data, nametag, log, loglen,
+ expand, value, len, &newvalue, &len);
+
+ if (newvalue != value)
+ {
+ if (free_value)
+ free (value);
+ value = newvalue;
+ free_value = 1;
+ }
+ }
+
+ if (log != NULL)
+ {
+ free (log);
+ log = NULL;
+ }
+
+ if (pfn != NULL)
+ {
+ /* The PFN interface is very simple to implement right now, as
+ we always have the entire file in memory. */
+ if (len != 0)
+ pfn (callerdat, value, len);
+ }
+ else
+ {
+ if (workfile == NULL)
+ {
+ if (sout == RUN_TTY)
+ ofp = stdout;
+ else
+ {
+ ofp = CVS_FOPEN (sout, expand == KFLAG_B ? "wb" : "w");
+ if (ofp == NULL)
+ error (1, errno, "cannot open %s", sout);
+ }
+ }
+ else
+ {
+ ofp = CVS_FOPEN (workfile, expand == KFLAG_B ? "wb" : "w");
+ if (ofp == NULL)
+ error (1, errno, "cannot open %s", workfile);
+ }
+
+ if (workfile == NULL && sout == RUN_TTY)
+ {
+ if (len > 0)
+ cvs_output (value, len);
+ }
+ else
+ {
+ if (fwrite (value, 1, len, ofp) != len)
+ error (1, errno, "cannot write %s",
+ (workfile != NULL
+ ? workfile
+ : (sout != RUN_TTY ? sout : "stdout")));
+ }
+
+ if (workfile != NULL)
+ {
+ if (fclose (ofp) < 0)
+ error (1, errno, "cannot close %s", workfile);
+ if (chmod (workfile,
+ sb.st_mode & ~(S_IWRITE | S_IWGRP | S_IWOTH)) < 0)
+ error (0, errno, "cannot change mode of file %s",
+ workfile);
+ }
+ else if (sout != RUN_TTY)
+ {
+ if (fclose (ofp) < 0)
+ error (1, errno, "cannot close %s", sout);
+ }
+ }
+
+ if (free_value)
+ free (value);
+ if (free_rev)
+ free (rev);
+
+ return 0;
+}
+
+/* This structure is passed between RCS_cmp_file and cmp_file_buffer. */
+
+struct cmp_file_data
+{
+ const char *filename;
+ FILE *fp;
+ int different;
+};
+
+/* Compare the contents of revision REV of RCS file RCS with the
+ contents of the file FILENAME. OPTIONS is a string for the keyword
+ expansion options. Return 0 if the contents of the revision are
+ the same as the contents of the file, 1 if they are different. */
+
+int
+RCS_cmp_file (rcs, rev, options, filename)
+ RCSNode *rcs;
+ char *rev;
+ char *options;
+ const char *filename;
+{
+ int binary;
+ FILE *fp;
+ struct cmp_file_data data;
+ int retcode;
+
+ if (options != NULL && options[0] != '\0')
+ binary = (strcmp (options, "-kb") == 0);
+ else
+ {
+ char *expand;
+
+ expand = RCS_getexpand (rcs);
+ if (expand != NULL && strcmp (expand, "b") == 0)
+ binary = 1;
+ else
+ binary = 0;
+ }
+
+ fp = CVS_FOPEN (filename, binary ? FOPEN_BINARY_READ : "r");
+
+ data.filename = filename;
+ data.fp = fp;
+ data.different = 0;
+
+ retcode = RCS_checkout (rcs, (char *) NULL, rev, (char *) NULL,
+ options, RUN_TTY, cmp_file_buffer,
+ (void *) &data);
+
+ /* If we have not yet found a difference, make sure that we are at
+ the end of the file. */
+ if (! data.different)
+ {
+ if (getc (fp) != EOF)
+ data.different = 1;
+ }
+
+ fclose (fp);
+
+ if (retcode != 0)
+ return 1;
+
+ return data.different;
+}
+
+/* This is a subroutine of RCS_cmp_file. It is passed to
+ RCS_checkout. */
+
+#define CMP_BUF_SIZE (8 * 1024)
+
+static void
+cmp_file_buffer (callerdat, buffer, len)
+ void *callerdat;
+ const char *buffer;
+ size_t len;
+{
+ struct cmp_file_data *data = (struct cmp_file_data *) callerdat;
+ char *filebuf;
+
+ /* If we've already found a difference, we don't need to check
+ further. */
+ if (data->different)
+ return;
+
+ filebuf = xmalloc (len > CMP_BUF_SIZE ? CMP_BUF_SIZE : len);
+
+ while (len > 0)
+ {
+ size_t checklen;
+
+ checklen = len > CMP_BUF_SIZE ? CMP_BUF_SIZE : len;
+ if (fread (filebuf, 1, checklen, data->fp) != checklen)
+ {
+ if (ferror (data->fp))
+ error (1, errno, "cannot read file %s for comparing",
+ data->filename);
+ data->different = 1;
+ free (filebuf);
+ return;
+ }
+
+ if (memcmp (filebuf, buffer, checklen) != 0)
+ {
+ data->different = 1;
+ free (filebuf);
+ return;
+ }
+
+ buffer += checklen;
+ len -= checklen;
+ }
+
+ free (filebuf);
+}
+
+/* For RCS file RCS, make symbolic tag TAG point to revision REV.
+ This validates that TAG is OK for a user to use. Return value is
+ -1 for error (and errno is set to indicate the error), positive for
+ error (and an error message has been printed), or zero for success. */
+
+int
+RCS_settag (rcs, tag, rev)
+ RCSNode *rcs;
+ const char *tag;
+ const char *rev;
+{
+ int ret;
+
+ /* FIXME: This check should be moved to RCS_check_tag. There is no
+ reason for it to be here. */
+ if (strcmp (tag, TAG_BASE) == 0
+ || strcmp (tag, TAG_HEAD) == 0)
+ {
+ /* Print the name of the tag might be considered redundant
+ with the caller, which also prints it. Perhaps this helps
+ clarify why the tag name is considered reserved, I don't
+ know. */
+ error (0, 0, "Attempt to add reserved tag name %s", tag);
+ return 1;
+ }
+
+ ret = RCS_exec_settag (rcs->path, tag, rev);
+ if (ret != 0)
+ return ret;
+
+ /* If we have already parsed the RCS file, update the tag
+ information. If we have not yet parsed it (i.e., the PARTIAL
+ flag is set), the new tag information will be read when and if
+ we do parse it. */
+ if ((rcs->flags & PARTIAL) == 0)
+ {
+ List *symbols;
+ Node *node;
+
+ /* At this point rcs->symbol_data may not have been parsed.
+ Calling RCS_symbols will force it to be parsed into a list
+ which we can easily manipulate. */
+ symbols = RCS_symbols (rcs);
+ if (symbols == NULL)
+ {
+ symbols = getlist ();
+ rcs->symbols = symbols;
+ }
+ node = findnode (symbols, tag);
+ if (node != NULL)
+ {
+ free (node->data);
+ node->data = xstrdup (rev);
+ }
+ else
+ {
+ node = getnode ();
+ node->key = xstrdup (tag);
+ node->data = xstrdup (rev);
+ (void) addnode (symbols, node);
+ }
+ }
+
+ /* Setting the tag will most likely have invalidated delta_pos. */
+ rcs->flags |= NODELTA;
+
+ return 0;
+}
+
+/* Delete the symbolic tag TAG from the RCS file RCS. NOERR is 1 to
+ suppress errors--FIXME it would be better to avoid the errors or
+ some cleaner solution. */
+
+int
+RCS_deltag (rcs, tag, noerr)
+ RCSNode *rcs;
+ const char *tag;
+ int noerr;
+{
+ int ret;
+
+ ret = RCS_exec_deltag (rcs->path, tag, noerr);
+ if (ret != 0)
+ return ret;
+
+ /* If we have already parsed the RCS file, update the tag
+ information. If we have not yet parsed it (i.e., the PARTIAL
+ flag is set), the new tag information will be read when and if
+ we do parse it. */
+ if ((rcs->flags & PARTIAL) == 0)
+ {
+ List *symbols;
+
+ /* At this point rcs->symbol_data may not have been parsed.
+ Calling RCS_symbols will force it to be parsed into a list
+ which we can easily manipulate. */
+ symbols = RCS_symbols (rcs);
+ if (symbols != NULL)
+ {
+ Node *node;
+
+ node = findnode (symbols, tag);
+ if (node != NULL)
+ delnode (node);
+ }
+ }
+
+ /* Deleting the tag will most likely have invalidated delta_pos. */
+ rcs->flags |= NODELTA;
+
+ return 0;
+}
+
+/* Set the default branch of RCS to REV. */
+
+int
+RCS_setbranch (rcs, rev)
+ RCSNode *rcs;
+ const char *rev;
+{
+ int ret;
+
+ if (rev == NULL && rcs->branch == NULL)
+ return 0;
+ if (rev != NULL && rcs->branch != NULL && strcmp (rev, rcs->branch) == 0)
+ return 0;
+
+ ret = RCS_exec_setbranch (rcs->path, rev);
+ if (ret != 0)
+ return ret;
+
+ if (rcs->branch != NULL)
+ free (rcs->branch);
+ rcs->branch = xstrdup (rev);
+
+ /* Changing the branch will have changed the data in the file, so
+ delta_pos will no longer be correct. */
+ rcs->flags |= NODELTA;
+
+ return 0;
+}
+
+/* Lock revision REV. NOERR is 1 to suppress errors--FIXME it would
+ be better to avoid the errors or some cleaner solution. FIXME:
+ This is only required because the RCS ci program requires a lock.
+ If we eventually do the checkin ourselves, this can become a no-op. */
+
+int
+RCS_lock (rcs, rev, noerr)
+ RCSNode *rcs;
+ const char *rev;
+ int noerr;
+{
+ int ret;
+
+ ret = RCS_exec_lock (rcs->path, rev, noerr);
+ if (ret != 0)
+ return ret;
+
+ /* Setting a lock will have changed the data in the file, so
+ delta_pos will no longer be correct. */
+ rcs->flags |= NODELTA;
+
+ return 0;
+}
+
+/* Unlock revision REV. NOERR is 1 to suppress errors--FIXME it would
+ be better to avoid the errors or some cleaner solution. FIXME:
+ Like RCS_lock, this can become a no-op if we do the checkin
+ ourselves. */
+
+int
+RCS_unlock (rcs, rev, noerr)
+ RCSNode *rcs;
+ const char *rev;
+ int noerr;
+{
+ int ret;
+
+ ret = RCS_exec_unlock (rcs->path, rev, noerr);
+ if (ret != 0)
+ return ret;
+
+ /* Setting a lock will have changed the data in the file, so
+ delta_pos will no longer be correct. */
+ rcs->flags |= NODELTA;
+
+ return 0;
+}
-/* Stuff related to annotate command. This should perhaps be split
- into the stuff which knows about the guts of RCS files, and the
- command parsing type stuff. */
+/* RCS_deltas and friends. Processing of the deltas in RCS files. */
/* Linked list of allocated blocks. Seems kind of silly to
reinvent the obstack wheel, and this isn't as nice as obstacks
@@ -1760,8 +3393,10 @@ block_free ()
struct line
{
- /* Text of this line, terminated by \n or \0. */
+ /* Text of this line. */
char *text;
+ /* Length of this line, not counting \n if has_newline is true. */
+ size_t len;
/* Version in which it was introduced. */
RCSVers *vers;
/* Nonzero if this line ends with \n. This will always be true
@@ -1786,37 +3421,45 @@ static void
linevector_init (vec)
struct linevector *vec;
{
- vec->lines_alloced = 10;
+ vec->lines_alloced = 0;
vec->nlines = 0;
- vec->vector = (struct line **)
- xmalloc (vec->lines_alloced * sizeof (*vec->vector));
+ vec->vector = NULL;
}
-static void linevector_add PROTO ((struct linevector *vec, char *text,
- RCSVers *vers, unsigned int pos));
+static int linevector_add PROTO ((struct linevector *vec, char *text,
+ size_t len, RCSVers *vers,
+ unsigned int pos));
/* Given some text TEXT, add each of its lines to VEC before line POS
(where line 0 is the first line). The last line in TEXT may or may
- not be \n terminated. All \n in TEXT are changed to \0. Set the
- version for each of the new lines to VERS. */
-static void
-linevector_add (vec, text, vers, pos)
+ not be \n terminated. All \n in TEXT are changed to \0 (FIXME: I
+ don't think this is needed, or used, now that we have the ->len
+ field). Set the version for each of the new lines to VERS. This
+ function returns non-zero for success. It returns zero if the line
+ number is out of range. */
+static int
+linevector_add (vec, text, len, vers, pos)
struct linevector *vec;
char *text;
+ size_t len;
RCSVers *vers;
unsigned int pos;
{
+ char *textend;
unsigned int i;
unsigned int nnew;
char *p;
struct line *lines;
- assert (vec->lines_alloced > 0);
+ if (len == 0)
+ return 1;
+
+ textend = text + len;
/* Count the number of lines we will need to add. */
nnew = 1;
- for (p = text; *p != '\0'; ++p)
- if (*p == '\n' && p[1] != '\0')
+ for (p = text; p < textend; ++p)
+ if (*p == '\n' && p + 1 < textend)
++nnew;
/* Allocate the struct line's. */
lines = block_alloc (nnew * sizeof (struct line));
@@ -1824,6 +3467,8 @@ linevector_add (vec, text, vers, pos)
/* Expand VEC->VECTOR if needed. */
if (vec->nlines + nnew >= vec->lines_alloced)
{
+ if (vec->lines_alloced == 0)
+ vec->lines_alloced = 10;
while (vec->nlines + nnew >= vec->lines_alloced)
vec->lines_alloced *= 2;
vec->vector = xrealloc (vec->vector,
@@ -1835,7 +3480,7 @@ linevector_add (vec, text, vers, pos)
vec->vector[i] = vec->vector[i - nnew];
if (pos > vec->nlines)
- error (1, 0, "invalid rcs file: line to add out of range");
+ return 0;
/* Actually add the lines, to LINES and VEC->VECTOR. */
i = pos;
@@ -1843,22 +3488,26 @@ linevector_add (vec, text, vers, pos)
lines[0].vers = vers;
lines[0].has_newline = 0;
vec->vector[i++] = &lines[0];
- for (p = text; *p != '\0'; ++p)
+ for (p = text; p < textend; ++p)
if (*p == '\n')
{
*p = '\0';
lines[i - pos - 1].has_newline = 1;
- if (p[1] == '\0')
+ if (p + 1 == textend)
/* If there are no characters beyond the last newline, we
don't consider it another line. */
break;
+ lines[i - pos - 1].len = p - lines[i - pos - 1].text;
lines[i - pos].text = p + 1;
lines[i - pos].vers = vers;
lines[i - pos].has_newline = 0;
vec->vector[i] = &lines[i - pos];
++i;
}
+ lines[i - pos - 1].len = p - lines[i - pos - 1].text;
vec->nlines += nnew;
+
+ return 1;
}
static void linevector_delete PROTO ((struct linevector *, unsigned int,
@@ -1891,6 +3540,8 @@ linevector_copy (to, from)
{
if (from->nlines > to->lines_alloced)
{
+ if (to->lines_alloced == 0)
+ to->lines_alloced = 10;
while (from->nlines > to->lines_alloced)
to->lines_alloced *= 2;
to->vector = (struct line **)
@@ -1909,7 +3560,8 @@ static void
linevector_free (vec)
struct linevector *vec;
{
- free (vec->vector);
+ if (vec->vector != NULL)
+ free (vec->vector);
}
static char *month_printname PROTO ((char *));
@@ -1935,279 +3587,617 @@ month_printname (month)
return (char *)months[mnum - 1];
}
-static int annotate_fileproc PROTO ((struct file_info *));
+static int
+apply_rcs_changes PROTO ((struct linevector *, const char *, size_t,
+ const char *, RCSVers *, RCSVers *));
+
+/* Apply changes to the line vector LINES. DIFFBUF is a buffer of
+ length DIFFLEN holding the change text from an RCS file (the output
+ of diff -n). NAME is used in error messages. The VERS field of
+ any line added is set to ADDVERS. The VERS field of any line
+ deleted is set to DELVERS, unless DELVERS is NULL, in which case
+ the VERS field of deleted lines is unchanged. The function returns
+ non-zero if the change text is applied successfully. It returns
+ zero if the change text does not appear to apply to LINES (e.g., a
+ line number is invalid). If the change text is improperly
+ formatted (e.g., it is not the output of diff -n), the function
+ calls error with a status of 1, causing the program to exit. */
static int
-annotate_fileproc (finfo)
- struct file_info *finfo;
+apply_rcs_changes (lines, diffbuf, difflen, name, addvers, delvers)
+ struct linevector *lines;
+ const char *diffbuf;
+ size_t difflen;
+ const char *name;
+ RCSVers *addvers;
+ RCSVers *delvers;
{
+ const char *p;
+ const char *q;
+ int op;
+ /* The RCS format throws us for a loop in that the deltafrags (if
+ we define a deltafrag as an add or a delete) need to be applied
+ in reverse order. So we stick them into a linked list. */
+ struct deltafrag {
+ enum {ADD, DELETE} type;
+ unsigned long pos;
+ unsigned long nlines;
+ char *new_lines;
+ size_t len;
+ struct deltafrag *next;
+ };
+ struct deltafrag *dfhead;
+ struct deltafrag *df;
+
+ dfhead = NULL;
+ for (p = diffbuf; p != NULL && p < diffbuf + difflen; )
+ {
+ op = *p++;
+ if (op != 'a' && op != 'd')
+ /* Can't just skip over the deltafrag, because the value
+ of op determines the syntax. */
+ error (1, 0, "unrecognized operation '%c' in %s", op, name);
+ df = (struct deltafrag *) xmalloc (sizeof (struct deltafrag));
+ df->next = dfhead;
+ dfhead = df;
+ df->pos = strtoul (p, (char **) &q, 10);
+
+ if (p == q)
+ error (1, 0, "number expected in %s", name);
+ p = q;
+ if (*p++ != ' ')
+ error (1, 0, "space expected in %s", name);
+ df->nlines = strtoul (p, (char **) &q, 10);
+ if (p == q)
+ error (1, 0, "number expected in %s", name);
+ p = q;
+ if (*p++ != '\012')
+ error (1, 0, "linefeed expected in %s", name);
+
+ if (op == 'a')
+ {
+ unsigned int i;
+
+ df->type = ADD;
+ i = df->nlines;
+ /* The text we want is the number of lines specified, or
+ until the end of the value, whichever comes first (it
+ will be the former except in the case where we are
+ adding a line which does not end in newline). */
+ for (q = p; i != 0; ++q)
+ if (*q == '\n')
+ --i;
+ else if (q == diffbuf + difflen)
+ {
+ if (i != 1)
+ error (1, 0, "premature end of change in %s", name);
+ else
+ break;
+ }
+
+ /* Copy the text we are adding into allocated space. */
+ df->new_lines = block_alloc (q - p);
+ memcpy (df->new_lines, p, q - p);
+ df->len = q - p;
+
+ p = q;
+ }
+ else
+ {
+ /* Correct for the fact that line numbers in RCS files
+ start with 1. */
+ --df->pos;
+
+ assert (op == 'd');
+ df->type = DELETE;
+ }
+ }
+
+ for (df = dfhead; df != NULL;)
+ {
+ unsigned int ln;
+
+ switch (df->type)
+ {
+ case ADD:
+ if (! linevector_add (lines, df->new_lines, df->len, addvers,
+ df->pos))
+ return 0;
+ break;
+ case DELETE:
+ if (df->pos > lines->nlines
+ || df->pos + df->nlines > lines->nlines)
+ return 0;
+ if (delvers != NULL)
+ for (ln = df->pos; ln < df->pos + df->nlines; ++ln)
+ lines->vector[ln]->vers = delvers;
+ linevector_delete (lines, df->pos, df->nlines);
+ break;
+ }
+ df = df->next;
+ free (dfhead);
+ dfhead = df;
+ }
+
+ return 1;
+}
+
+/* Apply an RCS change text to a buffer. The function name starts
+ with rcs rather than RCS because this does not take an RCSNode
+ argument. NAME is used in error messages. TEXTBUF is the text
+ buffer to change, and TEXTLEN is the size. DIFFBUF and DIFFLEN are
+ the change buffer and size. The new buffer is returned in *RETBUF
+ and *RETLEN. The new buffer is allocated by xmalloc. The function
+ changes the contents of TEXTBUF. This function returns 1 for
+ success. On failure, it calls error and returns 0. */
+
+int
+rcs_change_text (name, textbuf, textlen, diffbuf, difflen, retbuf, retlen)
+ const char *name;
+ char *textbuf;
+ size_t textlen;
+ const char *diffbuf;
+ size_t difflen;
+ char **retbuf;
+ size_t *retlen;
+{
+ struct linevector lines;
+ int ret;
+
+ *retbuf = NULL;
+ *retlen = 0;
+
+ linevector_init (&lines);
+
+ if (! linevector_add (&lines, textbuf, textlen, NULL, 0))
+ error (1, 0, "cannot initialize line vector");
+
+ if (! apply_rcs_changes (&lines, diffbuf, difflen, name, NULL, NULL))
+ {
+ error (0, 0, "invalid change text in %s", name);
+ ret = 0;
+ }
+ else
+ {
+ char *p;
+ size_t n;
+ unsigned int ln;
+
+ n = 0;
+ for (ln = 0; ln < lines.nlines; ++ln)
+ /* 1 for \n */
+ n += lines.vector[ln]->len + 1;
+
+ p = xmalloc (n);
+ *retbuf = p;
+
+ for (ln = 0; ln < lines.nlines; ++ln)
+ {
+ memcpy (p, lines.vector[ln]->text, lines.vector[ln]->len);
+ p += lines.vector[ln]->len;
+ if (lines.vector[ln]->has_newline)
+ *p++ = '\n';
+ }
+
+ *retlen = p - *retbuf;
+ assert (*retlen <= n);
+
+ ret = 1;
+ }
+
+ linevector_free (&lines);
+
+ /* Note that this assumes that we have not called from anything
+ else which uses the block vectors. FIXME: We could fix this by
+ saving and restoring the state of the block allocation code. */
+ block_free ();
+
+ return ret;
+}
+
+/* Walk the deltas in RCS to get to revision VERSION.
+
+ If OP is RCS_ANNOTATE, then write annotations using cvs_output.
+
+ If OP is RCS_FETCH, then put the contents of VERSION into a
+ newly-malloc'd array and put a pointer to it in *TEXT. Each line
+ is \n terminated; the caller is responsible for converting text
+ files if desired. The total length is put in *LEN.
+
+ If FP is non-NULL, it should be a file descriptor open to the file
+ RCS with file position pointing to the deltas. We close the file
+ when we are done.
+
+ If LOG is non-NULL, then *LOG is set to the log message of VERSION,
+ and *LOGLEN is set to the length of the log message.
+
+ On error, give a fatal error. */
+
+static void
+RCS_deltas (rcs, fp, version, op, text, len, log, loglen)
+ RCSNode *rcs;
FILE *fp;
+ char *version;
+ enum rcs_delta_op op;
+ char **text;
+ size_t *len;
+ char **log;
+ size_t *loglen;
+{
+ char *branchversion;
+ char *cpversion;
char *key;
char *value;
+ size_t vallen;
RCSVers *vers;
RCSVers *prev_vers;
+ RCSVers *trunk_vers;
+ char *next;
int n;
- int ishead;
+ int ishead, isnext, isversion, onbranch;
Node *node;
struct linevector headlines;
struct linevector curlines;
+ struct linevector trunklines;
+ int foundhead;
- if (finfo->rcs == NULL)
- return (1);
-
- /* Distinguish output for various files if we are processing
- several files. */
- cvs_outerr ("Annotations for ", 0);
- cvs_outerr (finfo->fullname, 0);
- cvs_outerr ("\n***************\n", 0);
-
- if (!(finfo->rcs->flags & PARTIAL))
- /* We are leaking memory by calling RCS_reparsefile again. */
- error (0, 0, "internal warning: non-partial rcs in annotate_fileproc");
- RCS_reparsercsfile (finfo->rcs, &fp);
+ if (fp == NULL)
+ {
+ if (rcs->flags & NODELTA)
+ {
+ free_rcsnode_contents (rcs);
+ RCS_reparsercsfile (rcs, 0, &fp);
+ }
+ else
+ {
+ fp = CVS_FOPEN (rcs->path, FOPEN_BINARY_READ);
+ if (fp == NULL)
+ error (1, 0, "unable to reopen `%s'", rcs->path);
+ if (fseek (fp, rcs->delta_pos, SEEK_SET) != 0)
+ error (1, 0, "cannot fseek RCS file");
+ }
+ }
ishead = 1;
vers = NULL;
+ prev_vers = NULL;
+ trunk_vers = NULL;
+ next = NULL;
+ onbranch = 0;
+ foundhead = 0;
+
+ linevector_init (&curlines);
+ linevector_init (&headlines);
+ linevector_init (&trunklines);
+
+ /* We set BRANCHVERSION to the version we are currently looking
+ for. Initially, this is the version on the trunk from which
+ VERSION branches off. If VERSION is not a branch, then
+ BRANCHVERSION is just VERSION. */
+ branchversion = xstrdup (version);
+ cpversion = strchr (branchversion, '.');
+ if (cpversion != NULL)
+ cpversion = strchr (cpversion + 1, '.');
+ if (cpversion != NULL)
+ *cpversion = '\0';
do {
getrcsrev (fp, &key);
- /* Stash the previous version. */
- prev_vers = vers;
+ if (next != NULL && strcmp (next, key) != 0)
+ {
+ /* This is not the next version we need. It is a branch
+ version which we want to ignore. */
+ isnext = 0;
+ isversion = 0;
+ }
+ else
+ {
+ isnext = 1;
+
+ /* look up the revision */
+ node = findnode (rcs->versions, key);
+ if (node == NULL)
+ error (1, 0,
+ "mismatch in rcs file %s between deltas and deltatexts",
+ rcs->path);
+
+ /* Stash the previous version. */
+ prev_vers = vers;
- /* look up the revision */
- node = findnode (finfo->rcs->versions, key);
- if (node == NULL)
- error (1, 0, "mismatch in rcs file %s between deltas and deltatexts",
- finfo->rcs->path);
- vers = (RCSVers *) node->data;
+ vers = (RCSVers *) node->data;
+ next = vers->next;
+
+ /* Compare key and trunkversion now, because key points to
+ storage controlled by getrcskey. */
+ if (strcmp (branchversion, key) == 0)
+ isversion = 1;
+ else
+ isversion = 0;
+ }
- while ((n = getrcskey (fp, &key, &value)) >= 0)
+ while ((n = getrcskey (fp, &key, &value, &vallen)) >= 0)
{
+ if (log != NULL
+ && isversion
+ && strcmp (key, "log") == 0
+ && strcmp (branchversion, version) == 0)
+ {
+ *log = xmalloc (vallen);
+ memcpy (*log, value, vallen);
+ *loglen = vallen;
+ }
+
if (strcmp (key, "text") == 0)
{
if (ishead)
{
char *p;
- p = block_alloc (strlen (value) + 1);
- strcpy (p, value);
+ p = block_alloc (vallen);
+ memcpy (p, value, vallen);
+
+ if (! linevector_add (&curlines, p, vallen, NULL, 0))
+ error (1, 0, "invalid rcs file %s", rcs->path);
- linevector_init (&headlines);
- linevector_init (&curlines);
- linevector_add (&headlines, p, NULL, 0);
- linevector_copy (&curlines, &headlines);
ishead = 0;
}
- else
+ else if (isnext)
{
- char *p;
- char *q;
- int op;
- /* The RCS format throws us for a loop in that the
- deltafrags (if we define a deltafrag as an
- add or a delete) need to be applied in reverse
- order. So we stick them into a linked list. */
- struct deltafrag {
- enum {ADD, DELETE} type;
- unsigned long pos;
- unsigned long nlines;
- char *new_lines;
- struct deltafrag *next;
- };
- struct deltafrag *dfhead;
- struct deltafrag *df;
-
- dfhead = NULL;
- for (p = value; p != NULL && *p != '\0'; )
- {
- op = *p++;
- if (op != 'a' && op != 'd')
- /* Can't just skip over the deltafrag, because
- the value of op determines the syntax. */
- error (1, 0, "unrecognized operation '%c' in %s",
- op, finfo->rcs->path);
- df = (struct deltafrag *)
- xmalloc (sizeof (struct deltafrag));
- df->next = dfhead;
- dfhead = df;
- df->pos = strtoul (p, &q, 10);
-
- if (p == q)
- error (1, 0, "number expected in %s",
- finfo->rcs->path);
- p = q;
- if (*p++ != ' ')
- error (1, 0, "space expected in %s",
- finfo->rcs->path);
- df->nlines = strtoul (p, &q, 10);
- if (p == q)
- error (1, 0, "number expected in %s",
- finfo->rcs->path);
- p = q;
- if (*p++ != '\012')
- error (1, 0, "linefeed expected in %s",
- finfo->rcs->path);
-
- if (op == 'a')
- {
- unsigned int i;
-
- df->type = ADD;
- i = df->nlines;
- /* The text we want is the number of lines
- specified, or until the end of the value,
- whichever comes first (it will be the former
- except in the case where we are adding a line
- which does not end in newline). */
- for (q = p; i != 0; ++q)
- if (*q == '\n')
- --i;
- else if (*q == '\0')
- {
- if (i != 1)
- error (1, 0, "\
-invalid rcs file %s: premature end of value",
- finfo->rcs->path);
- else
- break;
- }
-
- /* Copy the text we are adding into allocated
- space. */
- df->new_lines = block_alloc (q - p + 1);
- strncpy (df->new_lines, p, q - p);
- df->new_lines[q - p] = '\0';
-
- p = q;
- }
- else
- {
- /* Correct for the fact that line numbers in RCS
- files start with 1. */
- --df->pos;
-
- assert (op == 'd');
- df->type = DELETE;
- }
- }
- for (df = dfhead; df != NULL;)
- {
- unsigned int ln;
-
- switch (df->type)
- {
- case ADD:
- linevector_add (&curlines, df->new_lines,
- NULL, df->pos);
- break;
- case DELETE:
- if (df->pos > curlines.nlines
- || df->pos + df->nlines > curlines.nlines)
- error (1, 0, "\
-invalid rcs file %s (`d' operand out of range)",
- finfo->rcs->path);
- for (ln = df->pos; ln < df->pos + df->nlines; ++ln)
- curlines.vector[ln]->vers = prev_vers;
- linevector_delete (&curlines, df->pos, df->nlines);
- break;
- }
- df = df->next;
- free (dfhead);
- dfhead = df;
- }
+ if (! apply_rcs_changes (&curlines, value, vallen,
+ rcs->path,
+ onbranch ? vers : NULL,
+ onbranch ? NULL : prev_vers))
+ error (1, 0, "invalid change text in %s", rcs->path);
}
break;
}
}
if (n < 0)
goto l_error;
- } while (vers->next != NULL);
- if (fclose (fp) < 0)
- error (0, errno, "cannot close %s", finfo->rcs->path);
+ if (isversion)
+ {
+ /* This is either the version we want, or it is the
+ branchpoint to the version we want. */
+ if (strcmp (branchversion, version) == 0)
+ {
+ /* This is the version we want. */
+ linevector_copy (&headlines, &curlines);
+ foundhead = 1;
+ if (onbranch)
+ {
+ /* We have found this version by tracking up a
+ branch. Restore back to the lines we saved
+ when we left the trunk, and continue tracking
+ down the trunk. */
+ onbranch = 0;
+ vers = trunk_vers;
+ next = vers->next;
+ linevector_copy (&curlines, &trunklines);
+ }
+ }
+ else
+ {
+ Node *p;
- /* Now print out the data we have just computed. */
- {
- unsigned int ln;
+ /* We need to look up the branch. */
+ onbranch = 1;
- for (ln = 0; ln < headlines.nlines; ++ln)
- {
- char buf[80];
- /* Period which separates year from month in date. */
- char *ym;
- /* Period which separates month from day in date. */
- char *md;
- RCSVers *prvers;
+ if (numdots (branchversion) < 2)
+ {
+ unsigned int ln;
+
+ /* We are leaving the trunk; save the current
+ lines so that we can restore them when we
+ continue tracking down the trunk. */
+ trunk_vers = vers;
+ linevector_copy (&trunklines, &curlines);
+
+ /* Reset the version information we have
+ accumulated so far. It only applies to the
+ changes from the head to this version. */
+ for (ln = 0; ln < curlines.nlines; ++ln)
+ curlines.vector[ln]->vers = NULL;
+ }
- prvers = headlines.vector[ln]->vers;
- if (prvers == NULL)
- prvers = vers;
+ /* The next version we want is the entry on
+ VERS->branches which matches this branch. For
+ example, suppose VERSION is 1.21.4.3 and
+ BRANCHVERSION was 1.21. Then we look for an entry
+ starting with "1.21.4" and we'll put it (probably
+ 1.21.4.1) in NEXT. We'll advance BRANCHVERSION by
+ two dots (in this example, to 1.21.4.3). */
+
+ if (vers->branches == NULL)
+ error (1, 0, "missing expected branches in %s",
+ rcs->path);
+ *cpversion = '.';
+ ++cpversion;
+ cpversion = strchr (cpversion, '.');
+ if (cpversion == NULL)
+ error (1, 0, "version number confusion in %s",
+ rcs->path);
+ for (p = vers->branches->list->next;
+ p != vers->branches->list;
+ p = p->next)
+ if (strncmp (p->key, branchversion,
+ cpversion - branchversion) == 0)
+ break;
+ if (p == vers->branches->list)
+ error (1, 0, "missing expected branch in %s",
+ rcs->path);
- sprintf (buf, "%-12s (%-8.8s ",
- prvers->version,
- prvers->author);
- cvs_output (buf, 0);
+ next = p->key;
- /* Now output the date. */
- ym = strchr (prvers->date, '.');
- if (ym == NULL)
- cvs_output ("??-???-??", 0);
- else
- {
- md = strchr (ym + 1, '.');
- if (md == NULL)
- cvs_output ("??", 0);
- else
- cvs_output (md + 1, 2);
-
- cvs_output ("-", 1);
- cvs_output (month_printname (ym + 1), 0);
- cvs_output ("-", 1);
- /* Only output the last two digits of the year. Our output
- lines are long enough as it is without printing the
- century. */
- cvs_output (ym - 2, 2);
+ cpversion = strchr (cpversion + 1, '.');
+ if (cpversion != NULL)
+ *cpversion = '\0';
}
- cvs_output ("): ", 0);
- cvs_output (headlines.vector[ln]->text, 0);
- cvs_output ("\n", 1);
}
- }
+ if (op == RCS_FETCH && foundhead)
+ break;
+ } while (next != NULL);
+
+ if (fclose (fp) < 0)
+ error (0, errno, "cannot close %s", rcs->path);
- if (!ishead)
+ if (! foundhead)
+ error (1, 0, "could not find desired version %s in %s",
+ version, rcs->path);
+
+ /* Now print out or return the data we have just computed. */
+ switch (op)
{
- linevector_free (&curlines);
- linevector_free (&headlines);
+ case RCS_ANNOTATE:
+ {
+ unsigned int ln;
+
+ for (ln = 0; ln < headlines.nlines; ++ln)
+ {
+ char buf[80];
+ /* Period which separates year from month in date. */
+ char *ym;
+ /* Period which separates month from day in date. */
+ char *md;
+ RCSVers *prvers;
+
+ prvers = headlines.vector[ln]->vers;
+ if (prvers == NULL)
+ prvers = vers;
+
+ sprintf (buf, "%-12s (%-8.8s ",
+ prvers->version,
+ prvers->author);
+ cvs_output (buf, 0);
+
+ /* Now output the date. */
+ ym = strchr (prvers->date, '.');
+ if (ym == NULL)
+ cvs_output ("?\?-??\?-??", 0);
+ else
+ {
+ md = strchr (ym + 1, '.');
+ if (md == NULL)
+ cvs_output ("??", 0);
+ else
+ cvs_output (md + 1, 2);
+
+ cvs_output ("-", 1);
+ cvs_output (month_printname (ym + 1), 0);
+ cvs_output ("-", 1);
+ /* Only output the last two digits of the year. Our output
+ lines are long enough as it is without printing the
+ century. */
+ cvs_output (ym - 2, 2);
+ }
+ cvs_output ("): ", 0);
+ cvs_output (headlines.vector[ln]->text,
+ headlines.vector[ln]->len);
+ cvs_output ("\n", 1);
+ }
+ }
+ break;
+ case RCS_FETCH:
+ {
+ char *p;
+ size_t n;
+ unsigned int ln;
+
+ assert (text != NULL);
+ assert (len != NULL);
+
+ n = 0;
+ for (ln = 0; ln < headlines.nlines; ++ln)
+ /* 1 for \n */
+ n += headlines.vector[ln]->len + 1;
+ p = xmalloc (n);
+ *text = p;
+ for (ln = 0; ln < headlines.nlines; ++ln)
+ {
+ memcpy (p, headlines.vector[ln]->text,
+ headlines.vector[ln]->len);
+ p += headlines.vector[ln]->len;
+ if (headlines.vector[ln]->has_newline)
+ *p++ = '\n';
+ }
+ *len = p - *text;
+ assert (*len <= n);
+ }
+ break;
}
+
+ linevector_free (&curlines);
+ linevector_free (&headlines);
+ linevector_free (&trunklines);
+
block_free ();
- return 0;
+ return;
l_error:
if (ferror (fp))
- error (1, errno, "cannot read %s", finfo->rcs->path);
+ error (1, errno, "cannot read %s", rcs->path);
else
error (1, 0, "%s does not appear to be a valid rcs file",
- finfo->rcs->path);
- /* Shut up gcc -Wall. */
+ rcs->path);
+}
+
+
+/* Annotate command. In rcs.c for historical reasons (from back when
+ what is now RCS_deltas was part of annotate_fileproc). */
+
+/* Options from the command line. */
+
+static int force_tag_match = 1;
+static char *tag = NULL;
+static char *date = NULL;
+
+static int annotate_fileproc PROTO ((void *callerdat, struct file_info *));
+
+static int
+annotate_fileproc (callerdat, finfo)
+ void *callerdat;
+ struct file_info *finfo;
+{
+ FILE *fp = NULL;
+ char *version;
+
+ if (finfo->rcs == NULL)
+ return (1);
+
+ if (finfo->rcs->flags & PARTIAL)
+ RCS_reparsercsfile (finfo->rcs, 0, &fp);
+
+ version = RCS_getversion (finfo->rcs, tag, date, force_tag_match,
+ (int *) NULL);
+ if (version == NULL)
+ return 0;
+
+ /* Distinguish output for various files if we are processing
+ several files. */
+ cvs_outerr ("Annotations for ", 0);
+ cvs_outerr (finfo->fullname, 0);
+ cvs_outerr ("\n***************\n", 0);
+
+ RCS_deltas (finfo->rcs, fp, version, RCS_ANNOTATE, (char **) NULL,
+ (size_t) NULL, (char **) NULL, (size_t *) NULL);
+ free (version);
return 0;
}
static const char *const annotate_usage[] =
{
- "Usage: %s %s [-l] [files...]\n",
+ "Usage: %s %s [-lRf] [-r rev|-D date] [files...]\n",
"\t-l\tLocal directory only, no recursion.\n",
+ "\t-R\tProcess directories recursively.\n",
+ "\t-f\tUse head revision if tag/date not found.\n",
+ "\t-r rev\tAnnotate file as of specified revision/tag.\n",
+ "\t-D date\tAnnotate file as of specified date.\n",
NULL
};
/* Command to show the revision, date, and author where each line of a
- file was modified. Currently it will only show the trunk, all the
- way to the head, but it would be useful to enhance it to (a) allow
- one to specify a revision, and display only as far as that (easy;
- just have annotate_fileproc set all the ->vers fields to NULL when
- you hit that revision), and (b) handle branches (not as easy, but
- doable). The user interface for both (a) and (b) could be a -r
- option. */
+ file was modified. */
int
annotate (argc, argv)
@@ -2221,13 +4211,25 @@ annotate (argc, argv)
usage (annotate_usage);
optind = 0;
- while ((c = getopt (argc, argv, "+l")) != -1)
+ while ((c = getopt (argc, argv, "+lr:D:fR")) != -1)
{
switch (c)
{
case 'l':
local = 1;
break;
+ case 'R':
+ local = 0;
+ break;
+ case 'r':
+ tag = optarg;
+ break;
+ case 'D':
+ date = Make_Date (optarg);
+ break;
+ case 'f':
+ force_tag_match = 0;
+ break;
case '?':
default:
usage (annotate_usage);
@@ -2245,18 +4247,20 @@ annotate (argc, argv)
if (local)
send_arg ("-l");
+ if (!force_tag_match)
+ send_arg ("-f");
+ option_with_arg ("-r", tag);
+ if (date)
+ client_senddate (date);
send_file_names (argc, argv, SEND_EXPAND_WILD);
- /* FIXME: We shouldn't have to send current files, but I'm not sure
- whether it works. So send the files --
- it's slower but it works. */
- send_files (argc, argv, local, 0);
+ send_files (argc, argv, local, 0, SEND_NO_CONTENTS);
send_to_server ("annotate\012", 0);
return get_responses_and_close ();
}
#endif /* CLIENT_SUPPORT */
return start_recursion (annotate_fileproc, (FILESDONEPROC) NULL,
- (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL,
+ (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL, NULL,
argc, argv, local, W_LOCAL, 0, 1, (char *)NULL,
- 1, 0);
+ 1);
}
diff --git a/contrib/cvs/src/rcs.h b/contrib/cvs/src/rcs.h
index 698a3b1..3de8c91 100644
--- a/contrib/cvs/src/rcs.h
+++ b/contrib/cvs/src/rcs.h
@@ -1,5 +1,3 @@
-/* $CVSid: @(#)rcs.h 1.18 94/09/23 $ */
-
/*
* Copyright (c) 1992, Brian Berliner and Jeff Polk
* Copyright (c) 1989-1992, Brian Berliner
@@ -12,11 +10,12 @@
#define RCS "rcs"
#define RCS_CI "ci"
-#define RCS_CO "co"
-#define RCS_RLOG "rlog"
#define RCS_DIFF "rcsdiff"
#define RCS_RCSMERGE "rcsmerge"
-#define RCS_MERGE_PAT "^>>>>>>> " /* runs "grep" with this pattern */
+
+/* String which indicates a conflict if it occurs at the start of a line. */
+#define RCS_MERGE_PAT ">>>>>>> "
+
#define RCSEXT ",v"
#define RCSPAT "*,v"
#define RCSHEAD "head"
@@ -41,18 +40,27 @@
#define VALID 0x1 /* flags field contains valid data */
#define INATTIC 0x2 /* RCS file is located in the Attic */
#define PARTIAL 0x4 /* RCS file not completly parsed */
+#define NODELTA 0x8 /* delta_pos no longer valid */
struct rcsnode
{
int refcount;
int flags;
+
+ /* File name of the RCS file. This is not necessarily the name
+ as specified by the user, but it is a name which can be passed to
+ system calls and a name which is OK to print in error messages
+ (the various names might differ in case). */
char *path;
+
char *head;
char *branch;
char *symbols_data;
char *expand;
List *symbols;
List *versions;
+ long delta_pos;
+ List *other;
};
typedef struct rcsnode RCSNode;
@@ -62,9 +70,11 @@ struct rcsversnode
char *version;
char *date;
char *author;
+ char *state;
char *next;
int dead;
List *branches;
+ List *other;
};
typedef struct rcsversnode RCSVers;
@@ -77,17 +87,21 @@ typedef struct rcsversnode RCSVers;
*/
#define RCS_MAGIC_BRANCH 0
+/* The type of a function passed to RCS_checkout. */
+typedef void (*RCSCHECKOUTPROC) PROTO ((void *, const char *, size_t));
+
/*
* exported interfaces
*/
RCSNode *RCS_parse PROTO((const char *file, const char *repos));
RCSNode *RCS_parsercsfile PROTO((char *rcsfile));
+void RCS_fully_parse PROTO((RCSNode *));
char *RCS_check_kflag PROTO((const char *arg));
char *RCS_getdate PROTO((RCSNode * rcs, char *date, int force_tag_match));
char *RCS_gettag PROTO((RCSNode * rcs, char *symtag, int force_tag_match,
- int return_both));
+ int *simple_tag));
char *RCS_getversion PROTO((RCSNode * rcs, char *tag, char *date,
- int force_tag_match, int return_both));
+ int force_tag_match, int *simple_tag));
char *RCS_magicrev PROTO((RCSNode *rcs, char *rev));
int RCS_isbranch PROTO((RCSNode *rcs, const char *rev));
int RCS_nodeisbranch PROTO((RCSNode *rcs, const char *tag));
@@ -102,3 +116,13 @@ char *RCS_getbranch PROTO((RCSNode * rcs, char *tag, int force_tag_match));
int RCS_isdead PROTO((RCSNode *, const char *));
char *RCS_getexpand PROTO ((RCSNode *));
+int RCS_checkout PROTO ((RCSNode *, char *, char *, char *, char *, char *,
+ RCSCHECKOUTPROC, void *));
+int RCS_cmp_file PROTO ((RCSNode *, char *, char *, const char *));
+int RCS_settag PROTO ((RCSNode *, const char *, const char *));
+int RCS_deltag PROTO ((RCSNode *, const char *, int));
+int RCS_setbranch PROTO((RCSNode *, const char *));
+int RCS_lock PROTO ((RCSNode *, const char *, int));
+int RCS_unlock PROTO ((RCSNode *, const char *, int));
+int rcs_change_text PROTO ((const char *, char *, size_t, const char *,
+ size_t, char **, size_t *));
diff --git a/contrib/cvs/src/rcscmds.c b/contrib/cvs/src/rcscmds.c
index 66aea57..1f93fcf 100644
--- a/contrib/cvs/src/rcscmds.c
+++ b/contrib/cvs/src/rcscmds.c
@@ -12,28 +12,73 @@
#include "cvs.h"
#include <assert.h>
+/* This file, rcs.h, and rcs.c, are intended to define our interface
+ to RCS files. As of July, 1996, there are still a few places that
+ still exec RCS commands directly. The intended long-term direction
+ is to have CVS access RCS files via an RCS library (rcs.c can be
+ considered a start at one), for performance, cleanliness (CVS has
+ some awful hacks to work around RCS behaviors which don't make
+ sense for CVS), installation hassles, ease of implementing the CVS
+ server (I don't think that the output-out-of-order bug can be
+ completely fixed as long as CVS calls RCS), and perhaps other
+ reasons.
+
+ Whether there will also be a version of RCS which uses this
+ library, or whether the library will be packaged for uses beyond
+ CVS or RCS (many people would like such a thing) is an open
+ question. Some considerations:
+
+ 1. An RCS library for CVS must have the capabilities of the
+ existing CVS code which accesses RCS files. In particular, simple
+ approaches will often be slow.
+
+ 2. An RCS library should not use the code from the current RCS
+ (5.7 and its ancestors). The code has many problems. Too few
+ comments, too many layers of abstraction, too many global variables
+ (the correct number for a library is zero), too much intricately
+ interwoven functionality, and too many clever hacks. Paul Eggert,
+ the current RCS maintainer, agrees.
+
+ 3. More work needs to be done in terms of separating out the RCS
+ library from the rest of CVS (for example, cvs_output should be
+ replaced by a callback, and the declarations should be centralized
+ into rcs.h, and probably other such cleanups).
+
+ 4. To be useful for RCS and perhaps for other uses, the library
+ may need features beyond those needed by CVS.
+
+ 5. Any changes to the RCS file format *must* be compatible. Many,
+ many tools (not just CVS and RCS) can at least import this format.
+ RCS and CVS must preserve the current ability to import/export it
+ (preferably improved--magic branches are currently a roadblock).
+ See doc/RCSFILES in the CVS distribution for documentation of this
+ file format.
+
+ On somewhat related notes:
+
+ 1. A library for diff is an obvious idea. The one thing which I'm
+ not so sure about is that I think CVS probably wants the ability to
+ allow arbitrarily-bizarre (and possibly customized for particular
+ file formats) external diff programs.
+
+ 2. A library for patch is another such idea. CVS's needs are
+ smaller than the functionality of the standalone patch program (it
+ only calls patch in the client, and only needs to be able to patch
+ unmodified versions, which is something that RCS_deltas already
+ does in a different context). But it is silly for CVS to be making
+ people install patch as well as CVS for such a simple purpose. */
+
/* For RCS file PATH, make symbolic tag TAG point to revision REV.
This validates that TAG is OK for a user to use. Return value is
-1 for error (and errno is set to indicate the error), positive for
error (and an error message has been printed), or zero for success. */
int
-RCS_settag(path, tag, rev)
+RCS_exec_settag(path, tag, rev)
const char *path;
const char *tag;
const char *rev;
{
- if (strcmp (tag, TAG_BASE) == 0
- || strcmp (tag, TAG_HEAD) == 0)
- {
- /* Print the name of the tag might be considered redundant
- with the caller, which also prints it. Perhaps this helps
- clarify why the tag name is considered reserved, I don't
- know. */
- error (0, 0, "Attempt to add reserved tag name %s", tag);
- return 1;
- }
-
run_setup ("%s%s -x,v/ -q -N%s:%s", Rcsbin, RCS, tag, rev);
run_arg (path);
return run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL);
@@ -42,7 +87,7 @@ RCS_settag(path, tag, rev)
/* NOERR is 1 to suppress errors--FIXME it would
be better to avoid the errors or some cleaner solution. */
int
-RCS_deltag(path, tag, noerr)
+RCS_exec_deltag(path, tag, noerr)
const char *path;
const char *tag;
int noerr;
@@ -54,7 +99,7 @@ RCS_deltag(path, tag, noerr)
/* set RCS branch to REV */
int
-RCS_setbranch(path, rev)
+RCS_exec_setbranch(path, rev)
const char *path;
const char *rev;
{
@@ -66,7 +111,7 @@ RCS_setbranch(path, rev)
/* Lock revision REV. NOERR is 1 to suppress errors--FIXME it would
be better to avoid the errors or some cleaner solution. */
int
-RCS_lock(path, rev, noerr)
+RCS_exec_lock(path, rev, noerr)
const char *path;
const char *rev;
int noerr;
@@ -79,7 +124,7 @@ RCS_lock(path, rev, noerr)
/* Unlock revision REV. NOERR is 1 to suppress errors--FIXME it would
be better to avoid the errors or some cleaner solution. */
int
-RCS_unlock(path, rev, noerr)
+RCS_exec_unlock(path, rev, noerr)
const char *path;
const char *rev;
int noerr;
@@ -107,71 +152,53 @@ RCS_merge(path, options, rev1, rev2)
#ifndef HAVE_RCS5
if (status == 0)
{
- /* Run GREP to see if there appear to be conflicts in the file */
- run_setup ("%s", GREP);
- run_arg (RCS_MERGE_PAT);
- run_arg (path);
- status = (run_exec (RUN_TTY, DEVNULL, RUN_TTY, RUN_NORMAL) == 0);
-
+ error (1, 0, "CVS no longer supports RCS versions older than RCS5");
+ /* This case needs to call file_has_markers to see if the file
+ contains conflict indicators. But is anyone using the !HAVE_RCS5
+ code any more? */
}
#endif
return status;
}
-/* Check out a revision from RCSFILE into WORKFILE, or to standard output
- if WORKFILE is NULL. If WORKFILE is "", let RCS pick the working file
- name. TAG is the tag to check out, or NULL if one should check out
- the head of the default branch. OPTIONS is a string such as
- -kb or -kkv, for keyword expansion options, or NULL if there are none.
- If WORKFILE is NULL, run regardless of noexec; if non-NULL, noexec
- inhibits execution. SOUT is what to do with standard output
- (typically RUN_TTY). If FLAGS & RCS_FLAGS_LOCK, lock it. If
- FLAGS & RCS_FLAGS_FORCE, check out even on top of an existing file.
- If NOERR is nonzero, suppress errors. */
-int
-RCS_checkout (rcsfile, workfile, tag, options, sout, flags, noerr)
- char *rcsfile;
- char *workfile;
- char *tag;
- char *options;
- char *sout;
- int flags;
- int noerr;
-{
- run_setup ("%s%s -x,v/ -q %s%s", Rcsbin, RCS_CO,
- tag ? "-r" : "", tag ? tag : "");
- if (options != NULL && options[0] != '\0')
- run_arg (options);
- if (workfile == NULL)
- run_arg ("-p");
- if (flags & RCS_FLAGS_LOCK)
- run_arg ("-l");
- if (flags & RCS_FLAGS_FORCE)
- run_arg ("-f");
- run_arg (rcsfile);
- if (workfile != NULL && workfile[0] != '\0')
- run_arg (workfile);
- return run_exec (RUN_TTY, sout, noerr ? DEVNULL : RUN_TTY,
- workfile == NULL ? (RUN_NORMAL | RUN_REALLY) : RUN_NORMAL);
-}
-
/* Check in to RCSFILE with revision REV (which must be greater than the
largest revision) and message MESSAGE (which is checked for legality).
- If FLAGS & RCS_FLAGS_DEAD, check in a dead revision. If NOERR, do not
- report errors. If FLAGS & RCS_FLAGS_QUIET suppress errors somewhat more
- selectively. If FLAGS & RCS_FLAGS_MODTIME, use the working file's
- modification time for the checkin time. WORKFILE is the working file
- to check in from, or NULL to use the usual RCS rules for deriving it
- from the RCSFILE. */
+ If FLAGS & RCS_FLAGS_DEAD, check in a dead revision. If FLAGS &
+ RCS_FLAGS_QUIET, tell ci to be quiet. If FLAGS & RCS_FLAGS_MODTIME,
+ use the working file's modification time for the checkin time.
+ WORKFILE is the working file to check in from, or NULL to use the usual
+ RCS rules for deriving it from the RCSFILE.
+
+ Return value is -1 for error (and errno is set to indicate the
+ error), positive for error (and an error message has been printed),
+ or zero for success. */
int
-RCS_checkin (rcsfile, workfile, message, rev, flags, noerr)
+RCS_checkin (rcsfile, workfile, message, rev, flags)
char *rcsfile;
char *workfile;
char *message;
char *rev;
int flags;
- int noerr;
{
+ /* The desired behavior regarding permissions is to preserve the
+ permissions on RCSFILE if it already exists. Based on looking
+ at the RCS 5.7 source, it would appear that RCS_CI does this
+ except when it is creating RCSFILE (reasonable), or when
+ RCSFILE was created with rcs -i (this is strange, and quite
+ possibly unintentional). In those two cases it copies the
+ permissions from the workfile.
+
+ Anyway, the fix is simple enough: we preserve the mode ourself. */
+ struct stat sb;
+ int fix_mode = 1;
+ int retval;
+
+ if (CVS_STAT (rcsfile, &sb) < 0)
+ {
+ fix_mode = 0;
+ if (!existence_error (errno))
+ error (0, errno, "warning: cannot stat %s", rcsfile);
+ }
run_setup ("%s%s -x,v/ -f %s%s", Rcsbin, RCS_CI,
rev ? "-r" : "", rev ? rev : "");
if (flags & RCS_FLAGS_DEAD)
@@ -184,5 +211,12 @@ RCS_checkin (rcsfile, workfile, message, rev, flags, noerr)
if (workfile != NULL)
run_arg (workfile);
run_arg (rcsfile);
- return run_exec (RUN_TTY, RUN_TTY, noerr ? DEVNULL : RUN_TTY, RUN_NORMAL);
+ retval = run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL);
+ if (retval == 0 && fix_mode)
+ {
+ if (chmod (rcsfile, sb.st_mode) < 0)
+ error (0, errno, "warning: cannot change permissions on %s",
+ rcsfile);
+ }
+ return retval;
}
diff --git a/contrib/cvs/src/recurse.c b/contrib/cvs/src/recurse.c
index ec51a98..e18d576 100644
--- a/contrib/cvs/src/recurse.c
+++ b/contrib/cvs/src/recurse.c
@@ -19,79 +19,113 @@ static void addlist PROTO((List ** listp, char *key));
static int unroll_files_proc PROTO((Node *p, void *closure));
static void addfile PROTO((List **listp, char *dir, char *file));
-
-/*
- * Local static versions eliminates the need for globals
- */
-static FILEPROC fileproc;
-static FILESDONEPROC filesdoneproc;
-static DIRENTPROC direntproc;
-static DIRLEAVEPROC dirleaveproc;
-static int which;
-static Dtype flags;
-static int aflag;
-static int readlock;
-static int dosrcs;
-static char update_dir[PATH_MAX];
+static char *update_dir;
static char *repository = NULL;
static List *filelist = NULL; /* holds list of files on which to operate */
static List *dirlist = NULL; /* holds list of directories on which to operate */
struct recursion_frame {
- FILEPROC fileproc;
- FILESDONEPROC filesdoneproc;
- DIRENTPROC direntproc;
- DIRLEAVEPROC dirleaveproc;
- Dtype flags;
- int which;
- int aflag;
- int readlock;
- int dosrcs;
+ FILEPROC fileproc;
+ FILESDONEPROC filesdoneproc;
+ DIRENTPROC direntproc;
+ DIRLEAVEPROC dirleaveproc;
+ void *callerdat;
+ Dtype flags;
+ int which;
+ int aflag;
+ int readlock;
+ int dosrcs;
};
-/*
- * Called to start a recursive command.
- *
- * Command line arguments dictate the directories and files on which
- * we operate. In the special case of no arguments, we default to
- * ".".
- *
- * The general algorithm is as follows.
- */
+static int do_recursion PROTO ((struct recursion_frame *frame));
+
+/* I am half tempted to shove a struct file_info * into the struct
+ recursion_frame (but then we would need to modify or create a
+ recursion_frame for each file), or shove a struct recursion_frame *
+ into the struct file_info (more tempting, although it isn't completely
+ clear that the struct file_info should contain info about recursion
+ processor internals). So instead use this struct. */
+
+struct frame_and_file {
+ struct recursion_frame *frame;
+ struct file_info *finfo;
+};
+
+/* Similarly, we need to pass the entries list to do_dir_proc. */
+
+struct frame_and_entries {
+ struct recursion_frame *frame;
+ List *entries;
+};
+
+/* 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, filesdoneproc, direntproc, dirleaveproc,
+start_recursion (fileproc, filesdoneproc, direntproc, dirleaveproc, callerdat,
argc, argv, local, which, aflag, readlock,
- update_preload, dosrcs, wd_is_repos)
+ update_preload, dosrcs)
FILEPROC fileproc;
FILESDONEPROC filesdoneproc;
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 or W_ATTIC 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 and W_ATTIC are 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 or W_ATTIC. 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;
char *update_preload;
int dosrcs;
- int wd_is_repos; /* Set if caller has already cd'd to the repository */
{
int i, err = 0;
- Dtype flags;
List *files_by_dir = NULL;
struct recursion_frame frame;
+ frame.fileproc = fileproc;
+ frame.filesdoneproc = filesdoneproc;
+ 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;
+
expand_wild (argc, argv, &argc, &argv);
if (update_preload == NULL)
- update_dir[0] = '\0';
- else
- (void) strcpy (update_dir, update_preload);
-
- if (local)
- flags = R_SKIP_DIRS;
+ update_dir = xstrdup ("");
else
- flags = R_PROCESS;
+ update_dir = xstrdup (update_preload);
/* clean up from any previous calls to start_recursion */
if (repository)
@@ -101,10 +135,17 @@ start_recursion (fileproc, filesdoneproc, direntproc, dirleaveproc,
}
if (filelist)
dellist (&filelist); /* FIXME-krp: no longer correct. */
-/* FIXME-krp: clean up files_by_dir */
if (dirlist)
dellist (&dirlist);
+#ifdef SERVER_SUPPORT
+ if (server_active)
+ {
+ for (i = 0; i < argc; ++i)
+ server_pathname_check (argv[i]);
+ }
+#endif
+
if (argc == 0)
{
@@ -116,14 +157,12 @@ start_recursion (fileproc, filesdoneproc, direntproc, dirleaveproc,
* called with the list of sub-dirs of the current dir as args
*/
if ((which & W_LOCAL) && !isdir (CVSADM))
- dirlist = Find_Directories ((char *) NULL, W_LOCAL);
+ dirlist = Find_Directories ((char *) NULL, W_LOCAL, (List *) NULL);
else
addlist (&dirlist, ".");
- err += do_recursion (fileproc, filesdoneproc, direntproc,
- dirleaveproc, flags, which, aflag,
- readlock, dosrcs);
- return(err);
+ err += do_recursion (&frame);
+ goto out;
}
@@ -151,7 +190,6 @@ start_recursion (fileproc, filesdoneproc, direntproc, dirleaveproc,
/* otherwise, split argument into directory and component names. */
char *dir;
char *comp;
- char tmp[PATH_MAX];
char *file_to_try;
/* Now break out argv[i] into directory part (DIR) and file part (COMP).
@@ -174,45 +212,55 @@ start_recursion (fileproc, filesdoneproc, direntproc, dirleaveproc,
/* if this argument exists as a file in the current
working directory tree, then add it to the files list. */
- if (wd_is_repos)
+ if (!(which & W_LOCAL))
{
/* If doing rtag, we've done a chdir to the repository. */
- sprintf (tmp, "%s%s", argv[i], RCSEXT);
- file_to_try = tmp;
+ file_to_try = xmalloc (strlen (argv[i]) + sizeof (RCSEXT) + 5);
+ sprintf (file_to_try, "%s%s", argv[i], RCSEXT);
}
else
- file_to_try = argv[i];
+ file_to_try = xstrdup (argv[i]);
- if(isfile(file_to_try))
+ if (isfile (file_to_try))
addfile (&files_by_dir, dir, comp);
else if (isdir (dir))
{
- if (isdir (CVSADM))
+ if ((which & W_LOCAL) && isdir (CVSADM)
+#ifdef CLIENT_SUPPORT
+ && !client_active
+#endif
+ )
{
/* otherwise, look for it in the repository. */
- char *save_update_dir;
+ char *tmp_update_dir;
char *repos;
-
- /* save & set (aka push) update_dir */
- save_update_dir = xstrdup (update_dir);
+ char *reposfile;
+
+ tmp_update_dir = xmalloc (strlen (update_dir)
+ + strlen (dir)
+ + 5);
+ strcpy (tmp_update_dir, update_dir);
- if (*update_dir != '\0')
- (void) strcat (update_dir, "/");
+ if (*tmp_update_dir != '\0')
+ (void) strcat (tmp_update_dir, "/");
+
+ (void) strcat (tmp_update_dir, dir);
- (void) strcat (update_dir, dir);
-
/* look for it in the repository. */
- repos = Name_Repository (dir, update_dir);
- (void) sprintf (tmp, "%s/%s", repos, comp);
+ repos = Name_Repository (dir, tmp_update_dir);
+ reposfile = xmalloc (strlen (repos)
+ + strlen (comp)
+ + 5);
+ (void) sprintf (reposfile, "%s/%s", repos, comp);
free (repos);
- if (!wrap_name_has (comp, WRAP_TOCVS) && isdir(tmp))
+ if (!wrap_name_has (comp, WRAP_TOCVS) && isdir (reposfile))
addlist (&dirlist, argv[i]);
else
addfile (&files_by_dir, dir, comp);
- (void) sprintf (update_dir, "%s", save_update_dir);
- free (save_update_dir);
+ free (tmp_update_dir);
+ free (reposfile);
}
else
addfile (&files_by_dir, dir, comp);
@@ -220,6 +268,7 @@ start_recursion (fileproc, filesdoneproc, direntproc, dirleaveproc,
else
error (1, 0, "no such directory `%s'", dir);
+ free (file_to_try);
free (dir);
free (comp);
}
@@ -229,29 +278,21 @@ start_recursion (fileproc, filesdoneproc, direntproc, dirleaveproc,
a coupla lists. Now we unroll the lists, setting up and
calling do_recursion. */
- frame.fileproc = fileproc;
- frame.filesdoneproc = filesdoneproc;
- frame.direntproc = direntproc;
- frame.dirleaveproc = dirleaveproc;
- frame.flags = flags;
- frame.which = which;
- frame.aflag = aflag;
- frame.readlock = readlock;
- frame.dosrcs = dosrcs;
err += walklist (files_by_dir, unroll_files_proc, (void *) &frame);
+ dellist(&files_by_dir);
/* then do_recursion on the dirlist. */
if (dirlist != NULL)
- err += do_recursion (frame.fileproc, frame.filesdoneproc,
- frame.direntproc, frame.dirleaveproc,
- frame.flags, frame.which, frame.aflag,
- frame.readlock, frame.dosrcs);
+ err += do_recursion (&frame);
/* Free the data which expand_wild allocated. */
for (i = 0; i < argc; ++i)
free (argv[i]);
free (argv);
+ out:
+ free (update_dir);
+ update_dir = NULL;
return (err);
}
@@ -259,38 +300,21 @@ start_recursion (fileproc, filesdoneproc, direntproc, dirleaveproc,
* Implement the recursive policies on the local directory. This may be
* called directly, or may be called by start_recursion
*/
-int
-do_recursion (xfileproc, xfilesdoneproc, xdirentproc, xdirleaveproc,
- xflags, xwhich, xaflag, xreadlock, xdosrcs)
- FILEPROC xfileproc;
- FILESDONEPROC xfilesdoneproc;
- DIRENTPROC xdirentproc;
- DIRLEAVEPROC xdirleaveproc;
- Dtype xflags;
- int xwhich;
- int xaflag;
- int xreadlock;
- int xdosrcs;
+static int
+do_recursion (frame)
+ struct recursion_frame *frame;
{
int err = 0;
int dodoneproc = 1;
char *srepository;
List *entries = NULL;
+ int should_readlock;
/* do nothing if told */
- if (xflags == R_SKIP_ALL)
+ if (frame->flags == R_SKIP_ALL)
return (0);
- /* set up the static vars */
- fileproc = xfileproc;
- filesdoneproc = xfilesdoneproc;
- direntproc = xdirentproc;
- dirleaveproc = xdirleaveproc;
- flags = xflags;
- which = xwhich;
- aflag = xaflag;
- readlock = noexec ? 0 : xreadlock;
- dosrcs = xdosrcs;
+ should_readlock = noexec ? 0 : frame->readlock;
/* The fact that locks are not active here is what makes us fail to have
the
@@ -332,14 +356,14 @@ do_recursion (xfileproc, xfilesdoneproc, xdirentproc, xdirleaveproc,
*/
if (server_active
/* If there are writelocks around, we cannot pause here. */
- && (readlock || noexec))
+ && (should_readlock || noexec))
server_pause_check();
#endif
/*
* Fill in repository with the current repository
*/
- if (which & W_LOCAL)
+ if (frame->which & W_LOCAL)
{
if (isdir (CVSADM))
repository = Name_Repository ((char *) NULL, update_dir);
@@ -348,8 +372,9 @@ do_recursion (xfileproc, xfilesdoneproc, xdirentproc, xdirleaveproc,
}
else
{
- repository = xmalloc (PATH_MAX);
- (void) getwd (repository);
+ repository = xgetwd ();
+ if (repository == NULL)
+ error (1, errno, "could not get working directory");
}
srepository = repository; /* remember what to free */
@@ -373,41 +398,52 @@ do_recursion (xfileproc, xfilesdoneproc, xdirentproc, xdirleaveproc,
if (filelist == NULL && dirlist == NULL)
{
/* both lists were NULL, so start from scratch */
- if (fileproc != NULL && flags != R_SKIP_FILES)
+ if (frame->fileproc != NULL && frame->flags != R_SKIP_FILES)
{
- int lwhich = which;
+ int lwhich = frame->which;
/* be sure to look in the attic if we have sticky tags/date */
if ((lwhich & W_ATTIC) == 0)
if (isreadable (CVSADM_TAG))
lwhich |= W_ATTIC;
+ /* In the !(which & W_LOCAL) case, we filled in repository
+ earlier in the function. In the (which & W_LOCAL) case,
+ the Find_Names function is going to look through the
+ Entries file. If we do not have a repository, that
+ does not make sense, so we insist upon having a
+ repository at this point. Name_Repository will give a
+ reasonable error message. */
+ if (repository == NULL)
+ repository = Name_Repository ((char *) NULL, update_dir);
+
/* find the files and fill in entries if appropriate */
- filelist = Find_Names (repository, lwhich, aflag, &entries);
+ filelist = Find_Names (repository, lwhich, frame->aflag, &entries);
}
/* find sub-directories if we will recurse */
- if (flags != R_SKIP_DIRS)
- dirlist = Find_Directories (repository, which);
+ if (frame->flags != R_SKIP_DIRS)
+ dirlist = Find_Directories (repository, frame->which, entries);
}
else
{
/* something was passed on the command line */
- if (filelist != NULL && fileproc != NULL)
+ if (filelist != NULL && frame->fileproc != NULL)
{
/* we will process files, so pre-parse entries */
- if (which & W_LOCAL)
- entries = Entries_Open (aflag);
+ if (frame->which & W_LOCAL)
+ entries = Entries_Open (frame->aflag);
}
}
/* process the files (if any) */
- if (filelist != NULL && fileproc)
+ if (filelist != NULL && frame->fileproc)
{
struct file_info finfo_struct;
+ struct frame_and_file frfile;
/* read lock it if necessary */
- if (readlock && repository && Reader_Lock (repository) != 0)
+ if (should_readlock && repository && Reader_Lock (repository) != 0)
error (1, 0, "read lock failed - giving up");
#ifdef CLIENT_SUPPORT
@@ -424,39 +460,50 @@ do_recursion (xfileproc, xfilesdoneproc, xdirentproc, xdirleaveproc,
finfo_struct.entries = entries;
/* do_file_proc will fill in finfo_struct.file. */
+ frfile.finfo = &finfo_struct;
+ frfile.frame = frame;
+
/* process the files */
- err += walklist (filelist, do_file_proc, &finfo_struct);
+ err += walklist (filelist, do_file_proc, &frfile);
/* unlock it */
- if (readlock)
+ if (should_readlock)
Lock_Cleanup ();
/* clean up */
dellist (&filelist);
}
- if (entries)
- {
- Entries_Close (entries);
- entries = NULL;
- }
-
/* call-back files done proc (if any) */
- if (dodoneproc && filesdoneproc != NULL)
- err = filesdoneproc (err, repository, update_dir[0] ? update_dir : ".");
+ if (dodoneproc && frame->filesdoneproc != NULL)
+ err = frame->filesdoneproc (frame->callerdat, err, repository,
+ update_dir[0] ? update_dir : ".",
+ entries);
fileattr_write ();
fileattr_free ();
/* process the directories (if necessary) */
if (dirlist != NULL)
- err += walklist (dirlist, do_dir_proc, NULL);
-#ifdef notdef
- else if (dirleaveproc != NULL)
- err += dirleaveproc(".", err, ".");
+ {
+ struct frame_and_entries frent;
+
+ frent.frame = frame;
+ frent.entries = entries;
+ err += walklist (dirlist, do_dir_proc, (void *) &frent);
+ }
+#if 0
+ else if (frame->dirleaveproc != NULL)
+ err += frame->dirleaveproc (frame->callerdat, ".", err, ".");
#endif
dellist (&dirlist);
+ if (entries)
+ {
+ Entries_Close (entries);
+ entries = NULL;
+ }
+
/* free the saved copy of the pointer if necessary */
if (srepository)
{
@@ -475,7 +522,8 @@ do_file_proc (p, closure)
Node *p;
void *closure;
{
- struct file_info *finfo = (struct file_info *)closure;
+ struct frame_and_file *frfile = (struct frame_and_file *)closure;
+ struct file_info *finfo = frfile->finfo;
int ret;
finfo->file = p->key;
@@ -490,15 +538,20 @@ do_file_proc (p, closure)
}
strcat (finfo->fullname, finfo->file);
- if (dosrcs && repository)
+ if (frfile->frame->dosrcs && repository)
finfo->rcs = RCS_parse (finfo->file, repository);
else
finfo->rcs = (RCSNode *) NULL;
- ret = fileproc (finfo);
+ ret = frfile->frame->fileproc (frfile->frame->callerdat, finfo);
freercsnode(&finfo->rcs);
free (finfo->fullname);
+ /* Allow the user to monitor progress with tail -f. Doing this once
+ per file should be no big deal, but we don't want the performance
+ hit of flushing on every line like previous versions of CVS. */
+ cvs_flushout ();
+
return (ret);
}
@@ -510,8 +563,11 @@ do_dir_proc (p, closure)
Node *p;
void *closure;
{
+ struct frame_and_entries *frent = (struct frame_and_entries *) closure;
+ struct recursion_frame *frame = frent->frame;
+ struct recursion_frame xframe;
char *dir = p->key;
- char newrepos[PATH_MAX];
+ char *newrepos;
List *sdirlist;
char *srepository;
char *cp;
@@ -519,6 +575,46 @@ do_dir_proc (p, closure)
int stripped_dot = 0;
int err = 0;
struct saved_cwd cwd;
+ char *saved_update_dir;
+
+ if (fncmp (dir, CVSADM) == 0)
+ {
+ /* This seems to most often happen when users (beginning users,
+ generally), try "cvs ci *" or something similar. On that
+ theory, it is possible that we should just silently skip the
+ CVSADM directories, but on the other hand, using a wildcard
+ like this isn't necessarily a practice to encourage (it operates
+ only on files which exist in the working directory, unlike
+ regular CVS recursion). */
+
+ /* FIXME-reentrancy: printed_cvs_msg should be in a "command
+ struct" or some such, so that it gets cleared for each new
+ command (this is possible using the remote protocol and a
+ custom-written client). The struct recursion_frame is not
+ far back enough though, some commands (commit at least)
+ will call start_recursion several times. An alternate solution
+ would be to take this whole check and move it to a new function
+ validate_arguments or some such that all the commands call
+ and which snips the offending directory from the argc,argv
+ vector. */
+ static int printed_cvs_msg = 0;
+ if (!printed_cvs_msg)
+ {
+ error (0, 0, "warning: directory %s specified in argument",
+ dir);
+ error (0, 0, "\
+but CVS uses %s for its own purposes; skipping %s directory",
+ CVSADM, dir);
+ printed_cvs_msg = 1;
+ }
+ return 0;
+ }
+
+ saved_update_dir = update_dir;
+ update_dir = xmalloc (strlen (saved_update_dir)
+ + strlen (dir)
+ + 5);
+ strcpy (update_dir, saved_update_dir);
/* set up update_dir - skip dots if not at start */
if (strcmp (dir, ".") != 0)
@@ -539,9 +635,12 @@ do_dir_proc (p, closure)
* update -d and in that case the generated name will be correct.
*/
if (repository == NULL)
- newrepos[0] = '\0';
+ newrepos = xstrdup ("");
else
+ {
+ newrepos = xmalloc (strlen (repository) + strlen (dir) + 5);
(void) sprintf (newrepos, "%s/%s", repository, dir);
+ }
}
else
{
@@ -549,31 +648,33 @@ do_dir_proc (p, closure)
(void) strcpy (update_dir, dir);
if (repository == NULL)
- newrepos[0] = '\0';
+ newrepos = xstrdup ("");
else
- (void) strcpy (newrepos, repository);
+ newrepos = xstrdup (repository);
}
/* call-back dir entry proc (if any) */
- if (direntproc != NULL)
- dir_return = direntproc (dir, newrepos, update_dir);
+ if (frame->direntproc != NULL)
+ dir_return = frame->direntproc (frame->callerdat, dir, newrepos,
+ update_dir, frent->entries);
+ free (newrepos);
/* only process the dir if the return code was 0 */
if (dir_return != R_SKIP_ALL)
{
/* save our current directory and static vars */
if (save_cwd (&cwd))
- exit (EXIT_FAILURE);
+ error_exit ();
sdirlist = dirlist;
srepository = repository;
dirlist = NULL;
/* cd to the sub-directory */
- if (chdir (dir) < 0)
+ if ( CVS_CHDIR (dir) < 0)
error (1, errno, "could not chdir to %s", dir);
/* honor the global SKIP_DIRS (a.k.a. local) */
- if (flags == R_SKIP_DIRS)
+ if (frame->flags == R_SKIP_DIRS)
dir_return = R_SKIP_DIRS;
/* remember if the `.' will be stripped for subsequent dirs */
@@ -584,31 +685,37 @@ do_dir_proc (p, closure)
}
/* make the recursive call */
- err += do_recursion (fileproc, filesdoneproc, direntproc, dirleaveproc,
- dir_return, which, aflag, readlock, dosrcs);
+ xframe = *frame;
+ xframe.flags = dir_return;
+ err += do_recursion (&xframe);
/* put the `.' back if necessary */
if (stripped_dot)
(void) strcpy (update_dir, ".");
/* call-back dir leave proc (if any) */
- if (dirleaveproc != NULL)
- err = dirleaveproc (dir, err, update_dir);
+ if (frame->dirleaveproc != NULL)
+ err = frame->dirleaveproc (frame->callerdat, dir, err, update_dir,
+ frent->entries);
/* get back to where we started and restore state vars */
if (restore_cwd (&cwd, NULL))
- exit (EXIT_FAILURE);
+ error_exit ();
free_cwd (&cwd);
dirlist = sdirlist;
repository = srepository;
}
- /* put back update_dir */
+ /* Put back update_dir. I think this is the same as just setting
+ update_dir back to saved_update_dir, but there are a few cases I'm
+ not sure about (in particular, if DIR is "." and update_dir is
+ not ""), so for conservatism I'm leaving this here. */
cp = last_component (update_dir);
if (cp > update_dir)
cp[-1] = '\0';
else
update_dir[0] = '\0';
+ free (saved_update_dir);
return (err);
}
@@ -675,17 +782,22 @@ unroll_files_proc (p, closure)
/* otherwise, call dorecusion for this list of files. */
filelist = (List *) p->data;
+ p->data = NULL;
save_dirlist = dirlist;
dirlist = NULL;
if (strcmp(p->key, ".") != 0)
{
if (save_cwd (&cwd))
- exit (EXIT_FAILURE);
- if (chdir (p->key) < 0)
+ error_exit ();
+ if ( CVS_CHDIR (p->key) < 0)
error (1, errno, "could not chdir to %s", p->key);
- save_update_dir = xstrdup (update_dir);
+ save_update_dir = update_dir;
+ update_dir = xmalloc (strlen (save_update_dir)
+ + strlen (p->key)
+ + 5);
+ strcpy (update_dir, save_update_dir);
if (*update_dir != '\0')
(void) strcat (update_dir, "/");
@@ -693,18 +805,15 @@ unroll_files_proc (p, closure)
(void) strcat (update_dir, p->key);
}
- err += do_recursion (frame->fileproc, frame->filesdoneproc,
- frame->direntproc, frame->dirleaveproc,
- frame->flags, frame->which, frame->aflag,
- frame->readlock, frame->dosrcs);
+ err += do_recursion (frame);
if (save_update_dir != NULL)
{
- (void) strcpy (update_dir, save_update_dir);
- free (save_update_dir);
+ free (update_dir);
+ update_dir = save_update_dir;
if (restore_cwd (&cwd, NULL))
- exit (EXIT_FAILURE);
+ error_exit ();
free_cwd (&cwd);
}
diff --git a/contrib/cvs/src/release.c b/contrib/cvs/src/release.c
index b3ebb2b..f2f1edf 100644
--- a/contrib/cvs/src/release.c
+++ b/contrib/cvs/src/release.c
@@ -1,41 +1,61 @@
/*
* Release: "cancel" a checkout in the history log.
*
- * - Don't allow release if anything is active - Don't allow release if not
- * above or inside repository. - Don't allow release if ./CVS/Repository is
- * not the same as the directory specified in the module database.
- *
* - Enter a line in the history log indicating the "release". - If asked to,
* delete the local working directory.
*/
#include "cvs.h"
+#include "getline.h"
static void release_delete PROTO((char *dir));
static const char *const release_usage[] =
{
- "Usage: %s %s [-d] modules...\n",
+ "Usage: %s %s [-d] directories...\n",
"\t-d\tDelete the given directory.\n",
NULL
};
-static short delete_flag;
+#ifdef SERVER_SUPPORT
+static int release_server PROTO ((int argc, char **argv));
+
+/* This is the server side of cvs release. */
+static int
+release_server (argc, argv)
+ int argc;
+ char **argv;
+{
+ int i;
+
+ /* Note that we skip argv[0]. */
+ for (i = 1; i < argc; ++i)
+ history_write ('F', argv[i], "", argv[i], "");
+ return 0;
+}
+
+#endif /* SERVER_SUPPORT */
-/* FIXME: This implementation is cheezy in quite a few ways:
+/* There are various things to improve about this implementation:
- 1. The whole "cvs update" junk could be checked locally with a
+ 1. Using run_popen to run "cvs update" could be replaced by a
fairly simple start_recursion/classify_file loop--a win for
- portability, performance, and cleanliness.
+ portability, performance, and cleanliness. In particular, there is
+ no particularly good way to find the right "cvs".
- 2. Should be like edit/unedit in terms of working well if disconnected
- from the network, and then sending a delayed notification.
+ 2. The fact that "cvs update" contacts the server slows things down;
+ it undermines the case for using "cvs release" rather than "rm -rf".
+ However, for correctly printing "? foo" and correctly handling
+ CVSROOTADM_IGNORE, we currently need to contact the server.
- 3. Way too many network turnarounds. More than one for each argument.
- Puh-leeze.
+ 3. Would be nice to take processing things on the client side one step
+ further, and making it like edit/unedit in terms of working well if
+ disconnected from the network, and then sending a delayed
+ notification.
- 4. Oh, and as a purely stylistic nit, break this out into separate
- functions for client/local and for server. Those #ifdefs are a mess. */
+ 4. Having separate network turnarounds for the "Notify" request
+ which we do as part of unedit, and for the "release" itself, is slow
+ and unnecessary. */
int
release (argc, argv)
@@ -43,171 +63,140 @@ release (argc, argv)
char **argv;
{
FILE *fp;
- register int i, c;
- char *repository, *srepos;
- char line[PATH_MAX], update_cmd[PATH_MAX];
+ int i, c;
+ char *repository;
+ char *line = NULL;
+ size_t line_allocated = 0;
+ char *update_cmd;
char *thisarg;
int arg_start_idx;
int err = 0;
+ short delete_flag = 0;
#ifdef SERVER_SUPPORT
- if (!server_active)
- {
-#endif /* SERVER_SUPPORT */
- if (argc == -1)
- usage (release_usage);
- optind = 1;
- while ((c = getopt (argc, argv, "Qdq")) != -1)
- {
- switch (c)
- {
- case 'Q':
- case 'q':
-#ifdef SERVER_SUPPORT
- /* The CVS 1.5 client sends these options (in addition to
- Global_option requests), so we must ignore them. */
- if (!server_active)
+ if (server_active)
+ return release_server (argc, argv);
#endif
- error (1, 0,
- "-q or -Q must be specified before \"%s\"",
- command_name);
+
+ /* Everything from here on is client or local. */
+ if (argc == -1)
+ usage (release_usage);
+ optind = 1;
+ while ((c = getopt (argc, argv, "+Qdq")) != -1)
+ {
+ switch (c)
+ {
+ case 'Q':
+ case 'q':
+ error (1, 0,
+ "-q or -Q must be specified before \"%s\"",
+ command_name);
break;
- case 'd':
+ case 'd':
delete_flag++;
break;
- case '?':
- default:
+ case '?':
+ default:
usage (release_usage);
break;
- }
- }
- argc -= optind;
- argv += optind;
-#ifdef SERVER_SUPPORT
- }
-#endif /* SERVER_SUPPORT */
+ }
+ }
+ argc -= optind;
+ argv += optind;
/* We're going to run "cvs -n -q update" and check its output; if
* the output is sufficiently unalarming, then we release with no
* questions asked. Else we prompt, then maybe release.
*/
/* Construct the update command. */
+ update_cmd = xmalloc (strlen (program_path)
+ + strlen (CVSroot_original)
+ + 20);
sprintf (update_cmd, "%s -n -q -d %s update",
- program_path, CVSroot);
+ program_path, CVSroot_original);
#ifdef CLIENT_SUPPORT
/* Start the server; we'll close it after looping. */
if (client_active)
- {
+ {
start_server ();
ign_setup ();
- }
+ }
#endif /* CLIENT_SUPPORT */
- /* If !server_active, we already skipped over argv[0] in the "argc
- -= optind;" statement above. But if server_active, we need to
- skip it now. */
-#ifdef SERVER_SUPPORT
- if (server_active)
- arg_start_idx = 1;
- else
-#endif /* SERVER_SUPPORT */
- arg_start_idx = 0;
+ arg_start_idx = 0;
for (i = arg_start_idx; i < argc; i++)
{
- thisarg = argv[i];
-
-#ifdef SERVER_SUPPORT
- if (server_active)
- {
- /* Just log the release -- all the interesting stuff happened
- * on the client.
- */
- history_write ('F', thisarg, "", thisarg, ""); /* F == Free */
- }
- else
- {
-#endif /* SERVER_SUPPORT */
-
- /*
- * If we are in a repository, do it. Else if we are in the parent of
- * a directory with the same name as the module, "cd" into it and
- * look for a repository there.
- */
+ thisarg = argv[i];
+
if (isdir (thisarg))
{
- if (chdir (thisarg) < 0)
- {
- if (!really_quiet)
- error (0, 0, "can't chdir to: %s", thisarg);
- continue;
- }
- if (!isdir (CVSADM))
- {
- if (!really_quiet)
- error (0, 0, "no repository module: %s", thisarg);
- continue;
- }
+ if (CVS_CHDIR (thisarg) < 0)
+ {
+ if (!really_quiet)
+ error (0, errno, "can't chdir to: %s", thisarg);
+ continue;
+ }
+ if (!isdir (CVSADM))
+ {
+ if (!really_quiet)
+ error (0, 0, "no repository directory: %s", thisarg);
+ continue;
+ }
}
else
{
- if (!really_quiet)
- error (0, 0, "no such directory: %s", thisarg);
- continue;
+ if (!really_quiet)
+ error (0, 0, "no such directory: %s", thisarg);
+ continue;
}
repository = Name_Repository ((char *) NULL, (char *) NULL);
- srepos = Short_Repository (repository);
-
+
if (!really_quiet)
{
- /* The "release" command piggybacks on "update", which
- * does the real work of finding out if anything is not
- * up-to-date with the repository. Then "release" prompts
- * the user, telling her how many files have been
- * modified, and asking if she still wants to do the
- * release.
- */
- fp = run_popen (update_cmd, "r");
- c = 0;
-
- while (fgets (line, sizeof (line), fp))
- {
- if (strchr ("MARCZ", *line))
- c++;
- (void) printf (line);
- }
-
- /* If the update exited with an error, then we just want to
- * complain and go on to the next arg. Especially, we do
- * not want to delete the local copy, since it's obviously
- * not what the user thinks it is.
- */
- if ((pclose (fp)) != 0)
- {
- error (0, 0, "unable to release `%s'", thisarg);
- continue;
- }
-
- (void) printf ("You have [%d] altered files in this repository.\n",
- c);
- (void) printf ("Are you sure you want to release %smodule `%s': ",
- delete_flag ? "(and delete) " : "", thisarg);
- c = !yesno ();
- if (c) /* "No" */
- {
- (void) fprintf (stderr, "** `%s' aborted by user choice.\n",
- command_name);
- free (repository);
- continue;
- }
+ /* The "release" command piggybacks on "update", which
+ does the real work of finding out if anything is not
+ up-to-date with the repository. Then "release" prompts
+ the user, telling her how many files have been
+ modified, and asking if she still wants to do the
+ release. */
+ fp = run_popen (update_cmd, "r");
+ c = 0;
+
+ while (getline (&line, &line_allocated, fp) >= 0)
+ {
+ if (strchr ("MARCZ", *line))
+ c++;
+ (void) printf (line);
+ }
+
+ /* If the update exited with an error, then we just want to
+ complain and go on to the next arg. Especially, we do
+ not want to delete the local copy, since it's obviously
+ not what the user thinks it is. */
+ if ((pclose (fp)) != 0)
+ {
+ error (0, 0, "unable to release `%s'", thisarg);
+ continue;
+ }
+
+ printf ("You have [%d] altered files in this repository.\n",
+ c);
+ printf ("Are you sure you want to release %sdirectory `%s': ",
+ delete_flag ? "(and delete) " : "", thisarg);
+ c = !yesno ();
+ if (c) /* "No" */
+ {
+ (void) fprintf (stderr, "** `%s' aborted by user choice.\n",
+ command_name);
+ free (repository);
+ continue;
+ }
}
if (1
-#ifdef SERVER_SUPPORT
- && !server_active
-#endif
#ifdef CLIENT_SUPPORT
&& !(client_active
&& (!supported_request ("noop")
@@ -215,45 +204,53 @@ release (argc, argv)
#endif
)
{
- /* We are chdir'ed into the directory in question.
- So don't pass args to unedit. */
- int argc = 1;
- char *argv[3];
- argv[0] = "dummy";
- argv[1] = NULL;
- err += unedit (argc, argv);
+ /* We are chdir'ed into the directory in question.
+ So don't pass args to unedit. */
+ int argc = 1;
+ char *argv[3];
+ argv[0] = "dummy";
+ argv[1] = NULL;
+ err += unedit (argc, argv);
}
#ifdef CLIENT_SUPPORT
if (client_active)
{
- send_to_server ("Argument ", 0);
- send_to_server (thisarg, 0);
- send_to_server ("\012", 1);
- send_to_server ("release\012", 0);
- }
+ send_to_server ("Argument ", 0);
+ send_to_server (thisarg, 0);
+ send_to_server ("\012", 1);
+ send_to_server ("release\012", 0);
+ }
else
- {
#endif /* CLIENT_SUPPORT */
- history_write ('F', thisarg, "", thisarg, ""); /* F == Free */
-#ifdef CLIENT_SUPPORT
- } /* else client not active */
-#endif /* CLIENT_SUPPORT */
-
+ {
+ history_write ('F', thisarg, "", thisarg, ""); /* F == Free */
+ }
+
free (repository);
if (delete_flag) release_delete (thisarg);
-
+
#ifdef CLIENT_SUPPORT
if (client_active)
- return get_responses_and_close ();
- else
+ err += get_server_responses ();
#endif /* CLIENT_SUPPORT */
- return (0);
-
-#ifdef SERVER_SUPPORT
- } /* else server not active */
-#endif /* SERVER_SUPPORT */
- } /* `for' loop */
+ }
+
+#ifdef CLIENT_SUPPORT
+ if (client_active)
+ {
+ /* Unfortunately, client.c doesn't offer a way to close
+ the connection without waiting for responses. The extra
+ network turnaround here is quite unnecessary other than
+ that.... */
+ send_to_server ("noop\012", 0);
+ err += get_responses_and_close ();
+ }
+#endif /* CLIENT_SUPPORT */
+
+ free (update_cmd);
+ if (line != NULL)
+ free (line);
return err;
}
@@ -267,10 +264,10 @@ release_delete (dir)
struct stat st;
ino_t ino;
- (void) stat (".", &st);
+ (void) CVS_STAT (".", &st);
ino = st.st_ino;
- (void) chdir ("..");
- (void) stat (dir, &st);
+ (void) CVS_CHDIR ("..");
+ (void) CVS_STAT (dir, &st);
if (ino != st.st_ino)
{
error (0, 0,
diff --git a/contrib/cvs/src/remove.c b/contrib/cvs/src/remove.c
index 2911bf4..1571250 100644
--- a/contrib/cvs/src/remove.c
+++ b/contrib/cvs/src/remove.c
@@ -17,8 +17,14 @@
#include "cvs.h"
-static int remove_fileproc PROTO((struct file_info *finfo));
-static Dtype remove_dirproc PROTO((char *dir, char *repos, char *update_dir));
+#ifdef CLIENT_SUPPORT
+static int remove_force_fileproc PROTO ((void *callerdat,
+ struct file_info *finfo));
+#endif
+static int remove_fileproc PROTO ((void *callerdat, struct file_info *finfo));
+static Dtype remove_dirproc PROTO ((void *callerdat, char *dir,
+ char *repos, char *update_dir,
+ List *entries));
static int force;
static int local;
@@ -45,7 +51,7 @@ cvsremove (argc, argv)
usage (remove_usage);
optind = 1;
- while ((c = getopt (argc, argv, "flR")) != -1)
+ while ((c = getopt (argc, argv, "+flR")) != -1)
{
switch (c)
{
@@ -71,12 +77,31 @@ cvsremove (argc, argv)
#ifdef CLIENT_SUPPORT
if (client_active) {
+ /* 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,
+ (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL,
+ (void *) NULL, argc, argv, local, W_LOCAL,
+ 0, 0, (char *) NULL, 0);
+ }
+ /* else FIXME should probably act as if the file doesn't exist
+ in doing the following checks. */
+ }
+
start_server ();
ign_setup ();
if (local)
send_arg("-l");
- send_file_names (argc, argv, SEND_EXPAND_WILD);
- send_files (argc, argv, local, 0);
+ send_file_names (argc, argv, 0);
+ /* FIXME: Can't we set SEND_NO_CONTENTS here? Needs investigation. */
+ send_files (argc, argv, local, 0, 0);
send_to_server ("remove\012", 0);
return get_responses_and_close ();
}
@@ -84,8 +109,9 @@ cvsremove (argc, argv)
/* start the recursion processor */
err = start_recursion (remove_fileproc, (FILESDONEPROC) NULL,
- remove_dirproc, (DIRLEAVEPROC) NULL, argc, argv,
- local, W_LOCAL, 0, 1, (char *) NULL, 1, 0);
+ remove_dirproc, (DIRLEAVEPROC) NULL, NULL,
+ argc, argv,
+ local, W_LOCAL, 0, 1, (char *) NULL, 1);
if (removed_files)
error (0, 0, "use '%s commit' to remove %s permanently", program_name,
@@ -101,22 +127,42 @@ cvsremove (argc, argv)
return (err);
}
+#ifdef CLIENT_SUPPORT
+
+/*
+ * This is called via start_recursion if we are running as the client
+ * and the -f option was used. We just physically remove the file.
+ */
+
+/*ARGSUSED*/
+static int
+remove_force_fileproc (callerdat, finfo)
+ void *callerdat;
+ struct file_info *finfo;
+{
+ if (CVS_UNLINK (finfo->file) < 0 && ! existence_error (errno))
+ error (0, errno, "unable to remove %s", finfo->fullname);
+ return 0;
+}
+
+#endif
+
/*
* remove the file, only if it has already been physically removed
*/
/* ARGSUSED */
static int
-remove_fileproc (finfo)
+remove_fileproc (callerdat, finfo)
+ void *callerdat;
struct file_info *finfo;
{
- char fname[PATH_MAX];
Vers_TS *vers;
if (force)
{
if (!noexec)
{
- if (unlink (finfo->file) < 0 && ! existence_error (errno))
+ if ( CVS_UNLINK (finfo->file) < 0 && ! existence_error (errno))
{
error (0, errno, "unable to remove %s", finfo->fullname);
}
@@ -125,8 +171,7 @@ remove_fileproc (finfo)
in doing the following checks. */
}
- vers = Version_TS (finfo->repository, (char *) NULL, (char *) NULL, (char *) NULL,
- finfo->file, 0, 0, finfo->entries, finfo->rcs);
+ vers = Version_TS (finfo, NULL, NULL, NULL, 0, 0);
if (vers->ts_user != NULL)
{
@@ -142,11 +187,17 @@ remove_fileproc (finfo)
}
else if (vers->vn_user[0] == '0' && vers->vn_user[1] == '\0')
{
+ char *fname;
+
/*
* It's a file that has been added, but not commited yet. So,
* remove the ,t file for it and scratch it from the
* entries file. */
Scratch_Entry (finfo->entries, finfo->file);
+ fname = xmalloc (strlen (finfo->file)
+ + sizeof (CVSADM)
+ + sizeof (CVSEXT_LOG)
+ + 10);
(void) sprintf (fname, "%s/%s%s", CVSADM, finfo->file, CVSEXT_LOG);
(void) unlink_file (fname);
if (!quiet)
@@ -156,6 +207,7 @@ remove_fileproc (finfo)
if (server_active)
server_checked_in (finfo->file, finfo->update_dir, finfo->repository);
#endif
+ free (fname);
}
else if (vers->vn_user[0] == '-')
{
@@ -165,7 +217,10 @@ remove_fileproc (finfo)
}
else
{
+ char *fname;
+
/* Re-register it with a negative version number. */
+ fname = xmalloc (strlen (vers->vn_user) + 5);
(void) strcpy (fname, "-");
(void) strcat (fname, vers->vn_user);
Register (finfo->entries, finfo->file, fname, vers->ts_rcs, vers->options,
@@ -178,6 +233,7 @@ remove_fileproc (finfo)
if (server_active)
server_checked_in (finfo->file, finfo->update_dir, finfo->repository);
#endif
+ free (fname);
}
freevers_ts (&vers);
@@ -189,10 +245,12 @@ remove_fileproc (finfo)
*/
/* ARGSUSED */
static Dtype
-remove_dirproc (dir, repos, update_dir)
+remove_dirproc (callerdat, dir, repos, update_dir, entries)
+ void *callerdat;
char *dir;
char *repos;
char *update_dir;
+ List *entries;
{
if (!quiet)
error (0, 0, "Removing %s", update_dir);
diff --git a/contrib/cvs/src/repos.c b/contrib/cvs/src/repos.c
index 7beaaba..2590df5 100644
--- a/contrib/cvs/src/repos.c
+++ b/contrib/cvs/src/repos.c
@@ -7,6 +7,7 @@
*/
#include "cvs.h"
+#include "getline.h"
/* Determine the name of the RCS repository for directory DIR in the
current working directory, or for the current working directory
@@ -23,11 +24,10 @@ Name_Repository (dir, update_dir)
char *update_dir;
{
FILE *fpin;
- char *ret, *xupdate_dir;
- char repos[PATH_MAX];
- char path[PATH_MAX];
- char tmp[PATH_MAX];
- char cvsadm[PATH_MAX];
+ char *xupdate_dir;
+ char *repos = NULL;
+ size_t repos_allocated = 0;
+ char *tmp;
char *cp;
if (update_dir && *update_dir)
@@ -36,48 +36,61 @@ Name_Repository (dir, update_dir)
xupdate_dir = ".";
if (dir != NULL)
- (void) sprintf (cvsadm, "%s/%s", dir, CVSADM);
- else
- (void) strcpy (cvsadm, CVSADM);
-
- /* sanity checks */
- if (!isdir (cvsadm))
- {
- error (0, 0, "in directory %s:", xupdate_dir);
- error (1, 0, "there is no version here; do '%s checkout' first",
- program_name);
- }
-
- if (dir != NULL)
- (void) sprintf (tmp, "%s/%s", dir, CVSADM_ENT);
- else
- (void) strcpy (tmp, CVSADM_ENT);
-
- if (!isreadable (tmp))
{
- error (0, 0, "in directory %s:", xupdate_dir);
- error (1, 0, "*PANIC* administration files missing");
- }
-
- if (dir != NULL)
+ tmp = xmalloc (strlen (dir) + sizeof (CVSADM_REP) + 10);
(void) sprintf (tmp, "%s/%s", dir, CVSADM_REP);
- else
- (void) strcpy (tmp, CVSADM_REP);
-
- if (!isreadable (tmp))
- {
- error (0, 0, "in directory %s:", xupdate_dir);
- error (1, 0, "*PANIC* administration files missing");
}
+ else
+ tmp = xstrdup (CVSADM_REP);
/*
* The assumption here is that the repository is always contained in the
* first line of the "Repository" file.
*/
- fpin = open_file (tmp, "r");
+ fpin = CVS_FOPEN (tmp, "r");
- if (fgets (repos, PATH_MAX, fpin) == NULL)
+ if (fpin == NULL)
{
+ int save_errno = errno;
+ char *cvsadm;
+
+ if (dir != NULL)
+ {
+ cvsadm = xmalloc (strlen (dir) + sizeof (CVSADM) + 10);
+ (void) sprintf (cvsadm, "%s/%s", dir, CVSADM);
+ }
+ else
+ cvsadm = xstrdup (CVSADM);
+
+ if (!isdir (cvsadm))
+ {
+ error (0, 0, "in directory %s:", xupdate_dir);
+ error (1, 0, "there is no version here; do '%s checkout' first",
+ program_name);
+ }
+ free (cvsadm);
+
+ if (existence_error (save_errno))
+ {
+ /* FIXME: This is a very poorly worded error message. It
+ occurs at least in the case where the user manually
+ creates a directory named CVS, so the error message
+ should be more along the lines of "CVS directory found
+ without administrative files; use CVS to create the CVS
+ directory, or rename it to something else if the
+ intention is to store something besides CVS
+ administrative files". */
+ error (0, 0, "in directory %s:", xupdate_dir);
+ error (1, 0, "*PANIC* administration files missing");
+ }
+
+ error (1, save_errno, "cannot open %s", tmp);
+ }
+ free (tmp);
+
+ if (getline (&repos, &repos_allocated, fpin) < 0)
+ {
+ /* FIXME: should be checking for end of file separately. */
error (0, 0, "in directory %s:", xupdate_dir);
error (1, errno, "cannot read %s", CVSADM_REP);
}
@@ -98,30 +111,23 @@ Name_Repository (dir, update_dir)
}
if (! isabsolute(repos))
{
- if (CVSroot == NULL)
+ char *newrepos;
+
+ if (CVSroot_original == NULL)
{
error (0, 0, "in directory %s:", xupdate_dir);
error (0, 0, "must set the CVSROOT environment variable\n");
error (0, 0, "or specify the '-d' option to %s.", program_name);
error (1, 0, "illegal repository setting");
}
- (void) strcpy (path, repos);
- (void) sprintf (repos, "%s/%s", CVSroot, path);
- }
-#ifdef CLIENT_SUPPORT
- if (!client_active && !isdir (repos))
-#else
- if (!isdir (repos))
-#endif
- {
- error (0, 0, "in directory %s:", xupdate_dir);
- error (1, 0, "there is no repository %s", repos);
+ newrepos = xmalloc (strlen (CVSroot_directory) + strlen (repos) + 10);
+ (void) sprintf (newrepos, "%s/%s", CVSroot_directory, repos);
+ free (repos);
+ repos = newrepos;
}
- /* allocate space to return and fill it in */
- strip_path (repos);
- ret = xstrdup (repos);
- return (ret);
+ strip_trailing_slashes (repos);
+ return repos;
}
/*
@@ -137,9 +143,10 @@ Short_Repository (repository)
/* If repository matches CVSroot at the beginning, strip off CVSroot */
/* And skip leading '/' in rep, in case CVSroot ended with '/'. */
- if (strncmp (CVSroot, repository, strlen (CVSroot)) == 0)
+ if (strncmp (CVSroot_directory, repository,
+ strlen (CVSroot_directory)) == 0)
{
- char *rep = repository + strlen (CVSroot);
+ char *rep = repository + strlen (CVSroot_directory);
return (*rep == '/') ? rep+1 : rep;
}
else
diff --git a/contrib/cvs/src/root.c b/contrib/cvs/src/root.c
index 0742cf0..2691032 100644
--- a/contrib/cvs/src/root.c
+++ b/contrib/cvs/src/root.c
@@ -12,6 +12,16 @@
*/
#include "cvs.h"
+#include "getline.h"
+
+/* Printable names for things in the CVSroot_method enum variable.
+ Watch out if the enum is changed in cvs.h! */
+
+char *method_names[] = {
+ "local", "server (rsh)", "pserver", "kserver", "ext"
+};
+
+#ifndef DEBUG
char *
Name_Root(dir, update_dir)
@@ -20,9 +30,10 @@ Name_Root(dir, update_dir)
{
FILE *fpin;
char *ret, *xupdate_dir;
- char root[PATH_MAX];
- char tmp[PATH_MAX];
- char cvsadm[PATH_MAX];
+ char *root = NULL;
+ size_t root_allocated = 0;
+ char *tmp;
+ char *cvsadm;
char *cp;
if (update_dir && *update_dir)
@@ -32,13 +43,15 @@ Name_Root(dir, update_dir)
if (dir != NULL)
{
+ cvsadm = xmalloc (strlen (dir) + sizeof (CVSADM) + 10);
(void) sprintf (cvsadm, "%s/%s", dir, CVSADM);
+ tmp = xmalloc (strlen (dir) + sizeof (CVSADM_ROOT) + 10);
(void) sprintf (tmp, "%s/%s", dir, CVSADM_ROOT);
}
else
{
- (void) strcpy (cvsadm, CVSADM);
- (void) strcpy (tmp, CVSADM_ROOT);
+ cvsadm = xstrdup (CVSADM);
+ tmp = xstrdup (CVSADM_ROOT);
}
/*
@@ -48,17 +61,11 @@ Name_Root(dir, update_dir)
* It is possible that not all repositories will have a CVS/Root
* file. This is ok, but the user will need to specify -d
* /path/name or have the environment variable CVSROOT set in
- * order to continue.
- */
+ * order to continue. */
if ((!isdir (cvsadm)) || (!isreadable (tmp)))
{
- if (CVSroot == NULL)
- {
- error (0, 0, "in directory %s:", xupdate_dir);
- error (0, 0, "must set the CVSROOT environment variable");
- error (0, 0, "or specify the '-d' option to %s.", program_name);
- }
- return (NULL);
+ ret = NULL;
+ goto out;
}
/*
@@ -67,12 +74,15 @@ Name_Root(dir, update_dir)
*/
fpin = open_file (tmp, "r");
- if (fgets (root, PATH_MAX, fpin) == NULL)
+ if (getline (&root, &root_allocated, fpin) < 0)
{
+ /* FIXME: should be checking for end of file separately; errno
+ is not set in that case. */
error (0, 0, "in directory %s:", xupdate_dir);
error (0, errno, "cannot read %s", CVSADM_ROOT);
error (0, 0, "please correct this problem");
- return (NULL);
+ ret = NULL;
+ goto out;
}
(void) fclose (fpin);
if ((cp = strrchr (root, '\n')) != NULL)
@@ -80,22 +90,21 @@ Name_Root(dir, update_dir)
/*
* root now contains a candidate for CVSroot. It must be an
- * absolute pathname
+ * absolute pathname or specify a remote server.
*/
+ if (
#ifdef CLIENT_SUPPORT
- /* It must specify a server via remote CVS or be an absolute pathname. */
- if ((strchr (root, ':') == NULL)
- && ! isabsolute (root))
-#else /* ! CLIENT_SUPPORT */
- if (root[0] != '/')
-#endif /* CLIENT_SUPPORT */
+ (strchr (root, ':') == NULL) &&
+#endif
+ ! isabsolute (root))
{
error (0, 0, "in directory %s:", xupdate_dir);
error (0, 0,
"ignoring %s because it does not contain an absolute pathname.",
CVSADM_ROOT);
- return (NULL);
+ ret = NULL;
+ goto out;
}
#ifdef CLIENT_SUPPORT
@@ -108,12 +117,18 @@ Name_Root(dir, update_dir)
error (0, 0,
"ignoring %s because it specifies a non-existent repository %s",
CVSADM_ROOT, root);
- return (NULL);
+ ret = NULL;
+ goto out;
}
/* allocate space to return and fill it in */
- strip_path (root);
+ strip_trailing_slashes (root);
ret = xstrdup (root);
+ out:
+ free (cvsadm);
+ free (tmp);
+ if (root != NULL)
+ free (root);
return (ret);
}
@@ -130,9 +145,9 @@ same_directories (dir1, dir2)
struct stat sb2;
int ret;
- if (stat (dir1, &sb1) < 0)
+ if ( CVS_STAT (dir1, &sb1) < 0)
return (0);
- if (stat (dir2, &sb2) < 0)
+ if ( CVS_STAT (dir2, &sb2) < 0)
return (0);
ret = 0;
@@ -155,7 +170,7 @@ Create_Root (dir, rootdir)
char *rootdir;
{
FILE *fout;
- char tmp[PATH_MAX];
+ char *tmp;
if (noexec)
return;
@@ -165,13 +180,294 @@ Create_Root (dir, rootdir)
if (rootdir != NULL)
{
if (dir != NULL)
+ {
+ tmp = xmalloc (strlen (dir) + sizeof (CVSADM_ROOT) + 10);
(void) sprintf (tmp, "%s/%s", dir, CVSADM_ROOT);
+ }
else
- (void) strcpy (tmp, CVSADM_ROOT);
+ tmp = xstrdup (CVSADM_ROOT);
+
fout = open_file (tmp, "w+");
if (fprintf (fout, "%s\n", rootdir) < 0)
error (1, errno, "write to %s failed", tmp);
if (fclose (fout) == EOF)
error (1, errno, "cannot close %s", tmp);
+ free (tmp);
+ }
+}
+
+#endif /* ! DEBUG */
+
+
+/* Parse a CVSROOT variable into its constituent parts -- method,
+ * username, hostname, directory. The prototypical CVSROOT variable
+ * looks like:
+ *
+ * :method:user@host:path
+ *
+ * Some methods may omit fields; local, for example, doesn't need user
+ * and host.
+ *
+ * Returns zero on success, non-zero on failure. */
+
+char *CVSroot_original = NULL; /* the CVSroot that was passed in */
+int client_active; /* nonzero if we are doing remote access */
+CVSmethod CVSroot_method; /* one of the enum values defined in cvs.h */
+char *CVSroot_username; /* the username or NULL if method == local */
+char *CVSroot_hostname; /* the hostname or NULL if method == local */
+char *CVSroot_directory; /* the directory name */
+
+#ifdef AUTH_SERVER_SUPPORT
+/* Die if CVSroot_directory and Pserver_Repos don't match. */
+static void
+check_root_consistent ()
+{
+ /* FIXME: Should be using a deferred error, as the rest of
+ serve_root does. As it is now the call to error could conceivably
+ cause deadlock, as noted in server_cleanup. Best solution would
+ presumably be to write some code so that error() automatically
+ defers the error in those cases where that is needed. */
+ /* FIXME? Possible that the wording should be more clear (e.g.
+ Root says "%s" but pserver protocol says "%s"
+ or something which would aid people who are writing implementations
+ of the client side of the CVS protocol. I don't see any security
+ problem with revealing that information. */
+ if ((Pserver_Repos != NULL) && (CVSroot_directory != NULL))
+ if (strcmp (Pserver_Repos, CVSroot_directory) != 0)
+ error (1, 0, "repository mismatch: \"%s\" vs \"%s\"",
+ Pserver_Repos, CVSroot_directory);
+}
+
+#endif /* AUTH_SERVER_SUPPORT */
+
+
+int
+parse_cvsroot (CVSroot)
+ char *CVSroot;
+{
+ static int cvsroot_parsed = 0;
+ char *cvsroot_copy, *p;
+
+ /* Don't go through the trouble twice. */
+ if (cvsroot_parsed)
+ {
+ error (0, 0, "WARNING (parse_cvsroot): someone called me twice!\n");
+ return 0;
+ }
+
+ CVSroot_original = xstrdup (CVSroot);
+ cvsroot_copy = xstrdup (CVSroot);
+
+ if ((*cvsroot_copy == ':'))
+ {
+ char *method = ++cvsroot_copy;
+
+ /* Access method specified, as in
+ * "cvs -d :pserver:user@host:/path",
+ * "cvs -d :local:e:\path", or
+ * "cvs -d :kserver:user@host:/path".
+ * We need to get past that part of CVSroot before parsing the
+ * rest of it.
+ */
+
+ if (! (p = strchr (method, ':')))
+ {
+ error (0, 0, "bad CVSroot: %s", CVSroot);
+ return 1;
+ }
+ *p = '\0';
+ cvsroot_copy = ++p;
+
+ /* Now we have an access method -- see if it's valid. */
+
+ if (strcmp (method, "local") == 0)
+ CVSroot_method = local_method;
+ else if (strcmp (method, "pserver") == 0)
+ CVSroot_method = pserver_method;
+ else if (strcmp (method, "kserver") == 0)
+ CVSroot_method = kserver_method;
+ else if (strcmp (method, "server") == 0)
+ CVSroot_method = server_method;
+ else if (strcmp (method, "ext") == 0)
+ CVSroot_method = ext_method;
+ else
+ {
+ error (0, 0, "unknown method in CVSroot: %s", CVSroot);
+ return 1;
+ }
+ }
+ else
+ {
+ /* If the method isn't specified, assume
+ SERVER_METHOD/EXT_METHOD if the string contains a colon or
+ LOCAL_METHOD otherwise. */
+
+ CVSroot_method = ((strchr (cvsroot_copy, ':'))
+#ifdef RSH_NOT_TRANSPARENT
+ ? server_method
+#else
+ ? ext_method
+#endif
+ : local_method);
+ }
+
+ client_active = (CVSroot_method != local_method);
+
+ /* Check for username/hostname if we're not LOCAL_METHOD. */
+
+ CVSroot_username = NULL;
+ CVSroot_hostname = NULL;
+
+ if (CVSroot_method != local_method)
+ {
+ /* Check to see if there is a username in the string. */
+
+ if ((p = strchr (cvsroot_copy, '@')))
+ {
+ CVSroot_username = cvsroot_copy;
+ *p = '\0';
+ cvsroot_copy = ++p;
+ if (*CVSroot_username == '\0')
+ CVSroot_username = NULL;
+ }
+
+ if ((p = strchr (cvsroot_copy, ':')))
+ {
+ CVSroot_hostname = cvsroot_copy;
+ *p = '\0';
+ cvsroot_copy = ++p;
+
+ if (*CVSroot_hostname == '\0')
+ CVSroot_hostname = NULL;
+ }
+ }
+
+ CVSroot_directory = cvsroot_copy;
+#ifdef AUTH_SERVER_SUPPORT
+ check_root_consistent ();
+#endif /* AUTH_SERVER_SUPPORT */
+
+#if ! defined (CLIENT_SUPPORT) && ! defined (DEBUG)
+ if (CVSroot_method != local_method)
+ {
+ error (0, 0, "Your CVSROOT is set for a remote access method");
+ error (0, 0, "but your CVS executable doesn't support it");
+ error (0, 0, "(%s)", CVSroot);
+ return 1;
+ }
+#endif
+
+ /* Do various sanity checks. */
+
+ if (CVSroot_username && ! CVSroot_hostname)
+ {
+ error (0, 0, "missing hostname in CVSROOT: %s", CVSroot);
+ return 1;
+ }
+
+ switch (CVSroot_method)
+ {
+ case local_method:
+ if (CVSroot_username || CVSroot_hostname)
+ {
+ error (0, 0, "can't specify hostname and username in CVSROOT");
+ error (0, 0, "when using local access method");
+ error (0, 0, "(%s)", CVSroot);
+ return 1;
+ }
+ /* cvs.texinfo has always told people that CVSROOT must be an
+ absolute pathname. Furthermore, attempts to use a relative
+ pathname produced various errors (I couldn't get it to work),
+ so there would seem to be little risk in making this a fatal
+ error. */
+ if (!isabsolute (CVSroot_directory))
+ error (1, 0, "CVSROOT %s must be an absolute pathname",
+ CVSroot_directory);
+ break;
+ case kserver_method:
+#ifndef HAVE_KERBEROS
+ error (0, 0, "Your CVSROOT is set for a kerberos access method");
+ error (0, 0, "but your CVS executable doesn't support it");
+ error (0, 0, "(%s)", CVSroot);
+ return 1;
+#endif
+ case server_method:
+ case ext_method:
+ case pserver_method:
+ if (! CVSroot_hostname)
+ {
+ error (0, 0, "didn't specify hostname in CVSROOT: %s", CVSroot);
+ return 1;
+ }
+ break;
}
+
+ if (*CVSroot_directory == '\0')
+ {
+ error (0, 0, "missing directory in CVSROOT: %s", CVSroot);
+ return 1;
+ }
+
+ /* Hooray! We finally parsed it! */
+ return 0;
+}
+
+
+/* Set up the global CVSroot* variables as if we're using the local
+ repository DIR. */
+
+void
+set_local_cvsroot (dir)
+ char *dir;
+{
+ CVSroot_original = xstrdup (dir);
+ CVSroot_method = local_method;
+ CVSroot_directory = CVSroot_original;
+#ifdef AUTH_SERVER_SUPPORT
+ check_root_consistent ();
+#endif /* AUTH_SERVER_SUPPORT */
+ CVSroot_username = NULL;
+ CVSroot_hostname = NULL;
+ client_active = 0;
+}
+
+
+#ifdef DEBUG
+/* This is for testing the parsing function. */
+
+#include <stdio.h>
+
+char *CVSroot;
+char *program_name = "testing";
+char *command_name = "parse_cvsroot"; /* XXX is this used??? */
+
+void
+main (argc, argv)
+ int argc;
+ char *argv[];
+{
+ program_name = argv[0];
+
+ if (argc != 2)
+ {
+ fprintf (stderr, "Usage: %s <CVSROOT>\n", program_name);
+ exit (2);
+ }
+
+ if (parse_cvsroot (argv[1]))
+ {
+ fprintf (stderr, "%s: Parsing failed.", program_name);
+ exit (1);
+ }
+ printf ("CVSroot: %s\n", argv[1]);
+ printf ("CVSroot_method: %s\n", method_names[CVSroot_method]);
+ printf ("CVSroot_username: %s\n",
+ CVSroot_username ? CVSroot_username : "NULL");
+ printf ("CVSroot_hostname: %s\n",
+ CVSroot_hostname ? CVSroot_hostname : "NULL");
+ printf ("CVSroot_directory: %s\n", CVSroot_directory);
+
+ exit (0);
+ /* NOTREACHED */
}
+#endif
diff --git a/contrib/cvs/src/rtag.c b/contrib/cvs/src/rtag.c
index 8609647..1e2017b 100644
--- a/contrib/cvs/src/rtag.c
+++ b/contrib/cvs/src/rtag.c
@@ -13,15 +13,22 @@
#include "cvs.h"
-static int check_fileproc PROTO((struct file_info *finfo));
-static int check_filesdoneproc PROTO((int err, char *repos, char *update_dir));
+static int check_fileproc PROTO ((void *callerdat, struct file_info *finfo));
+static int check_filesdoneproc PROTO ((void *callerdat, int err,
+ char *repos, char *update_dir,
+ List *entries));
static int pretag_proc PROTO((char *repository, char *filter));
static void masterlist_delproc PROTO((Node *p));
static void tag_delproc PROTO((Node *p));
static int pretag_list_proc PROTO((Node *p, void *closure));
-static Dtype rtag_dirproc PROTO((char *dir, char *repos, char *update_dir));
-static int rtag_fileproc PROTO((struct file_info *finfo));
+static Dtype rtag_dirproc PROTO ((void *callerdat, char *dir,
+ char *repos, char *update_dir,
+ List *entries));
+static int rtag_fileproc PROTO ((void *callerdat, struct file_info *finfo));
+static int rtag_filesdoneproc PROTO ((void *callerdat, int err,
+ char *repos, char *update_dir,
+ List *entries));
static int rtag_proc PROTO((int *pargc, char **argv, char *xwhere,
char *mwhere, char *mfile, int shorten,
int local_specified, char *mname, char *msg));
@@ -85,7 +92,7 @@ rtag (argc, argv)
usage (rtag_usage);
optind = 1;
- while ((c = getopt (argc, argv, "FanfQqlRdbr:D:")) != -1)
+ while ((c = getopt (argc, argv, "+FanfQqlRdbr:D:")) != -1)
{
switch (c)
{
@@ -157,9 +164,11 @@ rtag (argc, argv)
{
/* We're the client side. Fire up the remote server. */
start_server ();
-
+
ign_setup ();
+ if (!force_tag_match)
+ send_arg ("-f");
if (local)
send_arg("-l");
if (delete_flag)
@@ -168,7 +177,7 @@ rtag (argc, argv)
send_arg("-b");
if (force_tag_move)
send_arg("-F");
- if (run_module_prog)
+ if (!run_module_prog)
send_arg("-n");
if (attic_too)
send_arg("-a");
@@ -222,19 +231,25 @@ rtag_proc (pargc, argv, xwhere, mwhere, mfile, shorten, local_specified,
char *mname;
char *msg;
{
+ /* Begin section which is identical to patch_proc--should this
+ be abstracted out somehow? */
int err = 0;
int which;
- char repository[PATH_MAX];
- char where[PATH_MAX];
+ char *repository;
+ char *where;
- (void) sprintf (repository, "%s/%s", CVSroot, argv[0]);
+ repository = xmalloc (strlen (CVSroot_directory) + strlen (argv[0])
+ + (mfile == NULL ? 0 : strlen (mfile)) + 30);
+ (void) sprintf (repository, "%s/%s", CVSroot_directory, argv[0]);
+ where = xmalloc (strlen (argv[0]) + (mfile == NULL ? 0 : strlen (mfile))
+ + 10);
(void) strcpy (where, argv[0]);
/* if mfile isn't null, we need to set up to do only part of the module */
if (mfile != NULL)
{
char *cp;
- char path[PATH_MAX];
+ char *path;
/* if the portion of the module is a path, put the dir part on repos */
if ((cp = strrchr (mfile, '/')) != NULL)
@@ -248,6 +263,7 @@ rtag_proc (pargc, argv, xwhere, mwhere, mfile, shorten, local_specified,
}
/* take care of the rest */
+ path = xmalloc (strlen (repository) + strlen (mfile) + 5);
(void) sprintf (path, "%s/%s", repository, mfile);
if (isdir (path))
{
@@ -266,14 +282,18 @@ rtag_proc (pargc, argv, xwhere, mwhere, mfile, shorten, local_specified,
argv[1] = xstrdup (mfile);
(*pargc) = 2;
}
+ free (path);
}
- /* chdir to the starting directory */
- if (chdir (repository) < 0)
+ /* cd to the starting repository */
+ if ( CVS_CHDIR (repository) < 0)
{
error (0, errno, "cannot chdir to %s", repository);
+ free (repository);
return (1);
}
+ free (repository);
+ /* End section which is identical to patch_proc. */
if (delete_flag || attic_too || (force_tag_match && numtag))
which = W_REPOS | W_ATTIC;
@@ -291,9 +311,9 @@ rtag_proc (pargc, argv, xwhere, mwhere, mfile, shorten, local_specified,
mtlist = getlist();
err = start_recursion (check_fileproc, check_filesdoneproc,
- (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL,
+ (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL, NULL,
*pargc - 1, argv + 1, local, which, 0, 1,
- where, 1, 1);
+ where, 1);
if (err)
{
@@ -301,10 +321,11 @@ rtag_proc (pargc, argv, xwhere, mwhere, mfile, shorten, local_specified,
}
/* start the recursion processor */
- err = start_recursion (rtag_fileproc, (FILESDONEPROC) NULL, rtag_dirproc,
- (DIRLEAVEPROC) NULL, *pargc - 1, argv + 1, local,
- which, 0, 1, where, 1, 1);
-
+ err = start_recursion (rtag_fileproc, rtag_filesdoneproc, rtag_dirproc,
+ (DIRLEAVEPROC) NULL, NULL,
+ *pargc - 1, argv + 1, local,
+ which, 0, 0, where, 1);
+ free (where);
dellist(&mtlist);
return (err);
@@ -314,7 +335,8 @@ rtag_proc (pargc, argv, xwhere, mwhere, mfile, shorten, local_specified,
/* All we do here is add it to our list */
static int
-check_fileproc (finfo)
+check_fileproc (callerdat, finfo)
+ void *callerdat;
struct file_info *finfo;
{
char *xdir;
@@ -349,15 +371,16 @@ check_fileproc (finfo)
p->key = xstrdup (finfo->file);
p->type = UPDATE;
p->delproc = tag_delproc;
- vers = Version_TS (finfo->repository, (char *) NULL, (char *) NULL,
- (char *) NULL, finfo->file, 0, 0, finfo->entries, finfo->rcs);
- p->data = RCS_getversion(vers->srcfile, numtag, date, force_tag_match, 0);
+ vers = Version_TS (finfo, NULL, NULL, NULL, 0, 0);
+ p->data = RCS_getversion(vers->srcfile, numtag, date, force_tag_match,
+ (int *) NULL);
if (p->data != NULL)
{
int addit = 1;
char *oversion;
- oversion = RCS_getversion (vers->srcfile, symtag, (char *) NULL, 1, 0);
+ oversion = RCS_getversion (vers->srcfile, symtag, (char *) NULL, 1,
+ (int *) NULL);
if (oversion == NULL)
{
if (delete_flag)
@@ -389,10 +412,12 @@ check_fileproc (finfo)
}
static int
-check_filesdoneproc(err, repos, update_dir)
+check_filesdoneproc (callerdat, err, repos, update_dir, entries)
+ void *callerdat;
int err;
char *repos;
char *update_dir;
+ List *entries;
{
int n;
Node *p;
@@ -496,13 +521,26 @@ pretag_list_proc(p, closure)
*/
/* ARGSUSED */
static int
-rtag_fileproc (finfo)
+rtag_fileproc (callerdat, finfo)
+ void *callerdat;
struct file_info *finfo;
{
RCSNode *rcsfile;
char *version, *rev;
int retcode = 0;
+ /* Lock the directory if it is not already locked. We might be
+ able to rely on rtag_dirproc for this. */
+
+ /* It would be nice to provide consistency with respect to
+ commits; however CVS lacks the infrastructure to do that (see
+ Concurrency in cvs.texinfo and comment in do_recursion). We
+ can and will prevent simultaneous tag operations from
+ interfering with each other, by write locking each directory as
+ we enter it, and unlocking it as we leave it. */
+
+ lock_dir_for_write (finfo->repository);
+
/* find the parsed RCS data */
if ((rcsfile = finfo->rcs) == NULL)
return (1);
@@ -527,7 +565,8 @@ rtag_fileproc (finfo)
return (rtag_delete (rcsfile));
}
- version = RCS_getversion (rcsfile, numtag, date, force_tag_match, 0);
+ version = RCS_getversion (rcsfile, numtag, date, force_tag_match,
+ (int *) NULL);
if (version == NULL)
{
/* If -a specified, clean up any old tags */
@@ -554,7 +593,7 @@ rtag_fileproc (finfo)
* the branch. Use a symbolic tag for that.
*/
rev = branch_mode ? RCS_magicrev (rcsfile, version) : numtag;
- retcode = RCS_settag(rcsfile->path, symtag, numtag);
+ retcode = RCS_settag(rcsfile, symtag, numtag);
}
else
{
@@ -570,7 +609,8 @@ rtag_fileproc (finfo)
* typical tagging operation.
*/
rev = branch_mode ? RCS_magicrev (rcsfile, version) : version;
- oversion = RCS_getversion (rcsfile, symtag, (char *) NULL, 1, 0);
+ oversion = RCS_getversion (rcsfile, symtag, (char *) NULL, 1,
+ (int *) NULL);
if (oversion != NULL)
{
int isbranch = RCS_isbranch (finfo->rcs, symtag);
@@ -602,7 +642,7 @@ rtag_fileproc (finfo)
}
free (oversion);
}
- retcode = RCS_settag(rcsfile->path, symtag, rev);
+ retcode = RCS_settag(rcsfile, symtag, rev);
}
if (retcode != 0)
@@ -641,18 +681,20 @@ rtag_delete (rcsfile)
if (numtag)
{
- version = RCS_getversion (rcsfile, numtag, (char *) NULL, 1, 0);
+ version = RCS_getversion (rcsfile, numtag, (char *) NULL, 1,
+ (int *) NULL);
if (version == NULL)
return (0);
free (version);
}
- version = RCS_getversion (rcsfile, symtag, (char *) NULL, 1, 0);
+ version = RCS_getversion (rcsfile, symtag, (char *) NULL, 1,
+ (int *) NULL);
if (version == NULL)
return (0);
free (version);
- if ((retcode = RCS_deltag(rcsfile->path, symtag, 1)) != 0)
+ if ((retcode = RCS_deltag(rcsfile, symtag, 1)) != 0)
{
if (!quiet)
error (0, retcode == -1 ? errno : 0,
@@ -663,15 +705,32 @@ rtag_delete (rcsfile)
return (0);
}
+/* Clear any lock we may hold on the current directory. */
+
+static int
+rtag_filesdoneproc (callerdat, err, repos, update_dir, entries)
+ void *callerdat;
+ int err;
+ char *repos;
+ char *update_dir;
+ List *entries;
+{
+ Lock_Cleanup ();
+
+ return (err);
+}
+
/*
* Print a warm fuzzy message
*/
/* ARGSUSED */
static Dtype
-rtag_dirproc (dir, repos, update_dir)
+rtag_dirproc (callerdat, dir, repos, update_dir, entries)
+ void *callerdat;
char *dir;
char *repos;
char *update_dir;
+ List *entries;
{
if (!quiet)
error (0, 0, "%s %s", delete_flag ? "Untagging" : "Tagging", update_dir);
diff --git a/contrib/cvs/src/run.c b/contrib/cvs/src/run.c
index 036821e..74e418d 100644
--- a/contrib/cvs/src/run.c
+++ b/contrib/cvs/src/run.c
@@ -10,11 +10,7 @@
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ GNU General Public License for more details. */
#include "cvs.h"
@@ -32,10 +28,11 @@
#endif
static void run_add_arg PROTO((const char *s));
-static void run_init_prog PROTO((void));
extern char *strtok ();
+extern int vasprintf ();
+
/*
* To exec a program under CVS, first call run_setup() to setup any initial
* arguments. The options to run_setup are essentially like printf(). The
@@ -49,7 +46,6 @@ extern char *strtok ();
* The execvp() syscall will be used, so that the PATH is searched correctly.
* File redirections can be performed in the call to run_exec().
*/
-static char *run_prog;
static char **run_argv;
static int run_argc;
static int run_argc_allocated;
@@ -70,8 +66,7 @@ run_setup (fmt, va_alist)
#endif
char *cp;
int i;
-
- run_init_prog ();
+ char *run_prog;
/* clean out any malloc'ed values from run_argv */
for (i = 0; i < run_argc; i++)
@@ -87,15 +82,18 @@ run_setup (fmt, va_alist)
/* process the varargs into run_prog */
#ifdef HAVE_VPRINTF
VA_START (args, fmt);
- (void) vsprintf (run_prog, fmt, args);
+ (void) vasprintf (&run_prog, fmt, args);
va_end (args);
#else
- (void) sprintf (run_prog, fmt, a1, a2, a3, a4, a5, a6, a7, a8);
+ you lose
#endif
+ if (run_prog == NULL)
+ error (1, 0, "out of memory");
/* put each word into run_argv, allocating it as we go */
for (cp = strtok (run_prog, " \t"); cp; cp = strtok ((char *) NULL, " \t"))
run_add_arg (cp);
+ free (run_prog);
}
void
@@ -119,20 +117,22 @@ run_args (fmt, va_alist)
#ifdef HAVE_VPRINTF
va_list args;
#endif
-
- run_init_prog ();
+ char *run_prog;
/* process the varargs into run_prog */
#ifdef HAVE_VPRINTF
VA_START (args, fmt);
- (void) vsprintf (run_prog, fmt, args);
+ (void) vasprintf (&run_prog, fmt, args);
va_end (args);
#else
- (void) sprintf (run_prog, fmt, a1, a2, a3, a4, a5, a6, a7, a8);
+ you lose
#endif
+ if (run_prog == NULL)
+ error (1, 0, "out of memory");
/* and add the (single) argument to the run_argv list */
run_add_arg (run_prog);
+ free (run_prog);
}
static void
@@ -153,14 +153,6 @@ run_add_arg (s)
run_argv[run_argc] = (char *) 0; /* not post-incremented on purpose! */
}
-static void
-run_init_prog ()
-{
- /* make sure that run_prog is allocated once */
- if (run_prog == (char *) 0)
- run_prog = xmalloc (10 * 1024); /* 10K of args for _setup and _arg */
-}
-
int
run_exec (stin, stout, sterr, flags)
char *stin;
@@ -192,12 +184,11 @@ run_exec (stin, stout, sterr, flags)
if (trace)
{
#ifdef SERVER_SUPPORT
- (void) fprintf (stderr, "%c-> system(", (server_active) ? 'S' : ' ');
-#else
- (void) fprintf (stderr, "-> system(");
+ cvs_outerr (server_active ? "S" : " ", 1);
#endif
+ cvs_outerr ("-> system(", 0);
run_print (stderr);
- (void) fprintf (stderr, ")\n");
+ cvs_outerr (")\n", 0);
}
if (noexec && (flags & RUN_REALLY) == 0)
return (0);
@@ -244,7 +235,14 @@ run_exec (stin, stout, sterr, flags)
fflush (stdout);
fflush (stderr);
- /* The output files, if any, are now created. Do the fork and dups */
+ /* The output files, if any, are now created. Do the fork and dups.
+
+ We use vfork not so much for the sake of unices without
+ copy-on-write (such systems are rare these days), but for the
+ sake of systems without an MMU, which therefore can't do
+ copy-on-write (e.g. Amiga). The other solution is spawn (see
+ windows-NT/run.c). */
+
#ifdef HAVE_VFORK
pid = vfork ();
#else
@@ -393,12 +391,22 @@ run_print (fp)
FILE *fp;
{
int i;
+ void (*outfn) PROTO ((const char *, size_t));
+
+ if (fp == stderr)
+ outfn = cvs_outerr;
+ else if (fp == stdout)
+ outfn = cvs_output;
+ else
+ error (1, 0, "internal error: bad argument to run_print");
for (i = 0; i < run_argc; i++)
{
- (void) fprintf (fp, "'%s'", run_argv[i]);
+ (*outfn) ("'", 1);
+ (*outfn) (run_argv[i], 0);
+ (*outfn) ("'", 1);
if (i != run_argc - 1)
- (void) fprintf (fp, " ");
+ (*outfn) (" ", 1);
}
}
@@ -437,7 +445,11 @@ piped_child (command, tofdp, fromfdp)
if (pipe (from_child_pipe) < 0)
error (1, errno, "cannot create pipe");
+#ifdef HAVE_VFORK
+ pid = vfork ();
+#else
pid = fork ();
+#endif
if (pid < 0)
error (1, errno, "cannot fork");
if (pid == 0)
@@ -494,7 +506,11 @@ filter_stream_through_program (oldfd, dir, prog, pidp)
if (pipe (p))
error (1, errno, "cannot create pipe");
+#ifdef HAVE_VFORK
+ newpid = vfork ();
+#else
newpid = fork ();
+#endif
if (pidp)
*pidp = newpid;
switch (newpid)
diff --git a/contrib/cvs/src/sanity.sh b/contrib/cvs/src/sanity.sh
index 4f80f90..38e32b4 100755
--- a/contrib/cvs/src/sanity.sh
+++ b/contrib/cvs/src/sanity.sh
@@ -13,10 +13,19 @@
# See TODO list at end of file.
+# You can't run CVS as root; print a nice error message here instead
+# of somewhere later, after making a mess.
+case "`whoami`" in
+ "root" )
+ echo "sanity.sh: test suite does not work correctly when run as root" >&2
+ exit 1
+ ;;
+esac
+
# required to make this script work properly.
unset CVSREAD
-TESTDIR=/tmp/cvs-sanity
+TESTDIR=${TESTDIR:-/tmp/cvs-sanity}
# "debugger"
#set -x
@@ -26,6 +35,12 @@ echo 'This test should produce no other output than this line, and a final "OK".
if test x"$1" = x"-r"; then
shift
remote=yes
+ # If we're going to do remote testing, make sure 'rsh' works first.
+ host="`hostname`"
+ if test "x`${CVS_RSH-rsh} $host -n 'echo hi'`" != "xhi"; then
+ echo "ERROR: cannot test remote CVS, because \`rsh $host' fails." >&2
+ exit 1
+ fi
else
remote=no
fi
@@ -61,6 +76,15 @@ shift
# special characters we are probably in big trouble.
PROG=`basename ${testcvs}`
+# Regexp to match an author name. I'm not really sure what characters
+# should be here. a-zA-Z obviously. People complained when 0-9 were
+# not allowed in usernames. Other than that I'm not sure.
+username="[a-zA-Z0-9][a-zA-Z0-9]*"
+
+# Regexp to match the name of a temporary file (from cvs_temp_name).
+# This appears in certain diff output.
+tempname="[-a-zA-Z0-9/.%_]*"
+
# FIXME: try things (what things? checkins?) without -m.
#
# Some of these tests are written to expect -Q. But testing with
@@ -79,18 +103,79 @@ if test -f check.log; then
mv check.log check.plog
fi
+GEXPRLOCS="`echo $PATH | sed 's/:/ /g'` /usr/local/bin /usr/contrib/bin /usr/gnu/bin /local/bin /local/gnu/bin /gun/bin"
+
+EXPR=expr
+
+# Cause NextStep 3.3 users to lose in a more graceful fashion.
+if $EXPR 'abc
+def' : 'abc
+def' >/dev/null; then
+ : good, it works
+else
+ for path in $GEXPRLOCS ; do
+ if test -x $path/gexpr ; then
+ if test "X`$path/gexpr --version`" != "X--version" ; then
+ EXPR=$path/gexpr
+ break
+ fi
+ fi
+ if test -x $path/expr ; then
+ if test "X`$path/expr --version`" != "X--version" ; then
+ EXPR=$path/expr
+ break
+ fi
+ fi
+ done
+ if test -z "$EXPR" ; then
+ echo 'Running these tests requires an "expr" program that can handle'
+ echo 'multi-line patterns. Make sure that such an expr (GNU, or many but'
+ echo 'not all vendor-supplied versions) is in your path.'
+ exit 1
+ fi
+fi
+
+# Warn SunOS, SysVr3.2, etc., users that they may be partially losing
+# if we can't find a GNU expr to ease their troubles...
+if $EXPR 'a
+b' : 'a
+c' >/dev/null; then
+ for path in $GEXPRLOCS ; do
+ if test -x $path/gexpr ; then
+ if test "X`$path/gexpr --version`" != "X--version" ; then
+ EXPR=$path/gexpr
+ break
+ fi
+ fi
+ if test -x $path/expr ; then
+ if test "X`$path/expr --version`" != "X--version" ; then
+ EXPR=$path/expr
+ break
+ fi
+ fi
+ done
+ if test -z "$EXPR" ; then
+ echo 'Warning: you are using a version of expr which does not correctly'
+ echo 'match multi-line patterns. Some tests may spuriously pass.'
+ echo 'You may wish to make sure GNU expr is in your path.'
+ EXPR=expr
+ fi
+else
+ : good, it works
+fi
+
# That we should have to do this is total bogosity, but GNU expr
-# version 1.9.4 uses the emacs definition of "$" instead of the unix
+# version 1.9.4-1.12 uses the emacs definition of "$" instead of the unix
# (e.g. SunOS 4.1.3 expr) one. Rumor has it this will be fixed in the
# next release of GNU expr after 1.12 (but we still have to cater to the old
# ones for some time because they are in many linux distributions).
ENDANCHOR="$"
-if expr 'abc
+if $EXPR 'abc
def' : 'abc$' >/dev/null; then
ENDANCHOR='\'\'
fi
-# Work around another GNU expr (version 1.10) bug/incompatibility.
+# Work around another GNU expr (version 1.10-1.12) bug/incompatibility.
# "." doesn't appear to match a newline (it does with SunOS 4.1.3 expr).
# Note that the workaround is not a complete equivalent of .* because
# the first parenthesized expression in the regexp must match something
@@ -99,7 +184,7 @@ fi
# next release of GNU expr after 1.12 (but we still have to cater to the old
# ones for some time because they are in many linux distributions).
DOTSTAR='.*'
-if expr 'abc
+if $EXPR 'abc
def' : "a${DOTSTAR}f" >/dev/null; then
: good, it works
else
@@ -115,7 +200,7 @@ fi
# next release of GNU expr after 1.12 (but we still have to cater to the old
# ones for some time because they are in many linux distributions).
PLUS='+'
-if expr 'a +b' : "a ${PLUS}b" >/dev/null; then
+if $EXPR 'a +b' : "a ${PLUS}b" >/dev/null; then
: good, it works
else
PLUS='\+'
@@ -123,35 +208,12 @@ fi
# Likewise, for ?
QUESTION='?'
-if expr 'a?b' : "a${QUESTION}b" >/dev/null; then
+if $EXPR 'a?b' : "a${QUESTION}b" >/dev/null; then
: good, it works
else
QUESTION='\?'
fi
-# Cause NextStep 3.3 users to lose in a more graceful fashion.
-if expr 'abc
-def' : 'abc
-def' >/dev/null; then
- : good, it works
-else
- echo 'Running these tests requires an "expr" program that can handle'
- echo 'multi-line patterns. Make sure that such an expr (GNU, or many but'
- echo 'not all vendor-supplied versions) is in your path.'
- exit 1
-fi
-
-# Warn SunOS, SysVr3.2, etc., users that they may be partially losing
-if expr 'a
-b' : 'a
-c' >/dev/null; then
- echo 'Warning: you are using a version of expr which does not correctly'
- echo 'match multi-line patterns. Some tests may spuriously pass.'
- echo 'You may wish to make sure GNU expr is in your path.'
-else
- : good, it works
-fi
-
pass ()
{
echo "PASS: $1" >>${LOGFILE}
@@ -174,25 +236,122 @@ dotest_internal ()
if test -s ${TESTDIR}/dotest.tmp; then
echo "** expected: " >>${LOGFILE}
echo "$3" >>${LOGFILE}
+ echo "$3" > ${TESTDIR}/dotest.exp
+ rm -f ${TESTDIR}/dotest.ex2
echo "** got: " >>${LOGFILE}
cat ${TESTDIR}/dotest.tmp >>${LOGFILE}
fail "$1"
else
- cat ${TESTDIR}/dotest.tmp >>${LOGFILE}
pass "$1"
fi
else
- if expr "`cat ${TESTDIR}/dotest.tmp`" : \
+ if $EXPR "`cat ${TESTDIR}/dotest.tmp`" : \
"$3"${ENDANCHOR} >/dev/null; then
+ # See below about writing this to the logfile.
cat ${TESTDIR}/dotest.tmp >>${LOGFILE}
pass "$1"
else
if test x"$4" != x; then
- if expr "`cat ${TESTDIR}/dotest.tmp`" : \
+ if $EXPR "`cat ${TESTDIR}/dotest.tmp`" : \
"$4"${ENDANCHOR} >/dev/null; then
+ # Why, I hear you ask, do we write this to the logfile
+ # even when the test passes? The reason is that the test
+ # may give us the regexp which we were supposed to match,
+ # but sometimes it may be useful to look at the exact
+ # text which was output. For example, suppose one wants
+ # to grep for a particular warning, and make _sure_ that
+ # CVS never hits it (even in cases where the tests might
+ # match it with .*). Or suppose one wants to see the exact
+ # date format output in a certain case (where the test will
+ # surely use a somewhat non-specific pattern).
+ cat ${TESTDIR}/dotest.tmp >>${LOGFILE}
+ pass "$1"
+ else
+ echo "** expected: " >>${LOGFILE}
+ echo "$3" >>${LOGFILE}
+ echo "$3" > ${TESTDIR}/dotest.ex1
+ echo "** or: " >>${LOGFILE}
+ echo "$4" >>${LOGFILE}
+ echo "$4" > ${TESTDIR}/dotest.ex2
+ echo "** got: " >>${LOGFILE}
cat ${TESTDIR}/dotest.tmp >>${LOGFILE}
+ fail "$1"
+ fi
+ else
+ echo "** expected: " >>${LOGFILE}
+ echo "$3" >>${LOGFILE}
+ echo "$3" > ${TESTDIR}/dotest.exp
+ echo "** got: " >>${LOGFILE}
+ cat ${TESTDIR}/dotest.tmp >>${LOGFILE}
+ fail "$1"
+ fi
+ fi
+ fi
+}
+
+dotest_all_in_one ()
+{
+ if $EXPR "`cat ${TESTDIR}/dotest.tmp`" : \
+ "`cat ${TESTDIR}/dotest.exp`" >/dev/null; then
+ return 0
+ fi
+ return 1
+}
+
+# WARNING: this won't work with REs that match newlines....
+#
+dotest_line_by_line ()
+{
+ line=1
+ while [ $line -le `wc -l ${TESTDIR}/dotest.tmp` ] ; do
+ echo "$line matched \c" >>$LOGFILE
+ if $EXPR "`sed -n ${line}p ${TESTDIR}/dotest.tmp`" : \
+ "`sed -n ${line}p ${TESTDIR}/dotest.exp`" >/dev/null; then
+ :
+ else
+ echo "**** expected line: " >>${LOGFILE}
+ sed -n ${line}p ${TESTDIR}/dotest.exp >>${LOGFILE}
+ echo "**** got line: " >>${LOGFILE}
+ sed -n ${line}p ${TESTDIR}/dotest.tmp >>${LOGFILE}
+ unset line
+ return 1
+ fi
+ line=`expr $line + 1`
+ done
+ unset line
+ return 0
+}
+
+# If you are having trouble telling which line of a multi-line
+# expression is not being matched, replace calls to dotest_internal()
+# with calls to this function:
+#
+dotest_internal_debug ()
+{
+ if test -z "$3"; then
+ if test -s ${TESTDIR}/dotest.tmp; then
+ echo "** expected: " >>${LOGFILE}
+ echo "$3" >>${LOGFILE}
+ echo "$3" > ${TESTDIR}/dotest.exp
+ rm -f ${TESTDIR}/dotest.ex2
+ echo "** got: " >>${LOGFILE}
+ cat ${TESTDIR}/dotest.tmp >>${LOGFILE}
+ fail "$1"
+ else
+ pass "$1"
+ fi
+ else
+ echo "$3" > ${TESTDIR}/dotest.exp
+ if dotest_line_by_line "$1" "$2"; then
+ pass "$1"
+ else
+ if test x"$4" != x; then
+ mv ${TESTDIR}/dotest.exp ${TESTDIR}/dotest.ex1
+ echo "$4" > ${TESTDIR}/dotest.exp
+ if dotest_line_by_line "$1" "$2"; then
pass "$1"
else
+ mv ${TESTDIR}/dotest.exp ${TESTDIR}/dotest.ex2
echo "** expected: " >>${LOGFILE}
echo "$3" >>${LOGFILE}
echo "** or: " >>${LOGFILE}
@@ -215,7 +374,7 @@ dotest_internal ()
# Usage:
# dotest TESTNAME COMMAND OUTPUT [OUTPUT2]
# TESTNAME is the name used in the log to identify the test.
-# COMMAND is the command to run; for the test to pass, it exits with
+# COMMAND is the command to run; for the test to pass, it exits with
# exitstatus zero.
# OUTPUT is a regexp which is compared against the output (stdout and
# stderr combined) from the test. It is anchored to the start and end
@@ -227,6 +386,7 @@ dotest_internal ()
# lack \|).
dotest ()
{
+ rm -f ${TESTDIR}/dotest.ex? 2>&1
if $2 >${TESTDIR}/dotest.tmp 2>&1; then
: so far so good
else
@@ -238,9 +398,34 @@ dotest ()
dotest_internal "$@"
}
+# Like dotest except only 2 args and result must exactly match stdin
+dotest_lit ()
+{
+ rm -f ${TESTDIR}/dotest.ex? 2>&1
+ if $2 >${TESTDIR}/dotest.tmp 2>&1; then
+ : so far so good
+ else
+ status=$?
+ cat ${TESTDIR}/dotest.tmp >>${LOGFILE}
+ echo "exit status was $status" >>${LOGFILE}
+ fail "$1"
+ fi
+ cat >${TESTDIR}/dotest.exp
+ if cmp ${TESTDIR}/dotest.exp ${TESTDIR}/dotest.tmp >/dev/null 2>&1; then
+ pass "$1"
+ else
+ echo "** expected: " >>${LOGFILE}
+ cat ${TESTDIR}/dotest.exp >>${LOGFILE}
+ echo "** got: " >>${LOGFILE}
+ cat ${TESTDIR}/dotest.tmp >>${LOGFILE}
+ fail "$1"
+ fi
+}
+
# Like dotest except exitstatus should be nonzero.
dotest_fail ()
{
+ rm -f ${TESTDIR}/dotest.ex? 2>&1
if $2 >${TESTDIR}/dotest.tmp 2>&1; then
status=$?
cat ${TESTDIR}/dotest.tmp >>${LOGFILE}
@@ -271,11 +456,20 @@ dotest_status ()
rm -rf ${TESTDIR}
mkdir ${TESTDIR}
cd ${TESTDIR}
+# This will show up in cvs history output where it prints the working
+# directory. It should *not* appear in any cvs output referring to the
+# repository; cvs should use the name of the repository as specified.
+TMPPWD=`/bin/pwd`
# Avoid picking up any stray .cvsrc, etc., from the user running the tests
mkdir home
HOME=${TESTDIR}/home; export HOME
+# Make sure this variable is not defined to anything that would
+# change the format of rcs dates. Otherwise people using e.g.,
+# RCSINIT=-zLT get lots of spurious failures.
+RCSINIT=; export RCSINIT
+
# Remaining arguments are the names of tests to run.
#
# The testsuite is broken up into (hopefully manageably-sized)
@@ -284,76 +478,20 @@ HOME=${TESTDIR}/home; export HOME
# tests.
if test x"$*" = x; then
- tests="basica basic1 deep basic2 death branches import new conflicts modules mflag errmsg1 devcom ignore binfiles info"
+ tests="basica basicb basic1 deep basic2 rdiff death death2 branches"
+ tests="${tests} multibranch import join new newb conflicts conflicts2"
+ tests="${tests} modules modules2 modules3 mflag errmsg1 devcom devcom2"
+ tests="${tests} devcom3 ignore binfiles binfiles2 binwrap info"
+ tests="${tests} serverpatch log log2 crerepos rcs big modes"
+ tests="${tests} sticky keyword"
else
tests="$*"
fi
-# this should die
-if ${CVS} -d `pwd`/cvsroot co cvs-sanity 2>> ${LOGFILE} ; then
- echo "FAIL: test 1" | tee -a ${LOGFILE}
- exit 1
-else
- echo "PASS: test 1" >>${LOGFILE}
-fi
-
-# this should still die
-mkdir cvsroot
-if ${CVS} -d `pwd`/cvsroot co cvs-sanity 2>> ${LOGFILE} ; then
- echo "FAIL: test 2" | tee -a ${LOGFILE}
- exit 1
-else
- echo "PASS: test 2" >>${LOGFILE}
-fi
-
-# this should still die
-mkdir cvsroot/CVSROOT
-if ${CVS} -d `pwd`/cvsroot co cvs-sanity 2>> ${LOGFILE} ; then
- echo "FAIL: test 3" | tee -a ${LOGFILE}
- exit 1
-else
- echo "PASS: test 3" >>${LOGFILE}
-fi
-
-# This one should work, although it should spit a warning.
-mkdir tmp ; cd tmp
-${CVS} -d `pwd`/../cvsroot co CVSROOT 2>> ${LOGFILE}
-cd .. ; rm -rf tmp
-
-# set up a minimal modules file...
-# (now that mkmodules is gone, this doesn't test -i the way it
-# used to. In fact, it looks like a noop to me).
-echo "CVSROOT CVSROOT" > cvsroot/CVSROOT/modules
-# The following line stolen from cvsinit.sh. FIXME: create our
-# repository via cvsinit.sh; that way we test it too.
-(cd cvsroot/CVSROOT; ci -q -u -t/dev/null \
- -m'initial checkin of modules' modules)
-
-# This one should succeed. No warnings.
-mkdir tmp ; cd tmp
-if ${CVS} -d `pwd`/../cvsroot co CVSROOT ; then
- echo "PASS: test 4" >>${LOGFILE}
-else
- echo "FAIL: test 4" | tee -a ${LOGFILE}
- exit 1
-fi
-
-if echo "yes" | ${CVS} -d `pwd`/../cvsroot release -d CVSROOT ; then
- echo "PASS: test 4.5" >>${LOGFILE}
-else
- echo "FAIL: test 4.5" | tee -a ${LOGFILE}
- exit 1
-fi
-# this had better be empty
-cd ..; rmdir tmp
-dotest_fail 4.75 "test -d tmp" ''
-
# a simple function to compare directory contents
#
-# BTW, I don't care any more -- if you don't have a /bin/sh that handles
-# shell functions, well get one.
-#
-# Returns: ISDIFF := true|false
+# Returns: {nothing}
+# Side Effects: ISDIFF := true|false
#
directory_cmp ()
{
@@ -380,33 +518,28 @@ directory_cmp ()
cd $OLDPWD
while read a
do
- if [ -f $DIR_1/"$a" ] ; then
+ if test -f $DIR_1/"$a" ; then
cmp -s $DIR_1/"$a" $DIR_2/"$a"
- if [ $? -ne 0 ] ; then
+ if test $? -ne 0 ; then
ISDIFF=true
fi
fi
done < /tmp/dc$$d1
-### FIXME:
-### rm -f /tmp/dc$$*
+ rm -f /tmp/dc$$*
}
-# so much for the setup. Let's try something harder.
-
-# Try setting CVSROOT so we don't have to worry about it anymore. (now that
-# we've tested -d cvsroot.)
+# Set up CVSROOT (the crerepos tests will test operating without CVSROOT set).
CVSROOT_DIRNAME=${TESTDIR}/cvsroot
CVSROOT=${CVSROOT_DIRNAME} ; export CVSROOT
if test "x$remote" = xyes; then
- CVSROOT=`hostname`:${CVSROOT_DIRNAME} ; export CVSROOT
- # Use rsh so we can test it without having to muck with inetd or anything
- # like that. Also needed to get CVS_SERVER to work.
- CVS_CLIENT_PORT=-1; export CVS_CLIENT_PORT
+ # Use rsh so we can test it without having to muck with inetd
+ # or anything like that. Also needed to get CVS_SERVER to
+ # work.
+ CVSROOT=:ext:`hostname`:${CVSROOT_DIRNAME} ; export CVSROOT
CVS_SERVER=${testcvs}; export CVS_SERVER
fi
-# start keeping history
-touch ${CVSROOT_DIRNAME}/CVSROOT/history
+dotest 1 "${testcvs} init" ''
### The big loop
for what in $tests; do
@@ -416,14 +549,19 @@ for what in $tests; do
# tests, but hopefully a lot faster. Also tests operating on
# files two directories down *without* operating on the parent dirs.
- # Using mkdir in the repository is used throughout these
- # tests to create a top-level directory. I think instead it
- # should be:
- # cvs co -l .
- # mkdir first-dir
- # cvs add first-dir
- # but currently that works only for local CVS, not remote.
- mkdir ${CVSROOT_DIRNAME}/first-dir
+ # Tests basica-0a and basica-0b provide the equivalent of the:
+ # mkdir ${CVSROOT_DIRNAME}/first-dir
+ # used by many of the tests. It is "more official" in the sense
+ # that is does everything through CVS; the reason most of the
+ # tests don't use it is mostly historical.
+ mkdir 1; cd 1
+ dotest basica-0a "${testcvs} -q co -l ." ''
+ mkdir first-dir
+ dotest basica-0b "${testcvs} add first-dir" \
+"Directory ${TESTDIR}/cvsroot/first-dir added to the repository"
+ cd ..
+ rm -rf 1
+
dotest basica-1 "${testcvs} -q co first-dir" ''
cd first-dir
@@ -434,12 +572,20 @@ for what in $tests; do
dotest basica-1a2 "${testcvs} -q status" ''
mkdir sdir
+ # Remote CVS gives the "cannot open CVS/Entries" error, which is
+ # clearly a bug, but not a simple one to fix.
+ dotest basica-1a10 "${testcvs} -n add sdir" \
+"Directory ${TESTDIR}/cvsroot/first-dir/sdir added to the repository" \
+"${PROG} add: cannot open CVS/Entries for reading: No such file or directory
+Directory ${TESTDIR}/cvsroot/first-dir/sdir added to the repository"
+ dotest_fail basica-1a11 \
+ "test -d ${CVSROOT_DIRNAME}/first-dir/sdir" ''
dotest basica-2 "${testcvs} add sdir" \
-'Directory /tmp/cvs-sanity/cvsroot/first-dir/sdir added to the repository'
+"Directory ${TESTDIR}/cvsroot/first-dir/sdir added to the repository"
cd sdir
mkdir ssdir
dotest basica-3 "${testcvs} add ssdir" \
-'Directory /tmp/cvs-sanity/cvsroot/first-dir/sdir/ssdir added to the repository'
+"Directory ${TESTDIR}/cvsroot/first-dir/sdir/ssdir added to the repository"
cd ssdir
echo ssfile >ssfile
@@ -461,25 +607,38 @@ for what in $tests; do
${PROG} "'\[[a-z]* aborted\]: correct the above errors first!'
cd ../..
dotest basica-5 "${testcvs} -q ci -m add-it" \
-'RCS file: /tmp/cvs-sanity/cvsroot/first-dir/sdir/ssdir/ssfile,v
+"RCS file: ${TESTDIR}/cvsroot/first-dir/sdir/ssdir/ssfile,v
done
Checking in sdir/ssdir/ssfile;
-/tmp/cvs-sanity/cvsroot/first-dir/sdir/ssdir/ssfile,v <-- ssfile
-initial revision: 1.1
-done'
+${TESTDIR}/cvsroot/first-dir/sdir/ssdir/ssfile,v <-- ssfile
+initial revision: 1\.1
+done"
dotest_fail basica-5a \
"${testcvs} -q tag BASE sdir/ssdir/ssfile" \
"${PROG} [a-z]*: Attempt to add reserved tag name BASE
-${PROG} \[[a-z]* aborted\]: failed to set tag BASE to revision 1.1 in /tmp/cvs-sanity/cvsroot/first-dir/sdir/ssdir/ssfile,v"
+${PROG} \[[a-z]* aborted\]: failed to set tag BASE to revision 1\.1 in ${TESTDIR}/cvsroot/first-dir/sdir/ssdir/ssfile,v"
dotest basica-5b "${testcvs} -q tag NOT_RESERVED" \
'T sdir/ssdir/ssfile'
dotest basica-6 "${testcvs} -q update" ''
echo "ssfile line 2" >>sdir/ssdir/ssfile
dotest_status basica-6.2 1 "${testcvs} -q diff -c" \
-'Index: sdir/ssdir/ssfile
+"Index: sdir/ssdir/ssfile
+===================================================================
+RCS file: ${TESTDIR}/cvsroot/first-dir/sdir/ssdir/ssfile,v
+retrieving revision 1\.1
+diff -c -r1\.1 ssfile
+\*\*\* ssfile [0-9/]* [0-9:]* 1\.1
+--- ssfile [0-9/]* [0-9:]*
+\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
+\*\*\* 1 \*\*\*\*
+--- 1,2 ----
+ ssfile
+${PLUS} ssfile line 2"
+ dotest_status basica-6.3 1 "${testcvs} -q diff -c -rBASE" \
+"Index: sdir/ssdir/ssfile
===================================================================
-RCS file: /tmp/cvs-sanity/cvsroot/first-dir/sdir/ssdir/ssfile,v
+RCS file: ${TESTDIR}/cvsroot/first-dir/sdir/ssdir/ssfile,v
retrieving revision 1\.1
diff -c -r1\.1 ssfile
\*\*\* ssfile [0-9/]* [0-9:]* 1\.1
@@ -488,140 +647,654 @@ diff -c -r1\.1 ssfile
\*\*\* 1 \*\*\*\*
--- 1,2 ----
ssfile
-'"${PLUS} ssfile line 2"
+${PLUS} ssfile line 2"
dotest basica-7 "${testcvs} -q ci -m modify-it" \
-'Checking in sdir/ssdir/ssfile;
-/tmp/cvs-sanity/cvsroot/first-dir/sdir/ssdir/ssfile,v <-- ssfile
-new revision: 1.2; previous revision: 1.1
-done'
+"Checking in sdir/ssdir/ssfile;
+${TESTDIR}/cvsroot/first-dir/sdir/ssdir/ssfile,v <-- ssfile
+new revision: 1\.2; previous revision: 1\.1
+done"
dotest_fail basica-nonexist "${testcvs} -q ci nonexist" \
"${PROG}"' [a-z]*: nothing known about `nonexist'\''
'"${PROG}"' \[[a-z]* aborted\]: correct above errors first!'
dotest basica-8 "${testcvs} -q update" ''
+
+ # Test the -f option to ci
+ cd sdir/ssdir
+ dotest basica-8a0 "${testcvs} -q ci -m not-modified ssfile" ''
+ dotest basica-8a "${testcvs} -q ci -f -m force-it" \
+"Checking in ssfile;
+${TESTDIR}/cvsroot/first-dir/sdir/ssdir/ssfile,v <-- ssfile
+new revision: 1\.3; previous revision: 1\.2
+done"
+ dotest basica-8a1 "${testcvs} -q ci -m bump-it -r 2.0" \
+"Checking in ssfile;
+${TESTDIR}/cvsroot/first-dir/sdir/ssdir/ssfile,v <-- ssfile
+new revision: 2\.0; previous revision: 1\.3
+done"
+ # -f should not be necessary, but it should be harmless.
+ # Also test the "-r 3" (rather than "-r 3.0") usage.
+ dotest basica-8a2 "${testcvs} -q ci -m bump-it -f -r 3" \
+"Checking in ssfile;
+${TESTDIR}/cvsroot/first-dir/sdir/ssdir/ssfile,v <-- ssfile
+new revision: 3\.1; previous revision: 2\.0
+done"
+ cd ../..
+ dotest basica-8b "${testcvs} -q diff -r1.2 -r1.3" \
+"Index: sdir/ssdir/ssfile
+===================================================================
+RCS file: ${TESTDIR}/cvsroot/first-dir/sdir/ssdir/ssfile,v
+retrieving revision 1\.2
+retrieving revision 1\.3
+diff -r1\.2 -r1\.3"
+
+ # The .* here will normally be "No such file or directory",
+ # but if memory serves some systems (AIX?) have a different message.
+: dotest_fail basica-9 \
+ "${testcvs} -q -d ${TESTDIR}/nonexist update" \
+"${PROG}: cannot access cvs root ${TESTDIR}/nonexist: .*"
dotest_fail basica-9 \
- "${testcvs} -q -d /tmp/cvs-sanity/nonexist update" \
-"${PROG}: .*/tmp/cvs-sanity/cvsroot value for CVS Root found in CVS/Root
-${PROG}"': does not match command line -d /tmp/cvs-sanity/nonexist setting
-'"${PROG}"': you may wish to try the cvs command again without the -d option '
+ "${testcvs} -q -d ${TESTDIR}/nonexist update" \
+"${PROG} \[[a-z]* aborted\]: ${TESTDIR}/nonexist/CVSROOT: .*"
dotest basica-10 "${testcvs} annotate" \
'Annotations for sdir/ssdir/ssfile
\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
-1.1 .[a-z@][a-z@ ]* [0-9a-zA-Z-]*.: ssfile
-1.2 .[a-z@][a-z@ ]* [0-9a-zA-Z-]*.: ssfile line 2'
+1\.1 .'"${username}"' *[0-9a-zA-Z-]*.: ssfile
+1\.2 .'"${username}"' *[0-9a-zA-Z-]*.: ssfile line 2'
cd ..
rm -rf ${CVSROOT_DIRNAME}/first-dir
rm -r first-dir
;;
- basic1) # first dive - add a files, first singly, then in a group.
- mkdir ${CVSROOT_DIRNAME}/first-dir
- # check out an empty directory
- if ${CVS} co first-dir ; then
- echo "PASS: test 13a" >>${LOGFILE}
- else
- echo "FAIL: test 13a" | tee -a ${LOGFILE}; exit 1
- fi
+ basicb)
+ # More basic tests, including non-branch tags and co -d.
+ mkdir 1; cd 1
+ dotest basicb-0a "${testcvs} -q co -l ." ''
+ touch topfile
+ dotest basicb-0b "${testcvs} add topfile" \
+"${PROG} [a-z]*: scheduling file .topfile. for addition
+${PROG} [a-z]*: use .cvs commit. to add this file permanently"
+ dotest basicb-0c "${testcvs} -q ci -m add-it topfile" \
+"RCS file: ${TESTDIR}/cvsroot/./topfile,v
+done
+Checking in topfile;
+${TESTDIR}/cvsroot/./topfile,v <-- topfile
+initial revision: 1\.1
+done"
+ cd ..
+ rm -rf 1
+ mkdir 2; cd 2
+ dotest basicb-0d "${testcvs} -q co -l ." "U topfile"
+ mkdir first-dir
+ dotest basicb-0e "${testcvs} add first-dir" \
+"Directory ${TESTDIR}/cvsroot/first-dir added to the repository"
+ cd ..
+ rm -rf 2
- cd first-dir
- files=first-file
- for i in a b ; do
- for j in ${files} ; do
- echo $j > $j
- done
+: mkdir ${CVSROOT_DIRNAME}/first-dir
+ dotest basicb-1 "${testcvs} -q co first-dir" ''
+ dotest basicb-1a "test -d CVS" ''
+ # See comment at modules3-7f for more on this behavior.
+ dotest basicb-1b "cat CVS/Repository" \
+"${TESTDIR}/cvsroot/first-dir" "${TESTDIR}/cvsroot/\."
+ dotest basicb-1c "cat first-dir/CVS/Repository" \
+"${TESTDIR}/cvsroot/first-dir"
- for do in add rm ; do
- for j in ${do} "commit -m test" ; do
- # ${do}
- if ${CVS} $j ${files} >> ${LOGFILE} 2>&1; then
- echo "PASS: test 14-${do}-$j" >>${LOGFILE}
- else
- echo "FAIL: test 14-${do}-$j" | tee -a ${LOGFILE}; exit 1
- fi
-
- # update it.
- if [ "${do}" = "rm" -a "$j" != "commit -m test" ] || ${CVS} update ${files} ; then
- echo "PASS: test 15-${do}-$j" >>${LOGFILE}
- else
- echo "FAIL: test 15-${do}-$j" | tee -a ${LOGFILE}; exit 1
- fi
-
- # update all.
- if ${CVS} update ; then
- echo "PASS: test 16-${do}-$j" >>${LOGFILE}
- else
- echo "FAIL: test 16-${do}-$j" | tee -a ${LOGFILE}; exit 1
- fi
-
- # status all.
- if ${CVS} status >> ${LOGFILE}; then
- echo "PASS: test 17-${do}-$j" >>${LOGFILE}
- else
- echo "FAIL: test 17-${do}-$j" | tee -a ${LOGFILE}; exit 1
- fi
-
- # FIXME: this one doesn't work yet for added files.
- # log all.
- if ${CVS} log >> ${LOGFILE}; then
- echo "PASS: test 18-${do}-$j" >>${LOGFILE}
- else
- echo "FAIL: test 18-${do}-$j" | tee -a ${LOGFILE}
- fi
-
- cd ..
- # update all.
- if ${CVS} update ; then
- echo "PASS: test 21-${do}-$j" >>${LOGFILE}
- else
- echo "FAIL: test 21-${do}-$j" | tee -a ${LOGFILE}; exit 1
- fi
-
- # log all.
- # FIXME: doesn't work right for added files.
- if ${CVS} log first-dir >> ${LOGFILE}; then
- echo "PASS: test 22-${do}-$j" >>${LOGFILE}
- else
- echo "FAIL: test 22-${do}-$j" | tee -a ${LOGFILE}
- fi
-
- # status all.
- if ${CVS} status first-dir >> ${LOGFILE}; then
- echo "PASS: test 23-${do}-$j" >>${LOGFILE}
- else
- echo "FAIL: test 23-${do}-$j" | tee -a ${LOGFILE}; exit 1
- fi
-
- # update all.
- if ${CVS} update first-dir ; then
- echo "PASS: test 24-${do}-$j" >>${LOGFILE}
- else
- echo "FAIL: test 24-${do}-$j" | tee -a ${LOGFILE} ; exit 1
- fi
-
- # update all.
- if ${CVS} co first-dir ; then
- echo "PASS: test 27-${do}-$j" >>${LOGFILE}
- else
- echo "FAIL: test 27-${do}-$j" | tee -a ${LOGFILE} ; exit 1
- fi
-
- cd first-dir
- done # j
- rm -f ${files}
- done # do
-
- files="file2 file3 file4 file5"
- done
- if ${CVS} tag first-dive ; then
- echo "PASS: test 28" >>${LOGFILE}
- else
- echo "FAIL: test 28" | tee -a ${LOGFILE} ; exit 1
- fi
- cd ..
- rm -rf ${CVSROOT_DIRNAME}/first-dir
- rm -rf first-dir
- ;;
+ cd first-dir
+ mkdir sdir1 sdir2
+ dotest basicb-2 "${testcvs} add sdir1 sdir2" \
+"Directory ${TESTDIR}/cvsroot/first-dir/sdir1 added to the repository
+Directory ${TESTDIR}/cvsroot/first-dir/sdir2 added to the repository"
+ cd sdir1
+ echo sfile1 starts >sfile1
+ dotest basicb-2a10 "${testcvs} -n add sfile1" \
+"${PROG} [a-z]*: scheduling file .sfile1. for addition
+${PROG} [a-z]*: use .cvs commit. to add this file permanently"
+ dotest basicb-2a11 "${testcvs} status sfile1" \
+"${PROG} [a-z]*: use .cvs add' to create an entry for sfile1
+===================================================================
+File: sfile1 Status: Unknown
+
+ Working revision: No entry for sfile1
+ Repository revision: No revision control file"
+ dotest basicb-3 "${testcvs} add sfile1" \
+"${PROG} [a-z]*: scheduling file .sfile1. for addition
+${PROG} [a-z]*: use .cvs commit. to add this file permanently"
+ dotest basicb-3a1 "${testcvs} status sfile1" \
+"===================================================================
+File: sfile1 Status: Locally Added
+
+ Working revision: New file!
+ Repository revision: No revision control file
+ Sticky Tag: (none)
+ Sticky Date: (none)
+ Sticky Options: (none)"
+
+ cd ../sdir2
+ echo sfile2 starts >sfile2
+ dotest basicb-4 "${testcvs} add sfile2" \
+"${PROG} [a-z]*: scheduling file .sfile2. for addition
+${PROG} [a-z]*: use .cvs commit. to add this file permanently"
+ dotest basicb-4a "${testcvs} -q ci CVS" \
+"${PROG} [a-z]*: warning: directory CVS specified in argument
+${PROG} [a-z]*: but CVS uses CVS for its own purposes; skipping CVS directory"
+ cd ..
+ dotest basicb-5 "${testcvs} -q ci -m add" \
+"RCS file: ${TESTDIR}/cvsroot/first-dir/sdir1/sfile1,v
+done
+Checking in sdir1/sfile1;
+${TESTDIR}/cvsroot/first-dir/sdir1/sfile1,v <-- sfile1
+initial revision: 1\.1
+done
+RCS file: ${TESTDIR}/cvsroot/first-dir/sdir2/sfile2,v
+done
+Checking in sdir2/sfile2;
+${TESTDIR}/cvsroot/first-dir/sdir2/sfile2,v <-- sfile2
+initial revision: 1\.1
+done"
+ echo sfile1 develops >sdir1/sfile1
+ dotest basicb-6 "${testcvs} -q ci -m modify" \
+"Checking in sdir1/sfile1;
+${TESTDIR}/cvsroot/first-dir/sdir1/sfile1,v <-- sfile1
+new revision: 1\.2; previous revision: 1\.1
+done"
+ dotest basicb-7 "${testcvs} -q tag release-1" 'T sdir1/sfile1
+T sdir2/sfile2'
+ echo not in time for release-1 >sdir2/sfile2
+ dotest basicb-8 "${testcvs} -q ci -m modify-2" \
+"Checking in sdir2/sfile2;
+${TESTDIR}/cvsroot/first-dir/sdir2/sfile2,v <-- sfile2
+new revision: 1\.2; previous revision: 1\.1
+done"
+ # See if CVS can correctly notice when an invalid numeric
+ # revision is specified.
+ # Commented out until we get around to fixing CVS
+: dotest basicb-8a0 "${testcvs} diff -r 1.5 -r 1.7 sfile2" 'error msg'
+ cd ..
+
+ # Test that we recurse into the correct directory when checking
+ # for existing files, even if co -d is in use.
+ touch first-dir/extra
+ dotest basicb-cod-1 "${testcvs} -q co -d first-dir1 first-dir" \
+'U first-dir1/sdir1/sfile1
+U first-dir1/sdir2/sfile2'
+ rm -rf first-dir1
+
+ rm -rf first-dir
+ dotest basicb-9 \
+"${testcvs} -q co -d newdir -r release-1 first-dir/sdir1 first-dir/sdir2" \
+'U newdir/sdir1/sfile1
+U newdir/sdir2/sfile2'
+ dotest basicb-9a "test -d CVS" ''
+ # See comment at modules3-7f for more on this behavior.
+ dotest basicb-9b "cat CVS/Repository" \
+"${TESTDIR}/cvsroot/first-dir" "${TESTDIR}/cvsroot/\."
+ dotest basicb-9c "cat newdir/CVS/Repository" \
+"${TESTDIR}/cvsroot/CVSROOT/Emptydir"
+ dotest basicb-10 "cat newdir/sdir1/sfile1 newdir/sdir2/sfile2" \
+"sfile1 develops
+sfile2 starts"
+
+ rm -rf newdir
+
+ # Hmm, this might be a case for CVSNULLREPOS, but CVS doesn't
+ # seem to deal with it...
+ if false; then
+ dotest basicb-11 "${testcvs} -q co -d sub1/sub2 first-dir" \
+"U sub1/sub2/sdir1/sfile1
+U sub1/sub2/sdir2/sfile2"
+ cd sub1
+ dotest basicb-12 "${testcvs} -q update" ''
+ touch xx
+ dotest basicb-13 "${testcvs} add xx" fixme
+ cd ..
+ rm -r sub1
+ # to test: sub1/sub2/sub3
+ fi # end of tests commented out.
+
+ # Create a second directory.
+ mkdir 1
+ cd 1
+ dotest basicb-14 "${testcvs} -q co -l ." 'U topfile'
+ mkdir second-dir
+ dotest basicb-15 "${testcvs} add second-dir" \
+"Directory ${TESTDIR}/cvsroot/second-dir added to the repository"
+ cd second-dir
+ touch aa
+ dotest basicb-16 "${testcvs} add aa" \
+"${PROG} [a-z]*: scheduling file .aa. for addition
+${PROG} [a-z]*: use .cvs commit. to add this file permanently"
+ dotest basicb-17 "${testcvs} -q ci -m add" \
+"RCS file: ${TESTDIR}/cvsroot/second-dir/aa,v
+done
+Checking in aa;
+${TESTDIR}/cvsroot/second-dir/aa,v <-- aa
+initial revision: 1\.1
+done"
+ cd ../..
+ rm -rf 1
+ # Now here is the kicker: note that the semantics of -d
+ # are fundamentally different if we specify two or more directories
+ # rather than one! I consider this to be seriously bogus,
+ # but for the moment I am just trying to figure out what
+ # CVS's current behaviors are.
+ dotest basicb-18 "${testcvs} -q co -d test2 first-dir second-dir" \
+"U test2/first-dir/sdir1/sfile1
+U test2/first-dir/sdir2/sfile2
+U test2/second-dir/aa"
+ cd test2
+ touch emptyfile
+ # The fact that CVS lets us add a file here is a CVS bug, right?
+ # I can just make this an error message (on the add and/or the
+ # commit) without getting flamed, right?
+ # Right?
+ # Right?
+ dotest basicb-19 "${testcvs} add emptyfile" \
+"${PROG} [a-z]*: scheduling file .emptyfile. for addition
+${PROG} [a-z]*: use .cvs commit. to add this file permanently"
+ dotest basicb-20 "${testcvs} -q ci -m add" \
+"RCS file: ${TESTDIR}/cvsroot/CVSROOT/Emptydir/emptyfile,v
+done
+Checking in emptyfile;
+${TESTDIR}/cvsroot/CVSROOT/Emptydir/emptyfile,v <-- emptyfile
+initial revision: 1\.1
+done"
+ cd ..
+
+ mkdir 1; cd 1
+ # "cvs admin" tests are scattered around a bit. Here we test
+ # ability to reject an unrecognized option. The "keyword"
+ # test has a test of "cvs admin -l" and the "binfiles" test
+ # has a test of "cvs admin -k". Note that -H is an illegal
+ # option. It probably should be an error message. But
+ # currently it is one error message for each file operated on,
+ # which in this case is zero files.
+ dotest basicb-21 "${testcvs} -q admin -H" ""
+ cd ..
+ rmdir 1
+
+ rm -rf test2
+
+ rm -rf ${CVSROOT_DIRNAME}/first-dir
+ rm -rf ${CVSROOT_DIRNAME}/second-dir
+ rm -f ${CVSROOT_DIRNAME}/topfile,v
+ ;;
+
+ basic1)
+ # first dive - add a files, first singly, then in a group.
+ mkdir ${CVSROOT_DIRNAME}/first-dir
+ mkdir 1; cd 1
+ # check out an empty directory
+ dotest basic1-1 "${testcvs} -q co first-dir" ''
+
+ cd first-dir
+ echo file2 >file2
+ echo file3 >file3
+ echo file4 >file4
+ echo file5 >file5
+
+ dotest basic1-14-add-add "${testcvs} add file2 file3 file4 file5" \
+"${PROG} [a-z]*: scheduling file \`file2' for addition
+${PROG} [a-z]*: scheduling file \`file3' for addition
+${PROG} [a-z]*: scheduling file \`file4' for addition
+${PROG} [a-z]*: scheduling file \`file5' for addition
+${PROG} [a-z]*: use 'cvs commit' to add these files permanently"
+ dotest basic1-15-add-add \
+"${testcvs} -q update file2 file3 file4 file5" \
+"A file2
+A file3
+A file4
+A file5"
+ dotest basic1-16-add-add "${testcvs} -q update" \
+"A file2
+A file3
+A file4
+A file5"
+ dotest basic1-17-add-add "${testcvs} -q status" \
+"===================================================================
+File: file2 Status: Locally Added
+
+ Working revision: New file!
+ Repository revision: No revision control file
+ Sticky Tag: (none)
+ Sticky Date: (none)
+ Sticky Options: (none)
+
+===================================================================
+File: file3 Status: Locally Added
+
+ Working revision: New file!
+ Repository revision: No revision control file
+ Sticky Tag: (none)
+ Sticky Date: (none)
+ Sticky Options: (none)
+
+===================================================================
+File: file4 Status: Locally Added
+
+ Working revision: New file!
+ Repository revision: No revision control file
+ Sticky Tag: (none)
+ Sticky Date: (none)
+ Sticky Options: (none)
+
+===================================================================
+File: file5 Status: Locally Added
+
+ Working revision: New file!
+ Repository revision: No revision control file
+ Sticky Tag: (none)
+ Sticky Date: (none)
+ Sticky Options: (none)"
+ dotest basic1-18-add-add "${testcvs} -q log" \
+"${PROG} [a-z]*: file2 has been added, but not committed
+${PROG} [a-z]*: file3 has been added, but not committed
+${PROG} [a-z]*: file4 has been added, but not committed
+${PROG} [a-z]*: file5 has been added, but not committed"
+ cd ..
+ dotest basic1-21-add-add "${testcvs} -q update" \
+"A first-dir/file2
+A first-dir/file3
+A first-dir/file4
+A first-dir/file5"
+ # FIXCVS? Shouldn't this read first-dir/file2 instead of file2?
+ dotest basic1-22-add-add "${testcvs} log first-dir" \
+"${PROG} [a-z]*: Logging first-dir
+${PROG} [a-z]*: file2 has been added, but not committed
+${PROG} [a-z]*: file3 has been added, but not committed
+${PROG} [a-z]*: file4 has been added, but not committed
+${PROG} [a-z]*: file5 has been added, but not committed"
+ dotest basic1-23-add-add "${testcvs} status first-dir" \
+"${PROG} [a-z]*: Examining first-dir
+===================================================================
+File: file2 Status: Locally Added
+
+ Working revision: New file!
+ Repository revision: No revision control file
+ Sticky Tag: (none)
+ Sticky Date: (none)
+ Sticky Options: (none)
+
+===================================================================
+File: file3 Status: Locally Added
+
+ Working revision: New file!
+ Repository revision: No revision control file
+ Sticky Tag: (none)
+ Sticky Date: (none)
+ Sticky Options: (none)
+
+===================================================================
+File: file4 Status: Locally Added
+
+ Working revision: New file!
+ Repository revision: No revision control file
+ Sticky Tag: (none)
+ Sticky Date: (none)
+ Sticky Options: (none)
+
+===================================================================
+File: file5 Status: Locally Added
+
+ Working revision: New file!
+ Repository revision: No revision control file
+ Sticky Tag: (none)
+ Sticky Date: (none)
+ Sticky Options: (none)"
+ dotest basic1-24-add-add "${testcvs} update first-dir" \
+"${PROG} [a-z]*: Updating first-dir
+A first-dir/file2
+A first-dir/file3
+A first-dir/file4
+A first-dir/file5"
+ dotest basic1-27-add-add "${testcvs} co first-dir" \
+"${PROG} [a-z]*: Updating first-dir
+A first-dir/file2
+A first-dir/file3
+A first-dir/file4
+A first-dir/file5"
+ cd first-dir
+ dotest basic1-14-add-ci \
+"${testcvs} commit -m test file2 file3 file4 file5" \
+"RCS file: ${TESTDIR}/cvsroot/first-dir/file2,v
+done
+Checking in file2;
+${TESTDIR}/cvsroot/first-dir/file2,v <-- file2
+initial revision: 1\.1
+done
+RCS file: ${TESTDIR}/cvsroot/first-dir/file3,v
+done
+Checking in file3;
+${TESTDIR}/cvsroot/first-dir/file3,v <-- file3
+initial revision: 1\.1
+done
+RCS file: ${TESTDIR}/cvsroot/first-dir/file4,v
+done
+Checking in file4;
+${TESTDIR}/cvsroot/first-dir/file4,v <-- file4
+initial revision: 1\.1
+done
+RCS file: ${TESTDIR}/cvsroot/first-dir/file5,v
+done
+Checking in file5;
+${TESTDIR}/cvsroot/first-dir/file5,v <-- file5
+initial revision: 1\.1
+done"
+ dotest basic1-15-add-ci \
+"${testcvs} -q update file2 file3 file4 file5" ''
+ dotest basic1-16-add-ci "${testcvs} -q update" ''
+ dotest basic1-17-add-ci "${testcvs} -q status" \
+"===================================================================
+File: file2 Status: Up-to-date
+
+ Working revision: 1\.1.*
+ Repository revision: 1\.1 ${TESTDIR}/cvsroot/first-dir/file2,v
+ Sticky Tag: (none)
+ Sticky Date: (none)
+ Sticky Options: (none)
+
+===================================================================
+File: file3 Status: Up-to-date
+
+ Working revision: 1\.1.*
+ Repository revision: 1\.1 ${TESTDIR}/cvsroot/first-dir/file3,v
+ Sticky Tag: (none)
+ Sticky Date: (none)
+ Sticky Options: (none)
+
+===================================================================
+File: file4 Status: Up-to-date
+
+ Working revision: 1\.1.*
+ Repository revision: 1\.1 ${TESTDIR}/cvsroot/first-dir/file4,v
+ Sticky Tag: (none)
+ Sticky Date: (none)
+ Sticky Options: (none)
+
+===================================================================
+File: file5 Status: Up-to-date
+
+ Working revision: 1\.1.*
+ Repository revision: 1\.1 ${TESTDIR}/cvsroot/first-dir/file5,v
+ Sticky Tag: (none)
+ Sticky Date: (none)
+ Sticky Options: (none)"
+ # The "log" tests and friends probably already test the output
+ # from log quite adequately.
+ # Note: using dotest fails here. It seems to be related
+ # to the output being sufficiently large (Red Hat 4.1).
+ # dotest basic1-18-add-ci "${testcvs} log" "${DOTSTAR}"
+ if ${testcvs} -q log >>${LOGFILE}; then
+ pass basic1-18-add-ci
+ else
+ pass basic1-18-add-ci
+ fi
+ cd ..
+ dotest basic1-21-add-ci "${testcvs} -q update" ''
+ # See test basic1-18-add-ci for explanation of non-use of dotest.
+ if ${testcvs} -q log first-dir >>${LOGFILE}; then
+ pass basic1-22-add-ci
+ else
+ pass basic1-22-add-ci
+ fi
+ # At least for the moment I am going to consider 17-add-ci
+ # an adequate test of the output here.
+ # See test basic1-18-add-ci for explanation of non-use of dotest.
+ if ${testcvs} -q status first-dir >>${LOGFILE}; then
+ pass basic1-23-add-ci
+ else
+ pass basic1-23-add-ci
+ fi
+ dotest basic1-24-add-ci "${testcvs} -q update first-dir" ''
+ dotest basic1-27-add-ci "${testcvs} -q co first-dir" ''
+
+ cd first-dir
+ rm file2 file3 file4 file5
+ dotest basic1-14-rm-rm "${testcvs} rm file2 file3 file4 file5" \
+"${PROG} [a-z]*: scheduling .file2. for removal
+${PROG} [a-z]*: scheduling .file3. for removal
+${PROG} [a-z]*: scheduling .file4. for removal
+${PROG} [a-z]*: scheduling .file5. for removal
+${PROG} [a-z]*: use .${PROG} commit. to remove these files permanently"
+ # 15-rm-rm was commented out. Why?
+ dotest basic1-15-rm-rm \
+"${testcvs} -q update file2 file3 file4 file5" \
+"R file2
+R file3
+R file4
+R file5"
+ dotest basic1-16-rm-rm "${testcvs} -q update" \
+"R file2
+R file3
+R file4
+R file5"
+ dotest basic1-17-rm-rm "${testcvs} -q status" \
+"===================================================================
+File: no file file2 Status: Locally Removed
+
+ Working revision: -1\.1.*
+ Repository revision: 1\.1 ${TESTDIR}/cvsroot/first-dir/file2,v
+ Sticky Tag: (none)
+ Sticky Date: (none)
+ Sticky Options: (none)
+
+===================================================================
+File: no file file3 Status: Locally Removed
+
+ Working revision: -1\.1.*
+ Repository revision: 1\.1 ${TESTDIR}/cvsroot/first-dir/file3,v
+ Sticky Tag: (none)
+ Sticky Date: (none)
+ Sticky Options: (none)
+
+===================================================================
+File: no file file4 Status: Locally Removed
+
+ Working revision: -1\.1.*
+ Repository revision: 1\.1 ${TESTDIR}/cvsroot/first-dir/file4,v
+ Sticky Tag: (none)
+ Sticky Date: (none)
+ Sticky Options: (none)
+
+===================================================================
+File: no file file5 Status: Locally Removed
+
+ Working revision: -1\.1.*
+ Repository revision: 1\.1 ${TESTDIR}/cvsroot/first-dir/file5,v
+ Sticky Tag: (none)
+ Sticky Date: (none)
+ Sticky Options: (none)"
+ # Would be nice to test that real logs appear (with dead state
+ # and all), either here or someplace like log2 tests.
+ if ${testcvs} -q log >>${LOGFILE}; then
+ pass basic1-18-rm-rm
+ else
+ fail basic1-18-rm-rm
+ fi
+ cd ..
+ dotest basic1-21-rm-rm "${testcvs} -q update" \
+"R first-dir/file2
+R first-dir/file3
+R first-dir/file4
+R first-dir/file5"
+ if ${testcvs} -q log first-dir >>${LOGFILE}; then
+ pass basic1-22-rm-rm
+ else
+ fail basic1-22-rm-rm
+ fi
+ if ${testcvs} -q status first-dir >>${LOGFILE}; then
+ pass basic1-23-rm-rm
+ else
+ fail basic1-23-rm-rm
+ fi
+ dotest basic1-24-rm-rm "${testcvs} -q update first-dir" \
+"R first-dir/file2
+R first-dir/file3
+R first-dir/file4
+R first-dir/file5"
+ dotest basic1-27-rm-rm "${testcvs} -q co first-dir" \
+"R first-dir/file2
+R first-dir/file3
+R first-dir/file4
+R first-dir/file5"
+ cd first-dir
+ dotest basic1-14-rm-ci "${testcvs} -q commit -m test" \
+"Removing file2;
+${TESTDIR}/cvsroot/first-dir/file2,v <-- file2
+new revision: delete; previous revision: 1\.1
+done
+Removing file3;
+${TESTDIR}/cvsroot/first-dir/file3,v <-- file3
+new revision: delete; previous revision: 1\.1
+done
+Removing file4;
+${TESTDIR}/cvsroot/first-dir/file4,v <-- file4
+new revision: delete; previous revision: 1\.1
+done
+Removing file5;
+${TESTDIR}/cvsroot/first-dir/file5,v <-- file5
+new revision: delete; previous revision: 1\.1
+done"
+ dotest basic1-15-rm-ci \
+"${testcvs} -q update file2 file3 file4 file5" ''
+ dotest basic1-16-rm-ci "${testcvs} -q update" ''
+ dotest basic1-17-rm-ci "${testcvs} -q status" ''
+ # Would be nice to test that real logs appear (with dead state
+ # and all), either here or someplace like log2 tests.
+ if ${testcvs} -q log >>${LOGFILE}; then
+ pass basic1-18-rm-ci
+ else
+ fail basic1-18-rm-ci
+ fi
+ cd ..
+ dotest basic1-21-rm-ci "${testcvs} -q update" ''
+ if ${testcvs} -q log first-dir >>${LOGFILE}; then
+ pass basic1-22-rm-ci
+ else
+ fail basic1-22-rm-ci
+ fi
+ if ${testcvs} -q status first-dir >>${LOGFILE}; then
+ pass basic1-23-rm-ci
+ else
+ fail basic1-23-rm-ci
+ fi
+ dotest basic1-24-rm-ci "${testcvs} -q update first-dir" ''
+ dotest basic1-27-rm-ci "${testcvs} -q co first-dir" ''
+ cd first-dir
+ # All the files are removed, so nothing gets tagged.
+ dotest basic1-28 "${testcvs} -q tag first-dive" ''
+ cd ..
+ cd ..
+
+ if test "$keep" = yes; then
+ echo Keeping ${TESTDIR} and exiting due to --keep
+ exit 0
+ fi
+
+ rm -rf 1
+ rm -rf ${CVSROOT_DIRNAME}/first-dir
+ ;;
deep)
# Test the ability to operate on directories nested rather deeply.
@@ -631,7 +1304,7 @@ ${PROG}"': does not match command line -d /tmp/cvs-sanity/nonexist setting
for i in dir1 dir2 dir3 dir4 dir5 dir6 dir7 dir8; do
mkdir $i
dotest deep-2-$i "${testcvs} add $i" \
-'Directory /tmp/cvs-sanity/cvsroot/first-dir/dir1[/dir0-9]* added to the repository'
+"Directory ${TESTDIR}/cvsroot/first-dir/dir1[/dir0-9]* added to the repository"
cd $i
echo file1 >file1
dotest deep-3-$i "${testcvs} add file1" \
@@ -639,55 +1312,121 @@ ${PROG}"': does not match command line -d /tmp/cvs-sanity/nonexist setting
'"${PROG}"' [a-z]*: use '\''cvs commit'\'' to add this file permanently'
done
cd ../../../../../../../../..
- dotest deep-4 "${testcvs} -q ci -m add-them first-dir" \
-'RCS file: /tmp/cvs-sanity/cvsroot/first-dir/dir1/file1,v
+ dotest_lit deep-4 "${testcvs} -q ci -m add-them first-dir" <<HERE
+RCS file: ${TESTDIR}/cvsroot/first-dir/dir1/file1,v
done
Checking in first-dir/dir1/file1;
-/tmp/cvs-sanity/cvsroot/first-dir/dir1/file1,v <-- file1
+${TESTDIR}/cvsroot/first-dir/dir1/file1,v <-- file1
initial revision: 1.1
done
-RCS file: /tmp/cvs-sanity/cvsroot/first-dir/dir1/dir2/file1,v
+RCS file: ${TESTDIR}/cvsroot/first-dir/dir1/dir2/file1,v
done
Checking in first-dir/dir1/dir2/file1;
-/tmp/cvs-sanity/cvsroot/first-dir/dir1/dir2/file1,v <-- file1
+${TESTDIR}/cvsroot/first-dir/dir1/dir2/file1,v <-- file1
initial revision: 1.1
done
-RCS file: /tmp/cvs-sanity/cvsroot/first-dir/dir1/dir2/dir3/file1,v
+RCS file: ${TESTDIR}/cvsroot/first-dir/dir1/dir2/dir3/file1,v
done
Checking in first-dir/dir1/dir2/dir3/file1;
-/tmp/cvs-sanity/cvsroot/first-dir/dir1/dir2/dir3/file1,v <-- file1
+${TESTDIR}/cvsroot/first-dir/dir1/dir2/dir3/file1,v <-- file1
initial revision: 1.1
done
-RCS file: /tmp/cvs-sanity/cvsroot/first-dir/dir1/dir2/dir3/dir4/file1,v
+RCS file: ${TESTDIR}/cvsroot/first-dir/dir1/dir2/dir3/dir4/file1,v
done
Checking in first-dir/dir1/dir2/dir3/dir4/file1;
-/tmp/cvs-sanity/cvsroot/first-dir/dir1/dir2/dir3/dir4/file1,v <-- file1
+${TESTDIR}/cvsroot/first-dir/dir1/dir2/dir3/dir4/file1,v <-- file1
initial revision: 1.1
done
-RCS file: /tmp/cvs-sanity/cvsroot/first-dir/dir1/dir2/dir3/dir4/dir5/file1,v
+RCS file: ${TESTDIR}/cvsroot/first-dir/dir1/dir2/dir3/dir4/dir5/file1,v
done
Checking in first-dir/dir1/dir2/dir3/dir4/dir5/file1;
-/tmp/cvs-sanity/cvsroot/first-dir/dir1/dir2/dir3/dir4/dir5/file1,v <-- file1
+${TESTDIR}/cvsroot/first-dir/dir1/dir2/dir3/dir4/dir5/file1,v <-- file1
initial revision: 1.1
done
-RCS file: /tmp/cvs-sanity/cvsroot/first-dir/dir1/dir2/dir3/dir4/dir5/dir6/file1,v
+RCS file: ${TESTDIR}/cvsroot/first-dir/dir1/dir2/dir3/dir4/dir5/dir6/file1,v
done
Checking in first-dir/dir1/dir2/dir3/dir4/dir5/dir6/file1;
-/tmp/cvs-sanity/cvsroot/first-dir/dir1/dir2/dir3/dir4/dir5/dir6/file1,v <-- file1
+${TESTDIR}/cvsroot/first-dir/dir1/dir2/dir3/dir4/dir5/dir6/file1,v <-- file1
initial revision: 1.1
done
-RCS file: /tmp/cvs-sanity/cvsroot/first-dir/dir1/dir2/dir3/dir4/dir5/dir6/dir7/file1,v
+RCS file: ${TESTDIR}/cvsroot/first-dir/dir1/dir2/dir3/dir4/dir5/dir6/dir7/file1,v
done
Checking in first-dir/dir1/dir2/dir3/dir4/dir5/dir6/dir7/file1;
-/tmp/cvs-sanity/cvsroot/first-dir/dir1/dir2/dir3/dir4/dir5/dir6/dir7/file1,v <-- file1
+${TESTDIR}/cvsroot/first-dir/dir1/dir2/dir3/dir4/dir5/dir6/dir7/file1,v <-- file1
initial revision: 1.1
done
-RCS file: /tmp/cvs-sanity/cvsroot/first-dir/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/file1,v
+RCS file: ${TESTDIR}/cvsroot/first-dir/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/file1,v
done
Checking in first-dir/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/file1;
-/tmp/cvs-sanity/cvsroot/first-dir/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/file1,v <-- file1
+${TESTDIR}/cvsroot/first-dir/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/file1,v <-- file1
initial revision: 1.1
-done'
+done
+HERE
+
+ cd first-dir/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8
+ rm file1
+ dotest deep-4a0 "${testcvs} rm file1" \
+"${PROG} [a-z]*: scheduling .file1. for removal
+${PROG} [a-z]*: use .${PROG} commit. to remove this file permanently"
+ dotest deep-4a1 "${testcvs} -q ci -m rm-it" "Removing file1;
+${TESTDIR}/cvsroot/first-dir/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/file1,v <-- file1
+new revision: delete; previous revision: 1\.1
+done"
+ cd ../../..
+ dotest deep-4a2 "${testcvs} -q update -P dir6/dir7" ''
+ # Should be using "test -e" if that is portable enough.
+ dotest_fail deep-4a3 "test -d dir6/dir7/dir8" ''
+
+ # Test that if we remove the working directory, CVS does not
+ # recreate it. (I realize that this behavior is what the
+ # users expect, but in the longer run we might want to
+ # re-think it. The corresponding behavior for a file is that
+ # CVS *will* recreate it, and we might want to make it so
+ # that "cvs release -d" is the way to delete the directory
+ # and have it stay gone -kingdon, Oct1996).
+ rm -rf dir6
+ dotest deep-4b1 "${testcvs} -q update" ''
+ dotest deep-4b2 "${testcvs} -q update -d -P" \
+'U dir6/file1
+U dir6/dir7/file1'
+
+ # Test what happens if one uses -P when there are files removed
+ # but not committed.
+ cd dir6/dir7
+ dotest deep-rm1 "${testcvs} rm -f file1" \
+"${PROG} [a-z]*: scheduling .file1. for removal
+${PROG} [a-z]*: use .${PROG} commit. to remove this file permanently"
+ cd ..
+ dotest deep-rm2 "${testcvs} -q update -d -P" 'R dir7/file1'
+ dotest deep-rm3 "test -d dir7" ''
+ dotest deep-rm4 "${testcvs} -q ci -m rm-it" "Removing dir7/file1;
+${TESTDIR}/cvsroot/first-dir/dir1/dir2/dir3/dir4/dir5/dir6/dir7/file1,v <-- file1
+new revision: delete; previous revision: 1\.1
+done"
+ dotest deep-rm5 "${testcvs} -q update -d -P" ''
+ dotest_fail deep-rm6 "test -d dir7" ''
+
+ # Test rm -f -R.
+ cd ../..
+ dotest deep-rm7 "${testcvs} rm -f -R dir5" \
+"${PROG} [a-z]*: Removing dir5
+${PROG} [a-z]*: scheduling .dir5/file1. for removal
+${PROG} [a-z]*: Removing dir5/dir6
+${PROG} [a-z]*: scheduling .dir5/dir6/file1. for removal
+${PROG} [a-z]*: use .${PROG} commit. to remove these files permanently"
+ dotest deep-rm8 "${testcvs} -q ci -m rm-it" \
+"Removing dir5/file1;
+${TESTDIR}/cvsroot/first-dir/dir1/dir2/dir3/dir4/dir5/file1,v <-- file1
+new revision: delete; previous revision: 1\.1
+done
+Removing dir5/dir6/file1;
+${TESTDIR}/cvsroot/first-dir/dir1/dir2/dir3/dir4/dir5/dir6/file1,v <-- file1
+new revision: delete; previous revision: 1\.1
+done"
+ dotest deep-rm9 "${testcvs} -q update -d -P" ''
+ dotest_fail deep-rm10 "test -d dir5"
+
+ cd ../../../../..
if echo "yes" | ${testcvs} release -d first-dir >>${LOGFILE}; then
pass deep-5
@@ -700,14 +1439,21 @@ done'
basic2)
# Test rtag, import, history, various miscellaneous operations
+ # NOTE: this section has reached the size and
+ # complexity where it is getting to be a good idea to
+ # add new tests to a new section rather than
+ # continuing to piggyback them onto the tests here.
+
# First empty the history file
rm ${CVSROOT_DIRNAME}/CVSROOT/history
touch ${CVSROOT_DIRNAME}/CVSROOT/history
+### XXX maybe should use 'cvs imprt -b1 -m new-module first-dir F F1' in an
+### empty directory to do this instead of hacking directly into $CVSROOT
mkdir ${CVSROOT_DIRNAME}/first-dir
dotest basic2-1 "${testcvs} -q co first-dir" ''
for i in first-dir dir1 dir2 ; do
- if [ ! -d $i ] ; then
+ if test ! -d $i ; then
mkdir $i
if ${CVS} add $i >> ${LOGFILE}; then
echo "PASS: test 29-$i" >>${LOGFILE}
@@ -748,7 +1494,8 @@ done'
echo "FAIL: test 33" | tee -a ${LOGFILE} ; exit 1
fi
-# if ${CVS} diff -u first-dir >> ${LOGFILE} || [ $? = 1 ] ; then
+# XXX why is this commented out???
+# if ${CVS} diff -u first-dir >> ${LOGFILE} || test $? = 1 ; then
# echo "PASS: test 34" >>${LOGFILE}
# else
# echo "FAIL: test 34" | tee -a ${LOGFILE} # ; exit 1
@@ -800,7 +1547,7 @@ done'
echo "FAIL: test 39" | tee -a ${LOGFILE} ; exit 1
fi
- # fixme: doesn't work right for added files
+ # FIXME: doesn't work right for added files
if ${CVS} log first-dir >> ${LOGFILE}; then
echo "PASS: test 40" >>${LOGFILE}
else
@@ -813,7 +1560,8 @@ done'
echo "FAIL: test 41" | tee -a ${LOGFILE} ; exit 1
fi
-# if ${CVS} diff -u first-dir >> ${LOGFILE} || [ $? = 1 ] ; then
+# XXX why is this commented out?
+# if ${CVS} diff -u first-dir >> ${LOGFILE} || test $? = 1 ; then
# echo "PASS: test 42" >>${LOGFILE}
# else
# echo "FAIL: test 42" | tee -a ${LOGFILE} # ; exit 1
@@ -839,7 +1587,7 @@ done'
fi
# end of third dive
- if [ -d first-dir ] ; then
+ if test -d first-dir ; then
echo "FAIL: test 45.5" | tee -a ${LOGFILE} ; exit 1
else
echo "PASS: test 45.5" >>${LOGFILE}
@@ -869,7 +1617,7 @@ done'
fi
# rdiff by revision
- if ${CVS} rdiff -r1.1 -rrtagged-by-head first-dir >> ${LOGFILE} || [ $? = 1 ] ; then
+ if ${CVS} rdiff -r1.1 -rrtagged-by-head first-dir >> ${LOGFILE} || test $? = 1 ; then
echo "PASS: test 49" >>${LOGFILE}
else
echo "FAIL: test 49" | tee -a ${LOGFILE} ; exit 1
@@ -913,33 +1661,33 @@ done'
fi
# directory copies are done in an oblique way in order to avoid a bug in sun's tmp filesystem.
- mkdir first-dir.cpy ; (cd first-dir ; tar cf - * | (cd ../first-dir.cpy ; tar xf -))
+ mkdir first-dir.cpy ; (cd first-dir ; tar cf - . | (cd ../first-dir.cpy ; tar xf -))
directory_cmp first-dir export-dir
- if $ISDIFF ; then
+ if $ISDIFF ; then
echo "FAIL: test 55" | tee -a ${LOGFILE} ; exit 1
else
echo "PASS: test 55" >>${LOGFILE}
fi
- # interrupt, while we've got a clean 1.1 here, let's import it into another tree.
+ # interrupt, while we've got a clean 1.1 here, let's import it
+ # into a couple of other modules.
cd export-dir
dotest 56 "${testcvs} import -m first-import second-dir first-immigration immigration1 immigration1_0" \
-'N second-dir/file14
+"N second-dir/file14
N second-dir/file6
N second-dir/file7
-'"${PROG}"' [a-z]*: Importing /tmp/cvs-sanity/cvsroot/second-dir/dir1
+${PROG} [a-z]*: Importing ${TESTDIR}/cvsroot/second-dir/dir1
N second-dir/dir1/file14
N second-dir/dir1/file6
N second-dir/dir1/file7
-'"${PROG}"' [a-z]*: Importing /tmp/cvs-sanity/cvsroot/second-dir/dir1/dir2
+${PROG} [a-z]*: Importing ${TESTDIR}/cvsroot/second-dir/dir1/dir2
N second-dir/dir1/dir2/file14
N second-dir/dir1/dir2/file6
N second-dir/dir1/dir2/file7
-No conflicts created by this import'
-
+No conflicts created by this import"
cd ..
if ${CVS} export -r HEAD second-dir ; then
@@ -957,9 +1705,10 @@ No conflicts created by this import'
fi
rm -rf second-dir
+
rm -rf export-dir first-dir
mkdir first-dir
- (cd first-dir.cpy ; tar cf - * | (cd ../first-dir ; tar xf -))
+ (cd first-dir.cpy ; tar cf - . | (cd ../first-dir ; tar xf -))
# update the top, cancelling sticky tags, retag, update other copy, compare.
cd first-dir
@@ -1011,7 +1760,7 @@ No conflicts created by this import'
# Test the cvs history command.
# The reason that there are two patterns rather than using
- # \(/tmp/cvs-sanity\|<remote>\) is that we are trying to
+ # \(${TESTDIR}\|<remote>\) is that we are trying to
# make this portable. Perhaps at some point we should
# ditch that notion and require GNU expr (or dejagnu or....)
# since it seems to be so painful.
@@ -1019,51 +1768,163 @@ No conflicts created by this import'
# why are there two lines at the end of the local output
# which don't exist in the remote output? would seem to be
# a CVS bug.
- dotest basic2-64 "${testcvs} his -e -a" \
-'O [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* first-dir =first-dir= /tmp/cvs-sanity/\*
-A [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* 1.1 file6 first-dir == /tmp/cvs-sanity
-A [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* 1.1 file7 first-dir == /tmp/cvs-sanity
-A [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* 1.1 file6 first-dir/dir1 == /tmp/cvs-sanity
-A [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* 1.1 file7 first-dir/dir1 == /tmp/cvs-sanity
-A [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* 1.1 file6 first-dir/dir1/dir2 == /tmp/cvs-sanity
-A [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* 1.1 file7 first-dir/dir1/dir2 == /tmp/cvs-sanity
-A [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* 1.1 file14 first-dir == /tmp/cvs-sanity
-M [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* 1.2 file6 first-dir == /tmp/cvs-sanity
-A [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* 1.1 file14 first-dir/dir1 == /tmp/cvs-sanity
-M [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* 1.2 file6 first-dir/dir1 == /tmp/cvs-sanity
-A [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* 1.1 file14 first-dir/dir1/dir2 == /tmp/cvs-sanity
-M [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* 1.2 file6 first-dir/dir1/dir2 == /tmp/cvs-sanity
-F [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* =first-dir= /tmp/cvs-sanity/\*
-T [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* first-dir \[rtagged-by-head:A\]
-T [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* first-dir \[rtagged-by-tag:rtagged-by-head\]
-T [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* first-dir \[rtagged-by-revision:1.1\]
-O [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* \[1.1\] first-dir =first-dir= /tmp/cvs-sanity/\*
-U [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* 1.2 file6 first-dir == /tmp/cvs-sanity/first-dir
-U [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* 1.2 file7 first-dir == /tmp/cvs-sanity/first-dir' \
-'O [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* first-dir =first-dir= <remote>/\*
-A [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* 1.1 file6 first-dir == <remote>
-A [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* 1.1 file7 first-dir == <remote>
-A [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* 1.1 file6 first-dir/dir1 == <remote>
-A [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* 1.1 file7 first-dir/dir1 == <remote>
-A [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* 1.1 file6 first-dir/dir1/dir2 == <remote>
-A [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* 1.1 file7 first-dir/dir1/dir2 == <remote>
-A [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* 1.1 file14 first-dir == <remote>
-M [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* 1.2 file6 first-dir == <remote>
-A [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* 1.1 file14 first-dir/dir1 == <remote>
-M [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* 1.2 file6 first-dir/dir1 == <remote>
-A [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* 1.1 file14 first-dir/dir1/dir2 == <remote>
-M [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* 1.2 file6 first-dir/dir1/dir2 == <remote>
-F [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* =first-dir= <remote>/\*
-T [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* first-dir \[rtagged-by-head:A\]
-T [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* first-dir \[rtagged-by-tag:rtagged-by-head\]
-T [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* first-dir \[rtagged-by-revision:1.1\]
-O [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* \[1.1\] first-dir =first-dir= <remote>/\*'
+ dotest basic2-64 "${testcvs} his -x TOFWUCGMAR -a" \
+"O [0-9/]* [0-9:]* ${PLUS}0000 [a-z0-9@][a-z0-9@]* first-dir =first-dir= ${TMPPWD}/\*
+A [0-9/]* [0-9:]* ${PLUS}0000 [a-z0-9@][a-z0-9@]* 1\.1 file6 first-dir == ${TMPPWD}
+A [0-9/]* [0-9:]* ${PLUS}0000 [a-z0-9@][a-z0-9@]* 1\.1 file7 first-dir == ${TMPPWD}
+A [0-9/]* [0-9:]* ${PLUS}0000 [a-z0-9@][a-z0-9@]* 1\.1 file6 first-dir/dir1 == ${TMPPWD}
+A [0-9/]* [0-9:]* ${PLUS}0000 [a-z0-9@][a-z0-9@]* 1\.1 file7 first-dir/dir1 == ${TMPPWD}
+A [0-9/]* [0-9:]* ${PLUS}0000 [a-z0-9@][a-z0-9@]* 1\.1 file6 first-dir/dir1/dir2 == ${TMPPWD}
+A [0-9/]* [0-9:]* ${PLUS}0000 [a-z0-9@][a-z0-9@]* 1\.1 file7 first-dir/dir1/dir2 == ${TMPPWD}
+A [0-9/]* [0-9:]* ${PLUS}0000 [a-z0-9@][a-z0-9@]* 1\.1 file14 first-dir == ${TMPPWD}
+M [0-9/]* [0-9:]* ${PLUS}0000 [a-z0-9@][a-z0-9@]* 1\.2 file6 first-dir == ${TMPPWD}
+A [0-9/]* [0-9:]* ${PLUS}0000 [a-z0-9@][a-z0-9@]* 1\.1 file14 first-dir/dir1 == ${TMPPWD}
+M [0-9/]* [0-9:]* ${PLUS}0000 [a-z0-9@][a-z0-9@]* 1\.2 file6 first-dir/dir1 == ${TMPPWD}
+A [0-9/]* [0-9:]* ${PLUS}0000 [a-z0-9@][a-z0-9@]* 1\.1 file14 first-dir/dir1/dir2 == ${TMPPWD}
+M [0-9/]* [0-9:]* ${PLUS}0000 [a-z0-9@][a-z0-9@]* 1\.2 file6 first-dir/dir1/dir2 == ${TMPPWD}
+F [0-9/]* [0-9:]* ${PLUS}0000 [a-z0-9@][a-z0-9@]* =first-dir= ${TMPPWD}/\*
+T [0-9/]* [0-9:]* ${PLUS}0000 [a-z0-9@][a-z0-9@]* first-dir \[rtagged-by-head:A\]
+T [0-9/]* [0-9:]* ${PLUS}0000 [a-z0-9@][a-z0-9@]* first-dir \[rtagged-by-tag:rtagged-by-head\]
+T [0-9/]* [0-9:]* ${PLUS}0000 [a-z0-9@][a-z0-9@]* first-dir \[rtagged-by-revision:1\.1\]
+O [0-9/]* [0-9:]* ${PLUS}0000 [a-z0-9@][a-z0-9@]* \[1\.1\] first-dir =first-dir= ${TMPPWD}/\*
+U [0-9/]* [0-9:]* ${PLUS}0000 [a-z0-9@][a-z0-9@]* 1\.2 file6 first-dir == ${TMPPWD}/first-dir
+U [0-9/]* [0-9:]* ${PLUS}0000 [a-z0-9@][a-z0-9@]* 1\.2 file7 first-dir == ${TMPPWD}/first-dir" \
+"O [0-9/]* [0-9:]* ${PLUS}0000 [a-z0-9@][a-z0-9@]* first-dir =first-dir= <remote>/\*
+A [0-9/]* [0-9:]* ${PLUS}0000 [a-z0-9@][a-z0-9@]* 1\.1 file6 first-dir == <remote>
+A [0-9/]* [0-9:]* ${PLUS}0000 [a-z0-9@][a-z0-9@]* 1\.1 file7 first-dir == <remote>
+A [0-9/]* [0-9:]* ${PLUS}0000 [a-z0-9@][a-z0-9@]* 1\.1 file6 first-dir/dir1 == <remote>
+A [0-9/]* [0-9:]* ${PLUS}0000 [a-z0-9@][a-z0-9@]* 1\.1 file7 first-dir/dir1 == <remote>
+A [0-9/]* [0-9:]* ${PLUS}0000 [a-z0-9@][a-z0-9@]* 1\.1 file6 first-dir/dir1/dir2 == <remote>
+A [0-9/]* [0-9:]* ${PLUS}0000 [a-z0-9@][a-z0-9@]* 1\.1 file7 first-dir/dir1/dir2 == <remote>
+A [0-9/]* [0-9:]* ${PLUS}0000 [a-z0-9@][a-z0-9@]* 1\.1 file14 first-dir == <remote>
+M [0-9/]* [0-9:]* ${PLUS}0000 [a-z0-9@][a-z0-9@]* 1\.2 file6 first-dir == <remote>
+A [0-9/]* [0-9:]* ${PLUS}0000 [a-z0-9@][a-z0-9@]* 1\.1 file14 first-dir/dir1 == <remote>
+M [0-9/]* [0-9:]* ${PLUS}0000 [a-z0-9@][a-z0-9@]* 1\.2 file6 first-dir/dir1 == <remote>
+A [0-9/]* [0-9:]* ${PLUS}0000 [a-z0-9@][a-z0-9@]* 1\.1 file14 first-dir/dir1/dir2 == <remote>
+M [0-9/]* [0-9:]* ${PLUS}0000 [a-z0-9@][a-z0-9@]* 1\.2 file6 first-dir/dir1/dir2 == <remote>
+F [0-9/]* [0-9:]* ${PLUS}0000 [a-z0-9@][a-z0-9@]* =first-dir= <remote>/\*
+T [0-9/]* [0-9:]* ${PLUS}0000 [a-z0-9@][a-z0-9@]* first-dir \[rtagged-by-head:A\]
+T [0-9/]* [0-9:]* ${PLUS}0000 [a-z0-9@][a-z0-9@]* first-dir \[rtagged-by-tag:rtagged-by-head\]
+T [0-9/]* [0-9:]* ${PLUS}0000 [a-z0-9@][a-z0-9@]* first-dir \[rtagged-by-revision:1\.1\]
+O [0-9/]* [0-9:]* ${PLUS}0000 [a-z0-9@][a-z0-9@]* \[1\.1\] first-dir =first-dir= <remote>/\*"
rm -rf ${CVSROOT_DIRNAME}/first-dir
rm -rf ${CVSROOT_DIRNAME}/second-dir
;;
- death) # next dive. test death support.
+ rdiff)
+ # Test rdiff
+ # XXX for now this is just the most essential test...
+ cd ${TESTDIR}
+
+ mkdir testimport
+ cd testimport
+ echo '$''Id$' > foo
+ echo '$''Name$' >> foo
+ echo '$''Id$' > bar
+ echo '$''Name$' >> bar
+ dotest rdiff-1 \
+ "${testcvs} import -I ! -m test-import-with-keyword trdiff TRDIFF T1" \
+'N trdiff/foo
+N trdiff/bar
+
+No conflicts created by this import'
+ dotest rdiff-2 \
+ "${testcvs} co -ko trdiff" \
+"${PROG} [a-z]*: Updating trdiff
+U trdiff/bar
+U trdiff/foo"
+ cd trdiff
+ echo something >> foo
+ dotest rdiff-3 \
+ "${testcvs} ci -m added-something foo" \
+"Checking in foo;
+${TESTDIR}/cvsroot/trdiff/foo,v <-- foo
+new revision: 1\.2; previous revision: 1\.1
+done"
+ echo '#ident "@(#)trdiff:$''Name$:$''Id$"' > new
+ echo "new file" >> new
+ dotest rdiff-4 \
+ "${testcvs} add -m new-file-description new" \
+"${PROG} [a-z]*: scheduling file \`new' for addition
+${PROG} [a-z]*: use 'cvs commit' to add this file permanently"
+ dotest rdiff-5 \
+ "${testcvs} commit -m added-new-file new" \
+"RCS file: ${TESTDIR}/cvsroot/trdiff/new,v
+done
+Checking in new;
+${TESTDIR}/cvsroot/trdiff/new,v <-- new
+initial revision: 1\.1
+done"
+ dotest rdiff-6 \
+ "${testcvs} tag local-v0" \
+"${PROG} [a-z]*: Tagging .
+T bar
+T foo
+T new"
+ dotest rdiff-7 \
+ "${testcvs} status -v foo" \
+"===================================================================
+File: foo Status: Up-to-date
+
+ Working revision: 1\.2.*
+ Repository revision: 1\.2 ${TESTDIR}/cvsroot/trdiff/foo,v
+ Sticky Tag: (none)
+ Sticky Date: (none)
+ Sticky Options: -ko
+
+ Existing Tags:
+ local-v0 (revision: 1\.2)
+ T1 (revision: 1\.1\.1\.1)
+ TRDIFF (branch: 1\.1\.1)"
+
+ cd ..
+ rm -rf trdiff
+
+ dotest rdiff-8 \
+ "${testcvs} rdiff -r T1 -r local-v0 trdiff" \
+"${PROG}"' [a-z]*: Diffing trdiff
+Index: trdiff/foo
+diff -c trdiff/foo:1\.1\.1\.1 trdiff/foo:1\.2
+\*\*\* trdiff/foo:1\.1\.1\.1 .*
+--- trdiff/foo .*
+\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
+\*\*\* 1,2 \*\*\*\*
+! \$''Id: foo,v 1\.1\.1\.1 [0-9/]* [0-9:]* '"${username}"' Exp \$
+! \$''Name: T1 \$
+--- 1,3 ----
+! \$''Id: foo,v 1\.2 [0-9/]* [0-9:]* '"${username}"' Exp \$
+! \$''Name: local-v0 \$
+! something
+Index: trdiff/new
+diff -c /dev/null trdiff/new:1\.1
+\*\*\* /dev/null .*
+--- trdiff/new .*
+\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
+\*\*\* 0 \*\*\*\*
+--- 1,2 ----
+'"${PLUS}"' #ident "@(#)trdiff:\$''Name: local-v0 \$:\$''Id: new,v 1\.1 [0-9/]* [0-9:]* '"${username}"' Exp \$"
+'"${PLUS}"' new file'
+
+# FIXME: will this work here?
+# if test "$keep" = yes; then
+# echo Keeping ${TESTDIR} and exiting due to --keep
+# exit 0
+# fi
+
+ cd ..
+ rm -rf testimport
+ rm -rf ${CVSROOT_DIRNAME}/trdiff
+ ;;
+
+ death)
+ # next dive. test death support.
+
+ # NOTE: this section has reached the size and
+ # complexity where it is getting to be a good idea to
+ # add new death support tests to a new section rather
+ # than continuing to piggyback them onto the tests here.
+
mkdir ${CVSROOT_DIRNAME}/first-dir
if ${CVS} co first-dir ; then
echo "PASS: test 65" >>${LOGFILE}
@@ -1077,28 +1938,28 @@ O [0-9/]* [0-9:]* '"${PLUS}"'0000 [a-z@][a-z@]* \[1.1\] first-dir =fir
# doesn't get confused by it.
mkdir subdir
dotest 65a0 "${testcvs} add subdir" \
-'Directory /tmp/cvs-sanity/cvsroot/first-dir/subdir added to the repository'
+"Directory ${TESTDIR}/cvsroot/first-dir/subdir added to the repository"
cd subdir
echo file in subdir >sfile
dotest 65a1 "${testcvs} add sfile" \
"${PROG}"' [a-z]*: scheduling file `sfile'\'' for addition
'"${PROG}"' [a-z]*: use '\''cvs commit'\'' to add this file permanently'
dotest 65a2 "${testcvs} -q ci -m add-it" \
-'RCS file: /tmp/cvs-sanity/cvsroot/first-dir/subdir/sfile,v
+"RCS file: ${TESTDIR}/cvsroot/first-dir/subdir/sfile,v
done
Checking in sfile;
-/tmp/cvs-sanity/cvsroot/first-dir/subdir/sfile,v <-- sfile
-initial revision: 1.1
-done'
+${TESTDIR}/cvsroot/first-dir/subdir/sfile,v <-- sfile
+initial revision: 1\.1
+done"
rm sfile
dotest 65a3 "${testcvs} rm sfile" \
"${PROG}"' [a-z]*: scheduling `sfile'\'' for removal
'"${PROG}"' [a-z]*: use '\'"${PROG}"' commit'\'' to remove this file permanently'
dotest 65a4 "${testcvs} -q ci -m remove-it" \
-'Removing sfile;
-/tmp/cvs-sanity/cvsroot/first-dir/subdir/sfile,v <-- sfile
-new revision: delete; previous revision: 1.1
-done'
+"Removing sfile;
+${TESTDIR}/cvsroot/first-dir/subdir/sfile,v <-- sfile
+new revision: delete; previous revision: 1\.1
+done"
cd ..
dotest 65a5 "${testcvs} -q update -P" ''
dotest_fail 65a6 "test -d subdir" ''
@@ -1170,21 +2031,25 @@ done'
"${PROG}"' [a-z]*: scheduling file `file4'\'' for addition
'"${PROG}"' [a-z]*: use '\''cvs commit'\'' to add this file permanently'
dotest death-file4-ciadd "${testcvs} -q ci -m add file4" \
-'RCS file: /tmp/cvs-sanity/cvsroot/first-dir/file4,v
+"RCS file: ${TESTDIR}/cvsroot/first-dir/file4,v
done
Checking in file4;
-/tmp/cvs-sanity/cvsroot/first-dir/file4,v <-- file4
-initial revision: 1.1
-done'
+${TESTDIR}/cvsroot/first-dir/file4,v <-- file4
+initial revision: 1\.1
+done"
rm file4
dotest death-file4-rm "${testcvs} remove file4" \
"${PROG}"' [a-z]*: scheduling `file4'\'' for removal
'"${PROG}"' [a-z]*: use '\'"${PROG}"' commit'\'' to remove this file permanently'
dotest death-file4-cirm "${testcvs} -q ci -m remove file4" \
-'Removing file4;
-/tmp/cvs-sanity/cvsroot/first-dir/file4,v <-- file4
-new revision: delete; previous revision: 1.1
-done'
+"Removing file4;
+${TESTDIR}/cvsroot/first-dir/file4,v <-- file4
+new revision: delete; previous revision: 1\.1
+done"
+
+ # Tag the branchpoint.
+ dotest death-72a "${testcvs} -q tag bp_branch1" 'T file1
+T file2'
# branch1
if ${CVS} tag -b branch1 ; then
@@ -1217,6 +2082,27 @@ done'
echo "FAIL: test 76" | tee -a ${LOGFILE} ; exit 1
fi
+ dotest death-76a0 \
+"${testcvs} -q rdiff -r bp_branch1 -r branch1 first-dir" \
+"Index: first-dir/file3
+diff -c /dev/null first-dir/file3:1\.1\.2\.1
+\*\*\* /dev/null .*
+--- first-dir/file3 .*
+\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
+\*\*\* 0 \*\*\*\*
+--- 1 ----
+${PLUS} line1 from branch1"
+ dotest death-76a1 \
+"${testcvs} -q rdiff -r branch1 -r bp_branch1 first-dir" \
+'Index: first-dir/file3
+diff -c first-dir/file3:1\.1\.2\.1 first-dir/file3:removed
+\*\*\* first-dir/file3:1\.1\.2\.1 .*
+--- first-dir/file3 .*
+\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
+\*\*\* 1 \*\*\*\*
+- line1 from branch1
+--- 0 ----'
+
# remove
rm file3
if ${CVS} rm file3 2>> ${LOGFILE}; then
@@ -1281,22 +2167,24 @@ done'
dotest_fail death-file4-4 "test -f file4" ''
- if [ -f file3 ] ; then
+ if test -f file3 ; then
echo "FAIL: test 85" | tee -a ${LOGFILE} ; exit 1
else
echo "PASS: test 85" >>${LOGFILE}
fi
# join
- if ${CVS} update -j branch1 >> ${LOGFILE} 2>&1; then
- echo "PASS: test 86" >>${LOGFILE}
- else
- echo "FAIL: test 86" | tee -a ${LOGFILE} ; exit 1
- fi
+ dotest 86 "${testcvs} -q update -j branch1" \
+"RCS file: ${TESTDIR}/cvsroot/first-dir/file1,v
+retrieving revision 1\.3
+retrieving revision 1\.3\.2\.1
+Merging differences between 1\.3 and 1\.3\.2\.1 into file1
+${PROG} [a-z]*: scheduling file2 for removal
+U file3"
dotest_fail death-file4-5 "test -f file4" ''
- if [ -f file3 ] ; then
+ if test -f file3 ; then
echo "PASS: test 87" >>${LOGFILE}
else
echo "FAIL: test 87" | tee -a ${LOGFILE} ; exit 1
@@ -1318,11 +2206,27 @@ done'
fi
# commit
- if ${CVS} ci -m test >>${LOGFILE} 2>&1; then
- echo "PASS: test 89" >>${LOGFILE}
- else
- echo "FAIL: test 89" | tee -a ${LOGFILE} ; exit 1
- fi
+ dotest 89 "${testcvs} -q ci -m test" \
+"Checking in file1;
+${TESTDIR}/cvsroot/first-dir/file1,v <-- file1
+new revision: 1\.4; previous revision: 1\.3
+done
+Removing file2;
+${TESTDIR}/cvsroot/first-dir/file2,v <-- file2
+new revision: delete; previous revision: 1\.1
+done
+Checking in file3;
+${TESTDIR}/cvsroot/first-dir/file3,v <-- file3
+new revision: 1\.2; previous revision: 1\.1
+done"
+ cd ..
+ mkdir 2
+ cd 2
+ dotest 89a "${testcvs} -q co first-dir" 'U first-dir/file1
+U first-dir/file3'
+ cd ..
+ rm -rf 2
+ cd first-dir
# remove first file.
rm file1
@@ -1339,7 +2243,7 @@ done'
echo "FAIL: test 91" | tee -a ${LOGFILE} ; exit 1
fi
- if [ -f file1 ] ; then
+ if test -f file1 ; then
echo "FAIL: test 92" | tee -a ${LOGFILE} ; exit 1
else
echo "PASS: test 92" >>${LOGFILE}
@@ -1354,7 +2258,7 @@ done'
else
echo "PASS: 92.1b" >>${LOGFILE}
fi
- if test -f file2 ; then
+ if test -f file3 ; then
echo "PASS: 92.1c" >>${LOGFILE}
else
echo "FAIL: 92.1c" | tee -a ${LOGFILE} ; exit 1
@@ -1369,23 +2273,308 @@ done'
dotest_fail death-file4-6 "test -f file4" ''
- if [ -f file1 ] ; then
+ if test -f file1 ; then
echo "PASS: test 94" >>${LOGFILE}
else
echo "FAIL: test 94" | tee -a ${LOGFILE} ; exit 1
fi
# and join
- if ${CVS} update -j HEAD >> ${LOGFILE} 2>&1; then
- echo "PASS: test 95" >>${LOGFILE}
- else
- echo "FAIL: test 95" | tee -a ${LOGFILE} ; exit 1
- fi
+ dotest 95 "${testcvs} -q update -j HEAD" \
+"${PROG}"' [a-z]*: file file1 has been modified, but has been removed in revision HEAD
+'"${PROG}"' [a-z]*: file file3 exists, but has been added in revision HEAD'
dotest_fail death-file4-7 "test -f file4" ''
+ # file2 should not have been recreated. It was
+ # deleted on the branch, and has not been modified on
+ # the trunk. That means that there have been no
+ # changes between the greatest common ancestor (the
+ # trunk version) and HEAD.
+ dotest_fail death-file2-1 "test -f file2" ''
+
cd .. ; rm -rf first-dir ${CVSROOT_DIRNAME}/first-dir
;;
+
+ death2)
+ # More tests of death support.
+ mkdir ${CVSROOT_DIRNAME}/first-dir
+ dotest death2-1 "${testcvs} -q co first-dir" ''
+
+ cd first-dir
+
+ # Add a file on the trunk.
+ echo "first revision" > file1
+ dotest death2-2 "${testcvs} add file1" \
+"${PROG}"' [a-z]*: scheduling file `file1'\'' for addition
+'"${PROG}"' [a-z]*: use '\''cvs commit'\'' to add this file permanently'
+
+ dotest death2-3 "${testcvs} -q commit -m add" \
+"RCS file: ${TESTDIR}/cvsroot/first-dir/file1,v
+done
+Checking in file1;
+${TESTDIR}/cvsroot/first-dir/file1,v <-- file1
+initial revision: 1\.1
+done"
+
+ # Make a branch and a non-branch tag.
+ dotest death2-4 "${testcvs} -q tag -b branch" 'T file1'
+ dotest death2-5 "${testcvs} -q tag tag" 'T file1'
+
+ # Switch over to the branch.
+ dotest death2-6 "${testcvs} -q update -r branch" ''
+
+ # Delete the file on the branch.
+ rm file1
+ dotest death2-7 "${testcvs} rm file1" \
+"${PROG} [a-z]*: scheduling .file1. for removal
+${PROG} [a-z]*: use .${PROG} commit. to remove this file permanently"
+
+ # Test diff of the removed file before it is committed.
+ dotest_fail death2-diff-1 "${testcvs} -q diff file1" \
+"${PROG} [a-z]*: file1 was removed, no comparison available"
+
+ dotest_fail death2-diff-2 "${testcvs} -q diff -N -c file1" \
+"Index: file1
+===================================================================
+RCS file: file1
+diff -N file1
+\*\*\* ${tempname}[ ][ ]*[a-zA-Z0-9: ]*
+--- /dev/null[ ][ ]*[a-zA-Z0-9: ]*
+\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
+\*\*\* 1 \*\*\*\*
+- first revision
+--- 0 ----"
+
+ dotest death2-8 "${testcvs} -q ci -m removed" \
+"Removing file1;
+${TESTDIR}/cvsroot/first-dir/file1,v <-- file1
+new revision: delete; previous revision: 1\.1\.2
+done"
+
+ # Test diff of a dead file.
+ dotest_fail death2-diff-3 \
+"${testcvs} -q diff -r1.1 -rbranch -c file1" \
+"${PROG} [a-z]*: file1 was removed, no comparison available"
+
+ dotest_fail death2-diff-4 \
+"${testcvs} -q diff -r1.1 -rbranch -N -c file1" \
+"Index: file1
+===================================================================
+RCS file: file1
+diff -N file1
+\*\*\* ${tempname}[ ][ ]*[a-zA-Z0-9: ]*
+--- /dev/null[ ][ ]*[a-zA-Z0-9: ]*
+\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
+\*\*\* 1 \*\*\*\*
+- first revision
+--- 0 ----"
+
+ dotest_fail death2-diff-5 "${testcvs} -q diff -rtag -c ." \
+"${PROG} [a-z]*: file1 no longer exists, no comparison available"
+
+ dotest_fail death2-diff-6 "${testcvs} -q diff -rtag -N -c ." \
+"Index: file1
+===================================================================
+RCS file: file1
+diff -N file1
+\*\*\* ${tempname}[ ][ ]*[a-zA-Z0-9: ]*
+--- /dev/null[ ][ ]*[a-zA-Z0-9: ]*
+\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
+\*\*\* 1 \*\*\*\*
+- first revision
+--- 0 ----"
+
+ # Test rdiff of a dead file.
+ dotest death2-rdiff-1 \
+"${testcvs} -q rtag -rbranch rdiff-tag first-dir" ''
+
+ dotest death2-rdiff-2 "${testcvs} -q rdiff -rtag -rbranch first-dir" \
+"Index: first-dir/file1
+diff -c first-dir/file1:1\.1 first-dir/file1:removed
+\*\*\* first-dir/file1:1\.1[ ][ ]*[a-zA-Z0-9: ]*
+--- first-dir/file1[ ][ ]*[a-zA-Z0-9: ]*
+\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
+\*\*\* 1 \*\*\*\*
+- first revision
+--- 0 ----"
+
+ # Readd the file to the branch.
+ echo "second revision" > file1
+ dotest death2-9 "${testcvs} add file1" \
+"${PROG}"' [a-z]*: file `file1'\'' will be added on branch `branch'\'' from version 1\.1\.2\.1
+'"${PROG}"' [a-z]*: use '\''cvs commit'\'' to add this file permanently'
+
+ # Test diff of the added file before it is committed.
+ dotest_fail death2-diff-7 "${testcvs} -q diff file1" \
+"${PROG} [a-z]*: file1 is a new entry, no comparison available"
+
+ dotest_fail death2-diff-8 "${testcvs} -q diff -N -c file1" \
+"Index: file1
+===================================================================
+RCS file: file1
+diff -N file1
+\*\*\* /dev/null[ ][ ]*[a-zA-Z0-9: ]*
+--- ${tempname}[ ][ ]*[a-zA-Z0-9: ]*
+\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
+\*\*\* 0 \*\*\*\*
+--- 1 ----
+${PLUS} second revision"
+
+ dotest death2-10 "${testcvs} -q commit -m add" \
+"Checking in file1;
+${TESTDIR}/cvsroot/first-dir/file1,v <-- file1
+new revision: 1\.1\.2\.2; previous revision: 1\.1\.2\.1
+done"
+
+ # Back to the trunk.
+ dotest death2-11 "${testcvs} -q update -A" 'U file1' 'P file1'
+
+ # Add another file on the trunk.
+ echo "first revision" > file2
+ dotest death2-12 "${testcvs} add file2" \
+"${PROG}"' [a-z]*: scheduling file `file2'\'' for addition
+'"${PROG}"' [a-z]*: use '\''cvs commit'\'' to add this file permanently'
+ dotest death2-13 "${testcvs} -q commit -m add" \
+"RCS file: ${TESTDIR}/cvsroot/first-dir/file2,v
+done
+Checking in file2;
+${TESTDIR}/cvsroot/first-dir/file2,v <-- file2
+initial revision: 1\.1
+done"
+
+ # Back to the branch.
+ # The ``no longer in the repository'' message doesn't really
+ # look right to me, but that's what CVS currently prints for
+ # this case.
+ dotest death2-14 "${testcvs} -q update -r branch" \
+"U file1
+${PROG} [a-z]*: file2 is no longer in the repository" \
+"P file1
+${PROG} [a-z]*: file2 is no longer in the repository"
+
+ # Add a file on the branch with the same name.
+ echo "branch revision" > file2
+ dotest death2-15 "${testcvs} add file2" \
+"${PROG}"' [a-z]*: scheduling file `file2'\'' for addition on branch `branch'\''
+'"${PROG}"' [a-z]*: use '\''cvs commit'\'' to add this file permanently'
+ dotest death2-16 "${testcvs} -q commit -m add" \
+"Checking in file2;
+${TESTDIR}/cvsroot/first-dir/file2,v <-- file2
+new revision: 1\.1\.2\.1; previous revision: 1\.1
+done"
+
+ # Add a new file on the branch.
+ echo "first revision" > file3
+ dotest death2-17 "${testcvs} add file3" \
+"${PROG}"' [a-z]*: scheduling file `file3'\'' for addition on branch `branch'\''
+'"${PROG}"' [a-z]*: use '\''cvs commit'\'' to add this file permanently'
+ dotest death2-18 "${testcvs} -q commit -m add" \
+"RCS file: ${TESTDIR}/cvsroot/first-dir/Attic/file3,v
+done
+Checking in file3;
+${TESTDIR}/cvsroot/first-dir/Attic/file3,v <-- file3
+new revision: 1\.1\.2\.1; previous revision: 1\.1
+done"
+
+ # Test diff of a nonexistent tag
+ dotest_fail death2-diff-9 "${testcvs} -q diff -rtag -c file3" \
+"${PROG} [a-z]*: tag tag is not in file file3"
+
+ dotest_fail death2-diff-10 "${testcvs} -q diff -rtag -N -c file3" \
+"Index: file3
+===================================================================
+RCS file: file3
+diff -N file3
+\*\*\* /dev/null[ ][ ]*[a-zA-Z0-9: ]*
+--- ${tempname}[ ][ ]*[a-zA-Z0-9: ]*
+\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
+\*\*\* 0 \*\*\*\*
+--- 1 ----
+${PLUS} first revision"
+
+ dotest_fail death2-diff-11 "${testcvs} -q diff -rtag -c ." \
+"Index: file1
+===================================================================
+RCS file: ${TESTDIR}/cvsroot/first-dir/file1,v
+retrieving revision 1\.1
+retrieving revision 1\.1\.2\.2
+diff -c -r1\.1 -r1\.1\.2\.2
+\*\*\* file1[ ][ ]*[a-zA-Z0-9:./ ]*
+--- file1[ ][ ]*[a-zA-Z0-9:./ ]*
+\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
+\*\*\* 1 \*\*\*\*
+! first revision
+--- 1 ----
+! second revision
+${PROG} [a-z]*: tag tag is not in file file2
+${PROG} [a-z]*: tag tag is not in file file3"
+
+ dotest_fail death2-diff-12 "${testcvs} -q diff -rtag -c -N ." \
+"Index: file1
+===================================================================
+RCS file: ${TESTDIR}/cvsroot/first-dir/file1,v
+retrieving revision 1\.1
+retrieving revision 1\.1\.2\.2
+diff -c -r1\.1 -r1\.1\.2\.2
+\*\*\* file1[ ][ ]*[a-zA-Z0-9:./ ]*
+--- file1[ ][ ]*[a-zA-Z0-9:./ ]*
+\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
+\*\*\* 1 \*\*\*\*
+! first revision
+--- 1 ----
+! second revision
+Index: file2
+===================================================================
+RCS file: file2
+diff -N file2
+\*\*\* /dev/null[ ][ ]*[a-zA-Z0-9: ]*
+--- ${tempname}[ ][ ]*[a-zA-Z0-9: ]*
+\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
+\*\*\* 0 \*\*\*\*
+--- 1 ----
+${PLUS} branch revision
+Index: file3
+===================================================================
+RCS file: file3
+diff -N file3
+\*\*\* /dev/null[ ][ ]*[a-zA-Z0-9: ]*
+--- ${tempname}[ ][ ]*[a-zA-Z0-9: ]*
+\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
+\*\*\* 0 \*\*\*\*
+--- 1 ----
+${PLUS} first revision"
+
+ # Switch to the nonbranch tag.
+ dotest death2-19 "${testcvs} -q update -r tag" \
+"U file1
+${PROG} [a-z]*: file2 is no longer in the repository
+${PROG} [a-z]*: file3 is no longer in the repository" \
+"P file1
+${PROG} [a-z]*: file2 is no longer in the repository
+${PROG} [a-z]*: file3 is no longer in the repository"
+
+ dotest_fail death2-20 "test -f file2"
+
+ # Make sure diff only reports appropriate files.
+ dotest_fail death2-diff-13 "${testcvs} -q diff -r rdiff-tag" \
+"${PROG} [a-z]*: file1 is a new entry, no comparison available"
+
+ dotest_fail death2-diff-14 "${testcvs} -q diff -r rdiff-tag -c -N" \
+"Index: file1
+===================================================================
+RCS file: file1
+diff -N file1
+\*\*\* /dev/null[ ][ ]*[a-zA-Z0-9: ]*
+--- ${tempname}[ ][ ]*[a-zA-Z0-9: ]*
+\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
+\*\*\* 0 \*\*\*\*
+--- 1 ----
+${PLUS} first revision"
+
+ cd .. ; rm -rf first-dir ${CVSROOT_DIRNAME}/first-dir
+ ;;
+
branches)
# More branch tests, including branches off of branches
mkdir ${CVSROOT_DIRNAME}/first-dir
@@ -1401,37 +2590,38 @@ done'
'"${PROG}"' [a-z]*: scheduling file `file3'\'' for addition
'"${PROG}"' [a-z]*: scheduling file `file4'\'' for addition
'"${PROG}"' [a-z]*: use '\''cvs commit'\'' to add these files permanently'
- dotest branches-3 "${testcvs} -q ci -m add-it" \
-'RCS file: /tmp/cvs-sanity/cvsroot/first-dir/file1,v
+ dotest_lit branches-3 "${testcvs} -q ci -m add-it" <<HERE
+RCS file: ${TESTDIR}/cvsroot/first-dir/file1,v
done
Checking in file1;
-/tmp/cvs-sanity/cvsroot/first-dir/file1,v <-- file1
+${TESTDIR}/cvsroot/first-dir/file1,v <-- file1
initial revision: 1.1
done
-RCS file: /tmp/cvs-sanity/cvsroot/first-dir/file2,v
+RCS file: ${TESTDIR}/cvsroot/first-dir/file2,v
done
Checking in file2;
-/tmp/cvs-sanity/cvsroot/first-dir/file2,v <-- file2
+${TESTDIR}/cvsroot/first-dir/file2,v <-- file2
initial revision: 1.1
done
-RCS file: /tmp/cvs-sanity/cvsroot/first-dir/file3,v
+RCS file: ${TESTDIR}/cvsroot/first-dir/file3,v
done
Checking in file3;
-/tmp/cvs-sanity/cvsroot/first-dir/file3,v <-- file3
+${TESTDIR}/cvsroot/first-dir/file3,v <-- file3
initial revision: 1.1
done
-RCS file: /tmp/cvs-sanity/cvsroot/first-dir/file4,v
+RCS file: ${TESTDIR}/cvsroot/first-dir/file4,v
done
Checking in file4;
-/tmp/cvs-sanity/cvsroot/first-dir/file4,v <-- file4
+${TESTDIR}/cvsroot/first-dir/file4,v <-- file4
initial revision: 1.1
-done'
+done
+HERE
echo 4:trunk-2 >file4
dotest branches-3.2 "${testcvs} -q ci -m trunk-before-branch" \
-'Checking in file4;
-/tmp/cvs-sanity/cvsroot/first-dir/file4,v <-- file4
-new revision: 1.2; previous revision: 1.1
-done'
+"Checking in file4;
+${TESTDIR}/cvsroot/first-dir/file4,v <-- file4
+new revision: 1\.2; previous revision: 1\.1
+done"
dotest branches-4 "${testcvs} tag -b br1" "${PROG}"' [a-z]*: Tagging \.
T file1
T file2
@@ -1443,18 +2633,18 @@ T file4'
echo 2:br1 >file2
echo 4:br1 >file4
dotest branches-6 "${testcvs} -q ci -m modify" \
-'Checking in file1;
-/tmp/cvs-sanity/cvsroot/first-dir/file1,v <-- file1
-new revision: 1.1.2.1; previous revision: 1.1
+"Checking in file1;
+${TESTDIR}/cvsroot/first-dir/file1,v <-- file1
+new revision: 1\.1\.2\.1; previous revision: 1\.1
done
Checking in file2;
-/tmp/cvs-sanity/cvsroot/first-dir/file2,v <-- file2
-new revision: 1.1.2.1; previous revision: 1.1
+${TESTDIR}/cvsroot/first-dir/file2,v <-- file2
+new revision: 1\.1\.2\.1; previous revision: 1\.1
done
Checking in file4;
-/tmp/cvs-sanity/cvsroot/first-dir/file4,v <-- file4
-new revision: 1.2.2.1; previous revision: 1.2
-done'
+${TESTDIR}/cvsroot/first-dir/file4,v <-- file4
+new revision: 1\.2\.2\.1; previous revision: 1\.2
+done"
dotest branches-7 "${testcvs} -q tag -b brbr" 'T file1
T file2
T file3
@@ -1463,14 +2653,14 @@ T file4'
echo 1:brbr >file1
echo 4:brbr >file4
dotest branches-9 "${testcvs} -q ci -m modify" \
-'Checking in file1;
-/tmp/cvs-sanity/cvsroot/first-dir/file1,v <-- file1
-new revision: 1.1.2.1.2.1; previous revision: 1.1.2.1
+"Checking in file1;
+${TESTDIR}/cvsroot/first-dir/file1,v <-- file1
+new revision: 1\.1\.2\.1\.2\.1; previous revision: 1\.1\.2\.1
done
Checking in file4;
-/tmp/cvs-sanity/cvsroot/first-dir/file4,v <-- file4
-new revision: 1.2.2.1.2.1; previous revision: 1.2.2.1
-done'
+${TESTDIR}/cvsroot/first-dir/file4,v <-- file4
+new revision: 1\.2\.2\.1\.2\.1; previous revision: 1\.2\.2\.1
+done"
dotest branches-10 "cat file1 file2 file3 file4" '1:brbr
2:br1
3:ancest
@@ -1484,10 +2674,10 @@ done'
4:br1'
echo 4:br1-2 >file4
dotest branches-12.2 "${testcvs} -q ci -m change-on-br1" \
-'Checking in file4;
-/tmp/cvs-sanity/cvsroot/first-dir/file4,v <-- file4
-new revision: 1.2.2.2; previous revision: 1.2.2.1
-done'
+"Checking in file4;
+${TESTDIR}/cvsroot/first-dir/file4,v <-- file4
+new revision: 1\.2\.2\.2; previous revision: 1\.2\.2\.1
+done"
dotest branches-13 "${testcvs} -q update -A" '[UP] file1
[UP] file2
[UP] file4'
@@ -1498,13 +2688,13 @@ done'
echo 4:trunk-3 >file4
dotest branches-14.2 \
"${testcvs} -q ci -m trunk-change-after-branch" \
-'Checking in file4;
-/tmp/cvs-sanity/cvsroot/first-dir/file4,v <-- file4
-new revision: 1.3; previous revision: 1.2
-done'
+"Checking in file4;
+${TESTDIR}/cvsroot/first-dir/file4,v <-- file4
+new revision: 1\.3; previous revision: 1\.2
+done"
dotest branches-14.3 "${testcvs} log file4" \
-'
-RCS file: /tmp/cvs-sanity/cvsroot/first-dir/file4,v
+"
+RCS file: ${TESTDIR}/cvsroot/first-dir/file4,v
Working file: file4
head: 1\.3
branch:
@@ -1518,36 +2708,36 @@ total revisions: 6; selected revisions: 6
description:
----------------------------
revision 1\.3
-date: [0-9/: ]*; author: [a-z@][a-z@]*; state: Exp; lines: '"${PLUS}"'1 -1
+date: [0-9/: ]*; author: [a-z0-9@][a-z0-9@]*; state: Exp; lines: ${PLUS}1 -1
trunk-change-after-branch
----------------------------
revision 1\.2
-date: [0-9/: ]*; author: [a-z@][a-z@]*; state: Exp; lines: '"${PLUS}"'1 -1
+date: [0-9/: ]*; author: [a-z0-9@][a-z0-9@]*; state: Exp; lines: ${PLUS}1 -1
branches: 1\.2\.2;
trunk-before-branch
----------------------------
revision 1\.1
-date: [0-9/: ]*; author: [a-z@][a-z@]*; state: Exp;
+date: [0-9/: ]*; author: [a-z0-9@][a-z0-9@]*; state: Exp;
add-it
----------------------------
revision 1\.2\.2\.2
-date: [0-9/: ]*; author: [a-z@][a-z@]*; state: Exp; lines: '"${PLUS}"'1 -1
+date: [0-9/: ]*; author: [a-z0-9@][a-z0-9@]*; state: Exp; lines: ${PLUS}1 -1
change-on-br1
----------------------------
revision 1\.2\.2\.1
-date: [0-9/: ]*; author: [a-z@][a-z@]*; state: Exp; lines: '"${PLUS}"'1 -1
+date: [0-9/: ]*; author: [a-z0-9@][a-z0-9@]*; state: Exp; lines: ${PLUS}1 -1
branches: 1\.2\.2\.1\.2;
modify
----------------------------
revision 1\.2\.2\.1\.2\.1
-date: [0-9/: ]*; author: [a-z@][a-z@]*; state: Exp; lines: '"${PLUS}"'1 -1
+date: [0-9/: ]*; author: [a-z0-9@][a-z0-9@]*; state: Exp; lines: ${PLUS}1 -1
modify
-============================================================================='
+============================================================================="
dotest_status branches-14.4 1 \
"${testcvs} diff -c -r 1.1 -r 1.3 file4" \
-'Index: file4
+"Index: file4
===================================================================
-RCS file: /tmp/cvs-sanity/cvsroot/first-dir/file4,v
+RCS file: ${TESTDIR}/cvsroot/first-dir/file4,v
retrieving revision 1\.1
retrieving revision 1\.3
diff -c -r1\.1 -r1\.3
@@ -1557,12 +2747,12 @@ diff -c -r1\.1 -r1\.3
\*\*\* 1 \*\*\*\*
! 4:trunk-1
--- 1 ----
-! 4:trunk-3'
+! 4:trunk-3"
dotest_status branches-14.5 1 \
"${testcvs} diff -c -r 1.1 -r 1.2.2.1 file4" \
-'Index: file4
+"Index: file4
===================================================================
-RCS file: /tmp/cvs-sanity/cvsroot/first-dir/file4,v
+RCS file: ${TESTDIR}/cvsroot/first-dir/file4,v
retrieving revision 1\.1
retrieving revision 1\.2\.2\.1
diff -c -r1\.1 -r1\.2\.2\.1
@@ -1572,23 +2762,106 @@ diff -c -r1\.1 -r1\.2\.2\.1
\*\*\* 1 \*\*\*\*
! 4:trunk-1
--- 1 ----
-! 4:br1'
+! 4:br1"
dotest branches-15 \
"${testcvs} update -j 1.1.2.1 -j 1.1.2.1.2.1 file1" \
- 'RCS file: /tmp/cvs-sanity/cvsroot/first-dir/file1,v
-retrieving revision 1.1.2.1
-retrieving revision 1.1.2.1.2.1
-Merging differences between 1.1.2.1 and 1.1.2.1.2.1 into file1
-rcsmerge: warning: conflicts during merge'
+ "RCS file: ${TESTDIR}/cvsroot/first-dir/file1,v
+retrieving revision 1\.1\.2\.1
+retrieving revision 1\.1\.2\.1\.2\.1
+Merging differences between 1\.1\.2\.1 and 1\.1\.2\.1\.2\.1 into file1
+rcsmerge: warning: conflicts during merge"
dotest branches-16 "cat file1" '<<<<<<< file1
1:ancest
=======
1:brbr
->>>>>>> 1.1.2.1.2.1'
+[>]>>>>>> 1\.1\.2\.1\.2\.1'
+ cd ..
+
+ if test "$keep" = yes; then
+ echo Keeping ${TESTDIR} and exiting due to --keep
+ exit 0
+ fi
+
+ rm -rf ${CVSROOT_DIRNAME}/first-dir
+ rm -r first-dir
+ ;;
+
+ multibranch)
+ # Test the ability to have several branchpoints coming off the
+ # same revision.
+ mkdir ${CVSROOT_DIRNAME}/first-dir
+ dotest multibranch-1 "${testcvs} -q co first-dir" ''
+ cd first-dir
+ echo 1:trunk-1 >file1
+ dotest multibranch-2 "${testcvs} add file1" \
+"${PROG}"' [a-z]*: scheduling file `file1'\'' for addition
+'"${PROG}"' [a-z]*: use '\''cvs commit'\'' to add this file permanently'
+ dotest_lit multibranch-3 "${testcvs} -q ci -m add-it" <<HERE
+RCS file: ${TESTDIR}/cvsroot/first-dir/file1,v
+done
+Checking in file1;
+${TESTDIR}/cvsroot/first-dir/file1,v <-- file1
+initial revision: 1.1
+done
+HERE
+ dotest multibranch-4 "${testcvs} tag -b br1" \
+"${PROG} [a-z]*: Tagging \.
+T file1"
+ dotest multibranch-5 "${testcvs} tag -b br2" \
+"${PROG} [a-z]*: Tagging \.
+T file1"
+ dotest multibranch-6 "${testcvs} -q update -r br1" ''
+ echo on-br1 >file1
+ dotest multibranch-7 "${testcvs} -q ci -m modify-on-br1" \
+"Checking in file1;
+${TESTDIR}/cvsroot/first-dir/file1,v <-- file1
+new revision: 1\.1\.2\.1; previous revision: 1\.1
+done"
+ dotest multibranch-8 "${testcvs} -q update -r br2" '[UP] file1'
+ echo br2 adds a line >>file1
+ dotest multibranch-9 "${testcvs} -q ci -m modify-on-br2" \
+"Checking in file1;
+${TESTDIR}/cvsroot/first-dir/file1,v <-- file1
+new revision: 1\.1\.4\.1; previous revision: 1\.1
+done"
+ dotest multibranch-10 "${testcvs} -q update -r br1" '[UP] file1'
+ dotest multibranch-11 "cat file1" 'on-br1'
+ dotest multibranch-12 "${testcvs} -q update -r br2" '[UP] file1'
+ dotest multibranch-13 "cat file1" '1:trunk-1
+br2 adds a line'
+
+ dotest multibranch-14 "${testcvs} log file1" \
+"
+RCS file: ${TESTDIR}/cvsroot/first-dir/file1,v
+Working file: file1
+head: 1\.1
+branch:
+locks: strict
+access list:
+symbolic names:
+ br2: 1\.1\.0\.4
+ br1: 1\.1\.0\.2
+keyword substitution: kv
+total revisions: 3; selected revisions: 3
+description:
+----------------------------
+revision 1\.1
+date: [0-9/]* [0-9:]*; author: ${username}; state: Exp;
+branches: 1\.1\.2; 1\.1\.4;
+add-it
+----------------------------
+revision 1\.1\.4\.1
+date: [0-9/]* [0-9:]*; author: ${username}; state: Exp; lines: ${PLUS}1 -0
+modify-on-br2
+----------------------------
+revision 1\.1\.2\.1
+date: [0-9/]* [0-9:]*; author: ${username}; state: Exp; lines: ${PLUS}1 -1
+modify-on-br1
+============================================================================="
cd ..
if test "$keep" = yes; then
- echo Keeping /tmp/cvs-sanity and exiting due to --keep
+ echo Keeping ${TESTDIR} and exiting due to --keep
exit 0
fi
@@ -1601,7 +2874,7 @@ rcsmerge: warning: conflicts during merge'
mkdir import-dir ; cd import-dir
for i in 1 2 3 4 ; do
- echo imported file"$i" > imported-file"$i"
+ echo imported file"$i" > imported-f"$i"
done
# This directory should be on the default ignore list,
@@ -1609,8 +2882,8 @@ rcsmerge: warning: conflicts during merge'
mkdir RCS
echo ignore.me >RCS/ignore.me
- echo 'import should not expand $''Id$' >>imported-file2
- cp imported-file2 ../imported-file2-orig.tmp
+ echo 'import should not expand $''Id$' >>imported-f2
+ cp imported-f2 ../imported-f2-orig.tmp
if ${CVS} import -m first-import first-dir vendor-branch junk-1_0 ; then
echo "PASS: test 96" >>${LOGFILE}
@@ -1618,7 +2891,7 @@ rcsmerge: warning: conflicts during merge'
echo "FAIL: test 96" | tee -a ${LOGFILE} ; exit 1
fi
- if cmp ../imported-file2-orig.tmp imported-file2; then
+ if cmp ../imported-f2-orig.tmp imported-f2; then
pass 96.5
else
fail 96.5
@@ -1634,7 +2907,7 @@ rcsmerge: warning: conflicts during merge'
cd first-dir
for i in 1 2 3 4 ; do
- if [ -f imported-file"$i" ] ; then
+ if test -f imported-f"$i" ; then
echo "PASS: test 98-$i" >>${LOGFILE}
else
echo "FAIL: test 98-$i" | tee -a ${LOGFILE} ; exit 1
@@ -1647,18 +2920,15 @@ rcsmerge: warning: conflicts during merge'
fi
# remove
- rm imported-file1
- if ${CVS} rm imported-file1 2>> ${LOGFILE}; then
+ rm imported-f1
+ if ${CVS} rm imported-f1 2>> ${LOGFILE}; then
echo "PASS: test 99" >>${LOGFILE}
else
echo "FAIL: test 99" | tee -a ${LOGFILE} ; exit 1
fi
# change
- # this sleep is significant. Otherwise, on some machines, things happen so
- # fast that the file mod times do not differ.
- sleep 1
- echo local-change >> imported-file2
+ echo local-change >> imported-f2
# commit
if ${CVS} ci -m local-changes >> ${LOGFILE} 2>&1; then
@@ -1668,7 +2938,7 @@ rcsmerge: warning: conflicts during merge'
fi
# log
- if ${CVS} log imported-file1 | grep '1.1.1.2 (dead)' ; then
+ if ${CVS} log imported-f1 | grep '1.1.1.2 (dead)' ; then
echo "FAIL: test 101" | tee -a ${LOGFILE} ; exit 1
else
echo "PASS: test 101" >>${LOGFILE}
@@ -1682,16 +2952,16 @@ rcsmerge: warning: conflicts during merge'
fi
# remove file4 on the vendor branch
- rm imported-file4
+ rm imported-f4
- if ${CVS} rm imported-file4 2>> ${LOGFILE}; then
+ if ${CVS} rm imported-f4 2>> ${LOGFILE}; then
echo "PASS: test 103" >>${LOGFILE}
else
echo "FAIL: test 103" | tee -a ${LOGFILE} ; exit 1
fi
# commit
- if ${CVS} ci -m vendor-removed imported-file4 >>${LOGFILE}; then
+ if ${CVS} ci -m vendor-removed imported-f4 >>${LOGFILE}; then
echo "PASS: test 104" >>${LOGFILE}
else
echo "FAIL: test 104" | tee -a ${LOGFILE} ; exit 1
@@ -1707,16 +2977,16 @@ rcsmerge: warning: conflicts during merge'
# second import - file4 deliberately unchanged
cd ../import-dir
for i in 1 2 3 ; do
- echo rev 2 of file $i >> imported-file"$i"
+ echo rev 2 of file $i >> imported-f"$i"
done
- cp imported-file2 ../imported-file2-orig.tmp
+ cp imported-f2 ../imported-f2-orig.tmp
if ${CVS} import -m second-import first-dir vendor-branch junk-2_0 ; then
echo "PASS: test 106" >>${LOGFILE}
else
echo "FAIL: test 106" | tee -a ${LOGFILE} ; exit 1
fi
- if cmp ../imported-file2-orig.tmp imported-file2; then
+ if cmp ../imported-f2-orig.tmp imported-f2; then
pass 106.5
else
fail 106.5
@@ -1732,14 +3002,14 @@ rcsmerge: warning: conflicts during merge'
cd first-dir
- if [ -f imported-file1 ] ; then
+ if test -f imported-f1 ; then
echo "FAIL: test 108" | tee -a ${LOGFILE} ; exit 1
else
echo "PASS: test 108" >>${LOGFILE}
fi
for i in 2 3 ; do
- if [ -f imported-file"$i" ] ; then
+ if test -f imported-f"$i" ; then
echo "PASS: test 109-$i" >>${LOGFILE}
else
echo "FAIL: test 109-$i" | tee -a ${LOGFILE} ; exit 1
@@ -1753,7 +3023,7 @@ rcsmerge: warning: conflicts during merge'
echo "FAIL: test 110" | tee -a ${LOGFILE} ; exit 1
fi
- if [ -f imported-file4 ] ; then
+ if test -f imported-f4 ; then
echo "PASS: test 111" >>${LOGFILE}
else
echo "FAIL: test 111" | tee -a ${LOGFILE} ; exit 1
@@ -1768,37 +3038,386 @@ rcsmerge: warning: conflicts during merge'
cd ..
- if ${CVS} co -jjunk-1_0 -jjunk-2_0 first-dir >>${LOGFILE} 2>&1; then
- echo "PASS: test 113" >>${LOGFILE}
- else
- echo "FAIL: test 113" | tee -a ${LOGFILE} ; exit 1
- fi
+ dotest import-113 \
+"${testcvs} -q co -jjunk-1_0 -jjunk-2_0 first-dir" \
+"${PROG} [a-z]*: file first-dir/imported-f1 is present in revision junk-2_0
+RCS file: ${TESTDIR}/cvsroot/first-dir/imported-f2,v
+retrieving revision 1\.1\.1\.1
+retrieving revision 1\.1\.1\.2
+Merging differences between 1\.1\.1\.1 and 1\.1\.1\.2 into imported-f2
+rcsmerge: warning: conflicts during merge"
cd first-dir
- if [ -f imported-file1 ] ; then
+ if test -f imported-f1 ; then
echo "FAIL: test 114" | tee -a ${LOGFILE} ; exit 1
else
echo "PASS: test 114" >>${LOGFILE}
fi
for i in 2 3 ; do
- if [ -f imported-file"$i" ] ; then
+ if test -f imported-f"$i" ; then
echo "PASS: test 115-$i" >>${LOGFILE}
else
echo "FAIL: test 115-$i" | tee -a ${LOGFILE} ; exit 1
fi
done
- if cat imported-file2 | grep '====' >> ${LOGFILE}; then
- echo "PASS: test 116" >>${LOGFILE}
- else
- echo "FAIL: test 116" | tee -a ${LOGFILE} ; exit 1
- fi
+ dotest import-116 'cat imported-f2' \
+'imported file2
+[<]<<<<<< imported-f2
+import should not expand \$''Id: imported-f2,v 1\.2 [0-9/]* [0-9:]* [a-z0-9@][a-z0-9@]* Exp \$
+local-change
+[=]======
+import should not expand \$''Id: imported-f2,v 1\.1\.1\.2 [0-9/]* [0-9:]* [a-z0-9@][a-z0-9@]* Exp \$
+rev 2 of file 2
+[>]>>>>>> 1\.1\.1\.2'
+
cd .. ; rm -rf first-dir ${CVSROOT_DIRNAME}/first-dir
rm -rf import-dir
;;
+ join)
+ # Test doing joins which involve adding and removing files.
+ # See also binfile2, which does similar things with binary files.
+
+ # We check merging changes from T1 to T2 into the main line.
+ # Here are the interesting cases I can think of:
+ # 1) File added between T1 and T2, not on main line.
+ # File should be marked for addition.
+ # 2) File added between T1 and T2, also added on main line.
+ # Conflict.
+ # 3) File removed between T1 and T2, unchanged on main line.
+ # File should be marked for removal.
+ # 4) File removed between T1 and T2, modified on main line.
+ # If mod checked in, file should be marked for removal.
+ # If mod still in working directory, conflict.
+ # 5) File removed between T1 and T2, was never on main line.
+ # Nothing should happen.
+ # 6) File removed between T1 and T2, also removed on main line.
+ # Nothing should happen.
+ # 7) File added on main line, not added between T1 and T2.
+ # Nothing should happen.
+ # 8) File removed on main line, not modified between T1 and T2.
+ # Nothing should happen.
+
+ # We also check merging changes from a branch into the main
+ # line. Here are the interesting cases:
+ # 1) File added on branch, not on main line.
+ # File should be marked for addition.
+ # 2) File added on branch, also added on main line.
+ # Conflict.
+ # 3) File removed on branch, unchanged on main line.
+ # File should be marked for removal.
+ # 4) File removed on branch, modified on main line.
+ # Conflict.
+ # 5) File removed on branch, was never on main line.
+ # Nothing should happen.
+ # 6) File removed on branch, also removed on main line.
+ # Nothing should happen.
+ # 7) File added on main line, not added on branch.
+ # Nothing should happen.
+ # 8) File removed on main line, not modified on branch.
+ # Nothing should happen.
+
+ # In the tests below, fileN represents case N in the above
+ # lists.
+
+ mkdir ${CVSROOT_DIRNAME}/first-dir
+ mkdir 1
+ cd 1
+ dotest join-1 "${testcvs} -q co first-dir" ''
+
+ cd first-dir
+
+ # Add two files.
+ echo 'first revision of file3' > file3
+ echo 'first revision of file4' > file4
+ echo 'first revision of file6' > file6
+ echo 'first revision of file8' > file8
+ dotest join-2 "${testcvs} add file3 file4 file6 file8" \
+"${PROG}"' [a-z]*: scheduling file `file3'\'' for addition
+'"${PROG}"' [a-z]*: scheduling file `file4'\'' for addition
+'"${PROG}"' [a-z]*: scheduling file `file6'\'' for addition
+'"${PROG}"' [a-z]*: scheduling file `file8'\'' for addition
+'"${PROG}"' [a-z]*: use '\''cvs commit'\'' to add these files permanently'
+
+ dotest join-3 "${testcvs} -q commit -m add" \
+"RCS file: ${TESTDIR}/cvsroot/first-dir/file3,v
+done
+Checking in file3;
+${TESTDIR}/cvsroot/first-dir/file3,v <-- file3
+initial revision: 1\.1
+done
+RCS file: ${TESTDIR}/cvsroot/first-dir/file4,v
+done
+Checking in file4;
+${TESTDIR}/cvsroot/first-dir/file4,v <-- file4
+initial revision: 1\.1
+done
+RCS file: ${TESTDIR}/cvsroot/first-dir/file6,v
+done
+Checking in file6;
+${TESTDIR}/cvsroot/first-dir/file6,v <-- file6
+initial revision: 1\.1
+done
+RCS file: ${TESTDIR}/cvsroot/first-dir/file8,v
+done
+Checking in file8;
+${TESTDIR}/cvsroot/first-dir/file8,v <-- file8
+initial revision: 1\.1
+done"
+
+ # Make a branch.
+ dotest join-4 "${testcvs} -q tag -b branch ." \
+'T file3
+T file4
+T file6
+T file8'
+
+ # Add file2 and file7, modify file4, and remove file6 and file8.
+ echo 'first revision of file2' > file2
+ echo 'second revision of file4' > file4
+ echo 'first revision of file7' > file7
+ rm file6 file8
+ dotest join-5 "${testcvs} add file2 file7" \
+"${PROG}"' [a-z]*: scheduling file `file2'\'' for addition
+'"${PROG}"' [a-z]*: scheduling file `file7'\'' for addition
+'"${PROG}"' [a-z]*: use '\''cvs commit'\'' to add these files permanently'
+ dotest join-6 "${testcvs} rm file6 file8" \
+"${PROG}"' [a-z]*: scheduling `file6'\'' for removal
+'"${PROG}"' [a-z]*: scheduling `file8'\'' for removal
+'"${PROG}"' [a-z]*: use '\'"${PROG} commit"\'' to remove these files permanently'
+ dotest join-7 "${testcvs} -q ci -mx ." \
+"RCS file: ${TESTDIR}/cvsroot/first-dir/file2,v
+done
+Checking in file2;
+${TESTDIR}/cvsroot/first-dir/file2,v <-- file2
+initial revision: 1\.1
+done
+Checking in file4;
+${TESTDIR}/cvsroot/first-dir/file4,v <-- file4
+new revision: 1\.2; previous revision: 1\.1
+done
+Removing file6;
+${TESTDIR}/cvsroot/first-dir/file6,v <-- file6
+new revision: delete; previous revision: 1\.1
+done
+RCS file: ${TESTDIR}/cvsroot/first-dir/file7,v
+done
+Checking in file7;
+${TESTDIR}/cvsroot/first-dir/file7,v <-- file7
+initial revision: 1\.1
+done
+Removing file8;
+${TESTDIR}/cvsroot/first-dir/file8,v <-- file8
+new revision: delete; previous revision: 1\.1
+done"
+
+ # Check out the branch.
+ cd ../..
+ mkdir 2
+ cd 2
+ dotest join-8 "${testcvs} -q co -r branch first-dir" \
+'U first-dir/file3
+U first-dir/file4
+U first-dir/file6
+U first-dir/file8'
+
+ cd first-dir
+
+ # Modify the files on the branch, so that T1 is not an
+ # ancestor of the main line, and add file5
+ echo 'first branch revision of file3' > file3
+ echo 'first branch revision of file4' > file4
+ echo 'first branch revision of file6' > file6
+ echo 'first branch revision of file5' > file5
+ dotest join-9 "${testcvs} add file5" \
+"${PROG}"' [a-z]*: scheduling file `file5'\'' for addition on branch `branch'\''
+'"${PROG}"' [a-z]*: use '\''cvs commit'\'' to add this file permanently'
+ dotest join-10 "${testcvs} -q ci -mx ." \
+"Checking in file3;
+${TESTDIR}/cvsroot/first-dir/file3,v <-- file3
+new revision: 1\.1\.2\.1; previous revision: 1\.1
+done
+Checking in file4;
+${TESTDIR}/cvsroot/first-dir/file4,v <-- file4
+new revision: 1\.1\.2\.1; previous revision: 1\.1
+done
+RCS file: ${TESTDIR}/cvsroot/first-dir/Attic/file5,v
+done
+Checking in file5;
+${TESTDIR}/cvsroot/first-dir/Attic/file5,v <-- file5
+new revision: 1\.1\.2\.1; previous revision: 1\.1
+done
+Checking in file6;
+${TESTDIR}/cvsroot/first-dir/Attic/file6,v <-- file6
+new revision: 1\.1\.2\.1; previous revision: 1\.1
+done"
+
+ # Tag the current revisions on the branch.
+ dotest join-11 "${testcvs} -q tag T1 ." \
+'T file3
+T file4
+T file5
+T file6
+T file8'
+
+ # Add file1 and file2, and remove the other files.
+ echo 'first branch revision of file1' > file1
+ echo 'first branch revision of file2' > file2
+ rm file3 file4 file5 file6
+ dotest join-12 "${testcvs} add file1 file2" \
+"${PROG}"' [a-z]*: scheduling file `file1'\'' for addition on branch `branch'\''
+'"${PROG}"' [a-z]*: scheduling file `file2'\'' for addition on branch `branch'\''
+'"${PROG}"' [a-z]*: use '\''cvs commit'\'' to add these files permanently'
+ dotest join-13 "${testcvs} rm file3 file4 file5 file6" \
+"${PROG}"' [a-z]*: scheduling `file3'\'' for removal
+'"${PROG}"' [a-z]*: scheduling `file4'\'' for removal
+'"${PROG}"' [a-z]*: scheduling `file5'\'' for removal
+'"${PROG}"' [a-z]*: scheduling `file6'\'' for removal
+'"${PROG}"' [a-z]*: use '\'"${PROG} commit"\'' to remove these files permanently'
+ dotest join-14 "${testcvs} -q ci -mx ." \
+"RCS file: ${TESTDIR}/cvsroot/first-dir/Attic/file1,v
+done
+Checking in file1;
+${TESTDIR}/cvsroot/first-dir/Attic/file1,v <-- file1
+new revision: 1\.1\.2\.1; previous revision: 1\.1
+done
+Checking in file2;
+${TESTDIR}/cvsroot/first-dir/file2,v <-- file2
+new revision: 1\.1\.2\.1; previous revision: 1\.1
+done
+Removing file3;
+${TESTDIR}/cvsroot/first-dir/file3,v <-- file3
+new revision: delete; previous revision: 1\.1\.2\.1
+done
+Removing file4;
+${TESTDIR}/cvsroot/first-dir/file4,v <-- file4
+new revision: delete; previous revision: 1\.1\.2\.1
+done
+Removing file5;
+${TESTDIR}/cvsroot/first-dir/Attic/file5,v <-- file5
+new revision: delete; previous revision: 1\.1\.2\.1
+done
+Removing file6;
+${TESTDIR}/cvsroot/first-dir/Attic/file6,v <-- file6
+new revision: delete; previous revision: 1\.1\.2\.1
+done"
+
+ # Tag the current revisions on the branch.
+ dotest join-15 "${testcvs} -q tag T2 ." \
+'T file1
+T file2
+T file8'
+
+ # Do a checkout with a merge.
+ cd ../..
+ mkdir 3
+ cd 3
+ dotest join-16 "${testcvs} -q co -jT1 -jT2 first-dir" \
+'U first-dir/file1
+U first-dir/file2
+'"${PROG}"' [a-z]*: file first-dir/file2 exists, but has been added in revision T2
+U first-dir/file3
+'"${PROG}"' [a-z]*: scheduling first-dir/file3 for removal
+U first-dir/file4
+'"${PROG}"' [a-z]*: scheduling first-dir/file4 for removal
+U first-dir/file7'
+
+ # Verify that the right changes have been scheduled.
+ cd first-dir
+ dotest join-17 "${testcvs} -q update" \
+'A file1
+R file3
+R file4'
+
+ # Modify file4 locally, and do an update with a merge.
+ cd ../../1/first-dir
+ echo 'third revision of file4' > file4
+ dotest join-18 "${testcvs} -q update -jT1 -jT2 ." \
+'U file1
+'"${PROG}"' [a-z]*: file file2 exists, but has been added in revision T2
+'"${PROG}"' [a-z]*: scheduling file3 for removal
+M file4
+'"${PROG}"' [a-z]*: file file4 is locally modified, but has been removed in revision T2'
+
+ # Verify that the right changes have been scheduled.
+ dotest join-19 "${testcvs} -q update" \
+'A file1
+R file3
+M file4'
+
+ # Do a checkout with a merge from a single revision.
+
+ # FIXME: CVS currently gets this wrong. file2 has been
+ # added on both the branch and the main line, and so should
+ # be regarded as a conflict. However, given the way that
+ # CVS sets up the RCS file, there is no way to distinguish
+ # this case from the case of file2 having existed before the
+ # branch was made. This could be fixed by reserving
+ # a revision somewhere, perhaps 1.1, as an always dead
+ # revision which can be used as the source for files added
+ # on branches.
+ cd ../../3
+ rm -rf first-dir
+ dotest join-20 "${testcvs} -q co -jbranch first-dir" \
+"U first-dir/file1
+U first-dir/file2
+RCS file: ${TESTDIR}/cvsroot/first-dir/file2,v
+retrieving revision 1\.1
+retrieving revision 1\.1\.2\.1
+Merging differences between 1\.1 and 1\.1\.2\.1 into file2
+U first-dir/file3
+${PROG} [a-z]*: scheduling first-dir/file3 for removal
+U first-dir/file4
+${PROG} [a-z]*: file first-dir/file4 has been modified, but has been removed in revision branch
+U first-dir/file7"
+
+ # Verify that the right changes have been scheduled.
+ # The M file2 line is a bug; see above join-20.
+ cd first-dir
+ dotest join-21 "${testcvs} -q update" \
+'A file1
+M file2
+R file3'
+
+ # Checkout the main line again.
+ cd ../../1
+ rm -rf first-dir
+ dotest join-22 "${testcvs} -q co first-dir" \
+'U first-dir/file2
+U first-dir/file3
+U first-dir/file4
+U first-dir/file7'
+
+ # Modify file4 locally, and do an update with a merge from a
+ # single revision.
+ # The file2 handling is a bug; see above join-20.
+ cd first-dir
+ echo 'third revision of file4' > file4
+ dotest join-23 "${testcvs} -q update -jbranch ." \
+"U file1
+RCS file: ${TESTDIR}/cvsroot/first-dir/file2,v
+retrieving revision 1\.1
+retrieving revision 1\.1\.2\.1
+Merging differences between 1\.1 and 1\.1\.2\.1 into file2
+${PROG} [a-z]*: scheduling file3 for removal
+M file4
+${PROG} [a-z]*: file file4 is locally modified, but has been removed in revision branch"
+
+ # Verify that the right changes have been scheduled.
+ # The M file2 line is a bug; see above join-20
+ dotest join-24 "${testcvs} -q update" \
+'A file1
+M file2
+R file3
+M file4'
+
+ cd ../..
+ rm -rf 1 2 3 ${CVSROOT_DIRNAME}/first-dir
+ ;;
+
new) # look for stray "no longer pertinent" messages.
mkdir ${CVSROOT_DIRNAME}/first-dir
@@ -1852,38 +3471,128 @@ rcsmerge: warning: conflicts during merge'
cd .. ; rm -rf first-dir ; rm -rf ${CVSROOT_DIRNAME}/first-dir
;;
+ newb)
+ # Test removing a file on a branch and then checking it out.
+
+ # We call this "newb" only because it, like the "new" tests,
+ # has something to do with "no longer pertinent" messages.
+ # Not necessarily the most brilliant nomenclature.
+
+ # Create file 'a'.
+ mkdir ${CVSROOT_DIRNAME}/first-dir
+ dotest newb-123a "${testcvs} -q co first-dir" ''
+ cd first-dir
+ touch a
+ dotest newb-123b "${testcvs} add a" \
+"${PROG} [a-z]*: scheduling file .a. for addition
+${PROG} [a-z]*: use .cvs commit. to add this file permanently"
+ dotest newb-123c "${testcvs} -q ci -m added" \
+"RCS file: ${TESTDIR}/cvsroot/first-dir/a,v
+done
+Checking in a;
+${TESTDIR}/cvsroot/first-dir/a,v <-- a
+initial revision: 1\.1
+done"
+
+ # Make a branch.
+ dotest newb-123d "${testcvs} -q tag -b branch" "T a"
+
+ # Check out the branch.
+ cd ..
+ rm -rf first-dir
+ mkdir 1
+ cd 1
+ dotest newb-123e "${testcvs} -q co -r branch first-dir" \
+"U first-dir/a"
+
+ # Remove 'a' on another copy of the branch.
+ cd ..
+ mkdir 2
+ cd 2
+ dotest newb-123f "${testcvs} -q co -r branch first-dir" \
+"U first-dir/a"
+ cd first-dir
+ rm a
+ dotest newb-123g "${testcvs} rm a" \
+"${PROG} [a-z]*: scheduling .a. for removal
+${PROG} [a-z]*: use .${PROG} commit. to remove this file permanently"
+ dotest newb-123h "${testcvs} -q ci -m removed" \
+"Removing a;
+${TESTDIR}/cvsroot/first-dir/a,v <-- a
+new revision: delete; previous revision: 1\.1\.2
+done"
+
+ # Check out the file on the branch. This should report
+ # that the file is not pertinent, but it should not
+ # say anything else.
+ cd ..
+ rm -rf first-dir
+ dotest newb-123i "${testcvs} -q co -r branch first-dir/a" \
+"${PROG} [a-z]*: warning: first-dir/a is not (any longer) pertinent"
+
+ # Update the other copy, and make sure that a is removed.
+ cd ../1/first-dir
+ # "Needs Patch" is a rather strange output here. Something like
+ # "Removed in Repository" would make more sense.
+ # The "Need Checkout" output is what CVS does if configured
+ # --disable-server.
+ dotest newb-123j0 "${testcvs} status a" \
+"===================================================================
+File: a Status: Needs \(Patch\|Checkout\)
+
+ Working revision: 1\.1.*
+ Repository revision: 1\.1\.2\.1 ${TESTDIR}/cvsroot/first-dir/a,v
+ Sticky Tag: branch (branch: 1\.1\.2)
+ Sticky Date: (none)
+ Sticky Options: (none)"
+ dotest newb-123j "${testcvs} -q update" \
+"${PROG} [a-z]*: warning: a is not (any longer) pertinent"
+
+ if test -f a; then
+ fail newb-123k
+ else
+ pass newb-123k
+ fi
+
+ cd ../..
+ rm -rf 1 2 ; rm -rf ${CVSROOT_DIRNAME}/first-dir
+ ;;
+
conflicts)
- rm -rf first-dir ${CVSROOT_DIRNAME}/first-dir
mkdir ${CVSROOT_DIRNAME}/first-dir
mkdir 1
cd 1
- if ${CVS} co first-dir ; then
- echo 'PASS: test 124' >>${LOGFILE}
- else
- echo 'FAIL: test 124' | tee -a ${LOGFILE}
- fi
+ dotest conflicts-124 "${testcvs} -q co first-dir" ''
cd first-dir
touch a
- if ${CVS} add a 2>>${LOGFILE} ; then
- echo 'PASS: test 125' >>${LOGFILE}
- else
- echo 'FAIL: test 125' | tee -a ${LOGFILE}
- fi
-
- if ${CVS} ci -m added >>${LOGFILE} 2>&1; then
- echo 'PASS: test 126' >>${LOGFILE}
- else
- echo 'FAIL: test 126' | tee -a ${LOGFILE}
- fi
+ dotest conflicts-125 "${testcvs} add a" \
+"${PROG} [a-z]*: scheduling file .a. for addition
+${PROG} [a-z]*: use .cvs commit. to add this file permanently"
+ dotest conflicts-126 "${testcvs} -q ci -m added" \
+"RCS file: ${TESTDIR}/cvsroot/first-dir/a,v
+done
+Checking in a;
+${TESTDIR}/cvsroot/first-dir/a,v <-- a
+initial revision: 1\.1
+done"
cd ../..
mkdir 2
cd 2
+ # The need for TMPPWD here is a (minor) CVS bug; the
+ # output should use the name of the repository as specified.
+ dotest conflicts-126.5 "${testcvs} co -p first-dir" \
+"${PROG} [a-z]*: Updating first-dir
+===================================================================
+Checking out first-dir/a
+RCS: ${TMPPWD}/cvsroot/first-dir/a,v
+VERS: 1\.1
+\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*"
if ${CVS} co first-dir ; then
echo 'PASS: test 127' >>${LOGFILE}
else
@@ -1900,62 +3609,122 @@ rcsmerge: warning: conflicts during merge'
echo add a line >>a
mkdir dir1
dotest conflicts-127b "${testcvs} add dir1" \
-'Directory /tmp/cvs-sanity/cvsroot/first-dir/dir1 added to the repository'
+"Directory ${TESTDIR}/cvsroot/first-dir/dir1 added to the repository"
dotest conflicts-128 "${testcvs} -q ci -m changed" \
-'Checking in a;
-/tmp/cvs-sanity/cvsroot/first-dir/a,v <-- a
-new revision: 1.2; previous revision: 1.1
-done'
- cd ../../2/first-dir
+"Checking in a;
+${TESTDIR}/cvsroot/first-dir/a,v <-- a
+new revision: 1\.2; previous revision: 1\.1
+done"
+ cd ../..
+
+ # Similar to conflicts-126.5, but now the file has nonempty
+ # contents.
+ mkdir 3
+ cd 3
+ # The need for TMPPWD here is a (minor) CVS bug; the
+ # output should use the name of the repository as specified.
+ dotest conflicts-128.5 "${testcvs} co -p -l first-dir" \
+"${PROG} [a-z]*: Updating first-dir
+===================================================================
+Checking out first-dir/a
+RCS: ${TMPPWD}/cvsroot/first-dir/a,v
+VERS: 1\.2
+\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*
+add a line"
+ cd ..
+ rmdir 3
+
+ # Now go over the to the other working directory and
+ # start testing conflicts
+ cd 2/first-dir
echo add a conflicting line >>a
dotest_fail conflicts-129 "${testcvs} -q ci -m changed" \
"${PROG}"' [a-z]*: Up-to-date check failed for `a'\''
'"${PROG}"' \[[a-z]* aborted\]: correct above errors first!'
mkdir dir1
mkdir sdir
+ dotest conflicts-status-0 "${testcvs} status a" \
+"===================================================================
+File: a Status: Needs Merge
+
+ Working revision: 1\.1.*
+ Repository revision: 1\.2 ${TESTDIR}/cvsroot/first-dir/a,v
+ Sticky Tag: (none)
+ Sticky Date: (none)
+ Sticky Options: (none)"
dotest conflicts-130 "${testcvs} -q update" \
-'RCS file: /tmp/cvs-sanity/cvsroot/first-dir/a,v
-retrieving revision 1.1
-retrieving revision 1.2
-Merging differences between 1.1 and 1.2 into a
+"RCS file: ${TESTDIR}/cvsroot/first-dir/a,v
+retrieving revision 1\.1
+retrieving revision 1\.2
+Merging differences between 1\.1 and 1\.2 into a
rcsmerge: warning: conflicts during merge
-'"${PROG}"' [a-z]*: conflicts found in a
+${PROG} [a-z]*: conflicts found in a
C a
-'"${QUESTION}"' dir1
-'"${QUESTION}"' sdir' \
-''"${QUESTION}"' dir1
-'"${QUESTION}"' sdir
-RCS file: /tmp/cvs-sanity/cvsroot/first-dir/a,v
-retrieving revision 1.1
-retrieving revision 1.2
-Merging differences between 1.1 and 1.2 into a
+${QUESTION} dir1
+${QUESTION} sdir" \
+"${QUESTION} dir1
+${QUESTION} sdir
+RCS file: ${TESTDIR}/cvsroot/first-dir/a,v
+retrieving revision 1\.1
+retrieving revision 1\.2
+Merging differences between 1\.1 and 1\.2 into a
rcsmerge: warning: conflicts during merge
-'"${PROG}"' [a-z]*: conflicts found in a
-C a'
+${PROG} [a-z]*: conflicts found in a
+C a"
+ rmdir dir1 sdir
- # Try to check in the file with the conflict markers in it.
- if ${CVS} ci -m try 2>>${LOGFILE}; then
- echo 'FAIL: test 131' | tee -a ${LOGFILE}
- else
- # Should tell us to resolve conflict first
- echo 'PASS: test 131' >>${LOGFILE}
- fi
+ dotest conflicts-status-1 "${testcvs} status a" \
+"===================================================================
+File: a Status: File had conflicts on merge
+
+ Working revision: 1\.2.*
+ Repository revision: 1\.2 ${TESTDIR}/cvsroot/first-dir/a,v
+ Sticky Tag: (none)
+ Sticky Date: (none)
+ Sticky Options: (none)"
+ dotest_fail conflicts-131 "${testcvs} -q ci -m try" \
+"${PROG} [a-z]*: file .a. had a conflict and has not been modified
+${PROG} \[[a-z]* aborted\]: correct above errors first!"
echo lame attempt at resolving it >>a
# Try to check in the file with the conflict markers in it.
- if ${CVS} ci -m try >>${LOGFILE} 2>&1; then
- echo 'FAIL: test 132' | tee -a ${LOGFILE}
- else
- # Should tell us to resolve conflict first
- echo 'PASS: test 132' >>${LOGFILE}
- fi
+ dotest conflicts-status-2 "${testcvs} status a" \
+"===================================================================
+File: a Status: File had conflicts on merge
+
+ Working revision: 1\.2.*
+ Repository revision: 1\.2 ${TESTDIR}/cvsroot/first-dir/a,v
+ Sticky Tag: (none)
+ Sticky Date: (none)
+ Sticky Options: (none)"
+ dotest_fail conflicts-132 "${testcvs} -q ci -m try" \
+"${PROG} [a-z]*: file .a. still contains conflict indicators
+${PROG} \[[a-z]* aborted\]: correct above errors first!"
echo resolve conflict >a
- if ${CVS} ci -m resolved >>${LOGFILE} 2>&1; then
- echo 'PASS: test 133' >>${LOGFILE}
- else
- echo 'FAIL: test 133' | tee -a ${LOGFILE}
- fi
+ dotest conflicts-status-3 "${testcvs} status a" \
+"===================================================================
+File: a Status: File had conflicts on merge
+
+ Working revision: 1\.2.*
+ Repository revision: 1\.2 ${TESTDIR}/cvsroot/first-dir/a,v
+ Sticky Tag: (none)
+ Sticky Date: (none)
+ Sticky Options: (none)"
+ dotest conflicts-133 "${testcvs} -q ci -m resolved" \
+"Checking in a;
+${TESTDIR}/cvsroot/first-dir/a,v <-- a
+new revision: 1\.3; previous revision: 1\.2
+done"
+ dotest conflicts-status-4 "${testcvs} status a" \
+"===================================================================
+File: a Status: Up-to-date
+
+ Working revision: 1\.3.*
+ Repository revision: 1\.3 ${TESTDIR}/cvsroot/first-dir/a,v
+ Sticky Tag: (none)
+ Sticky Date: (none)
+ Sticky Options: (none)"
# Now test that we can add a file in one working directory
# and have an update in another get it.
@@ -1972,7 +3741,8 @@ C a'
echo 'FAIL: test 135' | tee -a ${LOGFILE}
fi
cd ../../2
- dotest conflicts-136 "${testcvs} -q update" \
+ mkdir first-dir/dir1 first-dir/sdir
+ dotest conflicts-136 "${testcvs} -q update first-dir" \
'[UP] first-dir/abc
'"${QUESTION}"' first-dir/dir1
'"${QUESTION}"' first-dir/sdir' \
@@ -2024,12 +3794,132 @@ C a'
else
echo 'FAIL: test 142' | tee -a ${LOGFILE}
fi
-
- cd ../..
+ cd ../..
rm -rf 1 2 3 ; rm -rf ${CVSROOT_DIRNAME}/first-dir
;;
+
+ conflicts2)
+ # More conflicts tests; separate from conflicts to keep each
+ # test a manageable size.
+ mkdir ${CVSROOT_DIRNAME}/first-dir
+
+ mkdir 1
+ cd 1
+
+ dotest conflicts2-142a1 "${testcvs} -q co first-dir" ''
+
+ cd first-dir
+ touch a abc
+
+ dotest conflicts2-142a2 "${testcvs} add a abc" \
+"${PROG} [a-z]*: scheduling file .a. for addition
+${PROG} [a-z]*: scheduling file .abc. for addition
+${PROG} [a-z]*: use .cvs commit. to add these files permanently"
+ dotest conflicts2-142a3 "${testcvs} -q ci -m added" \
+"RCS file: ${TESTDIR}/cvsroot/first-dir/a,v
+done
+Checking in a;
+${TESTDIR}/cvsroot/first-dir/a,v <-- a
+initial revision: 1\.1
+done
+RCS file: ${TESTDIR}/cvsroot/first-dir/abc,v
+done
+Checking in abc;
+${TESTDIR}/cvsroot/first-dir/abc,v <-- abc
+initial revision: 1\.1
+done"
+
+ cd ../..
+ mkdir 2
+ cd 2
+
+ dotest conflicts2-142a4 "${testcvs} -q co first-dir" 'U first-dir/a
+U first-dir/abc'
+ cd ..
+
+ # Now test that if one person modifies and commits a
+ # file and a second person removes it, it is a
+ # conflict
+ cd 1/first-dir
+ echo modify a >>a
+ dotest conflicts2-142b2 "${testcvs} -q ci -m modify-a" \
+"Checking in a;
+${TESTDIR}/cvsroot/first-dir/a,v <-- a
+new revision: 1\.2; previous revision: 1\.1
+done"
+ cd ../../2/first-dir
+ rm a
+ dotest conflicts2-142b3 "${testcvs} rm a" \
+"${PROG} [a-z]*: scheduling .a. for removal
+${PROG} [a-z]*: use .${PROG} commit. to remove this file permanently"
+ dotest_fail conflicts2-142b4 "${testcvs} -q update" \
+"${PROG} [a-z]*: conflict: removed a was modified by second party
+C a"
+ # Resolve the conflict by deciding not to remove the file
+ # after all.
+ dotest conflicts2-142b5 "${testcvs} add a" "U a
+${PROG} [a-z]*: a, version 1\.1, resurrected"
+ dotest conflicts2-142b6 "${testcvs} -q update" ''
+ cd ../..
+
+ # Now test that if one person removes a file and
+ # commits it, and a second person removes it, is it
+ # not a conflict.
+ cd 1/first-dir
+ rm abc
+ dotest conflicts2-142c0 "${testcvs} rm abc" \
+"${PROG} [a-z]*: scheduling .abc. for removal
+${PROG} [a-z]*: use .${PROG} commit. to remove this file permanently"
+ dotest conflicts2-142c1 "${testcvs} -q ci -m remove-abc" \
+"Removing abc;
+${TESTDIR}/cvsroot/first-dir/abc,v <-- abc
+new revision: delete; previous revision: 1\.1
+done"
+ cd ../../2/first-dir
+ rm abc
+ dotest conflicts2-142c2 "${testcvs} rm abc" \
+"${PROG} [a-z]*: scheduling .abc. for removal
+${PROG} [a-z]*: use .${PROG} commit. to remove this file permanently"
+ dotest conflicts2-142c3 "${testcvs} update" \
+"${PROG} [a-z]*: Updating \."
+ cd ../..
+
+ # conflicts2-142d*: test that if one party adds a file, and another
+ # party has a file of the same name, cvs notices
+ cd 1/first-dir
+ touch aa.c
+ dotest conflicts2-142d0 "${testcvs} add aa.c" \
+"${PROG} [a-z]*: scheduling file .aa\.c. for addition
+${PROG} [a-z]*: use .cvs commit. to add this file permanently"
+ dotest conflicts2-142d1 "${testcvs} -q ci -m added" \
+"RCS file: ${TESTDIR}/cvsroot/first-dir/aa.c,v
+done
+Checking in aa.c;
+${TESTDIR}/cvsroot/first-dir/aa.c,v <-- aa.c
+initial revision: 1\.1
+done"
+ cd ../../2/first-dir
+ echo "don't you dare obliterate this text" >aa.c
+ # Doing this test separately for remote and local is a fair
+ # bit of a kludge, but the exit status differs. I'm not sure
+ # which exit status is the more appropriate one.
+ if test "$remote" = yes; then
+ dotest conflicts2-142d2 "${testcvs} -q update" \
+"${QUESTION} aa\.c
+U aa\.c
+${PROG} update: move away \./aa\.c; it is in the way"
+ else
+ dotest_fail conflicts2-142d2 "${testcvs} -q update" \
+"${PROG} [a-z]*: move away aa\.c; it is in the way
+C aa\.c"
+ fi
+ cd ../..
+
+ rm -rf 1 2 ; rm -rf ${CVSROOT_DIRNAME}/first-dir
+ ;;
+
modules)
- rm -rf first-dir ${CVSROOT_DIRNAME}/first-dir
+ # Tests of various ways to define and use modules.
mkdir ${CVSROOT_DIRNAME}/first-dir
mkdir 1
@@ -2085,11 +3975,13 @@ C a'
exit 1
fi
- echo realmodule first-dir/subdir a >>CVSROOT/modules
+ echo realmodule first-dir/subdir a >CVSROOT/modules
echo dirmodule first-dir/subdir >>CVSROOT/modules
echo namedmodule -d nameddir first-dir/subdir >>CVSROOT/modules
echo aliasmodule -a first-dir/subdir/a >>CVSROOT/modules
echo aliasnested -a first-dir/subdir/ssdir >>CVSROOT/modules
+ echo topfiles -a first-dir/file1 first-dir/file2 >>CVSROOT/modules
+ echo world -a . >>CVSROOT/modules
# Options must come before arguments. It is possible this should
# be relaxed at some point (though the result would be bizarre for
@@ -2103,18 +3995,19 @@ C a'
exit 1
fi
cd ..
- dotest 148a0 "${testcvs} co -c" 'CVSROOT CVSROOT
-aliasmodule -a first-dir/subdir/a
+ dotest 148a0 "${testcvs} co -c" 'aliasmodule -a first-dir/subdir/a
aliasnested -a first-dir/subdir/ssdir
bogusalias first-dir/subdir/a -a
dirmodule first-dir/subdir
namedmodule -d nameddir first-dir/subdir
-realmodule first-dir/subdir a'
+realmodule first-dir/subdir a
+topfiles -a first-dir/file1 first-dir/file2
+world -a .'
# I don't know why aliasmodule isn't printed (I would have thought
# that it gets printed without the -a; although I'm not sure that
# printing expansions without options is useful).
- dotest 148a1 "${testcvs} co -s" 'CVSROOT NONE CVSROOT
-bogusalias NONE first-dir/subdir/a -a
+ dotest 148a1 "${testcvs} co -s" \
+'bogusalias NONE first-dir/subdir/a -a
dirmodule NONE first-dir/subdir
namedmodule NONE first-dir/subdir
realmodule NONE first-dir/subdir a'
@@ -2258,12 +4151,313 @@ U nameddir/b'
dotest modules-155a2 "test -d first-dir/subdir" ''
dotest modules-155a3 "test -d first-dir/subdir/ssdir" ''
# Test that nothing extraneous got created.
- dotest modules-155a4 "ls -1" "first-dir"
+ dotest modules-155a4 "ls" "first-dir" \
+"CVS
+first-dir"
cd ..
rm -rf 2
+ # Test checking out everything.
+ mkdir 1
+ cd 1
+ dotest modules-155b "${testcvs} -q co world" \
+"U CVSROOT/${DOTSTAR}
+U first-dir/subdir/a
+U first-dir/subdir/b"
+ cd ..
+ rm -rf 1
+
+ # Test checking out a module which lists at least two
+ # specific files twice. At one time, this failed over
+ # remote CVS.
+ mkdir 1
+ cd 1
+ dotest modules-155c1 "${testcvs} -q co first-dir" \
+"U first-dir/subdir/a
+U first-dir/subdir/b"
+
+ cd first-dir
+ echo 'first revision' > file1
+ echo 'first revision' > file2
+ dotest modules-155c2 "${testcvs} add file1 file2" \
+"${PROG}"' [a-z]*: scheduling file `file1'\'' for addition
+'"${PROG}"' [a-z]*: scheduling file `file2'\'' for addition
+'"${PROG}"' [a-z]*: use '\''cvs commit'\'' to add these files permanently'
+ dotest modules-155c3 "${testcvs} -q ci -m add-it" \
+"RCS file: ${TESTDIR}/cvsroot/first-dir/file1,v
+done
+Checking in file1;
+${TESTDIR}/cvsroot/first-dir/file1,v <-- file1
+initial revision: 1\.1
+done
+RCS file: ${TESTDIR}/cvsroot/first-dir/file2,v
+done
+Checking in file2;
+${TESTDIR}/cvsroot/first-dir/file2,v <-- file2
+initial revision: 1\.1
+done"
+
+ cd ..
+ rm -rf first-dir
+ dotest modules-155c4 "${testcvs} -q co topfiles" \
+"U first-dir/file1
+U first-dir/file2"
+ dotest modules-155c5 "${testcvs} -q co topfiles" ""
+ cd ..
+ rm -rf 1
+
+ rm -rf ${CVSROOT_DIRNAME}/first-dir
+ ;;
+
+ modules2)
+ # More tests of modules, in particular the & feature.
+ mkdir ${CVSROOT_DIRNAME}/first-dir
+ mkdir ${CVSROOT_DIRNAME}/second-dir
+
+ mkdir 1
+ cd 1
+
+ dotest modules2-1 "${testcvs} -q co CVSROOT/modules" \
+'U CVSROOT/modules'
+ cd CVSROOT
+ echo 'ampermodule &first-dir &second-dir' > modules
+ # Depending on whether the user also ran the modules test
+ # we will be checking in revision 1.2 or 1.3.
+ dotest modules2-2 "${testcvs} -q ci -m add-modules" \
+"Checking in modules;
+${TESTDIR}/cvsroot/CVSROOT/modules,v <-- modules
+new revision: 1\.[0-9]*; previous revision: 1\.[0-9]*
+done
+${PROG} [a-z]*: Rebuilding administrative file database"
+
+ cd ..
+
+ dotest modules2-3 "${testcvs} -q co ampermodule" ''
+ dotest modules2-4 "test -d ampermodule/first-dir" ''
+ dotest modules2-5 "test -d ampermodule/second-dir" ''
+
+ # Test ability of cvs release to handle multiple arguments
+ cd ampermodule
+ if ${testcvs} release -d first-dir second-dir <<EOF >>${LOGFILE}
+yes
+yes
+EOF
+ then
+ pass modules2-6
+ else
+ fail modules2-6
+ fi
+ dotest_fail modules2-7 "test -d first-dir" ''
+ dotest_fail modules2-8 "test -d second-dir" ''
+
+ cd ..
+
+ # Test that CVS gives an error if one combines -a with
+ # other options.
+ cd CVSROOT
+ echo 'aliasopt -a -d onedir first-dir' >modules
+ dotest modules2-a0 "${testcvs} -q ci -m add-modules" \
+"Checking in modules;
+${TESTDIR}/cvsroot/CVSROOT/modules,v <-- modules
+new revision: 1\.[0-9]*; previous revision: 1\.[0-9]*
+done
+${PROG} [a-z]*: Rebuilding administrative file database"
+ cd ..
+ dotest_fail modules2-a1 "${testcvs} -q co aliasopt" \
+"${PROG} [a-z]*: -a cannot be specified in the modules file along with other options" \
+"${PROG} [a-z]*: -a cannot be specified in the modules file along with other options
+${PROG} \[[a-z]* aborted\]: cannot expand modules"
+
+ # Clean up.
+ rm -rf CVSROOT
+ cd ..
+ rm -rf 1
+ rm -rf ${CVSROOT_DIRNAME}/first-dir
+ rm -rf ${CVSROOT_DIRNAME}/second-dir
+ ;;
+
+ modules3)
+ # More tests of modules, in particular what happens if several
+ # modules point to the same file.
+
+ # First just set up a directory first-dir and a file file1 in it.
+ mkdir 1; cd 1
+
+ dotest modules3-0 "${testcvs} -q co -l ." ''
+ mkdir first-dir
+ dotest modules3-1 "${testcvs} add first-dir" \
+"Directory ${TESTDIR}/cvsroot/first-dir added to the repository"
+
+ cd first-dir
+ echo file1 >file1
+ dotest modules3-2 "${testcvs} add file1" \
+"${PROG}"' [a-z]*: scheduling file `file1'\'' for addition
+'"${PROG}"' [a-z]*: use '\''cvs commit'\'' to add this file permanently'
+ dotest modules3-3 "${testcvs} -q ci -m add-it" \
+"RCS file: ${TESTDIR}/cvsroot/first-dir/file1,v
+done
+Checking in file1;
+${TESTDIR}/cvsroot/first-dir/file1,v <-- file1
+initial revision: 1\.1
+done"
+ cd ..
+
+ dotest modules3-4 "${testcvs} -q co CVSROOT/modules" \
+'U CVSROOT/modules'
+ cd CVSROOT
+ cat >modules <<EOF
+mod1 -a first-dir/file1
+bigmod -a mod1 first-dir/file1
+namednest -d src/sub/dir first-dir
+nestdeeper -d src/sub1/sub2/sub3/dir first-dir
+nestshallow -d src/dir second-dir/suba/subb
+path/in/modules &mod1
+EOF
+ dotest modules3-5 "${testcvs} -q ci -m add-modules" \
+"Checking in modules;
+${TESTDIR}/cvsroot/CVSROOT/modules,v <-- modules
+new revision: 1\.[0-9]*; previous revision: 1\.[0-9]*
+done
+${PROG} [a-z]*: Rebuilding administrative file database"
+ cd ..
+
+ dotest modules3-6 "${testcvs} -q co bigmod" ''
+ rm -rf first-dir
+ dotest modules3-7 "${testcvs} -q co bigmod" 'U first-dir/file1'
+ cd ..
+ rm -r 1
+
+ mkdir 1; cd 1
+ mkdir suba
+ mkdir suba/subb
+ # This fails to work remote (it doesn't notice the directories,
+ # I suppose because they contain no files). Bummer, especially
+ # considering this is a documented technique and everything.
+ dotest modules3-7a \
+"${testcvs} import -m add-dirs second-dir tag1 tag2" \
+"${PROG} [a-z]*: Importing ${TESTDIR}/cvsroot/second-dir/suba
+${PROG} [a-z]*: Importing ${TESTDIR}/cvsroot/second-dir/suba/subb
+
+No conflicts created by this import" "
+No conflicts created by this import"
+ cd ..; rm -r 1
+ mkdir 1; cd 1
+ dotest modules3-7b "${testcvs} co second-dir" \
+"${PROG} [a-z]*: Updating second-dir
+${PROG} [a-z]*: Updating second-dir/suba
+${PROG} [a-z]*: Updating second-dir/suba/subb" \
+"${PROG} server: Updating second-dir"
+
+ if test "x$remote" = xyes; then
+ cd second-dir
+ mkdir suba
+ dotest modules3-7-workaround1 "${testcvs} add suba" \
+"Directory ${TESTDIR}/cvsroot/second-dir/suba added to the repository"
+ cd suba
+ mkdir subb
+ dotest modules3-7-workaround2 "${testcvs} add subb" \
+"Directory ${TESTDIR}/cvsroot/second-dir/suba/subb added to the repository"
+ cd ../..
+ fi
+
+ cd second-dir/suba/subb
+ touch fileb
+ dotest modules3-7c "${testcvs} add fileb" \
+"${PROG} [a-z]*: scheduling file .fileb. for addition
+${PROG} [a-z]*: use .cvs commit. to add this file permanently"
+ dotest modules3-7d "${testcvs} -q ci -m add-it" \
+"RCS file: ${TESTDIR}/cvsroot/second-dir/suba/subb/fileb,v
+done
+Checking in fileb;
+${TESTDIR}/cvsroot/second-dir/suba/subb/fileb,v <-- fileb
+initial revision: 1\.1
+done"
+ cd ../../..
+ cd ..; rm -r 1
+
+ mkdir 1; cd 1
+ dotest modules3-7e "${testcvs} -q co nestshallow" \
+"U src/dir/fileb"
+
+ # Using ${TESTDIR}/cvsroot/second-dir/suba instead of
+ # ${TESTDIR}/cvsroot/second-dir seems wrong, it seems like the
+ # 30 Dec 1996 change to build_dirs_and_chdir simply failed
+ # to consider what to put in CVS/Repository.
+ # Remote does "${TESTDIR}/cvsroot/\." which seems equally wrong,
+ # if in a different way, but variety is the spice of life,
+ # eh?
+ dotest modules3-7f "cat CVS/Repository" \
+"${TESTDIR}/cvsroot/second-dir/suba" "${TESTDIR}/cvsroot/\."
+
+ dotest modules3-7g "cat src/CVS/Repository" \
+"${TESTDIR}/cvsroot/second-dir/suba"
+ dotest modules3-7h "cat src/dir/CVS/Repository" \
+"${TESTDIR}/cvsroot/second-dir/suba/subb"
+ cd ..; rm -r 1
+
+ mkdir 1
+ cd 1
+ dotest modules3-8 "${testcvs} -q co namednest" \
+'U src/sub/dir/file1'
+ dotest modules3-9 "test -f src/sub/dir/file1" ''
+ cd ..
+ rm -r 1
+
+ # Try the same thing, but with the directories nested even
+ # deeper (deeply enough so they are nested more deeply than
+ # the number of directories from / to ${TESTDIR}).
+ mkdir 1
+ cd 1
+ dotest modules3-10 "${testcvs} -q co nestdeeper" \
+'U src/sub1/sub2/sub3/dir/file1'
+ dotest modules3-11 "test -f src/sub1/sub2/sub3/dir/file1" ''
+
+ # While we are doing things like twisted uses of '/' (e.g.
+ # modules3-12), try this one.
+ if test "x$remote" = xyes; then
+ dotest_fail modules3-11b \
+"${testcvs} -q update ${TESTDIR}/1/src/sub1/sub2/sub3/dir/file1" \
+"${PROG} .server aborted.: absolute pathname .${TESTDIR}/1/src/sub1/sub2/sub3/dir/file1. illegal for server"
+ fi # end of remote-only tests
+
+ cd ..
+ rm -r 1
+
+ # This one is almost too twisted for words. The pathname output
+ # in the message from "co" doesn't include the "path/in/modules",
+ # but those directories do get created (with no CVSADM except
+ # in "modules" which has a CVSNULLREPOS).
+ # I'm not sure anyone is relying on this nonsense or whether we
+ # need to keep doing it, but it is what CVS currently does...
+ # Skip it for remote; the remote code has the good sense to
+ # not deal with it (on the minus side it gives
+ # "internal error: repository string too short." instead of a
+ # real error).
+ # I kind of suspect that it would be OK to just make it a fatal
+ # error to have '/' in a module name.
+ if test "x$remote" = xno; then
+ mkdir 1; cd 1
+ dotest modules3-12 "${testcvs} -q co path/in/modules" \
+"U first-dir/file1"
+ dotest modules3-13 "test -f path/in/modules/first-dir/file1" ''
+ cd ..; rm -r 1
+
+ # Now here is where it gets seriously bogus.
+ mkdir 1; cd 1
+ dotest modules3-14 \
+"${testcvs} -q rtag tag1 path/in/modules" ''
+ # CVS creates this even though rtag should *never* affect
+ # the directory current when it is called!
+ dotest modules3-15 "test -d path/in/modules" ''
+ # Just for trivia's sake, rdiff is not similarly vulnerable
+ # because it passes 0 for run_module_prog to do_module.
+ cd ..; rm -r 1
+ fi # end of tests skipped for remote
+
rm -rf ${CVSROOT_DIRNAME}/first-dir
+ rm -rf ${CVSROOT_DIRNAME}/second-dir
;;
+
mflag)
for message in '' ' ' '
' ' test' ; do
@@ -2355,7 +4549,7 @@ U nameddir/b'
fi
chmod a-w 1dir
cd ../1/1dir
- rm foo;
+ rm foo;
if ${testcvs} rm foo >>${LOGFILE} 2>&1; then
echo 'PASS: test 166' >>${LOGFILE}
else
@@ -2556,6 +4750,11 @@ EOF
fi
dotest devcom-a0 "${testcvs} watchers" ''
+
+ # FIXME: This probably should be an error message instead
+ # of silently succeeding and printing nothing.
+ dotest devcom-a-nonexist "${testcvs} watchers nonexist" ''
+
dotest devcom-a1 "${testcvs} watch add" ''
dotest devcom-a2 "${testcvs} watchers" \
'abb [a-z0-9]* edit unedit commit
@@ -2564,12 +4763,160 @@ abc [a-z0-9]* edit unedit commit'
dotest devcom-a4 "${testcvs} watchers abb" \
'abb [a-z0-9]* edit commit'
+ # Check tagging and checking out while we have a CVS
+ # directory in the repository.
+ dotest devcom-t0 "${testcvs} -q tag tag" \
+'T abb
+T abc'
+ cd ../..
+ mkdir 3
+ cd 3
+
+ # Test commented out because the bug it tests for is not fixed
+ # The error is:
+ # cvs watchers: cannot open CVS/Entries for reading: No such file or directory
+ # cvs: ../../work/ccvs/src/fileattr.c:75: fileattr_read: Assertion `fileattr_stored_repos != ((void *)0)' failed.
+: dotest devcom-t-nonexist "${testcvs} watchers nonexist" fixme
+
+ dotest devcom-t1 "${testcvs} -q co -rtag first-dir/abb" \
+'U first-dir/abb'
+ cd ..
+ rm -rf 3
+
+ # Now remove all the file attributes
+ cd 2/first-dir
+ dotest devcom-b0 "${testcvs} watch off" ''
+ dotest devcom-b1 "${testcvs} watch remove" ''
+ # Test that CVS 1.6 and earlier can handle the repository.
+ dotest_fail devcom-b2 "test -d ${CVSROOT_DIRNAME}/first-dir/CVS"
+
+ # Now test watching just some, not all, files.
+ dotest devcom-some0 "${testcvs} watch on abc" ''
+ cd ../..
+ mkdir 3
+ cd 3
+ dotest devcom-some1 "${testcvs} -q co first-dir" 'U first-dir/abb
+U first-dir/abc'
+ dotest devcom-some2 "test -w first-dir/abb" ''
+ dotest_fail devcom-some3 "test -w first-dir/abc" ''
+ cd ..
+
+ if test "$keep" = yes; then
+ echo Keeping ${TESTDIR} and exiting due to --keep
+ exit 0
+ fi
+
+ rm -rf 1 2 3 ${CVSROOT_DIRNAME}/first-dir
+ ;;
+
+ devcom2)
+ # More watch tests, most notably setting watches on
+ # files in various different states.
+ mkdir ${CVSROOT_DIRNAME}/first-dir
+ mkdir 1
+ cd 1
+ dotest devcom2-1 "${testcvs} -q co first-dir" ''
+ cd first-dir
+
+ # This should probably be an error; setting a watch on a totally
+ # unknown file is more likely to be a typo than intentional.
+ # But that isn't the currently implemented behavior.
+ dotest devcom2-2 "${testcvs} watch on w1" ''
+
+ touch w1 w2 w3 nw1
+ dotest devcom2-3 "${testcvs} add w1 w2 w3 nw1" "${DOTSTAR}"
+ # Letting the user set the watch here probably can be considered
+ # a feature--although it leads to a few potentially strange
+ # consequences like one user can set the watch and another actually
+ # adds the file.
+ dotest devcom2-4 "${testcvs} watch on w2" ''
+ dotest devcom2-5 "${testcvs} -q ci -m add-them" "${DOTSTAR}"
+
+ # Note that this test differs in a subtle way from devcom-some0;
+ # in devcom-some0 the watch is creating a new fileattr file, and
+ # here we are modifying an existing one.
+ dotest devcom2-6 "${testcvs} watch on w3" ''
+
+ # Now test that all the watches got set on the correct files
+ # FIXME: CVS should have a way to report whether watches are
+ # set, I think. The "check it out and see if it read-only" is
+ # sort of OK, but is complicated by CVSREAD and doesn't help
+ # if the file is added and not yet committed or some such.
+ # Probably "cvs status" should report "watch: on" if watch is on
+ # (and nothing if watch is off, so existing behavior is preserved).
cd ../..
+ mkdir 2
+ cd 2
+ dotest devcom2-7 "${testcvs} -q co first-dir" 'U first-dir/nw1
+U first-dir/w1
+U first-dir/w2
+U first-dir/w3'
+ dotest devcom2-8 "test -w first-dir/nw1" ''
+ dotest_fail devcom2-9 "test -w first-dir/w1" ''
+ dotest_fail devcom2-10 "test -w first-dir/w2" ''
+ dotest_fail devcom2-11 "test -w first-dir/w3" ''
+ cd ..
+
rm -rf 1 2 ${CVSROOT_DIRNAME}/first-dir
;;
+ devcom3)
+ # More watch tests, most notably handling of features designed
+ # for future expansion.
+ mkdir ${CVSROOT_DIRNAME}/first-dir
+ mkdir 1
+ cd 1
+ dotest devcom3-1 "${testcvs} -q co first-dir" ''
+ cd first-dir
+
+ touch w1 w2
+ dotest devcom3-2 "${testcvs} add w1 w2" "${DOTSTAR}"
+ dotest devcom3-3 "${testcvs} watch on w1 w2" ''
+ dotest devcom3-4 "${testcvs} -q ci -m add-them" "${DOTSTAR}"
+
+ # OK, since we are about to delve into CVS's internals, make
+ # sure that we seem to be correct about how they work.
+ dotest devcom3-5 "cat ${CVSROOT_DIRNAME}/first-dir/CVS/fileattr" \
+"Fw1 _watched=
+Fw2 _watched="
+ # Now write a few more lines, just as if we were a newer version
+ # of CVS implementing some new feature.
+ cat <<EOF >>${CVSROOT_DIRNAME}/first-dir/CVS/fileattr
+Enew line here
+G@#$^!@#=&
+EOF
+ # Now get CVS to write to the fileattr file....
+ dotest devcom3-6 "${testcvs} watch off w1" ''
+ # ...and make sure that it hasn't clobbered our new lines.
+ # Note that writing these lines in another order would be OK
+ # too.
+ dotest devcom3-7 "cat ${CVSROOT_DIRNAME}/first-dir/CVS/fileattr" \
+"Fw2 _watched=
+G@#..!@#=&
+Enew line here"
+
+ # See what CVS does when a file name is duplicated. The
+ # behavior of all versions of CVS since file attributes were
+ # implemented is that it nukes the duplications. This seems
+ # reasonable enough, although it means it isn't clear how
+ # useful duplicates would be for purposes of future
+ # expansion. But in the interests of keeping behaviors
+ # predictable, might as well test for it, I guess.
+ echo 'Fw2 duplicate=' >>${CVSROOT_DIRNAME}/first-dir/CVS/fileattr
+ dotest devcom3-8 "${testcvs} watch on w1" ''
+ dotest devcom3-9 "cat ${CVSROOT_DIRNAME}/first-dir/CVS/fileattr" \
+"Fw2 _watched=
+Fw1 _watched=
+Enew line here
+G@#..!@#=&"
+
+ cd ../..
+
+ rm -rf 1 ${CVSROOT_DIRNAME}/first-dir
+ ;;
+
ignore)
- dotest 187a1 "${testcvs} -q co CVSROOT" 'U CVSROOT/modules'
+ dotest 187a1 "${testcvs} -q co CVSROOT" "U CVSROOT/${DOTSTAR}"
cd CVSROOT
echo rootig.c >cvsignore
dotest 187a2 "${testcvs} add cvsignore" "${PROG}"' [a-z]*: scheduling file `cvsignore'"'"' for addition
@@ -2578,13 +4925,13 @@ abc [a-z0-9]* edit unedit commit'
# As of Jan 96, local CVS prints "Examining ." and remote doesn't.
# Accept either.
dotest 187a3 " ${testcvs} ci -m added" \
-"${DOTSTAR}"'CS file: /tmp/cvs-sanity/cvsroot/CVSROOT/cvsignore,v
+"${DOTSTAR}CS file: ${TESTDIR}/cvsroot/CVSROOT/cvsignore,v
done
Checking in cvsignore;
-/tmp/cvs-sanity/cvsroot/CVSROOT/cvsignore,v <-- cvsignore
-initial revision: 1.1
+${TESTDIR}/cvsroot/CVSROOT/cvsignore,v <-- cvsignore
+initial revision: 1\.1
done
-'"${PROG}"' [a-z]*: Rebuilding administrative file database'
+${PROG} [a-z]*: Rebuilding administrative file database"
cd ..
if echo "yes" | ${testcvs} release -d CVSROOT >>${LOGFILE} ; then
@@ -2631,6 +4978,8 @@ No conflicts created by this import'
cd ..
rm -rf dir-to-import
+ mkdir 1
+ cd 1
dotest 189a "${testcvs} -q co second-dir" \
'U second-dir/bar.c
U second-dir/defig.o
@@ -2638,7 +4987,6 @@ U second-dir/envig.c
U second-dir/foobar.c
U second-dir/optig.c
U second-dir/rootig.c'
- rm -rf second-dir
dotest 189b "${testcvs} -q co first-dir" 'U first-dir/bar.c
U first-dir/foobar.c'
cd first-dir
@@ -2651,9 +4999,78 @@ ${QUESTION} defig.o
${QUESTION} envig.c
${QUESTION} optig.c
${QUESTION} notig.c"
- cd ..
- rm -rf first-dir
+ # Now test that commands other than update also print "? notig.c"
+ # where appropriate. Only test this for remote, because local
+ # CVS only prints it on update.
+ rm optig.c
+ if test "x$remote" = xyes; then
+ dotest 189e "${testcvs} -q diff" "${QUESTION} notig.c"
+
+ # Force the server to be contacted. Ugh. Having CVS
+ # contact the server for the sole purpose of checking
+ # the CVSROOT/cvsignore file does not seem like such a
+ # good idea, so I imagine this will continue to be
+ # necessary. Oh well, at least we test CVS's ablity to
+ # handle a file with a modified timestamp but unmodified
+ # contents.
+ touch bar.c
+
+ dotest 189f "${testcvs} -q ci -m commit-it" "${QUESTION} notig.c"
+ fi
+
+ # now test .cvsignore files
+ cd ..
+ echo notig.c >first-dir/.cvsignore
+ echo foobar.c >second-dir/.cvsignore
+ touch first-dir/notig.c second-dir/notig.c second-dir/foobar.c
+ dotest 190 "${testcvs} -qn update" \
+"${QUESTION} first-dir/.cvsignore
+${QUESTION} second-dir/.cvsignore
+${QUESTION} second-dir/notig.c" \
+"${QUESTION} first-dir/.cvsignore
+${QUESTION} second-dir/notig.c
+${QUESTION} second-dir/.cvsignore"
+ dotest 191 "${testcvs} -qn update -I! -I CVS" \
+"${QUESTION} first-dir/rootig.c
+${QUESTION} first-dir/defig.o
+${QUESTION} first-dir/envig.c
+${QUESTION} first-dir/.cvsignore
+${QUESTION} second-dir/.cvsignore
+${QUESTION} second-dir/notig.c" \
+"${QUESTION} first-dir/rootig.c
+${QUESTION} first-dir/defig.o
+${QUESTION} first-dir/envig.c
+${QUESTION} first-dir/.cvsignore
+${QUESTION} second-dir/notig.c
+${QUESTION} second-dir/.cvsignore"
+
+ if echo yes | ${testcvs} release -d first-dir \
+ >${TESTDIR}/ignore.tmp; then
+ pass ignore-192
+ else
+ fail ignore-192
+ fi
+ dotest ignore-193 "cat ${TESTDIR}/ignore.tmp" \
+"${QUESTION} \.cvsignore
+You have \[0\] altered files in this repository.
+Are you sure you want to release (and delete) directory .first-dir': "
+
+ echo add a line >>second-dir/foobar.c
+ rm second-dir/notig.c second-dir/.cvsignore
+ if echo yes | ${testcvs} release -d second-dir \
+ >${TESTDIR}/ignore.tmp; then
+ pass ignore-194
+ else
+ fail ignore-194
+ fi
+ dotest ignore-195 "cat ${TESTDIR}/ignore.tmp" \
+"M foobar.c
+You have \[1\] altered files in this repository.
+Are you sure you want to release (and delete) directory .second-dir': "
+ cd ..
+ rm -rf 1
+ rm ${TESTDIR}/ignore.tmp
rm -rf ${CVSROOT_DIRNAME}/first-dir ${CVSROOT_DIRNAME}/second-dir
;;
@@ -2671,12 +5088,12 @@ ${QUESTION} notig.c"
"${PROG}"' [a-z]*: scheduling file `binfile'\'' for addition
'"${PROG}"' [a-z]*: use '\''cvs commit'\'' to add this file permanently'
dotest binfiles-3 "${testcvs} -q ci -m add-it" \
-'RCS file: /tmp/cvs-sanity/cvsroot/first-dir/binfile,v
+"RCS file: ${TESTDIR}/cvsroot/first-dir/binfile,v
done
Checking in binfile;
-/tmp/cvs-sanity/cvsroot/first-dir/binfile,v <-- binfile
-initial revision: 1.1
-done'
+${TESTDIR}/cvsroot/first-dir/binfile,v <-- binfile
+initial revision: 1\.1
+done"
cd ../..
mkdir 2; cd 2
dotest binfiles-4 "${testcvs} -q co first-dir" 'U first-dir/binfile'
@@ -2686,24 +5103,73 @@ done'
# to testing that binary files work right on non-unix machines
# (until there is automated testing for such machines, of course).
dotest binfiles-5.5 "${testcvs} status binfile" \
-'===================================================================
+"===================================================================
+File: binfile Status: Up-to-date
+
+ Working revision: 1\.1.*
+ Repository revision: 1\.1 ${TESTDIR}/cvsroot/first-dir/binfile,v
+ Sticky Tag: (none)
+ Sticky Date: (none)
+ Sticky Options: -kb"
+
+ # Test whether the default options from the RCS file are
+ # also used when operating on files instead of whole
+ # directories
+ cd ../..
+ mkdir 3; cd 3
+ dotest binfiles-5.5b0 "${testcvs} -q co first-dir/binfile" \
+'U first-dir/binfile'
+ cd first-dir
+ dotest binfiles-5.5b1 "${testcvs} status binfile" \
+"===================================================================
File: binfile Status: Up-to-date
Working revision: 1\.1.*
- Repository revision: 1\.1 /tmp/cvs-sanity/cvsroot/first-dir/binfile,v
+ Repository revision: 1\.1 ${TESTDIR}/cvsroot/first-dir/binfile,v
Sticky Tag: (none)
Sticky Date: (none)
- Sticky Options: -kb'
+ Sticky Options: -kb"
+ cd ../..
+ rm -rf 3
+ cd 2/first-dir
+
cp ../../1/binfile2.dat binfile
dotest binfiles-6 "${testcvs} -q ci -m modify-it" \
-'Checking in binfile;
-/tmp/cvs-sanity/cvsroot/first-dir/binfile,v <-- binfile
-new revision: 1.2; previous revision: 1.1
-done'
+"Checking in binfile;
+${TESTDIR}/cvsroot/first-dir/binfile,v <-- binfile
+new revision: 1\.2; previous revision: 1\.1
+done"
cd ../../1/first-dir
dotest binfiles-7 "${testcvs} -q update" '[UP] binfile'
dotest binfiles-8 "cmp ../binfile2.dat binfile" ''
+ # Now test handling of conflicts with binary files.
+ cp ../binfile.dat binfile
+ dotest binfiles-con0 "${testcvs} -q ci -m modify-it" \
+"Checking in binfile;
+${TESTDIR}/cvsroot/first-dir/binfile,v <-- binfile
+new revision: 1\.3; previous revision: 1\.2
+done"
+ cd ../../2/first-dir
+ echo 'edits in dir 2' >binfile
+ dotest binfiles-con1 "${testcvs} -q update" \
+"U binfile
+${PROG} [a-z]*: binary file needs merge
+${PROG} [a-z]*: revision 1\.3 from repository is now in binfile
+${PROG} [a-z]*: file from working directory is now in \.#binfile\.1\.2
+C binfile"
+ dotest binfiles-con2 "cmp binfile ../../1/binfile.dat" ''
+ dotest binfiles-con3 "cat .#binfile.1.2" 'edits in dir 2'
+
+ cp ../../1/binfile2.dat binfile
+ dotest binfiles-con4 "${testcvs} -q ci -m resolve-it" \
+"Checking in binfile;
+${TESTDIR}/cvsroot/first-dir/binfile,v <-- binfile
+new revision: 1\.4; previous revision: 1\.3
+done"
+ cd ../../1/first-dir
+ dotest binfiles-con5 "${testcvs} -q update" '[UP] binfile'
+
# The bugs which these test for are apparently not fixed for remote.
if test "$remote" = no; then
dotest binfiles-9 "${testcvs} -q update -A" ''
@@ -2713,79 +5179,225 @@ done'
dotest binfiles-13 "${testcvs} -q update -A" ''
fi
- cd ../../2/first-dir
+ cd ../..
+ rm -rf 1
+
+ mkdir 3
+ cd 3
+ dotest binfiles-13a0 "${testcvs} -q co -r HEAD first-dir" \
+'U first-dir/binfile'
+ cd first-dir
+ dotest binfiles-13a1 "${testcvs} status binfile" \
+"===================================================================
+File: binfile Status: Up-to-date
+
+ Working revision: 1\.4.*
+ Repository revision: 1\.4 ${TESTDIR}/cvsroot/first-dir/binfile,v
+ Sticky Tag: HEAD (revision: 1\.4)
+ Sticky Date: (none)
+ Sticky Options: -kb"
+ cd ../..
+ rm -rf 3
+
+ cd 2/first-dir
echo 'this file is $''RCSfile$' >binfile
dotest binfiles-14a "${testcvs} -q ci -m modify-it" \
-'Checking in binfile;
-/tmp/cvs-sanity/cvsroot/first-dir/binfile,v <-- binfile
-new revision: 1.3; previous revision: 1.2
-done'
+"Checking in binfile;
+${TESTDIR}/cvsroot/first-dir/binfile,v <-- binfile
+new revision: 1\.5; previous revision: 1\.4
+done"
dotest binfiles-14b "cat binfile" 'this file is $''RCSfile$'
# See binfiles-5.5 for discussion of -kb.
dotest binfiles-14c "${testcvs} status binfile" \
-'===================================================================
+"===================================================================
File: binfile Status: Up-to-date
- Working revision: 1\.3.*
- Repository revision: 1\.3 /tmp/cvs-sanity/cvsroot/first-dir/binfile,v
+ Working revision: 1\.5.*
+ Repository revision: 1\.5 ${TESTDIR}/cvsroot/first-dir/binfile,v
Sticky Tag: (none)
Sticky Date: (none)
- Sticky Options: -kb'
+ Sticky Options: -kb"
dotest binfiles-14d "${testcvs} admin -kv binfile" \
-'RCS file: /tmp/cvs-sanity/cvsroot/first-dir/binfile,v
-done'
+"RCS file: ${TESTDIR}/cvsroot/first-dir/binfile,v
+done"
# cvs admin doesn't change the checked-out file or its sticky
# kopts. There probably should be a way which does (but
# what if the file is modified? And do we try to version
# control the kopt setting?)
dotest binfiles-14e "cat binfile" 'this file is $''RCSfile$'
dotest binfiles-14f "${testcvs} status binfile" \
-'===================================================================
+"===================================================================
File: binfile Status: Up-to-date
- Working revision: 1\.3.*
- Repository revision: 1\.3 /tmp/cvs-sanity/cvsroot/first-dir/binfile,v
+ Working revision: 1\.5.*
+ Repository revision: 1\.5 ${TESTDIR}/cvsroot/first-dir/binfile,v
Sticky Tag: (none)
Sticky Date: (none)
- Sticky Options: -kb'
+ Sticky Options: -kb"
dotest binfiles-14g "${testcvs} -q update -A" '[UP] binfile'
dotest binfiles-14h "cat binfile" 'this file is binfile,v'
dotest binfiles-14i "${testcvs} status binfile" \
-'===================================================================
+"===================================================================
File: binfile Status: Up-to-date
- Working revision: 1\.3.*
- Repository revision: 1\.3 /tmp/cvs-sanity/cvsroot/first-dir/binfile,v
+ Working revision: 1\.5.*
+ Repository revision: 1\.5 ${TESTDIR}/cvsroot/first-dir/binfile,v
Sticky Tag: (none)
Sticky Date: (none)
- Sticky Options: -kv'
+ Sticky Options: -kv"
+
+ # Do sticky options work when used with 'cvs update'?
+ echo "Not a binary file." > nibfile
+ dotest binfiles-sticky1 "${testcvs} -q add nibfile" \
+"${PROG} [a-z]*: use "\''cvs commit'\'' to add this file permanently'
+ dotest binfiles-sticky2 "${testcvs} -q ci -m add-it nibfile" \
+ "RCS file: ${TESTDIR}/cvsroot/first-dir/nibfile,v
+done
+Checking in nibfile;
+${TESTDIR}/cvsroot/first-dir/nibfile,v <-- nibfile
+initial revision: 1\.1
+done"
+ dotest binfiles-sticky3 "${testcvs} -q update -kb nibfile" \
+ '[UP] nibfile'
+ dotest binfiles-sticky4 "${testcvs} -q status nibfile" \
+"===================================================================
+File: nibfile Status: Up-to-date
+
+ Working revision: 1\.1.*
+ Repository revision: 1\.1 ${TESTDIR}/cvsroot/first-dir/nibfile,v
+ Sticky Tag: (none)
+ Sticky Date: (none)
+ Sticky Options: -kb"
+ # Eventually we should test that -A removes the -kb here...
cd ../..
rm -rf ${CVSROOT_DIRNAME}/first-dir
- rm -r 1 2
+ rm -r 2
+ ;;
+
+ binfiles2)
+ # Test cvs's ability to handle binary files, particularly branching
+ # and joining. The key thing we are worrying about is that CVS
+ # doesn't print "cannot merge binary files" or some such, in
+ # situations where no merging is required.
+ # See also "join" which does this with non-binary files.
+
+ mkdir ${CVSROOT_DIRNAME}/first-dir
+ mkdir 1; cd 1
+ dotest binfiles2-1 "${testcvs} -q co first-dir" ''
+ cd first-dir
+ # FIXCVS: unless a branch has at least one file on it,
+ # tag_check_valid won't know it exists. So creating a
+ # file here is a workaround.
+ touch dummy
+ dotest binfiles2-1a "${testcvs} add dummy" \
+"${PROG} [a-z]*: scheduling file .dummy. for addition
+${PROG} [a-z]*: use .cvs commit. to add this file permanently"
+ dotest binfiles2-1b "${testcvs} -q ci -m add-it" \
+"RCS file: ${TESTDIR}/cvsroot/first-dir/dummy,v
+done
+Checking in dummy;
+${TESTDIR}/cvsroot/first-dir/dummy,v <-- dummy
+initial revision: 1\.1
+done"
+ dotest binfiles2-2 "${testcvs} -q tag -b br" 'T dummy'
+ dotest binfiles2-3 "${testcvs} -q update -r br" ''
+ awk 'BEGIN { printf "%c%c%c%c%c%c", 2, 10, 137, 0, 13, 10 }' \
+ </dev/null >../binfile
+ cp ../binfile binfile.dat
+ dotest binfiles2-4 "${testcvs} add -kb binfile.dat" \
+"${PROG} [a-z]*: scheduling file .binfile\.dat. for addition on branch .br.
+${PROG} [a-z]*: use .cvs commit. to add this file permanently"
+ dotest binfiles2-5 "${testcvs} -q ci -m add-it" \
+"RCS file: ${TESTDIR}/cvsroot/first-dir/Attic/binfile\.dat,v
+done
+Checking in binfile\.dat;
+${TESTDIR}/cvsroot/first-dir/Attic/binfile\.dat,v <-- binfile\.dat
+new revision: 1\.1\.2\.1; previous revision: 1\.1
+done"
+ dotest binfiles2-6 "${testcvs} -q update -A" \
+"${PROG} [a-z]*: warning: binfile\.dat is not (any longer) pertinent"
+ dotest_fail binfiles2-7 "test -f binfile.dat" ''
+ dotest binfiles2-8 "${testcvs} -q update -j br" "U binfile.dat"
+ dotest binfiles2-9 "cmp ../binfile binfile.dat"
+ cd ..
+ cd ..
+
+ rm -rf ${CVSROOT_DIRNAME}/first-dir
+ rm -r 1
+ ;;
+
+ binwrap)
+ # Test the ability to specify binary-ness based on file name.
+ # We could also be testing the ability to use the other
+ # ways to specify a wrapper (CVSROOT/cvswrappers, etc.).
+
+ mkdir dir-to-import
+ cd dir-to-import
+ touch foo.c foo.exe
+
+ # While we're here, test for rejection of duplicate tag names.
+ dotest_fail binwrap-0 \
+ "${testcvs} import -m msg -I ! first-dir dup dup" \
+"${PROG} \[[a-z]* aborted\]: tag .dup. was specified more than once"
+
+ if ${testcvs} import -m message -I ! -W "*.exe -k 'b'" \
+ first-dir tag1 tag2 >>${LOGFILE}; then
+ pass binwrap-1
+ else
+ fail binwrap-1
+ fi
+ cd ..
+ rm -rf dir-to-import
+ dotest binwrap-2 "${testcvs} -q co first-dir" 'U first-dir/foo.c
+U first-dir/foo.exe'
+ dotest binwrap-3 "${testcvs} -q status first-dir" \
+"===================================================================
+File: foo\.c Status: Up-to-date
+
+ Working revision: 1\.1\.1\.1.*
+ Repository revision: 1\.1\.1\.1 ${TESTDIR}/cvsroot/first-dir/foo\.c,v
+ Sticky Tag: (none)
+ Sticky Date: (none)
+ Sticky Options: (none)
+
+===================================================================
+File: foo\.exe Status: Up-to-date
+
+ Working revision: 1\.1\.1\.1.*
+ Repository revision: 1\.1\.1\.1 ${TESTDIR}/cvsroot/first-dir/foo\.exe,v
+ Sticky Tag: (none)
+ Sticky Date: (none)
+ Sticky Options: -kb"
+ rm -rf first-dir ${CVSROOT_DIRNAME}/first-dir
;;
+
info)
# Test CVS's ability to handle *info files.
dotest info-1 "${testcvs} -q co CVSROOT" "[UP] CVSROOT${DOTSTAR}"
cd CVSROOT
echo "ALL sh -c \"echo x\${=MYENV}\${=OTHER}y\${=ZEE}=\$USER=\$CVSROOT= >>$TESTDIR/testlog; cat >/dev/null\"" > loginfo
- dotest info-2 "${testcvs} add loginfo" \
+ # The following cases test the format string substitution
+ echo "ALL echo %{sVv} >>$TESTDIR/testlog2; cat >/dev/null" >> loginfo
+ echo "ALL echo %{v} >>$TESTDIR/testlog2; cat >/dev/null" >> loginfo
+ echo "ALL echo %s >>$TESTDIR/testlog2; cat >/dev/null" >> loginfo
+ echo "ALL echo %{V}AX >>$TESTDIR/testlog2; cat >/dev/null" >> loginfo
+ echo "ALL echo %sux >>$TESTDIR/testlog2; cat >/dev/null" >> loginfo
+
+ # Might be nice to move this to crerepos tests; it should
+ # work to create a loginfo file if you didn't create one
+ # with "cvs init".
+ : dotest info-2 "${testcvs} add loginfo" \
"${PROG}"' [a-z]*: scheduling file `loginfo'"'"' for addition
'"${PROG}"' [a-z]*: use '"'"'cvs commit'"'"' to add this file permanently'
+
dotest info-3 "${testcvs} -q ci -m new-loginfo" \
-'RCS file: /tmp/cvs-sanity/cvsroot/CVSROOT/loginfo,v
+"Checking in loginfo;
+${TESTDIR}/cvsroot/CVSROOT/loginfo,v <-- loginfo
+new revision: 1\.[0-9]*; previous revision: 1\.[0-9]*
done
-Checking in loginfo;
-/tmp/cvs-sanity/cvsroot/CVSROOT/loginfo,v <-- loginfo
-initial revision: 1.1
-done
-'"${PROG}"' [a-z]*: Rebuilding administrative file database'
+${PROG} [a-z]*: Rebuilding administrative file database"
cd ..
- if echo "yes" | ${testcvs} release -d CVSROOT >>${LOGFILE} ; then
- pass info-4
- else
- fail info-4
- fi
mkdir ${CVSROOT_DIRNAME}/first-dir
dotest info-5 "${testcvs} -q co first-dir" ''
@@ -2796,34 +5408,1161 @@ done
'"${PROG}"' [a-z]*: use '\''cvs commit'\'' to add this file permanently'
echo "cvs -s OTHER=not-this -s MYENV=env-" >>$HOME/.cvsrc
dotest info-6a "${testcvs} -q -s OTHER=value ci -m add-it" \
-'RCS file: /tmp/cvs-sanity/cvsroot/first-dir/file1,v
+"RCS file: ${TESTDIR}/cvsroot/first-dir/file1,v
done
Checking in file1;
-/tmp/cvs-sanity/cvsroot/first-dir/file1,v <-- file1
-initial revision: 1.1
+${TESTDIR}/cvsroot/first-dir/file1,v <-- file1
+initial revision: 1\.1
done
-'"${PROG}"' [a-z]*: loginfo:1: no such user variable ${=ZEE}'
+${PROG} [a-z]*: loginfo:1: no such user variable \${=ZEE}"
echo line1 >>file1
dotest info-7 "${testcvs} -q -s OTHER=value -s ZEE=z ci -m mod-it" \
-'Checking in file1;
-/tmp/cvs-sanity/cvsroot/first-dir/file1,v <-- file1
-new revision: 1.2; previous revision: 1.1
-done'
+"Checking in file1;
+${TESTDIR}/cvsroot/first-dir/file1,v <-- file1
+new revision: 1\.2; previous revision: 1\.1
+done"
+ cd ..
+ dotest info-9 "cat $TESTDIR/testlog" "xenv-valueyz=[a-z0-9@][a-z0-9@]*=${TESTDIR}/cvsroot="
+ dotest info-10 "cat $TESTDIR/testlog2" 'first-dir file1,NONE,1.1
+first-dir 1.1
+first-dir file1
+first-dir NONEAX
+first-dir file1ux
+first-dir file1,1.1,1.2
+first-dir 1.2
+first-dir file1
+first-dir 1.1AX
+first-dir file1ux'
+
+ cd CVSROOT
+ echo '# do nothing' >loginfo
+ dotest info-11 "${testcvs} -q -s ZEE=garbage ci -m nuke-loginfo" \
+"Checking in loginfo;
+${TESTDIR}/cvsroot/CVSROOT/loginfo,v <-- loginfo
+new revision: 1\.[0-9]; previous revision: 1\.[0-9]
+done
+${PROG} [a-z]*: Rebuilding administrative file database"
+
+ # Now test verifymsg
+ cat >${TESTDIR}/vscript <<EOF
+#!/bin/sh
+if head -1 < \$1 | grep '^BugId:[ ]*[0-9][0-9]*$' > /dev/null; then
+ exit 0
+else
+ echo "No BugId found."
+ exit 1
+fi
+EOF
+ chmod +x ${TESTDIR}/vscript
+ echo "^first-dir ${TESTDIR}/vscript" >>verifymsg
+ dotest info-v1 "${testcvs} -q ci -m add-verification" \
+"Checking in verifymsg;
+${TESTDIR}/cvsroot/CVSROOT/verifymsg,v <-- verifymsg
+new revision: 1\.2; previous revision: 1\.1
+done
+${PROG} [a-z]*: Rebuilding administrative file database"
+
+ cd ../first-dir
+ echo line2 >>file1
+ dotest_fail info-v2 "${testcvs} -q ci -m bogus" \
+"No BugId found\.
+${PROG} \[[a-z]* aborted\]: Message verification failed"
+
+ cat >${TESTDIR}/comment.tmp <<EOF
+BugId: 42
+and many more lines after it
+EOF
+ dotest info-v3 "${testcvs} -q ci -F ${TESTDIR}/comment.tmp" \
+"Checking in file1;
+${TESTDIR}/cvsroot/first-dir/file1,v <-- file1
+new revision: 1\.3; previous revision: 1\.2
+done"
+ cd ..
+ mkdir another-dir
+ cd another-dir
+ touch file2
+ dotest_fail info-v4 \
+ "${testcvs} import -m bogus first-dir/another x y" \
+"No BugId found\.
+${PROG} \[[a-z]* aborted\]: Message verification failed"
+ rm file2
+ cd ..
+ rmdir another-dir
+
+ cd CVSROOT
+ echo '# do nothing' >verifymsg
+ dotest info-cleanup-verifymsg "${testcvs} -q ci -m nuke-verifymsg" \
+"Checking in verifymsg;
+${TESTDIR}/cvsroot/CVSROOT/verifymsg,v <-- verifymsg
+new revision: 1\.[0-9]; previous revision: 1\.[0-9]
+done
+${PROG} [a-z]*: Rebuilding administrative file database"
cd ..
+
+ if echo "yes" | ${testcvs} release -d CVSROOT >>${LOGFILE} ; then
+ pass info-cleanup
+ else
+ fail info-cleanup
+ fi
if echo "yes" | ${testcvs} release -d first-dir >>${LOGFILE} ; then
- pass info-8
+ pass info-cleanup-2
+ else
+ fail info-cleanup-2
+ fi
+ rm -rf ${CVSROOT_DIRNAME}/first-dir
+ ;;
+
+ serverpatch)
+ # Test remote CVS handling of unpatchable files. This isn't
+ # much of a test for local CVS.
+ mkdir ${CVSROOT_DIRNAME}/first-dir
+ mkdir 1
+ cd 1
+ dotest serverpatch-1 "${testcvs} -q co first-dir" ''
+
+ cd first-dir
+
+ # Add a file with an RCS keyword.
+ echo '$''Name$' > file1
+ echo '1' >> file1
+ dotest serverpatch-2 "${testcvs} add file1" \
+"${PROG}"' [a-z]*: scheduling file `file1'\'' for addition
+'"${PROG}"' [a-z]*: use '\''cvs commit'\'' to add this file permanently'
+
+ dotest serverpatch-3 "${testcvs} -q commit -m add" \
+"RCS file: ${TESTDIR}/cvsroot/first-dir/file1,v
+done
+Checking in file1;
+${TESTDIR}/cvsroot/first-dir/file1,v <-- file1
+initial revision: 1\.1
+done"
+
+ # Tag the file.
+ dotest serverpatch-4 "${testcvs} -q tag tag file1" 'T file1'
+
+ # Check out a tagged copy of the file.
+ cd ../..
+ mkdir 2
+ cd 2
+ dotest serverpatch-5 "${testcvs} -q co -r tag first-dir" \
+'U first-dir/file1'
+
+ # Remove the tag. This will leave the tag string in the
+ # expansion of the Name keyword.
+ dotest serverpatch-6 "${testcvs} -q update -A" ''
+
+ # Modify and check in the first copy.
+ cd ../1/first-dir
+ echo '2' >> file1
+ dotest serverpatch-7 "${testcvs} -q ci -mx file1" \
+"Checking in file1;
+${TESTDIR}/cvsroot/first-dir/file1,v <-- file1
+new revision: 1\.2; previous revision: 1\.1
+done"
+
+ # Now update the second copy. When using remote CVS, the
+ # patch will fail, forcing the file to be refetched.
+ cd ../../2/first-dir
+ dotest serverpatch-8 "${testcvs} -q update" \
+'U file1' \
+'P file1
+'"${PROG}"' [a-z]*: checksum failure after patch to ./file1; will refetch
+'"${PROG}"' [a-z]*: refetching unpatchable files
+U file1'
+
+ cd ../..
+ rm -rf 1 2 ${CVSROOT_DIRNAME}/first-dir
+ ;;
+
+ log)
+ # Test selecting revisions with cvs log.
+ # See also log2 tests for more tests.
+ # See also rcs tests, for -d option to log.
+ # See also branches-14.3 for logging with a branch off of a branch.
+ # See also multibranch-14 for logging with several branches off the
+ # same branchpoint.
+
+ # Check in a file with a few revisions and branches.
+ mkdir ${CVSROOT_DIRNAME}/first-dir
+ dotest log-1 "${testcvs} -q co first-dir" ''
+ cd first-dir
+ echo 'first revision' > file1
+ dotest log-2 "${testcvs} add file1" \
+"${PROG}"' [a-z]*: scheduling file `file1'\'' for addition
+'"${PROG}"' [a-z]*: use '\''cvs commit'\'' to add this file permanently'
+
+ dotest log-3 "${testcvs} -q commit -m 1" \
+"RCS file: ${TESTDIR}/cvsroot/first-dir/file1,v
+done
+Checking in file1;
+${TESTDIR}/cvsroot/first-dir/file1,v <-- file1
+initial revision: 1\.1
+done"
+
+ echo 'second revision' > file1
+ dotest log-4 "${testcvs} -q ci -m2 file1" \
+"Checking in file1;
+${TESTDIR}/cvsroot/first-dir/file1,v <-- file1
+new revision: 1\.2; previous revision: 1\.1
+done"
+
+ dotest log-5 "${testcvs} -q tag -b branch file1" 'T file1'
+
+ echo 'third revision' > file1
+ dotest log-6 "${testcvs} -q ci -m3 file1" \
+"Checking in file1;
+${TESTDIR}/cvsroot/first-dir/file1,v <-- file1
+new revision: 1\.3; previous revision: 1\.2
+done"
+
+ dotest log-7 "${testcvs} -q update -r branch" '[UP] file1'
+
+ echo 'first branch revision' > file1
+ dotest log-8 "${testcvs} -q ci -m1b file1" \
+"Checking in file1;
+${TESTDIR}/cvsroot/first-dir/file1,v <-- file1
+new revision: 1\.2\.2\.1; previous revision: 1\.2
+done"
+
+ dotest log-9 "${testcvs} -q tag tag file1" 'T file1'
+
+ echo 'second branch revision' > file1
+ dotest log-10 "${testcvs} -q ci -m2b file1" \
+"Checking in file1;
+${TESTDIR}/cvsroot/first-dir/file1,v <-- file1
+new revision: 1\.2\.2\.2; previous revision: 1\.2\.2\.1
+done"
+
+ # Set up a bunch of shell variables to make the later tests
+ # easier to describe.=
+ log_header="
+RCS file: ${TESTDIR}/cvsroot/first-dir/file1,v
+Working file: file1
+head: 1\.3
+branch:
+locks: strict
+access list:"
+ log_tags='symbolic names:
+ tag: 1\.2\.2\.1
+ branch: 1\.2\.0\.2'
+ log_header2='keyword substitution: kv'
+ log_dash='----------------------------
+revision'
+ log_date="date: [0-9/]* [0-9:]*; author: ${username}; state: Exp;"
+ log_lines=" lines: ${PLUS}1 -1"
+ log_rev1="${log_dash} 1\.1
+${log_date}
+1"
+ log_rev2="${log_dash} 1\.2
+${log_date}${log_lines}
+branches: 1\.2\.2;
+2"
+ log_rev3="${log_dash} 1\.3
+${log_date}${log_lines}
+3"
+ log_rev1b="${log_dash} 1\.2\.2\.1
+${log_date}${log_lines}
+1b"
+ log_rev2b="${log_dash} 1\.2\.2\.2
+${log_date}${log_lines}
+2b"
+ log_trailer='============================================================================='
+
+ # Now, finally, test the log output.
+
+ dotest log-11 "${testcvs} log file1" \
+"${log_header}
+${log_tags}
+${log_header2}
+total revisions: 5; selected revisions: 5
+description:
+${log_rev3}
+${log_rev2}
+${log_rev1}
+${log_rev2b}
+${log_rev1b}
+${log_trailer}"
+
+ dotest log-12 "${testcvs} log -N file1" \
+"${log_header}
+${log_header2}
+total revisions: 5; selected revisions: 5
+description:
+${log_rev3}
+${log_rev2}
+${log_rev1}
+${log_rev2b}
+${log_rev1b}
+${log_trailer}"
+
+ dotest log-13 "${testcvs} log -b file1" \
+"${log_header}
+${log_tags}
+${log_header2}
+total revisions: 5; selected revisions: 3
+description:
+${log_rev3}
+${log_rev2}
+${log_rev1}
+${log_trailer}"
+
+ dotest log-14 "${testcvs} log -r file1" \
+"${log_header}
+${log_tags}
+${log_header2}
+total revisions: 5; selected revisions: 1
+description:
+${log_rev3}
+${log_trailer}"
+
+ dotest log-15 "${testcvs} log -r1.2 file1" \
+"${log_header}
+${log_tags}
+${log_header2}
+total revisions: 5; selected revisions: 1
+description:
+${log_rev2}
+${log_trailer}"
+
+ dotest log-16 "${testcvs} log -r1.2.2 file1" \
+"${log_header}
+${log_tags}
+${log_header2}
+total revisions: 5; selected revisions: 2
+description:
+${log_rev2b}
+${log_rev1b}
+${log_trailer}"
+
+ # This test would fail with the old invocation of rlog, but it
+ # works with the builtin log support.
+ dotest log-17 "${testcvs} log -rbranch file1" \
+"${log_header}
+${log_tags}
+${log_header2}
+total revisions: 5; selected revisions: 2
+description:
+${log_rev2b}
+${log_rev1b}
+${log_trailer}"
+
+ dotest log-18 "${testcvs} log -r1.2.2. file1" \
+"${log_header}
+${log_tags}
+${log_header2}
+total revisions: 5; selected revisions: 1
+description:
+${log_rev2b}
+${log_trailer}"
+
+ # This test would fail with the old invocation of rlog, but it
+ # works with the builtin log support.
+ dotest log-19 "${testcvs} log -rbranch. file1" \
+"${log_header}
+${log_tags}
+${log_header2}
+total revisions: 5; selected revisions: 1
+description:
+${log_rev2b}
+${log_trailer}"
+
+ dotest log-20 "${testcvs} log -r1.2: file1" \
+"${log_header}
+${log_tags}
+${log_header2}
+total revisions: 5; selected revisions: 2
+description:
+${log_rev3}
+${log_rev2}
+${log_trailer}"
+
+ dotest log-21 "${testcvs} log -r:1.2 file1" \
+"${log_header}
+${log_tags}
+${log_header2}
+total revisions: 5; selected revisions: 2
+description:
+${log_rev2}
+${log_rev1}
+${log_trailer}"
+
+ dotest log-22 "${testcvs} log -r1.1:1.2 file1" \
+"${log_header}
+${log_tags}
+${log_header2}
+total revisions: 5; selected revisions: 2
+description:
+${log_rev2}
+${log_rev1}
+${log_trailer}"
+
+ cd ..
+ rm -rf first-dir ${CVSROOT_DIRNAME}/first-dir
+ ;;
+
+ log2)
+ # More "cvs log" tests, for example the file description.
+
+ # Setting the file description doesn't yet work client/server, so
+ # skip these tests for remote.
+ if test "x$remote" = xno; then
+
+ # Check in a file
+ mkdir ${CVSROOT_DIRNAME}/first-dir
+ dotest log2-1 "${testcvs} -q co first-dir" ''
+ cd first-dir
+ echo 'first revision' > file1
+ dotest log2-2 "${testcvs} add -m file1-is-for-testing file1" \
+"${PROG}"' [a-z]*: scheduling file `file1'\'' for addition
+'"${PROG}"' [a-z]*: use '\''cvs commit'\'' to add this file permanently'
+ dotest log2-3 "${testcvs} -q commit -m 1" \
+"RCS file: ${TESTDIR}/cvsroot/first-dir/file1,v
+done
+Checking in file1;
+${TESTDIR}/cvsroot/first-dir/file1,v <-- file1
+initial revision: 1\.1
+done"
+ dotest log2-4 "${testcvs} log -N file1" "
+RCS file: ${TESTDIR}/cvsroot/first-dir/file1,v
+Working file: file1
+head: 1\.1
+branch:
+locks: strict
+access list:
+keyword substitution: kv
+total revisions: 1; selected revisions: 1
+description:
+file1-is-for-testing
+----------------------------
+revision 1\.1
+date: [0-9/]* [0-9:]*; author: ${username}; state: Exp;
+1
+============================================================================="
+
+ cd ..
+ rm -rf first-dir ${CVSROOT_DIRNAME}/first-dir
+
+ fi # end of tests skipped for remote
+
+ ;;
+ crerepos)
+ # Various tests relating to creating repositories, operating
+ # on repositories created with old versions of CVS, etc.
+
+ # Because this test is all about -d options and such, it
+ # at least to some extent needs to be different for remote vs.
+ # local.
+ if test "x$remote" = "xno"; then
+
+ # First, if the repository doesn't exist at all...
+ dotest_fail crerepos-1 \
+"${testcvs} -d ${TESTDIR}/crerepos co cvs-sanity" \
+"${PROG} \[[a-z]* aborted\]: ${TESTDIR}/crerepos/CVSROOT: .*"
+ mkdir crerepos
+
+ # The repository exists but CVSROOT doesn't.
+ dotest_fail crerepos-2 \
+"${testcvs} -d ${TESTDIR}/crerepos co cvs-sanity" \
+"${PROG} \[[a-z]* aborted\]: ${TESTDIR}/crerepos/CVSROOT: .*"
+ mkdir crerepos/CVSROOT
+
+ # Checkout of nonexistent module
+ dotest_fail crerepos-3 \
+"${testcvs} -d ${TESTDIR}/crerepos co cvs-sanity" \
+"${PROG} [a-z]*: cannot find module .cvs-sanity. - ignored"
+
+ # Now test that CVS works correctly without a modules file
+ # or any of that other stuff. In particular, it *must*
+ # function if administrative files added to CVS recently (since
+ # CVS 1.3) do not exist, because the repository might have
+ # been created with an old version of CVS.
+ mkdir tmp; cd tmp
+ dotest crerepos-4 \
+"${testcvs} -q -d ${TESTDIR}/crerepos co CVSROOT" \
+''
+ if echo yes | \
+${testcvs} -d ${TESTDIR}/crerepos release -d CVSROOT >>${LOGFILE}; then
+ pass crerepos-5
+ else
+ fail crerepos-5
+ fi
+ rm -rf CVS
+ cd ..
+ # The directory tmp should be empty
+ dotest crerepos-6 "rmdir tmp" ''
+
+ else
+ # For remote, just create the repository. We don't yet do
+ # the various other tests above for remote but that should be
+ # changed.
+ mkdir crerepos
+ mkdir crerepos/CVSROOT
+ fi
+
+ if test "x$remote" = "xno"; then
+ # Test that CVS rejects a relative path in CVSROOT.
+ mkdir 1; cd 1
+ dotest_fail crerepos-6a "${testcvs} -q -d ../crerepos get ." \
+"${PROG} \[[a-z]* aborted\]: CVSROOT ../crerepos must be an absolute pathname"
+ cd ..
+ rm -rf 1
+
+ mkdir 1; cd 1
+ dotest_fail crerepos-6b "${testcvs} -d crerepos init" \
+"${PROG} \[[a-z]* aborted\]: CVSROOT crerepos must be an absolute pathname"
+ cd ..
+ rm -rf 1
+ else # remote
+ # Test that CVS rejects a relative path in CVSROOT.
+ mkdir 1; cd 1
+ dotest_fail crerepos-6a \
+"${testcvs} -q -d :ext:`hostname`:../crerepos get ." \
+"Root ../crerepos must be an absolute pathname"
+ cd ..
+ rm -rf 1
+
+ mkdir 1; cd 1
+ dotest_fail crerepos-6b \
+"${testcvs} -d :ext:`hostname`:crerepos init" \
+"Root crerepos must be an absolute pathname"
+ cd ..
+ rm -rf 1
+ fi # end of tests to be skipped for remote
+
+ # CVS better not create a history file--if the administrator
+ # doesn't need it and wants to save on disk space, they just
+ # delete it.
+ dotest_fail crerepos-7 \
+"test -f ${TESTDIR}/crerepos/CVSROOT/history" ''
+
+ ;;
+
+ rcs)
+ # Test ability to import an RCS file. Note that this format
+ # is fixed--files written by RCS5, and other software which
+ # implements this format, will be out there "forever" and
+ # CVS must always be able to import such files.
+
+ # TODO: would be nice to have a corresponding test for exporting
+ # RCS files. Rather than try to write a rigorous check for whether
+ # the file CVS exports is legal, we could just write a simpler test
+ # for what CVS actually exports, and revise the check as needed.
+
+ mkdir ${CVSROOT_DIRNAME}/first-dir
+
+ # Currently the way to import an RCS file is to copy it
+ # directly into the repository.
+ # This file was written by RCS 5.7, and then the dates were
+ # hacked so that we test year 2000 stuff. Note also that
+ # "author" names are just strings, as far as importing
+ # RCS files is concerned--they need not correspond to user
+ # IDs on any particular system.
+ cat <<EOF >${CVSROOT_DIRNAME}/first-dir/file1,v
+head 1.3;
+access;
+symbols;
+locks; strict;
+comment @# @;
+
+
+1.3
+date 2000.11.24.15.58.37; author kingdon; state Exp;
+branches;
+next 1.2;
+
+1.2
+date 96.11.24.15.57.41; author kingdon; state Exp;
+branches;
+next 1.1;
+
+1.1
+date 96.11.24.15.56.05; author kingdon; state Exp;
+branches;
+next ;
+
+
+desc
+@file1 is for testing CVS
+@
+
+
+1.3
+log
+@delete second line; modify twelfth line
+@
+text
+@This is the first line
+This is the third line
+This is the fourth line
+This is the fifth line
+This is the sixth line
+This is the seventh line
+This is the eighth line
+This is the ninth line
+This is the tenth line
+This is the eleventh line
+This is the twelfth line (and what a line it is)
+This is the thirteenth line
+@
+
+
+1.2
+log
+@add more lines
+@
+text
+@a1 1
+This is the second line
+d11 1
+a11 1
+This is the twelfth line
+@
+
+
+1.1
+log
+@add file1
+@
+text
+@d2 12
+@
+EOF
+ dotest rcs-1 "${testcvs} -q co first-dir" 'U first-dir/file1'
+ cd first-dir
+ dotest rcs-2 "${testcvs} -q log" "
+RCS file: ${TESTDIR}/cvsroot/first-dir/file1,v
+Working file: file1
+head: 1\.3
+branch:
+locks: strict
+access list:
+symbolic names:
+keyword substitution: kv
+total revisions: 3; selected revisions: 3
+description:
+file1 is for testing CVS
+----------------------------
+revision 1\.3
+date: 2000/11/24 15:58:37; author: kingdon; state: Exp; lines: ${PLUS}1 -2
+delete second line; modify twelfth line
+----------------------------
+revision 1\.2
+date: 1996/11/24 15:57:41; author: kingdon; state: Exp; lines: ${PLUS}12 -0
+add more lines
+----------------------------
+revision 1\.1
+date: 1996/11/24 15:56:05; author: kingdon; state: Exp;
+add file1
+============================================================================="
+
+ # Note that the dates here are chosen so that (a) we test
+ # at least one date after 2000, (b) we will notice if the
+ # month and day are getting mixed up with each other.
+ # TODO: also test that year isn't getting mixed up with month
+ # or day, for example 01-02-03.
+
+ # ISO8601 format. There are many, many, other variations
+ # specified by ISO8601 which we should be testing too.
+ dotest rcs-3 "${testcvs} -q log -d 1996-12-11<" "
+RCS file: ${TESTDIR}/cvsroot/first-dir/file1,v
+Working file: file1
+head: 1\.3
+branch:
+locks: strict
+access list:
+symbolic names:
+keyword substitution: kv
+total revisions: 3; selected revisions: 1
+description:
+file1 is for testing CVS
+----------------------------
+revision 1\.3
+date: 2000/11/24 15:58:37; author: kingdon; state: Exp; lines: ${PLUS}1 -2
+delete second line; modify twelfth line
+============================================================================="
+
+ # RFC822 format (as amended by RFC1123).
+ if ${testcvs} -q log -d '<3 Apr 2000 00:00' >${TESTDIR}/rcs4.tmp
+ then
+ dotest rcs-4 "cat ${TESTDIR}/rcs4.tmp" "
+RCS file: ${TESTDIR}/cvsroot/first-dir/file1,v
+Working file: file1
+head: 1\.3
+branch:
+locks: strict
+access list:
+symbolic names:
+keyword substitution: kv
+total revisions: 3; selected revisions: 2
+description:
+file1 is for testing CVS
+----------------------------
+revision 1\.2
+date: 1996/11/24 15:57:41; author: kingdon; state: Exp; lines: ${PLUS}12 -0
+add more lines
+----------------------------
+revision 1\.1
+date: 1996/11/24 15:56:05; author: kingdon; state: Exp;
+add file1
+============================================================================="
else
- fail info-8
+ fail rcs-4
fi
- dotest info-9 "cat $TESTDIR/testlog" 'xenv-valueyz=[a-z@][a-z@]*=/tmp/cvs-sanity/cvsroot='
- # I think this might be doable with cvs remove, or at least
- # checking in a version with only comments, but I'm too lazy
- # at the moment. Blow it away.
- rm -f ${CVSROOT_DIRNAME}/CVSROOT/loginfo*
+ rm -rf first-dir ${CVSROOT_DIRNAME}/first-dir ${TESTDIR}/rcs4.tmp
+ ;;
+
+ big)
+
+ # Test ability to operate on big files. Intention is to
+ # test various realloc'ing code in RCS_deltas, rcsgetkey,
+ # etc. "big" is currently defined to be 1000 lines (64000
+ # bytes), which in terms of files that users will use is not
+ # large, merely average, but my reasoning is that this
+ # should be big enough to make sure realloc'ing is going on
+ # and that raising it a lot would start to stress resources
+ # on machines which run the tests, without any significant
+ # benefit.
+ mkdir ${CVSROOT_DIRNAME}/first-dir
+ dotest big-1 "${testcvs} -q co first-dir" ''
+ cd first-dir
+ for i in 0 1 2 3 4 5 6 7 8 9; do
+ for j in 0 1 2 3 4 5 6 7 8 9; do
+ for k in 0 1 2 3 4 5 6 7 8 9; do
+ echo \
+"This is line ($i,$j,$k) which goes into the file file1 for testing" >>file1
+ done
+ done
+ done
+ dotest big-2 "${testcvs} add file1" \
+"${PROG} [a-z]*: scheduling file .file1. for addition
+${PROG} [a-z]*: use .cvs commit. to add this file permanently"
+ dotest big-3 "${testcvs} -q ci -m add" \
+"RCS file: ${TESTDIR}/cvsroot/first-dir/file1,v
+done
+Checking in file1;
+${TESTDIR}/cvsroot/first-dir/file1,v <-- file1
+initial revision: 1\.1
+done"
+ cd ..
+ rm -rf first-dir
+ dotest big-4 "${testcvs} -q get first-dir" "U first-dir/file1"
+
+ if test "$keep" = yes; then
+ echo Keeping ${TESTDIR} and exiting due to --keep
+ exit 0
+ fi
+
+ rm -rf first-dir
rm -rf ${CVSROOT_DIRNAME}/first-dir
;;
+
+ modes)
+ # Test repository permissions (CVSUMASK and so on).
+ # Although the tests in this section "cheat" by testing
+ # repository permissions, which are sort of not a user-visible
+ # sort of thing, the modes do have user-visible consequences,
+ # such as whether a second user can check out the files. But
+ # it would be awkward to test the consequences, so we don't.
+
+ # Solaris /bin/sh doesn't support export -n. I'm not sure
+ # what we can do about this, other than hope that whoever
+ # is running the tests doesn't have CVSUMASK set.
+ #export -n CVSUMASK # if unset, defaults to 002
+
+ umask 077
+ mkdir 1; cd 1
+ dotest modes-1 "${testcvs} -q co -l ." ''
+ mkdir first-dir
+ dotest modes-2 "${testcvs} add first-dir" \
+"Directory ${TESTDIR}/cvsroot/first-dir added to the repository"
+ cd first-dir
+ touch aa
+ dotest modes-3 "${testcvs} add aa" \
+"${PROG} [a-z]*: scheduling file .aa. for addition
+${PROG} [a-z]*: use .cvs commit. to add this file permanently"
+ dotest modes-4 "${testcvs} -q ci -m add" \
+"RCS file: ${TESTDIR}/cvsroot/first-dir/aa,v
+done
+Checking in aa;
+${TESTDIR}/cvsroot/first-dir/aa,v <-- aa
+initial revision: 1\.1
+done"
+ dotest modes-5 "ls -l ${TESTDIR}/cvsroot/first-dir/aa,v" \
+"-r--r--r-- .*"
+
+ # Test for whether we can set the execute bit.
+ chmod +x aa
+ echo change it >>aa
+ dotest modes-6 "${testcvs} -q ci -m set-execute-bit" \
+"Checking in aa;
+${TESTDIR}/cvsroot/first-dir/aa,v <-- aa
+new revision: 1\.2; previous revision: 1\.1
+done"
+ # If CVS let us update the execute bit, it would be set here.
+ # But it doesn't, and as far as I know that is longstanding
+ # CVS behavior.
+ dotest modes-7 "ls -l ${TESTDIR}/cvsroot/first-dir/aa,v" \
+"-r--r--r-- .*"
+
+ # OK, now manually change the modes and see what happens.
+ chmod g=r,o= ${TESTDIR}/cvsroot/first-dir/aa,v
+ echo second line >>aa
+ dotest modes-7a "${testcvs} -q ci -m set-execute-bit" \
+"Checking in aa;
+${TESTDIR}/cvsroot/first-dir/aa,v <-- aa
+new revision: 1\.3; previous revision: 1\.2
+done"
+ dotest modes-7b "ls -l ${TESTDIR}/cvsroot/first-dir/aa,v" \
+"-r--r----- .*"
+
+ CVSUMASK=007
+ export CVSUMASK
+ touch ab
+ # Might as well test the execute bit too.
+ chmod +x ab
+ dotest modes-8 "${testcvs} add ab" \
+"${PROG} [a-z]*: scheduling file .ab. for addition
+${PROG} [a-z]*: use .cvs commit. to add this file permanently"
+ dotest modes-9 "${testcvs} -q ci -m add" \
+"RCS file: ${TESTDIR}/cvsroot/first-dir/ab,v
+done
+Checking in ab;
+${TESTDIR}/cvsroot/first-dir/ab,v <-- ab
+initial revision: 1\.1
+done"
+ if test "x$remote" = xyes; then
+ # The problem here is that the CVSUMASK environment variable
+ # needs to be set on the server (e.g. .bashrc). This is, of
+ # course, bogus, but that is the way it is currently.
+ dotest modes-10 "ls -l ${TESTDIR}/cvsroot/first-dir/ab,v" \
+"-r-xr-x---.*" "-r-xr-xr-x.*"
+ else
+ dotest modes-10 "ls -l ${TESTDIR}/cvsroot/first-dir/ab,v" \
+"-r-xr-x---.*"
+ fi
+
+ # OK, now add a file on a branch. Check that the mode gets
+ # set the same way (it is a different code path in CVS).
+ dotest modes-11 "${testcvs} -q tag -b br" 'T aa
+T ab'
+ dotest modes-12 "${testcvs} -q update -r br" ''
+ touch ac
+ dotest modes-13 "${testcvs} add ac" \
+"${PROG} [a-z]*: scheduling file .ac. for addition on branch .br.
+${PROG} [a-z]*: use .cvs commit. to add this file permanently"
+ # Not sure it really makes sense to refer to a "previous revision"
+ # when we are just now adding the file; as far as I know
+ # that is longstanding CVS behavior, for what it's worth.
+ dotest modes-14 "${testcvs} -q ci -m add" \
+"RCS file: ${TESTDIR}/cvsroot/first-dir/Attic/ac,v
+done
+Checking in ac;
+${TESTDIR}/cvsroot/first-dir/Attic/ac,v <-- ac
+new revision: 1\.1\.2\.1; previous revision: 1\.1
+done"
+ if test "x$remote" = xyes; then
+ # The problem here is that the CVSUMASK environment variable
+ # needs to be set on the server (e.g. .bashrc). This is, of
+ # course, bogus, but that is the way it is currently.
+ dotest modes-15 \
+"ls -l ${TESTDIR}/cvsroot/first-dir/Attic/ac,v" \
+"-r--r--r--.*"
+ else
+ dotest modes-15 \
+"ls -l ${TESTDIR}/cvsroot/first-dir/Attic/ac,v" \
+"-r--r-----.*"
+ fi
+
+ cd ../..
+ rm -rf 1 ${CVSROOT_DIRNAME}/first-dir
+ # Perhaps should restore the umask and CVSUMASK. But the other
+ # tests "should" not care about them...
+ ;;
+
+ sticky)
+ # More tests of sticky tags, particularly non-branch sticky tags.
+ mkdir 1; cd 1
+ dotest sticky-1 "${testcvs} -q co -l ." ''
+ mkdir first-dir
+ dotest sticky-2 "${testcvs} add first-dir" \
+"Directory ${TESTDIR}/cvsroot/first-dir added to the repository"
+ cd first-dir
+
+ touch file1
+ dotest sticky-3 "${testcvs} add file1" \
+"${PROG} [a-z]*: scheduling file .file1. for addition
+${PROG} [a-z]*: use .cvs commit. to add this file permanently"
+ dotest sticky-4 "${testcvs} -q ci -m add" \
+"RCS file: ${TESTDIR}/cvsroot/first-dir/file1,v
+done
+Checking in file1;
+${TESTDIR}/cvsroot/first-dir/file1,v <-- file1
+initial revision: 1\.1
+done"
+ dotest sticky-5 "${testcvs} -q tag tag1" "T file1"
+ echo add a line >>file1
+ dotest sticky-6 "${testcvs} -q ci -m modify" \
+"Checking in file1;
+${TESTDIR}/cvsroot/first-dir/file1,v <-- file1
+new revision: 1\.2; previous revision: 1\.1
+done"
+ dotest sticky-7 "${testcvs} -q update -r tag1" "[UP] file1"
+ dotest sticky-8 "cat file1" ''
+ dotest sticky-9 "${testcvs} -q update" ''
+ dotest sticky-10 "cat file1" ''
+ touch file2
+ dotest_fail sticky-11 "${testcvs} add file2" \
+"${PROG} [a-z]*: cannot add file on non-branch tag tag1"
+ dotest sticky-12 "${testcvs} -q update -A" "[UP] file1
+${QUESTION} file2" "${QUESTION} file2
+[UP] file1"
+ dotest sticky-13 "${testcvs} add file2" \
+"${PROG} [a-z]*: scheduling file .file2. for addition
+${PROG} [a-z]*: use .cvs commit. to add this file permanently"
+
+ cd ../..
+ rm -rf 1 ${CVSROOT_DIRNAME}/first-dir
+ ;;
+
+ keyword)
+ # Test keyword expansion.
+ mkdir 1; cd 1
+ dotest keyword-1 "${testcvs} -q co -l ." ''
+ mkdir first-dir
+ dotest keyword-2 "${testcvs} add first-dir" \
+"Directory ${TESTDIR}/cvsroot/first-dir added to the repository"
+ cd first-dir
+
+ echo '$''Author$' > file1
+ echo '$''Date$' >> file1
+ echo '$''Header$' >> file1
+ echo '$''Id$' >> file1
+ echo '$''Locker$' >> file1
+ echo '$''Name$' >> file1
+ echo '$''RCSfile$' >> file1
+ echo '$''Revision$' >> file1
+ echo '$''Source$' >> file1
+ echo '$''State$' >> file1
+ echo '$''Nonkey$' >> file1
+ # Omit the trailing dollar sign
+ echo '$''Date' >> file1
+ # Put two keywords on one line
+ echo '$''State$' '$''State$' >> file1
+ # Use a header for Log
+ echo 'xx $''Log$' >> file1
+
+ dotest keyword-3 "${testcvs} add file1" \
+"${PROG} [a-z]*: scheduling file .file1. for addition
+${PROG} [a-z]*: use .cvs commit. to add this file permanently"
+ dotest keyword-4 "${testcvs} -q ci -m add" \
+"RCS file: ${TESTDIR}/cvsroot/first-dir/file1,v
+done
+Checking in file1;
+${TESTDIR}/cvsroot/first-dir/file1,v <-- file1
+initial revision: 1\.1
+done"
+ dotest keyword-5 "cat file1" \
+'\$'"Author: ${username} "'\$'"
+"'\$'"Date: [0-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9] "'\$'"
+"'\$'"Header: ${TESTDIR}/cvsroot/first-dir/file1,v 1\.1 [0-9/]* [0-9:]* ${username} Exp "'\$'"
+"'\$'"Id: file1,v 1\.1 [0-9/]* [0-9:]* ${username} Exp "'\$'"
+"'\$'"Locker: "'\$'"
+"'\$'"Name: "'\$'"
+"'\$'"RCSfile: file1,v "'\$'"
+"'\$'"Revision: 1\.1 "'\$'"
+"'\$'"Source: ${TESTDIR}/cvsroot/first-dir/file1,v "'\$'"
+"'\$'"State: Exp "'\$'"
+"'\$'"Nonkey"'\$'"
+"'\$'"Date
+"'\$'"State: Exp "'\$'" "'\$'"State: Exp "'\$'"
+xx "'\$'"Log: file1,v "'\$'"
+xx Revision 1\.1 [0-9/]* [0-9:]* ${username}
+xx add
+xx"
+
+ # Use cvs admin to lock the RCS file in order to check -kkvl
+ # vs. -kkv. CVS does not normally lock RCS files, but some
+ # people use cvs admin to enforce reserved checkouts.
+ dotest keyword-6 "${testcvs} admin -l file1" \
+"RCS file: ${TESTDIR}/cvsroot/first-dir/file1,v
+1\.1 locked
+done"
+
+ dotest keyword-7 "${testcvs} update -kkv file1" "U file1"
+ dotest keyword-8 "cat file1" \
+'\$'"Author: ${username} "'\$'"
+"'\$'"Date: [0-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9] "'\$'"
+"'\$'"Header: ${TESTDIR}/cvsroot/first-dir/file1,v 1\.1 [0-9/]* [0-9:]* ${username} Exp "'\$'"
+"'\$'"Id: file1,v 1\.1 [0-9/]* [0-9:]* ${username} Exp "'\$'"
+"'\$'"Locker: "'\$'"
+"'\$'"Name: "'\$'"
+"'\$'"RCSfile: file1,v "'\$'"
+"'\$'"Revision: 1\.1 "'\$'"
+"'\$'"Source: ${TESTDIR}/cvsroot/first-dir/file1,v "'\$'"
+"'\$'"State: Exp "'\$'"
+"'\$'"Nonkey"'\$'"
+"'\$'"Date
+"'\$'"State: Exp "'\$'" "'\$'"State: Exp "'\$'"
+xx "'\$'"Log: file1,v "'\$'"
+xx Revision 1\.1 [0-9/]* [0-9:]* ${username}
+xx add
+xx"
+
+ dotest keyword-9 "${testcvs} update -kkvl file1" "U file1"
+ dotest keyword-10 "cat file1" \
+'\$'"Author: ${username} "'\$'"
+"'\$'"Date: [0-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9] "'\$'"
+"'\$'"Header: ${TESTDIR}/cvsroot/first-dir/file1,v 1\.1 [0-9/]* [0-9:]* ${username} Exp ${username} "'\$'"
+"'\$'"Id: file1,v 1\.1 [0-9/]* [0-9:]* ${username} Exp ${username} "'\$'"
+"'\$'"Locker: ${username} "'\$'"
+"'\$'"Name: "'\$'"
+"'\$'"RCSfile: file1,v "'\$'"
+"'\$'"Revision: 1\.1 "'\$'"
+"'\$'"Source: ${TESTDIR}/cvsroot/first-dir/file1,v "'\$'"
+"'\$'"State: Exp "'\$'"
+"'\$'"Nonkey"'\$'"
+"'\$'"Date
+"'\$'"State: Exp "'\$'" "'\$'"State: Exp "'\$'"
+xx "'\$'"Log: file1,v "'\$'"
+xx Revision 1\.1 [0-9/]* [0-9:]* ${username}
+xx add
+xx"
+
+ dotest keyword-11 "${testcvs} update -kk file1" "U file1"
+ dotest keyword-12 "cat file1" \
+'\$'"Author"'\$'"
+"'\$'"Date"'\$'"
+"'\$'"Header"'\$'"
+"'\$'"Id"'\$'"
+"'\$'"Locker"'\$'"
+"'\$'"Name"'\$'"
+"'\$'"RCSfile"'\$'"
+"'\$'"Revision"'\$'"
+"'\$'"Source"'\$'"
+"'\$'"State"'\$'"
+"'\$'"Nonkey"'\$'"
+"'\$'"Date
+"'\$'"State"'\$'" "'\$'"State"'\$'"
+xx "'\$'"Log"'\$'"
+xx Revision 1\.1 [0-9/]* [0-9:]* ${username}
+xx add
+xx"
+
+ dotest keyword-13 "${testcvs} update -kv file1" "U file1"
+ dotest keyword-14 "cat file1" \
+"${username}
+[0-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]
+${TESTDIR}/cvsroot/first-dir/file1,v 1\.1 [0-9/]* [0-9:]* ${username} Exp
+file1,v 1\.1 [0-9/]* [0-9:]* ${username} Exp
+
+
+file1,v
+1\.1
+${TESTDIR}/cvsroot/first-dir/file1,v
+Exp
+"'\$'"Nonkey"'\$'"
+"'\$'"Date
+Exp Exp
+xx file1,v
+xx Revision 1\.1 [0-9/]* [0-9:]* ${username}
+xx add
+xx"
+
+ dotest keyword-15 "${testcvs} update -ko file1" "U file1"
+ dotest keyword-16 "cat file1" \
+'\$'"Author"'\$'"
+"'\$'"Date"'\$'"
+"'\$'"Header"'\$'"
+"'\$'"Id"'\$'"
+"'\$'"Locker"'\$'"
+"'\$'"Name"'\$'"
+"'\$'"RCSfile"'\$'"
+"'\$'"Revision"'\$'"
+"'\$'"Source"'\$'"
+"'\$'"State"'\$'"
+"'\$'"Nonkey"'\$'"
+"'\$'"Date
+"'\$'"State"'\$'" "'\$'"State"'\$'"
+xx "'\$'"Log"'\$'
+
+ # Test the Name keyword. First go back to normal expansion.
+
+ # FIXME: When using remote, update -A does not revert the
+ # keyword expansion mode. We work around that bug here.
+ # This workaround should be removed when the bug is fixed.
+ if test "x$remote" = "xyes"; then
+ cd ..
+ rm -rf first-dir
+ dotest keyword-17 "${testcvs} -q co first-dir" "U first-dir/file1"
+ cd first-dir
+ else
+ dotest keyword-17 "${testcvs} update -A file1" "U file1"
+ fi
+
+ echo '$''Name$' > file1
+ dotest keyword-18 "${testcvs} ci -m modify file1" \
+"Checking in file1;
+${TESTDIR}/cvsroot/first-dir/file1,v <-- file1
+new revision: 1\.2; previous revision: 1\.1
+done"
+ dotest keyword-19 "${testcvs} -q tag tag1" "T file1"
+ echo "change" >> file1
+ dotest keyword-20 "${testcvs} -q ci -m mod2 file1" \
+"Checking in file1;
+${TESTDIR}/cvsroot/first-dir/file1,v <-- file1
+new revision: 1\.3; previous revision: 1\.2
+done"
+ dotest keyword-21 "${testcvs} -q update -r tag1" "[UP] file1"
+
+ # FIXME: This test fails when remote. The second expect
+ # string below should be removed when this is fixed.
+ dotest keyword-22 "cat file1" '\$'"Name: tag1 "'\$' \
+'\$'"Name: "'\$'
+
+ dotest keyword-23 "${testcvs} update -A file1" "[UP] file1"
+
+ # Test the Log keyword.
+ echo 'xx $''Log$' > file1
+ cat >${TESTDIR}/comment.tmp <<EOF
+First log line
+Second log line
+EOF
+ dotest keyword-24 "${testcvs} ci -F ${TESTDIR}/comment.tmp file1" \
+"Checking in file1;
+${TESTDIR}/cvsroot/first-dir/file1,v <-- file1
+new revision: 1\.4; previous revision: 1\.3
+done"
+ rm -f ${TESTDIR}/comment.tmp
+ dotest keyword-25 "cat file1" \
+"xx "'\$'"Log: file1,v "'\$'"
+xx Revision 1\.4 [0-9/]* [0-9:]* ${username}
+xx First log line
+xx Second log line
+xx"
+
+ echo "change" >> file1
+ dotest keyword-26 "${testcvs} ci -m modify file1" \
+"Checking in file1;
+${TESTDIR}/cvsroot/first-dir/file1,v <-- file1
+new revision: 1\.5; previous revision: 1\.4
+done"
+ dotest keyword-27 "cat file1" \
+"xx "'\$'"Log: file1,v "'\$'"
+xx Revision 1\.5 [0-9/]* [0-9:]* ${username}
+xx modify
+xx
+xx Revision 1\.4 [0-9/]* [0-9:]* ${username}
+xx First log line
+xx Second log line
+xx
+change"
+
+ cd ../..
+ rm -rf 1 ${CVSROOT_DIRNAME}/first-dir
+ ;;
+
*)
echo $what is not the name of a test -- ignored
;;
@@ -2833,33 +6572,36 @@ done
echo "OK, all tests completed."
# TODO:
-# * Test `cvs admin'.
+# * use "test" not "[" and see if all test's support `-z'
# * Test `cvs update -d foo' (where foo does not exist).
-# * Test `cvs update foo bar' (where foo and bar are both from the same
-# repository). Suppose one is a branch--make sure that both directories
-# get updated with the respective correct thing.
+# * Test `cvs update foo bar' (where foo and bar are both from the
+# same directory in the repository). Suppose one is a branch--make
+# sure that both directories get updated with the respective correct
+# thing.
# * `cvs update ../foo'. Also ../../foo ./../foo foo/../../bar /foo/bar
# foo/.././../bar foo/../bar etc.
# * Test all flags in modules file.
# Test that ciprog gets run both on checkin in that directory, or a
# higher-level checkin which recurses into it.
-# * Test that $ followed by "Header" followed by $ gets expanded on checkin.
-# * Test operations on a directory that contains other directories but has
+# * More tests of keyword expansion.
+# * Test operations on a directory that contains other directories but has
# no files of its own.
# * -t global option
# * cvs rm followed by cvs add or vice versa (with no checkin in between).
# * cvs rm twice (should be a nice error message).
# * -P option to checkout--(a) refrains from checking out new empty dirs,
# (b) prunes empty dirs already there.
-# * Test that cvs -d `hostname`:/tmp/cvs-sanity/non/existent co foo
-# gives an appropriate error (e.g.
-# Cannot access /tmp/cvs-sanity/non-existent/CVSROOT
+# * Test that cvs -d `hostname`:${TESTDIR}/non/existent co foo
+# gives an appropriate error (e.g.
+# Cannot access ${TESTDIR}/non-existent/CVSROOT
# No such file or directory).
+# (like basica-9, but for remote).
# * Test ability to send notifications in response to watches. (currently
# hard to test because CVS doesn't send notifications if username is the
# same).
# * Test that remote edit and/or unedit works when disconnected from
# server (e.g. set CVS_SERVER to "foobar").
+# * Test things to do with the CVS/* files, esp. CVS/Root....
# End of TODO list.
# Remove the test directory, but first change out of it.
diff --git a/contrib/cvs/src/server.c b/contrib/cvs/src/server.c
index e92445b..65b1dd3 100644
--- a/contrib/cvs/src/server.c
+++ b/contrib/cvs/src/server.c
@@ -1,31 +1,81 @@
+/* This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details. */
+
#include <assert.h>
#include "cvs.h"
#include "watch.h"
#include "edit.h"
#include "fileattr.h"
+#include "getline.h"
+#include "buffer.h"
#ifdef SERVER_SUPPORT
+#ifdef HAVE_WINSOCK_H
+#include <winsock.h>
+#endif
+
+#if defined (AUTH_SERVER_SUPPORT) || defined (HAVE_KERBEROS)
+#include <sys/socket.h>
+#endif
+
+#ifdef HAVE_KERBEROS
+#include <netinet/in.h>
+#include <krb.h>
+#ifndef HAVE_KRB_GET_ERR_TEXT
+#define krb_get_err_text(status) krb_err_txt[status]
+#endif
+
+/* Information we need if we are going to use Kerberos encryption. */
+static C_Block kblock;
+static Key_schedule sched;
+
+#endif
+
/* for select */
#include <sys/types.h>
#ifdef HAVE_SYS_BSDTYPES_H
#include <sys/bsdtypes.h>
#endif
-#include <sys/time.h>
-#if HAVE_SYS_SELECT_H
-#include <sys/select.h>
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
#endif
-#if HAVE_FCNTL_H
-#include <fcntl.h>
+#if HAVE_SYS_SELECT_H
+#include <sys/select.h>
#endif
#ifndef O_NONBLOCK
#define O_NONBLOCK O_NDELAY
#endif
+/* EWOULDBLOCK is not defined by POSIX, but some BSD systems will
+ return it, rather than EAGAIN, for nonblocking writes. */
+#ifdef EWOULDBLOCK
+#define blocking_error(err) ((err) == EWOULDBLOCK || (err) == EAGAIN)
+#else
+#define blocking_error(err) ((err) == EAGAIN)
+#endif
+
#ifdef AUTH_SERVER_SUPPORT
+#ifdef HAVE_GETSPNAM
+#include <shadow.h>
+#endif
/* For initgroups(). */
#if HAVE_INITGROUPS
#include <grp.h>
@@ -33,23 +83,28 @@
#endif /* AUTH_SERVER_SUPPORT */
-/* Functions which the server calls. */
-int add PROTO((int argc, char **argv));
-int admin PROTO((int argc, char **argv));
-int checkout PROTO((int argc, char **argv));
-int commit PROTO((int argc, char **argv));
-int diff PROTO((int argc, char **argv));
-int history PROTO((int argc, char **argv));
-int import PROTO((int argc, char **argv));
-int cvslog PROTO((int argc, char **argv));
-int patch PROTO((int argc, char **argv));
-int release PROTO((int argc, char **argv));
-int cvsremove PROTO((int argc, char **argv));
-int rtag PROTO((int argc, char **argv));
-int status PROTO((int argc, char **argv));
-int tag PROTO((int argc, char **argv));
-int update PROTO((int argc, char **argv));
+#ifdef AUTH_SERVER_SUPPORT
+
+/* The cvs username sent by the client, which might or might not be
+ the same as the system username the server eventually switches to
+ run as. CVS_Username gets set iff password authentication is
+ successful. */
+static char *CVS_Username = NULL;
+
+/* Used to check that same repos is transmitted in pserver auth and in
+ later CVS protocol. Exported because root.c also uses. */
+char *Pserver_Repos = NULL;
+
+#endif /* AUTH_SERVER_SUPPORT */
+
+/* While processing requests, this buffer accumulates data to be sent to
+ the client, and then once we are in do_cvs_command, we use it
+ for all the data to be sent. */
+static struct buffer *buf_to_net;
+
+/* This buffer is used to read input from the client. */
+static struct buffer *buf_from_net;
/*
* This is where we stash stuff we are going to use. Format string
@@ -57,64 +112,189 @@ int update PROTO((int argc, char **argv));
*/
static char *server_temp_dir;
+/* This is the original value of server_temp_dir, before any possible
+ changes inserted by serve_max_dotdot. */
+static char *orig_server_temp_dir;
+
/* Nonzero if we should keep the temp directory around after we exit. */
static int dont_delete_temp;
-static char no_mem_error;
-#define NO_MEM_ERROR (&no_mem_error)
-
static void server_write_entries PROTO((void));
-/*
- * Read a line from the stream "instream" without command line editing.
- *
- * Action is compatible with "readline", e.g. space for the result is
- * malloc'd and should be freed by the caller.
- *
- * A NULL return means end of file. A return of NO_MEM_ERROR means
- * that we are out of memory.
- */
-static char *read_line PROTO((FILE *));
+/* All server communication goes through buffer structures. Most of
+ the buffers are built on top of a file descriptor. This structure
+ is used as the closure field in a buffer. */
-static char *
-read_line (stream)
- FILE *stream;
+struct fd_buffer
{
- int c;
- char *result;
- int input_index = 0;
- int result_size = 80;
-
- fflush (stdout);
- result = (char *) malloc (result_size);
- if (result == NULL)
- return NO_MEM_ERROR;
-
- while (1)
+ /* The file descriptor. */
+ int fd;
+ /* Nonzero if the file descriptor is in blocking mode. */
+ int blocking;
+};
+
+static struct buffer *fd_buffer_initialize
+ PROTO ((int, int, void (*) (struct buffer *)));
+static int fd_buffer_input PROTO((void *, char *, int, int, int *));
+static int fd_buffer_output PROTO((void *, const char *, int, int *));
+static int fd_buffer_flush PROTO((void *));
+static int fd_buffer_block PROTO((void *, int));
+
+/* Initialize a buffer built on a file descriptor. FD is the file
+ descriptor. INPUT is nonzero if this is for input, zero if this is
+ for output. MEMORY is the function to call when a memory error
+ occurs. */
+
+static struct buffer *
+fd_buffer_initialize (fd, input, memory)
+ int fd;
+ int input;
+ void (*memory) PROTO((struct buffer *));
+{
+ struct fd_buffer *n;
+
+ n = (struct fd_buffer *) xmalloc (sizeof *n);
+ n->fd = fd;
+ n->blocking = 1;
+ return buf_initialize (input ? fd_buffer_input : NULL,
+ input ? NULL : fd_buffer_output,
+ input ? NULL : fd_buffer_flush,
+ fd_buffer_block,
+ (int (*) PROTO((void *))) NULL,
+ memory,
+ n);
+}
+
+/* The buffer input function for a buffer built on a file descriptor. */
+
+static int
+fd_buffer_input (closure, data, need, size, got)
+ void *closure;
+ char *data;
+ int need;
+ int size;
+ int *got;
+{
+ struct fd_buffer *fd = (struct fd_buffer *) closure;
+ int nbytes;
+
+ if (! fd->blocking)
+ nbytes = read (fd->fd, data, size);
+ else
{
- c = fgetc (stream);
-
- if (c == EOF)
- {
- free (result);
- return NULL;
- }
-
- if (c == '\n')
- break;
-
- result[input_index++] = c;
- while (input_index >= result_size)
+ /* This case is not efficient. Fortunately, I don't think it
+ ever actually happens. */
+ nbytes = read (fd->fd, data, need == 0 ? 1 : need);
+ }
+
+ if (nbytes > 0)
+ {
+ *got = nbytes;
+ return 0;
+ }
+
+ *got = 0;
+
+ if (nbytes == 0)
+ {
+ /* End of file. This assumes that we are using POSIX or BSD
+ style nonblocking I/O. On System V we will get a zero
+ return if there is no data, even when not at EOF. */
+ return -1;
+ }
+
+ /* Some error occurred. */
+
+ if (blocking_error (errno))
+ {
+ /* Everything's fine, we just didn't get any data. */
+ return 0;
+ }
+
+ return errno;
+}
+
+/* The buffer output function for a buffer built on a file descriptor. */
+
+static int
+fd_buffer_output (closure, data, have, wrote)
+ void *closure;
+ const char *data;
+ int have;
+ int *wrote;
+{
+ struct fd_buffer *fd = (struct fd_buffer *) closure;
+
+ *wrote = 0;
+
+ while (have > 0)
+ {
+ int nbytes;
+
+ nbytes = write (fd->fd, data, have);
+
+ if (nbytes <= 0)
{
- result_size *= 2;
- result = (char *) realloc (result, result_size);
- if (result == NULL)
- return NO_MEM_ERROR;
+ if (! fd->blocking
+ && (nbytes == 0 || blocking_error (errno)))
+ {
+ /* A nonblocking write failed to write any data. Just
+ return. */
+ return 0;
+ }
+
+ /* Some sort of error occurred. */
+
+ if (nbytes == 0)
+ return EIO;
+
+ return errno;
}
+
+ *wrote += nbytes;
+ data += nbytes;
+ have -= nbytes;
}
-
- result[input_index++] = '\0';
- return result;
+
+ return 0;
+}
+
+/* The buffer flush function for a buffer built on a file descriptor. */
+
+/*ARGSUSED*/
+static int
+fd_buffer_flush (closure)
+ void *closure;
+{
+ /* Nothing to do. File descriptors are always flushed. */
+ return 0;
+}
+
+/* The buffer block function for a buffer built on a file descriptor. */
+
+static int
+fd_buffer_block (closure, block)
+ void *closure;
+ int block;
+{
+ struct fd_buffer *fd = (struct fd_buffer *) closure;
+ int flags;
+
+ flags = fcntl (fd->fd, F_GETFL, 0);
+ if (flags < 0)
+ return errno;
+
+ if (block)
+ flags &= ~O_NONBLOCK;
+ else
+ flags |= O_NONBLOCK;
+
+ if (fcntl (fd->fd, F_SETFL, flags) < 0)
+ return errno;
+
+ fd->blocking = block;
+
+ return 0;
}
/*
@@ -134,6 +314,8 @@ mkdir_p (dir)
if (q == NULL)
return ENOMEM;
+ retval = 0;
+
/*
* Skip over leading slash if present. We won't bother to try to
* make '/'.
@@ -149,10 +331,12 @@ mkdir_p (dir)
q[p - dir] = '\0';
if (CVS_MKDIR (q, 0777) < 0)
{
- if (errno != EEXIST
- && (errno != EACCES || !isdir(q)))
+ int saved_errno = errno;
+
+ if (saved_errno != EEXIST
+ && (saved_errno != EACCES || !isdir (q)))
{
- retval = errno;
+ retval = saved_errno;
goto done;
}
}
@@ -162,8 +346,6 @@ mkdir_p (dir)
{
if (CVS_MKDIR (dir, 0777) < 0)
retval = errno;
- else
- retval = 0;
goto done;
}
}
@@ -176,17 +358,20 @@ mkdir_p (dir)
* Print the error response for error code STATUS. The caller is
* reponsible for making sure we get back to the command loop without
* any further output occuring.
+ * Must be called only in contexts where it is OK to send output.
*/
static void
print_error (status)
int status;
{
char *msg;
- printf ("error ");
+ buf_output0 (buf_to_net, "error ");
msg = strerror (status);
if (msg)
- printf ("%s", msg);
- printf ("\n");
+ buf_output0 (buf_to_net, msg);
+ buf_append_char (buf_to_net, '\n');
+
+ buf_flush (buf_to_net, 0);
}
static int pending_error;
@@ -196,17 +381,22 @@ static int pending_error;
*/
static char *pending_error_text;
-/* If an error is pending, print it and return 1. If not, return 0. */
+/* If an error is pending, print it and return 1. If not, return 0.
+ Must be called only in contexts where it is OK to send output. */
static int
print_pending_error ()
{
if (pending_error_text)
{
- printf ("%s\n", pending_error_text);
+ buf_output0 (buf_to_net, pending_error_text);
+ buf_append_char (buf_to_net, '\n');
if (pending_error)
print_error (pending_error);
else
- printf ("error \n");
+ buf_output0 (buf_to_net, "error \n");
+
+ buf_flush (buf_to_net, 0);
+
pending_error = 0;
free (pending_error_text);
pending_error_text = NULL;
@@ -224,8 +414,32 @@ print_pending_error ()
/* Is an error pending? */
#define error_pending() (pending_error || pending_error_text)
+
+static int alloc_pending PROTO ((size_t size));
+
+/* Allocate SIZE bytes for pending_error_text and return nonzero
+ if we could do it. */
+static int
+alloc_pending (size)
+ size_t size;
+{
+ if (error_pending ())
+ /* Probably alloc_pending callers will have already checked for
+ this case. But we might as well handle it if they don't, I
+ guess. */
+ return 0;
+ pending_error_text = malloc (size);
+ if (pending_error_text == NULL)
+ {
+ pending_error = ENOMEM;
+ return 0;
+ }
+ return 1;
+}
-int
+static int supported_response PROTO ((char *));
+
+static int
supported_response (name)
char *name;
{
@@ -270,8 +484,24 @@ serve_valid_responses (arg)
{
if (rs->status == rs_essential)
{
- printf ("E response `%s' not supported by client\nerror \n",
- rs->name);
+ buf_output0 (buf_to_net, "E response `");
+ buf_output0 (buf_to_net, rs->name);
+ buf_output0 (buf_to_net, "' not supported by client\nerror \n");
+
+ /* FIXME: This call to buf_flush could conceivably
+ cause deadlock, as noted in server_cleanup. */
+ buf_flush (buf_to_net, 1);
+
+ /* I'm doing this manually rather than via error_exit ()
+ because I'm not sure whether we want to call server_cleanup.
+ Needs more investigation.... */
+
+#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 (EXIT_FAILURE);
}
else if (rs->status == rs_optional)
@@ -279,20 +509,30 @@ serve_valid_responses (arg)
}
}
-static int use_dir_and_repos = 0;
-
static void
serve_root (arg)
char *arg;
{
char *env;
- extern char *CVSroot;
- char path[PATH_MAX];
+ char *path;
int save_errno;
if (error_pending()) return;
-
- (void) sprintf (path, "%s/%s", arg, CVSROOTADM);
+
+ if (!isabsolute (arg))
+ {
+ if (alloc_pending (80 + strlen (arg)))
+ sprintf (pending_error_text,
+ "E Root %s must be an absolute pathname", arg);
+ return;
+ }
+ set_local_cvsroot (arg);
+
+ path = xmalloc (strlen (CVSroot_directory)
+ + sizeof (CVSROOTADM)
+ + sizeof (CVSROOTADM_HISTORY)
+ + 10);
+ (void) sprintf (path, "%s/%s", CVSroot_directory, CVSROOTADM);
if (!isaccessible (path, R_OK | X_OK))
{
save_errno = errno;
@@ -312,26 +552,42 @@ serve_root (arg)
Sorry, you don't have read/write access to the history file %s", path);
pending_error = save_errno;
}
+ free (path);
- CVSroot = malloc (strlen (arg) + 1);
- if (CVSroot == NULL)
- {
- pending_error = ENOMEM;
- return;
- }
- strcpy (CVSroot, arg);
#ifdef HAVE_PUTENV
- env = malloc (strlen (CVSROOT_ENV) + strlen (CVSroot) + 1 + 1);
+ env = malloc (strlen (CVSROOT_ENV) + strlen (CVSroot_directory) + 1 + 1);
if (env == NULL)
{
pending_error = ENOMEM;
return;
}
- (void) sprintf (env, "%s=%s", CVSROOT_ENV, arg);
+ (void) sprintf (env, "%s=%s", CVSROOT_ENV, CVSroot_directory);
(void) putenv (env);
/* do not free env, as putenv has control of it */
#endif
}
+
+static int max_dotdot_limit = 0;
+
+/* Is this pathname OK to recurse into when we are running as the server?
+ If not, call error() with a fatal error. */
+void
+server_pathname_check (path)
+ char *path;
+{
+ /* An absolute pathname is almost surely a path on the *client* machine,
+ and is unlikely to do us any good here. It also is probably capable
+ of being a security hole in the anonymous readonly case. */
+ if (isabsolute (path))
+ error (1, 0, "absolute pathname `%s' illegal for server", path);
+ if (pathname_levels (path) > max_dotdot_limit)
+ {
+ /* Similar to the isabsolute case in security implications. */
+ error (0, 0, "protocol error: `%s' contains more leading ..", path);
+ error (1, 0, "than the %d which Max-dotdot specified",
+ max_dotdot_limit);
+ }
+}
/*
* Add as many directories to the temp directory as the client tells us it
@@ -357,8 +613,10 @@ serve_max_dotdot (arg)
strcpy (p, server_temp_dir);
for (i = 0; i < lim; ++i)
strcat (p, "/d");
- free (server_temp_dir);
+ if (server_temp_dir != orig_server_temp_dir)
+ free (server_temp_dir);
server_temp_dir = p;
+ max_dotdot_limit = lim;
}
static char *dir_name;
@@ -370,6 +628,7 @@ dirswitch (dir, repos)
{
int status;
FILE *f;
+ char *b;
server_write_entries ();
@@ -378,6 +637,19 @@ dirswitch (dir, repos)
if (dir_name != NULL)
free (dir_name);
+ /* Check for a trailing '/'. This is not ISDIRSEP because \ in the
+ protocol is an ordinary character, not a directory separator (of
+ course, it is perhaps unwise to use it in directory names, but that
+ is another issue). */
+ if (strlen (dir) > 0
+ && dir[strlen (dir) - 1] == '/')
+ {
+ if (alloc_pending (80 + strlen (dir)))
+ sprintf (pending_error_text,
+ "E protocol error: illegal directory syntax in %s", dir);
+ return;
+ }
+
dir_name = malloc (strlen (server_temp_dir) + strlen (dir) + 40);
if (dir_name == NULL)
{
@@ -394,15 +666,21 @@ dirswitch (dir, repos)
&& status != EEXIST)
{
pending_error = status;
- pending_error_text = malloc (80 + strlen(dir_name));
- sprintf(pending_error_text, "E cannot mkdir %s", dir_name);
+ if (alloc_pending (80 + strlen (dir_name)))
+ sprintf (pending_error_text, "E cannot mkdir %s", dir_name);
return;
}
- if (chdir (dir_name) < 0)
+
+ b = strrchr (dir_name, '/');
+ *b = '\0';
+ Subdir_Register ((List *) NULL, dir_name, b + 1);
+ *b = '/';
+
+ if ( CVS_CHDIR (dir_name) < 0)
{
pending_error = errno;
- pending_error_text = malloc (80 + strlen(dir_name));
- sprintf(pending_error_text, "E cannot change to %s", dir_name);
+ if (alloc_pending (80 + strlen (dir_name)))
+ sprintf (pending_error_text, "E cannot change to %s", dir_name);
return;
}
/*
@@ -417,13 +695,33 @@ dirswitch (dir, repos)
pending_error = errno;
return;
}
- f = fopen (CVSADM_REP, "w");
+ f = CVS_FOPEN (CVSADM_REP, "w");
if (f == NULL)
{
pending_error = errno;
return;
}
- if (fprintf (f, "%s\n", repos) < 0)
+ if (fprintf (f, "%s", repos) < 0)
+ {
+ pending_error = errno;
+ fclose (f);
+ return;
+ }
+ /* Non-remote CVS handles a module representing the entire tree
+ (e.g., an entry like ``world -a .'') by putting /. at the end
+ of the Repository file, so we do the same. */
+ if (strcmp (dir, ".") == 0
+ && CVSroot_directory != NULL
+ && strcmp (CVSroot_directory, repos) == 0)
+ {
+ if (fprintf (f, "/.") < 0)
+ {
+ pending_error = errno;
+ fclose (f);
+ return;
+ }
+ }
+ if (fprintf (f, "\n") < 0)
{
pending_error = errno;
fclose (f);
@@ -434,19 +732,21 @@ dirswitch (dir, repos)
pending_error = errno;
return;
}
- f = fopen (CVSADM_ENT, "w+");
+ /* We open in append mode because we don't want to clobber an
+ existing Entries file. */
+ f = CVS_FOPEN (CVSADM_ENT, "a");
if (f == NULL)
{
pending_error = errno;
- pending_error_text = malloc (80 + strlen(CVSADM_ENT));
- sprintf(pending_error_text, "E cannot open %s", CVSADM_ENT);
+ if (alloc_pending (80 + strlen (CVSADM_ENT)))
+ sprintf (pending_error_text, "E cannot open %s", CVSADM_ENT);
return;
}
if (fclose (f) == EOF)
{
pending_error = errno;
- pending_error_text = malloc (80 + strlen(CVSADM_ENT));
- sprintf(pending_error_text, "E cannot close %s", CVSADM_ENT);
+ if (alloc_pending (80 + strlen (CVSADM_ENT)))
+ sprintf (pending_error_text, "E cannot close %s", CVSADM_ENT);
return;
}
}
@@ -455,42 +755,50 @@ static void
serve_repository (arg)
char *arg;
{
- dirswitch (arg + 1, arg);
+ pending_error_text = malloc (80);
+ if (pending_error_text == NULL)
+ pending_error = ENOMEM;
+ else
+ strcpy (pending_error_text,
+ "E Repository request is obsolete; aborted");
+ return;
}
static void
serve_directory (arg)
char *arg;
{
+ int status;
char *repos;
- use_dir_and_repos = 1;
- repos = read_line (stdin);
- if (repos == NULL)
+
+ status = buf_read_line (buf_from_net, &repos, (int *) NULL);
+ if (status == 0)
{
- pending_error_text = malloc (80 + strlen (arg));
- if (pending_error_text)
- {
- if (feof (stdin))
- sprintf (pending_error_text,
- "E end of file reading mode for %s", arg);
- else
- {
- sprintf (pending_error_text,
- "E error reading mode for %s", arg);
- pending_error = errno;
- }
- }
- else
- pending_error = ENOMEM;
+ dirswitch (arg, repos);
+ free (repos);
}
- else if (repos == NO_MEM_ERROR)
+ else if (status == -2)
{
- pending_error = ENOMEM;
+ pending_error = ENOMEM;
}
else
{
- dirswitch (arg, repos);
- free (repos);
+ pending_error_text = malloc (80 + strlen (arg));
+ if (pending_error_text == NULL)
+ {
+ pending_error = ENOMEM;
+ }
+ else if (status == -1)
+ {
+ sprintf (pending_error_text,
+ "E end of file reading mode for %s", arg);
+ }
+ else
+ {
+ sprintf (pending_error_text,
+ "E error reading mode for %s", arg);
+ pending_error = status;
+ }
}
}
@@ -499,19 +807,22 @@ serve_static_directory (arg)
char *arg;
{
FILE *f;
- f = fopen (CVSADM_ENTSTAT, "w+");
+
+ if (error_pending ()) return;
+
+ f = CVS_FOPEN (CVSADM_ENTSTAT, "w+");
if (f == NULL)
{
pending_error = errno;
- pending_error_text = malloc (80 + strlen(CVSADM_ENTSTAT));
- sprintf(pending_error_text, "E cannot open %s", CVSADM_ENTSTAT);
+ if (alloc_pending (80 + strlen (CVSADM_ENTSTAT)))
+ sprintf (pending_error_text, "E cannot open %s", CVSADM_ENTSTAT);
return;
}
if (fclose (f) == EOF)
{
pending_error = errno;
- pending_error_text = malloc (80 + strlen(CVSADM_ENTSTAT));
- sprintf(pending_error_text, "E cannot close %s", CVSADM_ENTSTAT);
+ if (alloc_pending (80 + strlen (CVSADM_ENTSTAT)))
+ sprintf (pending_error_text, "E cannot close %s", CVSADM_ENTSTAT);
return;
}
}
@@ -521,32 +832,35 @@ serve_sticky (arg)
char *arg;
{
FILE *f;
- f = fopen (CVSADM_TAG, "w+");
+
+ if (error_pending ()) return;
+
+ f = CVS_FOPEN (CVSADM_TAG, "w+");
if (f == NULL)
{
pending_error = errno;
- pending_error_text = malloc (80 + strlen(CVSADM_TAG));
- sprintf(pending_error_text, "E cannot open %s", CVSADM_TAG);
+ if (alloc_pending (80 + strlen (CVSADM_TAG)))
+ sprintf (pending_error_text, "E cannot open %s", CVSADM_TAG);
return;
}
if (fprintf (f, "%s\n", arg) < 0)
{
pending_error = errno;
- pending_error_text = malloc (80 + strlen(CVSADM_TAG));
- sprintf(pending_error_text, "E cannot write to %s", CVSADM_TAG);
+ if (alloc_pending (80 + strlen (CVSADM_TAG)))
+ sprintf (pending_error_text, "E cannot write to %s", CVSADM_TAG);
return;
}
if (fclose (f) == EOF)
{
pending_error = errno;
- pending_error_text = malloc (80 + strlen(CVSADM_TAG));
- sprintf(pending_error_text, "E cannot close %s", CVSADM_TAG);
+ if (alloc_pending (80 + strlen (CVSADM_TAG)))
+ sprintf (pending_error_text, "E cannot close %s", CVSADM_TAG);
return;
}
}
/*
- * Read SIZE bytes from stdin, write them to FILE.
+ * Read SIZE bytes from buf_from_net, write them to FILE.
*
* Currently this isn't really used for receiving parts of a file --
* the file is still sent over in one chunk. But if/when we get
@@ -559,62 +873,67 @@ receive_partial_file (size, file)
int size;
int file;
{
- char buf[16*1024], *bufp;
- int toread, nread, nwrote;
while (size > 0)
{
- toread = sizeof (buf);
- if (toread > size)
- toread = size;
+ int status, nread;
+ char *data;
- nread = fread (buf, 1, toread, stdin);
- if (nread <= 0)
+ status = buf_read_data (buf_from_net, size, &data, &nread);
+ if (status != 0)
{
- if (feof (stdin))
+ if (status == -2)
+ pending_error = ENOMEM;
+ else
{
pending_error_text = malloc (80);
- if (pending_error_text)
+ if (pending_error_text == NULL)
+ pending_error = ENOMEM;
+ else if (status == -1)
{
sprintf (pending_error_text,
"E premature end of file from client");
pending_error = 0;
}
else
- pending_error = ENOMEM;
- }
- else if (ferror (stdin))
- {
- pending_error_text = malloc (40);
- if (pending_error_text)
+ {
sprintf (pending_error_text,
"E error reading from client");
- pending_error = errno;
- }
- else
- {
- pending_error_text = malloc (40);
- if (pending_error_text)
- sprintf (pending_error_text,
- "E short read from client");
- pending_error = 0;
+ pending_error = status;
+ }
}
return;
}
+
size -= nread;
- bufp = buf;
- while (nread)
+
+ while (nread > 0)
{
- nwrote = write (file, bufp, nread);
+ int nwrote;
+
+ nwrote = write (file, data, nread);
if (nwrote < 0)
{
pending_error_text = malloc (40);
- if (pending_error_text)
+ if (pending_error_text != NULL)
sprintf (pending_error_text, "E unable to write");
pending_error = errno;
+
+ /* Read and discard the file data. */
+ while (size > 0)
+ {
+ int status, nread;
+ char *data;
+
+ status = buf_read_data (buf_from_net, size, &data, &nread);
+ if (status != 0)
+ return;
+ size -= nread;
+ }
+
return;
}
nread -= nwrote;
- bufp += nwrote;
+ data += nwrote;
}
}
}
@@ -632,7 +951,7 @@ receive_file (size, file, gzipped)
int gzip_status;
/* Write the file. */
- fd = open (arg, O_WRONLY | O_CREAT | O_TRUNC, 0600);
+ fd = CVS_OPEN (arg, O_WRONLY | O_CREAT | O_TRUNC, 0600);
if (fd < 0)
{
pending_error_text = malloc (40 + strlen (arg));
@@ -689,78 +1008,102 @@ static void
serve_modified (arg)
char *arg;
{
- int size;
+ int size, status;
char *size_text;
char *mode_text;
int gzipped = 0;
- if (error_pending ()) return;
+ /*
+ * This used to return immediately if error_pending () was true.
+ * However, that fails, because it causes each line of the file to
+ * be echoed back to the client as an unrecognized command. The
+ * client isn't reading from the socket, so eventually both
+ * processes block trying to write to the other. Now, we try to
+ * read the file if we can.
+ */
- mode_text = read_line (stdin);
- if (mode_text == NULL)
+ status = buf_read_line (buf_from_net, &mode_text, (int *) NULL);
+ if (status != 0)
{
- pending_error_text = malloc (80 + strlen (arg));
- if (pending_error_text)
+ if (status == -2)
+ pending_error = ENOMEM;
+ else
{
- if (feof (stdin))
- sprintf (pending_error_text,
- "E end of file reading mode for %s", arg);
+ pending_error_text = malloc (80 + strlen (arg));
+ if (pending_error_text == NULL)
+ pending_error = ENOMEM;
else
{
- sprintf (pending_error_text,
- "E error reading mode for %s", arg);
- pending_error = errno;
+ if (status == -1)
+ sprintf (pending_error_text,
+ "E end of file reading mode for %s", arg);
+ else
+ {
+ sprintf (pending_error_text,
+ "E error reading mode for %s", arg);
+ pending_error = status;
+ }
}
}
- else
- pending_error = ENOMEM;
- return;
- }
- else if (mode_text == NO_MEM_ERROR)
- {
- pending_error = ENOMEM;
return;
}
- size_text = read_line (stdin);
- if (size_text == NULL)
+
+ status = buf_read_line (buf_from_net, &size_text, (int *) NULL);
+ if (status != 0)
{
- pending_error_text = malloc (80 + strlen (arg));
- if (pending_error_text)
+ if (status == -2)
+ pending_error = ENOMEM;
+ else
{
- if (feof (stdin))
- sprintf (pending_error_text,
- "E end of file reading size for %s", arg);
+ pending_error_text = malloc (80 + strlen (arg));
+ if (pending_error_text == NULL)
+ pending_error = ENOMEM;
else
{
- sprintf (pending_error_text,
- "E error reading size for %s", arg);
- pending_error = errno;
+ if (status == -1)
+ sprintf (pending_error_text,
+ "E end of file reading size for %s", arg);
+ else
+ {
+ sprintf (pending_error_text,
+ "E error reading size for %s", arg);
+ pending_error = errno;
+ }
}
}
- else
- pending_error = ENOMEM;
- return;
- }
- else if (size_text == NO_MEM_ERROR)
- {
- pending_error = ENOMEM;
return;
}
if (size_text[0] == 'z')
- {
+ {
gzipped = 1;
size = atoi (size_text + 1);
- }
+ }
else
- size = atoi (size_text);
+ size = atoi (size_text);
free (size_text);
+ if (error_pending ())
+ {
+ /* Now that we know the size, read and discard the file data. */
+ while (size > 0)
+ {
+ int status, nread;
+ char *data;
+
+ status = buf_read_data (buf_from_net, size, &data, &nread);
+ if (status != 0)
+ return;
+ size -= nread;
+ }
+ return;
+ }
+
if (size >= 0)
- {
+ {
receive_file (size, arg, gzipped);
if (error_pending ()) return;
- }
+ }
{
int status = change_mode (arg, mode_text);
@@ -777,108 +1120,120 @@ serve_modified (arg)
}
}
-#endif /* SERVER_SUPPORT */
-#if defined(SERVER_SUPPORT) || defined(CLIENT_SUPPORT)
-
-int use_unchanged = 0;
-
-#endif
-#ifdef SERVER_SUPPORT
-
static void
serve_enable_unchanged (arg)
char *arg;
{
- use_unchanged = 1;
}
+struct an_entry {
+ struct an_entry *next;
+ char *entry;
+};
+
+static struct an_entry *entries;
+
+static void serve_unchanged PROTO ((char *));
+
static void
-serve_lost (arg)
+serve_unchanged (arg)
char *arg;
{
- if (use_unchanged)
- {
- /* A missing file already indicates it is nonexistent. */
+ struct an_entry *p;
+ char *name;
+ char *cp;
+ char *timefield;
+
+ if (error_pending ())
return;
- }
- else
+
+ /* Rewrite entries file to have `=' in timestamp field. */
+ for (p = entries; p != NULL; p = p->next)
{
- struct utimbuf ut;
- int fd = open (arg, O_WRONLY | O_CREAT | O_TRUNC, 0666);
- if (fd < 0 || close (fd) < 0)
- {
- pending_error = errno;
- pending_error_text = malloc (80 + strlen(arg));
- sprintf(pending_error_text, "E cannot open %s", arg);
- return;
- }
- /*
- * Set the times to the beginning of the epoch to tell time_stamp()
- * that the file was lost.
- */
- ut.actime = 0;
- ut.modtime = 0;
- if (utime (arg, &ut) < 0)
+ name = p->entry + 1;
+ cp = strchr (name, '/');
+ if (cp != NULL
+ && strlen (arg) == cp - name
+ && strncmp (arg, name, cp - name) == 0)
{
- pending_error = errno;
- pending_error_text = malloc (80 + strlen(arg));
- sprintf(pending_error_text, "E cannot utime %s", arg);
- return;
+ timefield = strchr (cp + 1, '/') + 1;
+ if (*timefield != '=')
+ {
+ cp = timefield + strlen (timefield);
+ cp[1] = '\0';
+ while (cp > timefield)
+ {
+ *cp = cp[-1];
+ --cp;
+ }
+ *timefield = '=';
+ }
+ break;
}
}
}
-struct an_entry {
- struct an_entry *next;
- char *entry;
-};
-
-static struct an_entry *entries;
+static void serve_is_modified PROTO ((char *));
static void
-serve_unchanged (arg)
+serve_is_modified (arg)
char *arg;
{
+ struct an_entry *p;
+ char *name;
+ char *cp;
+ char *timefield;
+ /* Have we found this file in "entries" yet. */
+ int found;
+
if (error_pending ())
return;
- if (!use_unchanged)
- {
- /* A missing file already indicates it is unchanged. */
- return;
- }
- else
- {
- struct an_entry *p;
- char *name;
- char *cp;
- char *timefield;
- /* Rewrite entries file to have `=' in timestamp field. */
- for (p = entries; p != NULL; p = p->next)
+ /* Rewrite entries file to have `M' in timestamp field. */
+ found = 0;
+ for (p = entries; p != NULL; p = p->next)
+ {
+ name = p->entry + 1;
+ cp = strchr (name, '/');
+ if (cp != NULL
+ && strlen (arg) == cp - name
+ && strncmp (arg, name, cp - name) == 0)
{
- name = p->entry + 1;
- cp = strchr (name, '/');
- if (cp != NULL
- && strlen (arg) == cp - name
- && strncmp (arg, name, cp - name) == 0)
+ timefield = strchr (cp + 1, '/') + 1;
+ if (!(timefield[0] == 'M' && timefield[1] == '/'))
{
- timefield = strchr (cp + 1, '/') + 1;
- if (*timefield != '=')
+ cp = timefield + strlen (timefield);
+ cp[1] = '\0';
+ while (cp > timefield)
{
- cp = timefield + strlen (timefield);
- cp[1] = '\0';
- while (cp > timefield)
- {
- *cp = cp[-1];
- --cp;
- }
- *timefield = '=';
+ *cp = cp[-1];
+ --cp;
}
- break;
+ *timefield = 'M';
}
+ found = 1;
+ break;
}
}
+ if (!found)
+ {
+ /* We got Is-modified but no Entry. Add a dummy entry.
+ The "D" timestamp is what makes it a dummy. */
+ struct an_entry *p;
+ p = (struct an_entry *) malloc (sizeof (struct an_entry));
+ if (p == NULL)
+ {
+ pending_error = ENOMEM;
+ return;
+ }
+ p->entry = xmalloc (strlen (arg) + 80);
+ strcpy (p->entry, "/");
+ strcat (p->entry, arg);
+ strcat (p->entry, "//D//");
+ p->next = entries;
+ entries = p;
+ }
}
static void
@@ -921,12 +1276,17 @@ server_write_entries ()
/* Note that we free all the entries regardless of errors. */
if (!error_pending ())
{
- f = fopen (CVSADM_ENT, "w");
+ /* We open in append mode because we don't want to clobber an
+ existing Entries file. If we are checking out a module
+ which explicitly lists more than one file in a particular
+ directory, then we will wind up calling
+ server_write_entries for each such file. */
+ f = CVS_FOPEN (CVSADM_ENT, "a");
if (f == NULL)
{
pending_error = errno;
- pending_error_text = malloc (80 + strlen(CVSADM_ENT));
- sprintf(pending_error_text, "E cannot open %s", CVSADM_ENT);
+ if (alloc_pending (80 + strlen (CVSADM_ENT)))
+ sprintf (pending_error_text, "E cannot open %s", CVSADM_ENT);
}
}
for (p = entries; p != NULL;)
@@ -936,8 +1296,9 @@ server_write_entries ()
if (fprintf (f, "%s\n", p->entry) < 0)
{
pending_error = errno;
- pending_error_text = malloc (80 + strlen(CVSADM_ENT));
- sprintf(pending_error_text, "E cannot write to %s", CVSADM_ENT);
+ if (alloc_pending (80 + strlen(CVSADM_ENT)))
+ sprintf (pending_error_text,
+ "E cannot write to %s", CVSADM_ENT);
}
}
free (p->entry);
@@ -949,8 +1310,8 @@ server_write_entries ()
if (f != NULL && fclose (f) == EOF && !error_pending ())
{
pending_error = errno;
- pending_error_text = malloc (80 + strlen(CVSADM_ENT));
- sprintf(pending_error_text, "E cannot close %s", CVSADM_ENT);
+ if (alloc_pending (80 + strlen (CVSADM_ENT)))
+ sprintf (pending_error_text, "E cannot close %s", CVSADM_ENT);
}
}
@@ -984,6 +1345,7 @@ serve_notify (arg)
{
struct notify_note *new;
char *data;
+ int status;
if (error_pending ()) return;
@@ -1010,28 +1372,29 @@ serve_notify (arg)
}
strcpy (new->filename, arg);
- data = read_line (stdin);
- if (data == NULL)
+ status = buf_read_line (buf_from_net, &data, (int *) NULL);
+ if (status != 0)
{
- pending_error_text = malloc (80 + strlen (arg));
- if (pending_error_text)
+ if (status == -2)
+ pending_error = ENOMEM;
+ else
{
- if (feof (stdin))
- sprintf (pending_error_text,
- "E end of file reading mode for %s", arg);
+ pending_error_text = malloc (80 + strlen (arg));
+ if (pending_error_text == NULL)
+ pending_error = ENOMEM;
else
{
- sprintf (pending_error_text,
- "E error reading mode for %s", arg);
- pending_error = errno;
+ if (status == -1)
+ sprintf (pending_error_text,
+ "E end of file reading notification for %s", arg);
+ else
+ {
+ sprintf (pending_error_text,
+ "E error reading notification for %s", arg);
+ pending_error = status;
+ }
}
}
- else
- pending_error = ENOMEM;
- }
- else if (data == NO_MEM_ERROR)
- {
- pending_error = ENOMEM;
}
else
{
@@ -1092,47 +1455,37 @@ server_notify ()
{
struct notify_note *p;
char *repos;
- List *list;
- Node *node;
- int status;
while (notify_list != NULL)
{
- if (chdir (notify_list->dir) < 0)
+ if ( CVS_CHDIR (notify_list->dir) < 0)
{
error (0, errno, "cannot change to %s", notify_list->dir);
return -1;
}
repos = Name_Repository (NULL, NULL);
- /* Now writelock. */
- list = getlist ();
- node = getnode ();
- node->type = LOCK;
- node->key = xstrdup (repos);
- status = addnode (list, node);
- assert (status == 0);
- Writer_Lock (list);
+ lock_dir_for_write (repos);
fileattr_startdir (repos);
notify_do (*notify_list->type, notify_list->filename, getcaller(),
notify_list->val, notify_list->watches, repos);
- printf ("Notified ");
- if (use_dir_and_repos)
+ buf_output0 (buf_to_net, "Notified ");
{
char *dir = notify_list->dir + strlen (server_temp_dir) + 1;
if (dir[0] == '\0')
- fputs (".", stdout);
+ buf_append_char (buf_to_net, '.');
else
- fputs (dir, stdout);
- fputs ("/\n", stdout);
+ buf_output0 (buf_to_net, dir);
+ buf_append_char (buf_to_net, '/');
+ buf_append_char (buf_to_net, '\n');
}
- fputs (repos, stdout);
- fputs ("/", stdout);
- fputs (notify_list->filename, stdout);
- fputs ("\n", stdout);
+ buf_output0 (buf_to_net, repos);
+ buf_append_char (buf_to_net, '/');
+ buf_output0 (buf_to_net, notify_list->filename);
+ buf_append_char (buf_to_net, '\n');
p = notify_list->next;
free (notify_list->filename);
@@ -1144,13 +1497,13 @@ server_notify ()
fileattr_write ();
fileattr_free ();
- /* Remove the writelock. */
Lock_Cleanup ();
- dellist (&list);
}
- /* do_cvs_command writes to stdout via write(), not stdio, so better
- flush out the buffer. */
- fflush (stdout);
+
+ /* The code used to call fflush (stdout) here, but that is no
+ longer necessary. The data is now buffered in buf_to_net,
+ which will be flushed by the caller, do_cvs_command. */
+
return 0;
}
@@ -1215,9 +1568,10 @@ serve_global_option (arg)
if (arg[0] != '-' || arg[1] == '\0' || arg[2] != '\0')
{
error_return:
- pending_error_text = malloc (strlen (arg) + 80);
- sprintf (pending_error_text, "E Protocol error: bad global option %s",
- arg);
+ if (alloc_pending (strlen (arg) + 80))
+ sprintf (pending_error_text,
+ "E Protocol error: bad global option %s",
+ arg);
return;
}
switch (arg[1])
@@ -1253,62 +1607,27 @@ serve_set (arg)
put into pending_error. */
variable_set (arg);
}
-
-/*
- * We must read data from a child process and send it across the
- * network. We do not want to block on writing to the network, so we
- * store the data from the child process in memory. A BUFFER
- * structure holds the status of one communication, and uses a linked
- * list of buffer_data structures to hold data.
- */
-
-struct buffer
-{
- /* Data. */
- struct buffer_data *data;
-
- /* Last buffer on data chain. */
- struct buffer_data *last;
- /* File descriptor to write to or read from. */
- int fd;
-
- /* Nonzero if this is an output buffer (sanity check). */
- int output;
-
- /* Nonzero if the file descriptor is in nonblocking mode. */
- int nonblocking;
-
- /* Function to call if we can't allocate memory. */
- void (*memory_error) PROTO((struct buffer *));
-};
+#ifdef ENCRYPTION
+#ifdef HAVE_KERBEROS
-/* Data is stored in lists of these structures. */
-
-struct buffer_data
+static void
+serve_kerberos_encrypt (arg)
+ char *arg;
{
- /* Next buffer in linked list. */
- struct buffer_data *next;
-
- /*
- * A pointer into the data area pointed to by the text field. This
- * is where to find data that has not yet been written out.
- */
- char *bufp;
-
- /* The number of data bytes found at BUFP. */
- int size;
-
- /*
- * Actual buffer. This never changes after the structure is
- * allocated. The buffer is BUFFER_DATA_SIZE bytes.
- */
- char *text;
-};
-
-/* The size we allocate for each buffer_data structure. */
-#define BUFFER_DATA_SIZE (4096)
+ /* All future communication with the client will be encrypted. */
+
+ buf_to_net = krb_encrypt_buffer_initialize (buf_to_net, 0, sched,
+ kblock,
+ buf_to_net->memory_error);
+ buf_from_net = krb_encrypt_buffer_initialize (buf_from_net, 1, sched,
+ kblock,
+ buf_from_net->memory_error);
+}
+#endif /* HAVE_KERBEROS */
+#endif /* ENCRYPTION */
+
#ifdef SERVER_FLOWCONTROL
/* The maximum we'll queue to the remote client before blocking. */
# ifndef SERVER_HI_WATER
@@ -1318,274 +1637,9 @@ struct buffer_data
# ifndef SERVER_LO_WATER
# define SERVER_LO_WATER (1 * 1024 * 1024)
# endif /* SERVER_LO_WATER */
-#endif /* SERVER_FLOWCONTROL */
-
-/* Linked list of available buffer_data structures. */
-static struct buffer_data *free_buffer_data;
-
-static void allocate_buffer_datas PROTO((void));
-static inline struct buffer_data *get_buffer_data PROTO((void));
-static int buf_empty_p PROTO((struct buffer *));
-static void buf_output PROTO((struct buffer *, const char *, int));
-static void buf_output0 PROTO((struct buffer *, const char *));
-static inline void buf_append_char PROTO((struct buffer *, int));
-static int buf_send_output PROTO((struct buffer *));
-static int set_nonblock PROTO((struct buffer *));
-static int set_block PROTO((struct buffer *));
-static int buf_send_counted PROTO((struct buffer *));
-static inline void buf_append_data PROTO((struct buffer *,
- struct buffer_data *,
- struct buffer_data *));
-static int buf_read_file PROTO((FILE *, long, struct buffer_data **,
- struct buffer_data **));
-static int buf_input_data PROTO((struct buffer *, int *));
-static void buf_copy_lines PROTO((struct buffer *, struct buffer *, int));
-static int buf_copy_counted PROTO((struct buffer *, struct buffer *));
-#ifdef SERVER_FLOWCONTROL
-static int buf_count_mem PROTO((struct buffer *));
static int set_nonblock_fd PROTO((int));
-#endif /* SERVER_FLOWCONTROL */
-
-/* Allocate more buffer_data structures. */
-
-static void
-allocate_buffer_datas ()
-{
- struct buffer_data *alc;
- char *space;
- int i;
-
- /* Allocate buffer_data structures in blocks of 16. */
-#define ALLOC_COUNT (16)
-
- alc = ((struct buffer_data *)
- malloc (ALLOC_COUNT * sizeof (struct buffer_data)));
- space = (char *) valloc (ALLOC_COUNT * BUFFER_DATA_SIZE);
- if (alc == NULL || space == NULL)
- return;
- for (i = 0; i < ALLOC_COUNT; i++, alc++, space += BUFFER_DATA_SIZE)
- {
- alc->next = free_buffer_data;
- free_buffer_data = alc;
- alc->text = space;
- }
-}
-
-/* Get a new buffer_data structure. */
-
-static inline struct buffer_data *
-get_buffer_data ()
-{
- struct buffer_data *ret;
-
- if (free_buffer_data == NULL)
- {
- allocate_buffer_datas ();
- if (free_buffer_data == NULL)
- return NULL;
- }
-
- ret = free_buffer_data;
- free_buffer_data = ret->next;
- return ret;
-}
-
-/* See whether a buffer is empty. */
-
-static int
-buf_empty_p (buf)
- struct buffer *buf;
-{
- struct buffer_data *data;
-
- for (data = buf->data; data != NULL; data = data->next)
- if (data->size > 0)
- return 0;
- return 1;
-}
-
-#ifdef SERVER_FLOWCONTROL
-/*
- * Count how much data is stored in the buffer..
- * Note that each buffer is a malloc'ed chunk BUFFER_DATA_SIZE.
- */
-
-static int
-buf_count_mem (buf)
- struct buffer *buf;
-{
- struct buffer_data *data;
- int mem = 0;
-
- for (data = buf->data; data != NULL; data = data->next)
- mem += BUFFER_DATA_SIZE;
-
- return mem;
-}
-#endif /* SERVER_FLOWCONTROL */
-
-/* Add data DATA of length LEN to BUF. */
-
-static void
-buf_output (buf, data, len)
- struct buffer *buf;
- const char *data;
- int len;
-{
- if (buf->data != NULL
- && (((buf->last->text + BUFFER_DATA_SIZE)
- - (buf->last->bufp + buf->last->size))
- >= len))
- {
- memcpy (buf->last->bufp + buf->last->size, data, len);
- buf->last->size += len;
- return;
- }
-
- while (1)
- {
- struct buffer_data *newdata;
-
- newdata = get_buffer_data ();
- if (newdata == NULL)
- {
- (*buf->memory_error) (buf);
- return;
- }
-
- if (buf->data == NULL)
- buf->data = newdata;
- else
- buf->last->next = newdata;
- newdata->next = NULL;
- buf->last = newdata;
-
- newdata->bufp = newdata->text;
-
- if (len <= BUFFER_DATA_SIZE)
- {
- newdata->size = len;
- memcpy (newdata->text, data, len);
- return;
- }
-
- newdata->size = BUFFER_DATA_SIZE;
- memcpy (newdata->text, data, BUFFER_DATA_SIZE);
-
- data += BUFFER_DATA_SIZE;
- len -= BUFFER_DATA_SIZE;
- }
-
- /*NOTREACHED*/
-}
-
-/* Add a '\0' terminated string to BUF. */
-
-static void
-buf_output0 (buf, string)
- struct buffer *buf;
- const char *string;
-{
- buf_output (buf, string, strlen (string));
-}
-
-/* Add a single character to BUF. */
-
-static inline void
-buf_append_char (buf, ch)
- struct buffer *buf;
- int ch;
-{
- if (buf->data != NULL
- && (buf->last->text + BUFFER_DATA_SIZE
- != buf->last->bufp + buf->last->size))
- {
- *(buf->last->bufp + buf->last->size) = ch;
- ++buf->last->size;
- }
- else
- {
- char b;
-
- b = ch;
- buf_output (buf, &b, 1);
- }
-}
-
-/*
- * Send all the output we've been saving up. Returns 0 for success or
- * errno code. If the buffer has been set to be nonblocking, this
- * will just write until the write would block.
- */
-
-static int
-buf_send_output (buf)
- struct buffer *buf;
-{
- if (! buf->output)
- abort ();
-
- while (buf->data != NULL)
- {
- struct buffer_data *data;
-
- data = buf->data;
- while (data->size > 0)
- {
- int nbytes;
-
- nbytes = write (buf->fd, data->bufp, data->size);
- if (nbytes <= 0)
- {
- int status;
-
- if (buf->nonblocking
- && (nbytes == 0
-#ifdef EWOULDBLOCK
- || errno == EWOULDBLOCK
-#endif
- || errno == EAGAIN))
- {
- /*
- * A nonblocking write failed to write any data.
- * Just return.
- */
- return 0;
- }
-
- /*
- * An error, or EOF. Throw away all the data and
- * return.
- */
- if (nbytes == 0)
- status = EIO;
- else
- status = errno;
-
- buf->last->next = free_buffer_data;
- free_buffer_data = buf->data;
- buf->data = NULL;
- buf->last = NULL;
-
- return status;
- }
-
- data->size -= nbytes;
- data->bufp += nbytes;
- }
-
- buf->data = data->next;
- data->next = free_buffer_data;
- free_buffer_data = data;
- }
-
- buf->last = NULL;
- return 0;
-}
-
-#ifdef SERVER_FLOWCONTROL
/*
* Set buffer BUF to non-blocking I/O. Returns 0 for success or errno
* code.
@@ -1604,553 +1658,9 @@ set_nonblock_fd (fd)
return errno;
return 0;
}
-#endif /* SERVER_FLOWCONTROL */
-
-static int
-set_nonblock (buf)
- struct buffer *buf;
-{
- int flags;
-
- if (buf->nonblocking)
- return 0;
- flags = fcntl (buf->fd, F_GETFL, 0);
- if (flags < 0)
- return errno;
- if (fcntl (buf->fd, F_SETFL, flags | O_NONBLOCK) < 0)
- return errno;
- buf->nonblocking = 1;
- return 0;
-}
-
-/*
- * Set buffer BUF to blocking I/O. Returns 0 for success or errno
- * code.
- */
-
-static int
-set_block (buf)
- struct buffer *buf;
-{
- int flags;
-
- if (! buf->nonblocking)
- return 0;
- flags = fcntl (buf->fd, F_GETFL, 0);
- if (flags < 0)
- return errno;
- if (fcntl (buf->fd, F_SETFL, flags & ~O_NONBLOCK) < 0)
- return errno;
- buf->nonblocking = 0;
- return 0;
-}
-
-/*
- * Send a character count and some output. Returns errno code or 0 for
- * success.
- *
- * Sending the count in binary is OK since this is only used on a pipe
- * within the same system.
- */
-
-static int
-buf_send_counted (buf)
- struct buffer *buf;
-{
- int size;
- struct buffer_data *data;
-
- if (! buf->output)
- abort ();
-
- size = 0;
- for (data = buf->data; data != NULL; data = data->next)
- size += data->size;
-
- data = get_buffer_data ();
- if (data == NULL)
- {
- (*buf->memory_error) (buf);
- return ENOMEM;
- }
-
- data->next = buf->data;
- buf->data = data;
- if (buf->last == NULL)
- buf->last = data;
-
- data->bufp = data->text;
- data->size = sizeof (int);
-
- *((int *) data->text) = size;
-
- return buf_send_output (buf);
-}
-
-/* Append a list of buffer_data structures to an buffer. */
-
-static inline void
-buf_append_data (buf, data, last)
- struct buffer *buf;
- struct buffer_data *data;
- struct buffer_data *last;
-{
- if (data != NULL)
- {
- if (buf->data == NULL)
- buf->data = data;
- else
- buf->last->next = data;
- buf->last = last;
- }
-}
-
-/*
- * Copy the contents of file F into buffer_data structures. We can't
- * copy directly into an buffer, because we want to handle failure and
- * succeess differently. Returns 0 on success, or -2 if out of
- * memory, or a status code on error. Since the caller happens to
- * know the size of the file, it is passed in as SIZE. On success,
- * this function sets *RETP and *LASTP, which may be passed to
- * buf_append_data.
- */
-
-static int
-buf_read_file (f, size, retp, lastp)
- FILE *f;
- long size;
- struct buffer_data **retp;
- struct buffer_data **lastp;
-{
- int status;
-
- *retp = NULL;
- *lastp = NULL;
-
- while (size > 0)
- {
- struct buffer_data *data;
- int get;
-
- data = get_buffer_data ();
- if (data == NULL)
- {
- status = -2;
- goto error_return;
- }
-
- if (*retp == NULL)
- *retp = data;
- else
- (*lastp)->next = data;
- data->next = NULL;
- *lastp = data;
-
- data->bufp = data->text;
- data->size = 0;
-
- if (size > BUFFER_DATA_SIZE)
- get = BUFFER_DATA_SIZE;
- else
- get = size;
-
- errno = EIO;
- if (fread (data->text, get, 1, f) != 1)
- {
- status = errno;
- goto error_return;
- }
-
- data->size += get;
- size -= get;
- }
-
- return 0;
-
- error_return:
- if (*retp != NULL)
- {
- (*lastp)->next = free_buffer_data;
- free_buffer_data = *retp;
- }
- return status;
-}
-
-static int
-buf_read_file_to_eof (f, retp, lastp)
- FILE *f;
- struct buffer_data **retp;
- struct buffer_data **lastp;
-{
- int status;
-
- *retp = NULL;
- *lastp = NULL;
-
- while (!feof (f))
- {
- struct buffer_data *data;
- int get, nread;
-
- data = get_buffer_data ();
- if (data == NULL)
- {
- status = -2;
- goto error_return;
- }
-
- if (*retp == NULL)
- *retp = data;
- else
- (*lastp)->next = data;
- data->next = NULL;
- *lastp = data;
-
- data->bufp = data->text;
- data->size = 0;
-
- get = BUFFER_DATA_SIZE;
-
- errno = EIO;
- nread = fread (data->text, 1, get, f);
- if (nread == 0 && !feof (f))
- {
- status = errno;
- goto error_return;
- }
-
- data->size = nread;
- }
-
- return 0;
-
- error_return:
- if (*retp != NULL)
- {
- (*lastp)->next = free_buffer_data;
- free_buffer_data = *retp;
- }
- return status;
-}
-
-static int
-buf_chain_length (buf)
- struct buffer_data *buf;
-{
- int size = 0;
- while (buf)
- {
- size += buf->size;
- buf = buf->next;
- }
- return size;
-}
-
-/*
- * Read an arbitrary amount of data from a file descriptor into an
- * input buffer. The file descriptor will be in nonblocking mode, and
- * we just grab what we can. Return 0 on success, or -1 on end of
- * file, or -2 if out of memory, or an error code. If COUNTP is not
- * NULL, *COUNTP is set to the number of bytes read.
- */
-
-static int
-buf_input_data (buf, countp)
- struct buffer *buf;
- int *countp;
-{
- if (buf->output)
- abort ();
-
- if (countp != NULL)
- *countp = 0;
-
- while (1)
- {
- int get;
- int nbytes;
-
- if (buf->data == NULL
- || (buf->last->bufp + buf->last->size
- == buf->last->text + BUFFER_DATA_SIZE))
- {
- struct buffer_data *data;
-
- data = get_buffer_data ();
- if (data == NULL)
- {
- (*buf->memory_error) (buf);
- return -2;
- }
-
- if (buf->data == NULL)
- buf->data = data;
- else
- buf->last->next = data;
- data->next = NULL;
- buf->last = data;
-
- data->bufp = data->text;
- data->size = 0;
- }
-
- get = ((buf->last->text + BUFFER_DATA_SIZE)
- - (buf->last->bufp + buf->last->size));
- nbytes = read (buf->fd, buf->last->bufp + buf->last->size, get);
- if (nbytes <= 0)
- {
- if (nbytes == 0)
- {
- /*
- * This assumes that we are using POSIX or BSD style
- * nonblocking I/O. On System V we will get a zero
- * return if there is no data, even when not at EOF.
- */
- return -1;
- }
-
- if (errno == EAGAIN
-#ifdef EWOULDBLOCK
- || errno == EWOULDBLOCK
-#endif
- )
- return 0;
-
- return errno;
- }
-
- buf->last->size += nbytes;
- if (countp != NULL)
- *countp += nbytes;
- }
-
- /*NOTREACHED*/
-}
-
-/*
- * Copy lines from an input buffer to an output buffer. This copies
- * all complete lines (characters up to a newline) from INBUF to
- * OUTBUF. Each line in OUTBUF is preceded by the character COMMAND
- * and a space.
- */
-
-static void
-buf_copy_lines (outbuf, inbuf, command)
- struct buffer *outbuf;
- struct buffer *inbuf;
- int command;
-{
- if (! outbuf->output || inbuf->output)
- abort ();
-
- while (1)
- {
- struct buffer_data *data;
- struct buffer_data *nldata;
- char *nl;
- int len;
-
- /* See if there is a newline in INBUF. */
- nldata = NULL;
- nl = NULL;
- for (data = inbuf->data; data != NULL; data = data->next)
- {
- nl = memchr (data->bufp, '\n', data->size);
- if (nl != NULL)
- {
- nldata = data;
- break;
- }
- }
-
- if (nldata == NULL)
- {
- /* There are no more lines in INBUF. */
- return;
- }
-
- /* Put in the command. */
- buf_append_char (outbuf, command);
- buf_append_char (outbuf, ' ');
-
- if (inbuf->data != nldata)
- {
- /*
- * Simply move over all the buffers up to the one containing
- * the newline.
- */
- for (data = inbuf->data; data->next != nldata; data = data->next)
- ;
- data->next = NULL;
- buf_append_data (outbuf, inbuf->data, data);
- inbuf->data = nldata;
- }
-
- /*
- * If the newline is at the very end of the buffer, just move
- * the buffer onto OUTBUF. Otherwise we must copy the data.
- */
- len = nl + 1 - nldata->bufp;
- if (len == nldata->size)
- {
- inbuf->data = nldata->next;
- if (inbuf->data == NULL)
- inbuf->last = NULL;
-
- nldata->next = NULL;
- buf_append_data (outbuf, nldata, nldata);
- }
- else
- {
- buf_output (outbuf, nldata->bufp, len);
- nldata->bufp += len;
- nldata->size -= len;
- }
- }
-}
-
-/*
- * Copy counted data from one buffer to another. The count is an
- * integer, host size, host byte order (it is only used across a
- * pipe). If there is enough data, it should be moved over. If there
- * is not enough data, it should remain on the original buffer. This
- * returns the number of bytes it needs to see in order to actually
- * copy something over.
- */
-
-static int
-buf_copy_counted (outbuf, inbuf)
- struct buffer *outbuf;
- struct buffer *inbuf;
-{
- if (! outbuf->output || inbuf->output)
- abort ();
-
- while (1)
- {
- struct buffer_data *data;
- int need;
- union
- {
- char intbuf[sizeof (int)];
- int i;
- } u;
- char *intp;
- int count;
- struct buffer_data *start;
- int startoff;
- struct buffer_data *stop;
- int stopwant;
-
- /* See if we have enough bytes to figure out the count. */
- need = sizeof (int);
- intp = u.intbuf;
- for (data = inbuf->data; data != NULL; data = data->next)
- {
- if (data->size >= need)
- {
- memcpy (intp, data->bufp, need);
- break;
- }
- memcpy (intp, data->bufp, data->size);
- intp += data->size;
- need -= data->size;
- }
- if (data == NULL)
- {
- /* We don't have enough bytes to form an integer. */
- return need;
- }
-
- count = u.i;
- start = data;
- startoff = need;
-
- /*
- * We have an integer in COUNT. We have gotten all the data
- * from INBUF in all buffers before START, and we have gotten
- * STARTOFF bytes from START. See if we have enough bytes
- * remaining in INBUF.
- */
- need = count - (start->size - startoff);
- if (need <= 0)
- {
- stop = start;
- stopwant = count;
- }
- else
- {
- for (data = start->next; data != NULL; data = data->next)
- {
- if (need <= data->size)
- break;
- need -= data->size;
- }
- if (data == NULL)
- {
- /* We don't have enough bytes. */
- return need;
- }
- stop = data;
- stopwant = need;
- }
-
- /*
- * We have enough bytes. Free any buffers in INBUF before
- * START, and remove STARTOFF bytes from START, so that we can
- * forget about STARTOFF.
- */
- start->bufp += startoff;
- start->size -= startoff;
-
- if (start->size == 0)
- start = start->next;
-
- if (stop->size == stopwant)
- {
- stop = stop->next;
- stopwant = 0;
- }
-
- while (inbuf->data != start)
- {
- data = inbuf->data;
- inbuf->data = data->next;
- data->next = free_buffer_data;
- free_buffer_data = data;
- }
- /*
- * We want to copy over the bytes from START through STOP. We
- * only want STOPWANT bytes from STOP.
- */
-
- if (start != stop)
- {
- /* Attach the buffers from START through STOP to OUTBUF. */
- for (data = start; data->next != stop; data = data->next)
- ;
- inbuf->data = stop;
- data->next = NULL;
- buf_append_data (outbuf, start, data);
- }
-
- if (stopwant > 0)
- {
- buf_output (outbuf, stop->bufp, stopwant);
- stop->bufp += stopwant;
- stop->size -= stopwant;
- }
- }
-
- /*NOTREACHED*/
-}
+#endif /* SERVER_FLOWCONTROL */
-/* While processing requests, this buffer accumulates data to be sent to
- the client, and then once we are in do_cvs_command, we use it
- for all the data to be sent. */
-static struct buffer buf_to_net;
-
static void serve_questionable PROTO((char *));
static void
@@ -2169,7 +1679,7 @@ serve_questionable (arg)
if (dir_name == NULL)
{
- buf_output0 (&buf_to_net, "E Protocol error: 'Directory' missing");
+ buf_output0 (buf_to_net, "E Protocol error: 'Directory' missing");
return;
}
@@ -2177,15 +1687,15 @@ serve_questionable (arg)
{
char *update_dir;
- buf_output (&buf_to_net, "M ? ", 4);
+ buf_output (buf_to_net, "M ? ", 4);
update_dir = dir_name + strlen (server_temp_dir) + 1;
if (!(update_dir[0] == '.' && update_dir[1] == '\0'))
{
- buf_output0 (&buf_to_net, update_dir);
- buf_output (&buf_to_net, "/", 1);
+ buf_output0 (buf_to_net, update_dir);
+ buf_output (buf_to_net, "/", 1);
}
- buf_output0 (&buf_to_net, arg);
- buf_output (&buf_to_net, "\n", 1);
+ buf_output0 (buf_to_net, arg);
+ buf_output (buf_to_net, "\n", 1);
}
}
@@ -2198,14 +1708,14 @@ serve_case (arg)
ign_case = 1;
}
-static struct buffer protocol;
+static struct buffer *protocol;
/* This is the output which we are saving up to send to the server, in the
child process. We will push it through, via the `protocol' buffer, when
we have a complete line. */
-static struct buffer saved_output;
+static struct buffer *saved_output;
/* Likewise, but stuff which will go to stderr. */
-static struct buffer saved_outerr;
+static struct buffer *saved_outerr;
static void
protocol_memory_error (buf)
@@ -2237,8 +1747,7 @@ error ENOMEM Virtual memory exhausted.\n";
/* If this gives an error, not much we could do. syslog() it? */
write (STDOUT_FILENO, msg, sizeof (msg) - 1);
- server_cleanup (0);
- exit (EXIT_FAILURE);
+ error_exit ();
}
static void
@@ -2248,6 +1757,155 @@ input_memory_error (buf)
outbuf_memory_error (buf);
}
+
+
+/* If command is legal, return 1.
+ * Else if command is illegal and croak_on_illegal is set, then die.
+ * Else just return 0 to indicate that command is illegal.
+ */
+static int
+check_command_legal_p (cmd_name)
+ char *cmd_name;
+{
+ /* Right now, only pserver notices illegal commands -- namely,
+ * write attempts by a read-only user. Therefore, if CVS_Username
+ * is not set, this just returns 1, because CVS_Username unset
+ * means pserver is not active.
+ */
+#ifdef AUTH_SERVER_SUPPORT
+ if (CVS_Username == NULL)
+ return 1;
+
+ if (lookup_command_attribute (cmd_name) & CVS_CMD_MODIFIES_REPOSITORY)
+ {
+ /* This command has the potential to modify the repository, so
+ * we check if the user have permission to do that.
+ *
+ * (Only relevant for remote users -- local users can do
+ * whatever normal Unix file permissions allow them to do.)
+ *
+ * The decision method:
+ *
+ * If $CVSROOT/CVSADMROOT_READERS exists and user is listed
+ * in it, then read-only access for user.
+ *
+ * Or if $CVSROOT/CVSADMROOT_WRITERS exists and user NOT
+ * listed in it, then also read-only access for user.
+ *
+ * Else read-write access for user.
+ */
+
+ char *linebuf = NULL;
+ int num_red = 0;
+ size_t linebuf_len = 0;
+ char *fname;
+ size_t flen;
+ FILE *fp;
+ int found_it = 0;
+
+ /* else */
+ flen = strlen (CVSroot_directory)
+ + strlen (CVSROOTADM)
+ + strlen (CVSROOTADM_READERS)
+ + 3;
+
+ fname = xmalloc (flen);
+ (void) sprintf (fname, "%s/%s/%s", CVSroot_directory,
+ CVSROOTADM, CVSROOTADM_READERS);
+
+ fp = fopen (fname, "r");
+ free (fname);
+
+ if (fp == NULL)
+ goto do_writers;
+ else /* successfully opened readers file */
+ {
+ while ((num_red = getline (&linebuf, &linebuf_len, fp)) >= 0)
+ {
+ /* Hmmm, is it worth importing my own readline
+ library into CVS? It takes care of chopping
+ leading and trailing whitespace, "#" comments, and
+ newlines automatically when so requested. Would
+ save some code here... -kff */
+
+ /* Chop newline by hand, for strcmp()'s sake. */
+ if (linebuf[num_red - 1] == '\n')
+ linebuf[num_red - 1] = '\0';
+
+ if (strcmp (linebuf, CVS_Username) == 0)
+ goto handle_illegal;
+ }
+
+ /* If not listed specifically as a reader, then this user
+ has write access by default unless writers are also
+ specified in a file . */
+ fclose (fp);
+ goto do_writers;
+ }
+
+ do_writers:
+
+ flen = strlen (CVSroot_directory)
+ + strlen (CVSROOTADM)
+ + strlen (CVSROOTADM_WRITERS)
+ + 3;
+
+ fname = xmalloc (flen);
+ (void) sprintf (fname, "%s/%s/%s", CVSroot_directory,
+ CVSROOTADM, CVSROOTADM_WRITERS);
+
+ fp = fopen (fname, "r");
+ free (fname);
+
+ if (fp == NULL)
+ {
+ /* writers file does not exist, so everyone is a writer,
+ by default */
+ if (linebuf)
+ free (linebuf);
+ return 1;
+ }
+
+ /* else */
+
+ found_it = 0;
+ while ((num_red = getline (&linebuf, &linebuf_len, fp)) >= 0)
+ {
+ /* Chop newline by hand, for strcmp()'s sake. */
+ if (linebuf[num_red - 1] == '\n')
+ linebuf[num_red - 1] = '\0';
+
+ if (strcmp (linebuf, CVS_Username) == 0)
+ {
+ found_it = 1;
+ break;
+ }
+ }
+
+ if (found_it)
+ {
+ fclose (fp);
+ if (linebuf)
+ free (linebuf);
+ return 1;
+ }
+ else /* writers file exists, but this user not listed in it */
+ {
+ handle_illegal:
+ fclose (fp);
+ if (linebuf)
+ free (linebuf);
+ return 0;
+ }
+ }
+#endif /* AUTH_SERVER_SUPPORT */
+
+ /* If ever reach end of this function, command must be legal. */
+ return 1;
+}
+
+
+
/* Execute COMMAND in a subprocess with the approriate funky things done. */
static struct fd_set_wrapper { fd_set fds; } command_fds_to_drain;
@@ -2258,7 +1916,8 @@ static int flowcontrol_pipe[2];
#endif /* SERVER_FLOWCONTROL */
static void
-do_cvs_command (command)
+do_cvs_command (cmd_name, command)
+ char *cmd_name;
int (*command) PROTO((int argc, char **argv));
{
/*
@@ -2294,6 +1953,21 @@ do_cvs_command (command)
if (print_pending_error ())
goto free_args_and_return;
+ /* Global `command_name' is probably "server" right now -- only
+ serve_export() sets it to anything else. So we will use local
+ parameter `cmd_name' to determine if this command is legal for
+ this user. */
+ if (!check_command_legal_p (cmd_name))
+ {
+ buf_output0 (buf_to_net, "E ");
+ buf_output0 (buf_to_net, program_name);
+ buf_output0 (buf_to_net, " [server aborted]: \"");
+ buf_output0 (buf_to_net, cmd_name);
+ buf_output0 (buf_to_net, "\" requires write access to the repository\n\
+error \n");
+ goto free_args_and_return;
+ }
+
(void) server_notify ();
/*
@@ -2329,13 +2003,29 @@ do_cvs_command (command)
set_nonblock_fd (flowcontrol_pipe[1]);
#endif /* SERVER_FLOWCONTROL */
- dev_null_fd = open ("/dev/null", O_RDONLY);
+ dev_null_fd = CVS_OPEN (DEVNULL, O_RDONLY);
if (dev_null_fd < 0)
{
print_error (errno);
goto error_exit;
}
+ /* We shouldn't have any partial lines from cvs_output and
+ cvs_outerr, but we handle them here in case there is a bug. */
+ if (! buf_empty_p (saved_output))
+ {
+ buf_append_char (saved_output, '\n');
+ buf_copy_lines (buf_to_net, saved_output, 'M');
+ }
+ if (! buf_empty_p (saved_outerr))
+ {
+ buf_append_char (saved_outerr, '\n');
+ buf_copy_lines (buf_to_net, saved_outerr, 'E');
+ }
+
+ /* Flush out any pending data. */
+ buf_flush (buf_to_net, 1);
+
/* Don't use vfork; we're not going to exec(). */
command_pid = fork ();
if (command_pid < 0)
@@ -2352,18 +2042,20 @@ do_cvs_command (command)
flag. */
error_use_protocol = 0;
- protocol.data = protocol.last = NULL;
- protocol.fd = protocol_pipe[1];
- protocol.output = 1;
- protocol.nonblocking = 0;
- protocol.memory_error = protocol_memory_error;
+ protocol = fd_buffer_initialize (protocol_pipe[1], 0,
+ protocol_memory_error);
+
+ /* At this point we should no longer be using buf_to_net and
+ buf_from_net. Instead, everything should go through
+ protocol. */
+ buf_to_net = NULL;
+ buf_from_net = NULL;
- saved_output.data = saved_output.last = NULL;
- saved_output.fd = -1;
- saved_output.output = 0;
- saved_output.nonblocking = 0;
- saved_output.memory_error = protocol_memory_error;
- saved_outerr = saved_output;
+ /* These were originally set up to use outbuf_memory_error.
+ Since we're now in the child, we should use the simpler
+ protocol_memory_error function. */
+ saved_output->memory_error = protocol_memory_error;
+ saved_outerr->memory_error = protocol_memory_error;
if (dup2 (dev_null_fd, STDIN_FILENO) < 0)
error (1, errno, "can't set up pipes");
@@ -2399,9 +2091,9 @@ do_cvs_command (command)
/* OK, sit around getting all the input from the child. */
{
- struct buffer stdoutbuf;
- struct buffer stderrbuf;
- struct buffer protocol_inbuf;
+ struct buffer *stdoutbuf;
+ struct buffer *stderrbuf;
+ struct buffer *protocol_inbuf;
/* Number of file descriptors to check in select (). */
int num_to_check;
int count_needed = 0;
@@ -2428,32 +2120,25 @@ do_cvs_command (command)
++num_to_check;
if (num_to_check > FD_SETSIZE)
{
- printf ("E internal error: FD_SETSIZE not big enough.\nerror \n");
+ buf_output0 (buf_to_net,
+ "E internal error: FD_SETSIZE not big enough.\n\
+error \n");
goto error_exit;
}
- stdoutbuf.data = stdoutbuf.last = NULL;
- stdoutbuf.fd = stdout_pipe[0];
- stdoutbuf.output = 0;
- stdoutbuf.nonblocking = 0;
- stdoutbuf.memory_error = input_memory_error;
-
- stderrbuf.data = stderrbuf.last = NULL;
- stderrbuf.fd = stderr_pipe[0];
- stderrbuf.output = 0;
- stderrbuf.nonblocking = 0;
- stderrbuf.memory_error = input_memory_error;
-
- protocol_inbuf.data = protocol_inbuf.last = NULL;
- protocol_inbuf.fd = protocol_pipe[0];
- protocol_inbuf.output = 0;
- protocol_inbuf.nonblocking = 0;
- protocol_inbuf.memory_error = input_memory_error;
-
- set_nonblock (&buf_to_net);
- set_nonblock (&stdoutbuf);
- set_nonblock (&stderrbuf);
- set_nonblock (&protocol_inbuf);
+ stdoutbuf = fd_buffer_initialize (stdout_pipe[0], 1,
+ input_memory_error);
+
+ stderrbuf = fd_buffer_initialize (stderr_pipe[0], 1,
+ input_memory_error);
+
+ protocol_inbuf = fd_buffer_initialize (protocol_pipe[0], 1,
+ input_memory_error);
+
+ set_nonblock (buf_to_net);
+ set_nonblock (stdoutbuf);
+ set_nonblock (stderrbuf);
+ set_nonblock (protocol_inbuf);
if (close (stdout_pipe[1]) < 0)
{
@@ -2506,7 +2191,7 @@ do_cvs_command (command)
* See if we are swamping the remote client and filling our VM.
* Tell child to hold off if we do.
*/
- bufmemsize = buf_count_mem (&buf_to_net);
+ bufmemsize = buf_count_mem (buf_to_net);
if (!have_flowcontrolled && (bufmemsize > SERVER_HI_WATER))
{
if (write(flowcontrol_pipe[1], "S", 1) == 1)
@@ -2521,7 +2206,7 @@ do_cvs_command (command)
FD_ZERO (&readfds);
FD_ZERO (&writefds);
- if (! buf_empty_p (&buf_to_net))
+ if (! buf_empty_p (buf_to_net))
FD_SET (STDOUT_FILENO, &writefds);
if (stdout_pipe[0] >= 0)
@@ -2537,6 +2222,14 @@ do_cvs_command (command)
FD_SET (protocol_pipe[0], &readfds);
}
+ /* This process of selecting on the three pipes means that
+ we might not get output in the same order in which it
+ was written, thus producing the well-known
+ "out-of-order" bug. If the child process uses
+ cvs_output and cvs_outerr, it will send everything on
+ the protocol_pipe and avoid this problem, so the
+ solution is to use cvs_output and cvs_outerr in the
+ child process. */
do {
/* This used to select on exceptions too, but as far
as I know there was never any reason to do that and
@@ -2554,7 +2247,7 @@ do_cvs_command (command)
if (FD_ISSET (STDOUT_FILENO, &writefds))
{
/* What should we do with errors? syslog() them? */
- buf_send_output (&buf_to_net);
+ buf_send_output (buf_to_net);
}
if (stdout_pipe[0] >= 0
@@ -2562,9 +2255,9 @@ do_cvs_command (command)
{
int status;
- status = buf_input_data (&stdoutbuf, (int *) NULL);
+ status = buf_input_data (stdoutbuf, (int *) NULL);
- buf_copy_lines (&buf_to_net, &stdoutbuf, 'M');
+ buf_copy_lines (buf_to_net, stdoutbuf, 'M');
if (status == -1)
stdout_pipe[0] = -1;
@@ -2575,7 +2268,7 @@ do_cvs_command (command)
}
/* What should we do with errors? syslog() them? */
- buf_send_output (&buf_to_net);
+ buf_send_output (buf_to_net);
}
if (stderr_pipe[0] >= 0
@@ -2583,9 +2276,9 @@ do_cvs_command (command)
{
int status;
- status = buf_input_data (&stderrbuf, (int *) NULL);
+ status = buf_input_data (stderrbuf, (int *) NULL);
- buf_copy_lines (&buf_to_net, &stderrbuf, 'E');
+ buf_copy_lines (buf_to_net, stderrbuf, 'E');
if (status == -1)
stderr_pipe[0] = -1;
@@ -2596,7 +2289,7 @@ do_cvs_command (command)
}
/* What should we do with errors? syslog() them? */
- buf_send_output (&buf_to_net);
+ buf_send_output (buf_to_net);
}
if (protocol_pipe[0] >= 0
@@ -2604,8 +2297,17 @@ do_cvs_command (command)
{
int status;
int count_read;
+ int special;
- status = buf_input_data (&protocol_inbuf, &count_read);
+ status = buf_input_data (protocol_inbuf, &count_read);
+
+ if (status == -1)
+ protocol_pipe[0] = -1;
+ else if (status > 0)
+ {
+ print_error (status);
+ goto error_exit;
+ }
/*
* We only call buf_copy_counted if we have read
@@ -2614,20 +2316,30 @@ do_cvs_command (command)
* have.
*/
count_needed -= count_read;
- if (count_needed <= 0)
- count_needed = buf_copy_counted (&buf_to_net,
- &protocol_inbuf);
-
- if (status == -1)
- protocol_pipe[0] = -1;
- else if (status > 0)
+ while (count_needed <= 0)
{
- print_error (status);
- goto error_exit;
- }
+ count_needed = buf_copy_counted (buf_to_net,
+ protocol_inbuf,
+ &special);
+
+ /* What should we do with errors? syslog() them? */
+ buf_send_output (buf_to_net);
+
+ /* If SPECIAL got set to -1, it means that the child
+ wants us to flush the pipe. We don't want to block
+ on the network, but we flush what we can. If the
+ client supports the 'F' command, we send it. */
+ if (special == -1)
+ {
+ if (supported_response ("F"))
+ {
+ buf_append_char (buf_to_net, 'F');
+ buf_append_char (buf_to_net, '\n');
+ }
- /* What should we do with errors? syslog() them? */
- buf_send_output (&buf_to_net);
+ cvs_flusherr ();
+ }
+ }
}
}
@@ -2636,18 +2348,18 @@ do_cvs_command (command)
* anything left on stdoutbuf or stderrbuf (this could only
* happen if there was no trailing newline), send it over.
*/
- if (! buf_empty_p (&stdoutbuf))
+ if (! buf_empty_p (stdoutbuf))
{
- buf_append_char (&stdoutbuf, '\n');
- buf_copy_lines (&buf_to_net, &stdoutbuf, 'M');
+ buf_append_char (stdoutbuf, '\n');
+ buf_copy_lines (buf_to_net, stdoutbuf, 'M');
}
- if (! buf_empty_p (&stderrbuf))
+ if (! buf_empty_p (stderrbuf))
{
- buf_append_char (&stderrbuf, '\n');
- buf_copy_lines (&buf_to_net, &stderrbuf, 'E');
+ buf_append_char (stderrbuf, '\n');
+ buf_copy_lines (buf_to_net, stderrbuf, 'E');
}
- if (! buf_empty_p (&protocol_inbuf))
- buf_output0 (&buf_to_net,
+ if (! buf_empty_p (protocol_inbuf))
+ buf_output0 (buf_to_net,
"E Protocol error: uncounted data discarded\n");
errs = 0;
@@ -2671,6 +2383,7 @@ do_cvs_command (command)
else
{
int sig = WTERMSIG (status);
+ char buf[50];
/*
* This is really evil, because signals might be numbered
* differently on the two systems. We should be using
@@ -2678,14 +2391,17 @@ do_cvs_command (command)
* variety). But cvs doesn't currently use libiberty...we
* could roll our own.... FIXME.
*/
- printf ("E Terminated with fatal signal %d\n", sig);
+ buf_output0 (buf_to_net, "E Terminated with fatal signal ");
+ sprintf (buf, "%d\n", sig);
+ buf_output0 (buf_to_net, buf);
/* Test for a core dump. Is this portable? */
if (status & 0x80)
{
- printf ("E Core dumped; preserving %s on server.\n\
-E CVS locks may need cleaning up.\n",
- server_temp_dir);
+ buf_output0 (buf_to_net, "E Core dumped; preserving ");
+ buf_output0 (buf_to_net, orig_server_temp_dir);
+ buf_output0 (buf_to_net, " on server.\n\
+E CVS locks may need cleaning up.\n");
dont_delete_temp = 1;
}
++errs;
@@ -2698,15 +2414,15 @@ E CVS locks may need cleaning up.\n",
* OK, we've waited for the child. By now all CVS locks are free
* and it's OK to block on the network.
*/
- set_block (&buf_to_net);
- buf_send_output (&buf_to_net);
+ set_block (buf_to_net);
+ buf_flush (buf_to_net, 1);
}
if (errs)
/* We will have printed an error message already. */
- printf ("error \n");
+ buf_output0 (buf_to_net, "error \n");
else
- printf ("ok\n");
+ buf_output0 (buf_to_net, "ok\n");
goto free_args_and_return;
error_exit:
@@ -2743,6 +2459,11 @@ E CVS locks may need cleaning up.\n",
argument_count = 1;
}
+
+ /* Flush out any data not yet sent. */
+ set_block (buf_to_net);
+ buf_flush (buf_to_net, 1);
+
return;
}
@@ -2787,7 +2508,9 @@ server_pause_check()
if (FD_ISSET (flowcontrol_pipe[0], &fds))
{
- while (read (flowcontrol_pipe[0], buf, 1) == 1)
+ int got;
+
+ while ((got = read (flowcontrol_pipe[0], buf, 1)) == 1)
{
if (*buf == 'S') /* Stop */
paused = 1;
@@ -2796,11 +2519,24 @@ server_pause_check()
else
return; /* ??? */
}
+
+ /* This assumes that we are using BSD or POSIX nonblocking
+ I/O. System V nonblocking I/O returns zero if there is
+ nothing to read. */
+ if (got == 0)
+ error (1, 0, "flow control EOF");
+ if (got < 0 && ! blocking_error (errno))
+ {
+ error (1, errno, "flow control read failed");
+ }
}
}
}
#endif /* SERVER_FLOWCONTROL */
+/* This variable commented in server.h. */
+char *server_dir = NULL;
+
static void output_dir PROTO((char *, char *));
static void
@@ -2808,16 +2544,18 @@ output_dir (update_dir, repository)
char *update_dir;
char *repository;
{
- if (use_dir_and_repos)
+ if (server_dir != NULL)
{
- if (update_dir[0] == '\0')
- buf_output0 (&protocol, ".");
- else
- buf_output0 (&protocol, update_dir);
- buf_output0 (&protocol, "/\n");
+ buf_output0 (protocol, server_dir);
+ buf_output0 (protocol, "/");
}
- buf_output0 (&protocol, repository);
- buf_output0 (&protocol, "/");
+ if (update_dir[0] == '\0')
+ buf_output0 (protocol, ".");
+ else
+ buf_output0 (protocol, update_dir);
+ buf_output0 (protocol, "/\n");
+ buf_output0 (protocol, repository);
+ buf_output0 (protocol, "/");
}
/*
@@ -2929,9 +2667,9 @@ server_scratch (fname)
if (scratched_file != NULL)
{
- buf_output0 (&protocol,
+ buf_output0 (protocol,
"E CVS server internal error: duplicate Scratch_Entry\n");
- buf_send_counted (&protocol);
+ buf_send_counted (protocol);
return;
}
scratched_file = xstrdup (fname);
@@ -2950,22 +2688,23 @@ new_entries_line ()
{
if (entries_line)
{
- buf_output0 (&protocol, entries_line);
- buf_output (&protocol, "\n", 1);
+ buf_output0 (protocol, entries_line);
+ buf_output (protocol, "\n", 1);
}
else
/* Return the error message as the Entries line. */
- buf_output0 (&protocol,
+ buf_output0 (protocol,
"CVS server internal error: Register missing\n");
free (entries_line);
entries_line = NULL;
}
+
static void
serve_ci (arg)
char *arg;
{
- do_cvs_command (commit);
+ do_cvs_command ("commit", commit);
}
static void
@@ -2979,7 +2718,7 @@ checked_in_response (file, update_dir, repository)
struct stat sb;
char *mode_string;
- if (stat (file, &sb) < 0)
+ if ( CVS_STAT (file, &sb) < 0)
{
/* Not clear to me why the file would fail to exist, but it
was happening somewhere in the testsuite. */
@@ -2988,18 +2727,18 @@ checked_in_response (file, update_dir, repository)
}
else
{
- buf_output0 (&protocol, "Mode ");
+ buf_output0 (protocol, "Mode ");
mode_string = mode_to_string (sb.st_mode);
- buf_output0 (&protocol, mode_string);
- buf_output0 (&protocol, "\n");
+ buf_output0 (protocol, mode_string);
+ buf_output0 (protocol, "\n");
free (mode_string);
}
}
- buf_output0 (&protocol, "Checked-in ");
+ buf_output0 (protocol, "Checked-in ");
output_dir (update_dir, repository);
- buf_output0 (&protocol, file);
- buf_output (&protocol, "\n", 1);
+ buf_output0 (protocol, file);
+ buf_output (protocol, "\n", 1);
new_entries_line ();
}
@@ -3017,10 +2756,10 @@ server_checked_in (file, update_dir, repository)
* This happens if we are now doing a "cvs remove" after a previous
* "cvs add" (without a "cvs ci" in between).
*/
- buf_output0 (&protocol, "Remove-entry ");
+ buf_output0 (protocol, "Remove-entry ");
output_dir (update_dir, repository);
- buf_output0 (&protocol, file);
- buf_output (&protocol, "\n", 1);
+ buf_output0 (protocol, file);
+ buf_output (protocol, "\n", 1);
free (scratched_file);
scratched_file = NULL;
}
@@ -3028,7 +2767,7 @@ server_checked_in (file, update_dir, repository)
{
checked_in_response (file, update_dir, repository);
}
- buf_send_counted (&protocol);
+ buf_send_counted (protocol);
}
void
@@ -3046,105 +2785,105 @@ server_update_entries (file, update_dir, repository, updated)
{
if (!supported_response ("New-entry"))
return;
- buf_output0 (&protocol, "New-entry ");
+ buf_output0 (protocol, "New-entry ");
output_dir (update_dir, repository);
- buf_output0 (&protocol, file);
- buf_output (&protocol, "\n", 1);
+ buf_output0 (protocol, file);
+ buf_output (protocol, "\n", 1);
new_entries_line ();
}
- buf_send_counted (&protocol);
+ buf_send_counted (protocol);
}
static void
serve_update (arg)
char *arg;
{
- do_cvs_command (update);
+ do_cvs_command ("update", update);
}
static void
serve_diff (arg)
char *arg;
{
- do_cvs_command (diff);
+ do_cvs_command ("diff", diff);
}
static void
serve_log (arg)
char *arg;
{
- do_cvs_command (cvslog);
+ do_cvs_command ("cvslog", cvslog);
}
static void
serve_add (arg)
char *arg;
{
- do_cvs_command (add);
+ do_cvs_command ("add", add);
}
static void
serve_remove (arg)
char *arg;
{
- do_cvs_command (cvsremove);
+ do_cvs_command ("cvsremove", cvsremove);
}
static void
serve_status (arg)
char *arg;
{
- do_cvs_command (status);
+ do_cvs_command ("status", status);
}
static void
serve_rdiff (arg)
char *arg;
{
- do_cvs_command (patch);
+ do_cvs_command ("patch", patch);
}
static void
serve_tag (arg)
char *arg;
{
- do_cvs_command (tag);
+ do_cvs_command ("cvstag", cvstag);
}
static void
serve_rtag (arg)
char *arg;
{
- do_cvs_command (rtag);
+ do_cvs_command ("rtag", rtag);
}
static void
serve_import (arg)
char *arg;
{
- do_cvs_command (import);
+ do_cvs_command ("import", import);
}
static void
serve_admin (arg)
char *arg;
{
- do_cvs_command (admin);
+ do_cvs_command ("admin", admin);
}
static void
serve_history (arg)
char *arg;
{
- do_cvs_command (history);
+ do_cvs_command ("history", history);
}
static void
serve_release (arg)
char *arg;
{
- do_cvs_command (release);
+ do_cvs_command ("release", release);
}
static void serve_watch_on PROTO ((char *));
@@ -3153,7 +2892,7 @@ static void
serve_watch_on (arg)
char *arg;
{
- do_cvs_command (watch_on);
+ do_cvs_command ("watch_on", watch_on);
}
static void serve_watch_off PROTO ((char *));
@@ -3162,7 +2901,7 @@ static void
serve_watch_off (arg)
char *arg;
{
- do_cvs_command (watch_off);
+ do_cvs_command ("watch_off", watch_off);
}
static void serve_watch_add PROTO ((char *));
@@ -3171,7 +2910,7 @@ static void
serve_watch_add (arg)
char *arg;
{
- do_cvs_command (watch_add);
+ do_cvs_command ("watch_add", watch_add);
}
static void serve_watch_remove PROTO ((char *));
@@ -3180,7 +2919,7 @@ static void
serve_watch_remove (arg)
char *arg;
{
- do_cvs_command (watch_remove);
+ do_cvs_command ("watch_remove", watch_remove);
}
static void serve_watchers PROTO ((char *));
@@ -3189,7 +2928,7 @@ static void
serve_watchers (arg)
char *arg;
{
- do_cvs_command (watchers);
+ do_cvs_command ("watchers", watchers);
}
static void serve_editors PROTO ((char *));
@@ -3198,7 +2937,7 @@ static void
serve_editors (arg)
char *arg;
{
- do_cvs_command (editors);
+ do_cvs_command ("editors", editors);
}
static int noop PROTO ((int, char **));
@@ -3217,7 +2956,7 @@ static void
serve_noop (arg)
char *arg;
{
- do_cvs_command (noop);
+ do_cvs_command ("noop", noop);
}
static void serve_init PROTO ((char *));
@@ -3226,15 +2965,17 @@ static void
serve_init (arg)
char *arg;
{
- CVSroot = malloc (strlen (arg) + 1);
- if (CVSroot == NULL)
+ if (!isabsolute (arg))
{
- pending_error = ENOMEM;
- return;
+ if (alloc_pending (80 + strlen (arg)))
+ sprintf (pending_error_text,
+ "E Root %s must be an absolute pathname", arg);
+ /* Fall through to do_cvs_command which will return the
+ actual error. */
}
- strcpy (CVSroot, arg);
+ set_local_cvsroot (arg);
- do_cvs_command (init);
+ do_cvs_command ("init", init);
}
static void serve_annotate PROTO ((char *));
@@ -3243,7 +2984,7 @@ static void
serve_annotate (arg)
char *arg;
{
- do_cvs_command (annotate);
+ do_cvs_command ("annotate", annotate);
}
static void
@@ -3265,7 +3006,7 @@ serve_co (arg)
tempdir = malloc (strlen (server_temp_dir) + 80);
if (tempdir == NULL)
{
- printf ("E Out of memory\n");
+ buf_output0 (buf_to_net, "E Out of memory\n");
return;
}
strcpy (tempdir, server_temp_dir);
@@ -3273,22 +3014,34 @@ serve_co (arg)
status = mkdir_p (tempdir);
if (status != 0 && status != EEXIST)
{
- printf ("E Cannot create %s\n", tempdir);
+ buf_output0 (buf_to_net, "E Cannot create ");
+ buf_output0 (buf_to_net, tempdir);
+ buf_append_char (buf_to_net, '\n');
print_error (errno);
free (tempdir);
return;
}
- if (chdir (tempdir) < 0)
+ if ( CVS_CHDIR (tempdir) < 0)
{
- printf ("E Cannot change to directory %s\n", tempdir);
+ buf_output0 (buf_to_net, "E Cannot change to directory ");
+ buf_output0 (buf_to_net, tempdir);
+ buf_append_char (buf_to_net, '\n');
print_error (errno);
free (tempdir);
return;
}
free (tempdir);
}
- do_cvs_command (checkout);
+
+ /* Compensate for server_export()'s setting of command_name.
+ *
+ * [It probably doesn't matter if do_cvs_command() gets "export"
+ * or "checkout", but we ought to be accurate where possible.]
+ */
+ do_cvs_command ((strcmp (command_name, "export") == 0) ?
+ "export" : "checkout",
+ checkout);
}
static void
@@ -3309,34 +3062,27 @@ server_copy_file (file, update_dir, repository, newfile)
{
if (!supported_response ("Copy-file"))
return;
- buf_output0 (&protocol, "Copy-file ");
+ buf_output0 (protocol, "Copy-file ");
output_dir (update_dir, repository);
- buf_output0 (&protocol, file);
- buf_output0 (&protocol, "\n");
- buf_output0 (&protocol, newfile);
- buf_output0 (&protocol, "\n");
+ buf_output0 (protocol, file);
+ buf_output0 (protocol, "\n");
+ buf_output0 (protocol, newfile);
+ buf_output0 (protocol, "\n");
}
+/* See server.h for description. */
+
void
-server_updated (file, update_dir, repository, updated, file_info, checksum)
- char *file;
- char *update_dir;
- char *repository;
+server_updated (finfo, vers, updated, file_info, checksum)
+ struct file_info *finfo;
+ Vers_TS *vers;
enum server_updated_arg4 updated;
struct stat *file_info;
unsigned char *checksum;
{
- char *short_pathname;
-
if (noexec)
return;
- short_pathname = xmalloc (strlen (update_dir) + strlen (file) + 10);
- if (update_dir[0] == '\0')
- strcpy (short_pathname, file);
- else
- sprintf (short_pathname, "%s/%s", update_dir, file);
-
if (entries_line != NULL && scratched_file == NULL)
{
FILE *f;
@@ -3345,7 +3091,7 @@ server_updated (file, update_dir, repository, updated, file_info, checksum)
unsigned long size;
char size_text[80];
- if (stat (file, &sb) < 0)
+ if ( CVS_STAT (finfo->file, &sb) < 0)
{
if (existence_error (errno))
{
@@ -3353,13 +3099,12 @@ server_updated (file, update_dir, repository, updated, file_info, checksum)
* If we have a sticky tag for a branch on which the
* file is dead, and cvs update the directory, it gets
* a T_CHECKOUT but no file. So in this case just
- * forget the whole thing.
- */
+ * forget the whole thing. */
free (entries_line);
entries_line = NULL;
goto done;
}
- error (1, errno, "reading %s", short_pathname);
+ error (1, errno, "reading %s", finfo->fullname);
}
if (checksum != NULL)
@@ -3376,27 +3121,52 @@ server_updated (file, update_dir, repository, updated, file_info, checksum)
int i;
char buf[3];
- buf_output0 (&protocol, "Checksum ");
+ buf_output0 (protocol, "Checksum ");
for (i = 0; i < 16; i++)
{
sprintf (buf, "%02x", (unsigned int) checksum[i]);
- buf_output0 (&protocol, buf);
+ buf_output0 (protocol, buf);
}
- buf_append_char (&protocol, '\n');
+ buf_append_char (protocol, '\n');
}
}
if (updated == SERVER_UPDATED)
- buf_output0 (&protocol, "Updated ");
+ {
+ Node *node;
+ Entnode *entnode;
+
+ if (!(supported_response ("Created")
+ && supported_response ("Update-existing")))
+ buf_output0 (protocol, "Updated ");
+ else
+ {
+ assert (vers != NULL);
+ if (vers->ts_user == NULL)
+ buf_output0 (protocol, "Created ");
+ else
+ buf_output0 (protocol, "Update-existing ");
+ }
+
+ /* Now munge the entries to say that the file is unmodified,
+ in case we end up processing it again (e.g. modules3-6
+ in the testsuite). */
+ node = findnode_fn (finfo->entries, finfo->file);
+ entnode = (Entnode *)node->data;
+ free (entnode->timestamp);
+ entnode->timestamp = xstrdup ("=");
+ }
else if (updated == SERVER_MERGED)
- buf_output0 (&protocol, "Merged ");
+ buf_output0 (protocol, "Merged ");
else if (updated == SERVER_PATCHED)
- buf_output0 (&protocol, "Patched ");
+ buf_output0 (protocol, "Patched ");
+ else if (updated == SERVER_RCS_DIFF)
+ buf_output0 (protocol, "Rcs-diff ");
else
abort ();
- output_dir (update_dir, repository);
- buf_output0 (&protocol, file);
- buf_output (&protocol, "\n", 1);
+ output_dir (finfo->update_dir, finfo->repository);
+ buf_output0 (protocol, finfo->file);
+ buf_output (protocol, "\n", 1);
new_entries_line ();
@@ -3404,15 +3174,14 @@ server_updated (file, update_dir, repository, updated, file_info, checksum)
char *mode_string;
/* FIXME: When we check out files the umask of the server
- (set in .bashrc if rsh is in use, or set in main.c in
- the kerberos case, I think) affects what mode we send,
- and it shouldn't. */
+ (set in .bashrc if rsh is in use) affects what mode we
+ send, and it shouldn't. */
if (file_info != NULL)
mode_string = mode_to_string (file_info->st_mode);
else
mode_string = mode_to_string (sb.st_mode);
- buf_output0 (&protocol, mode_string);
- buf_output0 (&protocol, "\n");
+ buf_output0 (protocol, mode_string);
+ buf_output0 (protocol, "\n");
free (mode_string);
}
@@ -3424,7 +3193,7 @@ server_updated (file, update_dir, repository, updated, file_info, checksum)
file we are sending. The client handles any line ending
translation if necessary. */
- if (gzip_level
+ if (file_gzip_level
/*
* For really tiny files, the gzip process startup
* time will outweigh the compression savings. This
@@ -3436,51 +3205,51 @@ server_updated (file, update_dir, repository, updated, file_info, checksum)
int status, fd, gzip_status;
pid_t gzip_pid;
- fd = open (file, O_RDONLY | OPEN_BINARY, 0);
+ fd = CVS_OPEN (finfo->file, O_RDONLY | OPEN_BINARY, 0);
if (fd < 0)
- error (1, errno, "reading %s", short_pathname);
- fd = filter_through_gzip (fd, 1, gzip_level, &gzip_pid);
+ error (1, errno, "reading %s", finfo->fullname);
+ fd = filter_through_gzip (fd, 1, file_gzip_level, &gzip_pid);
f = fdopen (fd, "rb");
status = buf_read_file_to_eof (f, &list, &last);
size = buf_chain_length (list);
if (status == -2)
- (*protocol.memory_error) (&protocol);
+ (*protocol->memory_error) (protocol);
else if (status != 0)
error (1, ferror (f) ? errno : 0, "reading %s",
- short_pathname);
+ finfo->fullname);
if (fclose (f) == EOF)
- error (1, errno, "reading %s", short_pathname);
+ error (1, errno, "reading %s", finfo->fullname);
if (waitpid (gzip_pid, &gzip_status, 0) == -1)
error (1, errno, "waiting for gzip process %ld",
(long) gzip_pid);
else if (gzip_status != 0)
error (1, 0, "gzip exited %d", gzip_status);
/* Prepending length with "z" is flag for using gzip here. */
- buf_output0 (&protocol, "z");
+ buf_output0 (protocol, "z");
}
else
{
long status;
size = sb.st_size;
- f = fopen (file, "rb");
+ f = CVS_FOPEN (finfo->file, "rb");
if (f == NULL)
- error (1, errno, "reading %s", short_pathname);
+ error (1, errno, "reading %s", finfo->fullname);
status = buf_read_file (f, sb.st_size, &list, &last);
if (status == -2)
- (*protocol.memory_error) (&protocol);
+ (*protocol->memory_error) (protocol);
else if (status != 0)
error (1, ferror (f) ? errno : 0, "reading %s",
- short_pathname);
+ finfo->fullname);
if (fclose (f) == EOF)
- error (1, errno, "reading %s", short_pathname);
+ error (1, errno, "reading %s", finfo->fullname);
}
}
sprintf (size_text, "%lu\n", size);
- buf_output0 (&protocol, size_text);
+ buf_output0 (protocol, size_text);
- buf_append_data (&protocol, list, last);
+ buf_append_data (protocol, list, last);
/* Note we only send a newline here if the file ended with one. */
/*
@@ -3490,29 +3259,31 @@ server_updated (file, update_dir, repository, updated, file_info, checksum)
* not up-to-date, and we indicate that by leaving the file there.
* I'm thinking of cases like "cvs update foo/foo.c foo".
*/
- if ((updated == SERVER_UPDATED || updated == SERVER_PATCHED)
+ if ((updated == SERVER_UPDATED
+ || updated == SERVER_PATCHED
+ || updated == SERVER_RCS_DIFF)
/* But if we are joining, we'll need the file when we call
join_file. */
&& !joining ())
- unlink (file);
+ CVS_UNLINK (finfo->file);
}
else if (scratched_file != NULL && entries_line == NULL)
{
- if (strcmp (scratched_file, file) != 0)
+ if (strcmp (scratched_file, finfo->file) != 0)
error (1, 0,
"CVS server internal error: `%s' vs. `%s' scratched",
scratched_file,
- file);
+ finfo->file);
free (scratched_file);
scratched_file = NULL;
if (kill_scratched_file)
- buf_output0 (&protocol, "Removed ");
+ buf_output0 (protocol, "Removed ");
else
- buf_output0 (&protocol, "Remove-entry ");
- output_dir (update_dir, repository);
- buf_output0 (&protocol, file);
- buf_output (&protocol, "\n", 1);
+ buf_output0 (protocol, "Remove-entry ");
+ output_dir (finfo->update_dir, finfo->repository);
+ buf_output0 (protocol, finfo->file);
+ buf_output (protocol, "\n", 1);
}
else if (scratched_file == NULL && entries_line == NULL)
{
@@ -3524,9 +3295,16 @@ server_updated (file, update_dir, repository, updated, file_info, checksum)
else
error (1, 0,
"CVS server internal error: Register *and* Scratch_Entry.\n");
- buf_send_counted (&protocol);
- done:
- free (short_pathname);
+ buf_send_counted (protocol);
+ done:;
+}
+
+/* Return whether we should send patches in RCS format. */
+
+int
+server_use_rcs_diff ()
+{
+ return supported_response ("Rcs-diff");
}
void
@@ -3539,10 +3317,10 @@ server_set_entstat (update_dir, repository)
set_static_supported = supported_response ("Set-static-directory");
if (!set_static_supported) return;
- buf_output0 (&protocol, "Set-static-directory ");
+ buf_output0 (protocol, "Set-static-directory ");
output_dir (update_dir, repository);
- buf_output0 (&protocol, "\n");
- buf_send_counted (&protocol);
+ buf_output0 (protocol, "\n");
+ buf_send_counted (protocol);
}
void
@@ -3558,20 +3336,24 @@ server_clear_entstat (update_dir, repository)
if (noexec)
return;
- buf_output0 (&protocol, "Clear-static-directory ");
+ buf_output0 (protocol, "Clear-static-directory ");
output_dir (update_dir, repository);
- buf_output0 (&protocol, "\n");
- buf_send_counted (&protocol);
+ buf_output0 (protocol, "\n");
+ buf_send_counted (protocol);
}
void
-server_set_sticky (update_dir, repository, tag, date)
+server_set_sticky (update_dir, repository, tag, date, nonbranch)
char *update_dir;
char *repository;
char *tag;
char *date;
+ int nonbranch;
{
static int set_sticky_supported = -1;
+
+ assert (update_dir != NULL);
+
if (set_sticky_supported == -1)
set_sticky_supported = supported_response ("Set-sticky");
if (!set_sticky_supported) return;
@@ -3581,28 +3363,31 @@ server_set_sticky (update_dir, repository, tag, date)
if (tag == NULL && date == NULL)
{
- buf_output0 (&protocol, "Clear-sticky ");
+ buf_output0 (protocol, "Clear-sticky ");
output_dir (update_dir, repository);
- buf_output0 (&protocol, "\n");
+ buf_output0 (protocol, "\n");
}
else
{
- buf_output0 (&protocol, "Set-sticky ");
+ buf_output0 (protocol, "Set-sticky ");
output_dir (update_dir, repository);
- buf_output0 (&protocol, "\n");
+ buf_output0 (protocol, "\n");
if (tag != NULL)
{
- buf_output0 (&protocol, "T");
- buf_output0 (&protocol, tag);
+ if (nonbranch)
+ buf_output0 (protocol, "N");
+ else
+ buf_output0 (protocol, "T");
+ buf_output0 (protocol, tag);
}
else
{
- buf_output0 (&protocol, "D");
- buf_output0 (&protocol, date);
+ buf_output0 (protocol, "D");
+ buf_output0 (protocol, date);
}
- buf_output0 (&protocol, "\n");
+ buf_output0 (protocol, "\n");
}
- buf_send_counted (&protocol);
+ buf_send_counted (protocol);
}
struct template_proc_data
@@ -3629,11 +3414,11 @@ template_proc (repository, template)
if (!supported_response ("Template"))
/* Might want to warn the user that the rcsinfo feature won't work. */
return 0;
- buf_output0 (&protocol, "Template ");
+ buf_output0 (protocol, "Template ");
output_dir (data->update_dir, data->repository);
- buf_output0 (&protocol, "\n");
+ buf_output0 (protocol, "\n");
- fp = fopen (template, "rb");
+ fp = CVS_FOPEN (template, "rb");
if (fp == NULL)
{
error (0, errno, "Couldn't open rcsinfo template file %s", template);
@@ -3645,11 +3430,11 @@ template_proc (repository, template)
return 1;
}
sprintf (buf, "%ld\n", (long) sb.st_size);
- buf_output0 (&protocol, buf);
+ buf_output0 (protocol, buf);
while (!feof (fp))
{
n = fread (buf, 1, sizeof buf, fp);
- buf_output (&protocol, buf, n);
+ buf_output (protocol, buf, n);
if (ferror (fp))
{
error (0, errno, "cannot read rcsinfo template file %s", template);
@@ -3682,7 +3467,24 @@ serve_gzip_contents (arg)
level = atoi (arg);
if (level == 0)
level = 6;
- gzip_level = level;
+ file_gzip_level = level;
+}
+
+static void
+serve_gzip_stream (arg)
+ char *arg;
+{
+ int level;
+ level = atoi (arg);
+ if (level == 0)
+ level = 6;
+
+ /* All further communication with the client will be compressed. */
+
+ buf_to_net = compress_buffer_initialize (buf_to_net, 0, level,
+ buf_to_net->memory_error);
+ buf_from_net = compress_buffer_initialize (buf_from_net, 1, level,
+ buf_from_net->memory_error);
}
static void
@@ -3720,23 +3522,37 @@ expand_proc (pargc, argv, where, mwhere, mfile, shorten,
if (mwhere != NULL)
{
- printf ("Module-expansion %s", mwhere);
+ buf_output0 (buf_to_net, "Module-expansion ");
+ buf_output0 (buf_to_net, mwhere);
if (mfile != NULL)
{
- printf ("/%s", mfile);
+ buf_append_char (buf_to_net, '/');
+ buf_output0 (buf_to_net, mfile);
}
- printf ("\n");
+ buf_append_char (buf_to_net, '\n');
}
else
- {
+ {
/* We may not need to do this anymore -- check the definition
of aliases before removing */
if (*pargc == 1)
- printf ("Module-expansion %s\n", dir);
+ {
+ buf_output0 (buf_to_net, "Module-expansion ");
+ buf_output0 (buf_to_net, dir);
+ buf_append_char (buf_to_net, '\n');
+ }
else
- for (i = 1; i < *pargc; ++i)
- printf ("Module-expansion %s/%s\n", dir, argv[i]);
- }
+ {
+ for (i = 1; i < *pargc; ++i)
+ {
+ buf_output0 (buf_to_net, "Module-expansion ");
+ buf_output0 (buf_to_net, dir);
+ buf_append_char (buf_to_net, '/');
+ buf_output0 (buf_to_net, argv[i]);
+ buf_append_char (buf_to_net, '\n');
+ }
+ }
+ }
return 0;
}
@@ -3749,11 +3565,6 @@ serve_expand_modules (arg)
DBM *db;
err = 0;
- /*
- * FIXME: error handling is bogus; do_module can write to stdout and/or
- * stderr and we're not using do_cvs_command.
- */
-
server_expanding = 1;
db = open_module ();
for (i = 1; i < argument_count; i++)
@@ -3775,9 +3586,13 @@ serve_expand_modules (arg)
}
if (err)
/* We will have printed an error message already. */
- printf ("error \n");
+ buf_output0 (buf_to_net, "error \n");
else
- printf ("ok\n");
+ buf_output0 (buf_to_net, "ok\n");
+
+ /* The client is waiting for the module expansions, so we must
+ send the output now. */
+ buf_flush (buf_to_net, 1);
}
void
@@ -3788,20 +3603,23 @@ server_prog (dir, name, which)
{
if (!supported_response ("Set-checkin-prog"))
{
- printf ("E \
+ buf_output0 (buf_to_net, "E \
warning: this client does not support -i or -u flags in the modules file.\n");
return;
}
switch (which)
{
case PROG_CHECKIN:
- printf ("Set-checkin-prog ");
+ buf_output0 (buf_to_net, "Set-checkin-prog ");
break;
case PROG_UPDATE:
- printf ("Set-update-prog ");
+ buf_output0 (buf_to_net, "Set-update-prog ");
break;
}
- printf ("%s\n%s\n", dir, name);
+ buf_output0 (buf_to_net, dir);
+ buf_append_char (buf_to_net, '\n');
+ buf_output0 (buf_to_net, name);
+ buf_append_char (buf_to_net, '\n');
}
static void
@@ -3809,26 +3627,27 @@ serve_checkin_prog (arg)
char *arg;
{
FILE *f;
- f = fopen (CVSADM_CIPROG, "w+");
+ f = CVS_FOPEN (CVSADM_CIPROG, "w+");
if (f == NULL)
{
pending_error = errno;
- pending_error_text = malloc (80 + strlen(CVSADM_CIPROG));
- sprintf(pending_error_text, "E cannot open %s", CVSADM_CIPROG);
+ if (alloc_pending (80 + strlen (CVSADM_CIPROG)))
+ sprintf (pending_error_text, "E cannot open %s", CVSADM_CIPROG);
return;
}
if (fprintf (f, "%s\n", arg) < 0)
{
pending_error = errno;
- pending_error_text = malloc (80 + strlen(CVSADM_CIPROG));
- sprintf(pending_error_text, "E cannot write to %s", CVSADM_CIPROG);
+ if (alloc_pending (80 + strlen (CVSADM_CIPROG)))
+ sprintf (pending_error_text,
+ "E cannot write to %s", CVSADM_CIPROG);
return;
}
if (fclose (f) == EOF)
{
pending_error = errno;
- pending_error_text = malloc (80 + strlen(CVSADM_CIPROG));
- sprintf(pending_error_text, "E cannot close %s", CVSADM_CIPROG);
+ if (alloc_pending (80 + strlen (CVSADM_CIPROG)))
+ sprintf (pending_error_text, "E cannot close %s", CVSADM_CIPROG);
return;
}
}
@@ -3838,26 +3657,39 @@ serve_update_prog (arg)
char *arg;
{
FILE *f;
- f = fopen (CVSADM_UPROG, "w+");
+
+ /* Before we do anything we need to make sure we are not in readonly
+ mode. */
+ if (!check_command_legal_p ("commit"))
+ {
+ /* I might be willing to make this a warning, except we lack the
+ machinery to do so. */
+ if (alloc_pending (80))
+ sprintf (pending_error_text, "\
+E Flag -u in modules not allowed in readonly mode");
+ return;
+ }
+
+ f = CVS_FOPEN (CVSADM_UPROG, "w+");
if (f == NULL)
{
pending_error = errno;
- pending_error_text = malloc (80 + strlen(CVSADM_UPROG));
- sprintf(pending_error_text, "E cannot open %s", CVSADM_UPROG);
+ if (alloc_pending (80 + strlen (CVSADM_UPROG)))
+ sprintf (pending_error_text, "E cannot open %s", CVSADM_UPROG);
return;
}
if (fprintf (f, "%s\n", arg) < 0)
{
pending_error = errno;
- pending_error_text = malloc (80 + strlen(CVSADM_UPROG));
- sprintf(pending_error_text, "E cannot write to %s", CVSADM_UPROG);
+ if (alloc_pending (80 + strlen (CVSADM_UPROG)))
+ sprintf (pending_error_text, "E cannot write to %s", CVSADM_UPROG);
return;
}
if (fclose (f) == EOF)
{
pending_error = errno;
- pending_error_text = malloc (80 + strlen(CVSADM_UPROG));
- sprintf(pending_error_text, "E cannot close %s", CVSADM_UPROG);
+ if (alloc_pending (80 + strlen (CVSADM_UPROG)))
+ sprintf (pending_error_text, "E cannot close %s", CVSADM_UPROG);
return;
}
}
@@ -3884,8 +3716,8 @@ struct request requests[] =
REQ_LINE("Root", serve_root, rq_essential),
REQ_LINE("Valid-responses", serve_valid_responses, rq_essential),
REQ_LINE("valid-requests", serve_valid_requests, rq_essential),
- REQ_LINE("Repository", serve_repository, rq_essential),
- REQ_LINE("Directory", serve_directory, rq_optional),
+ REQ_LINE("Repository", serve_repository, rq_optional),
+ REQ_LINE("Directory", serve_directory, rq_essential),
REQ_LINE("Max-dotdot", serve_max_dotdot, rq_optional),
REQ_LINE("Static-directory", serve_static_directory, rq_optional),
REQ_LINE("Sticky", serve_sticky, rq_optional),
@@ -3893,16 +3725,27 @@ struct request requests[] =
REQ_LINE("Update-prog", serve_update_prog, rq_optional),
REQ_LINE("Entry", serve_entry, rq_essential),
REQ_LINE("Modified", serve_modified, rq_essential),
- REQ_LINE("Lost", serve_lost, rq_optional),
+ REQ_LINE("Is-modified", serve_is_modified, rq_optional),
+
+ /* The client must send this request to interoperate with CVS 1.5
+ through 1.9 servers. The server must support it (although it can
+ be and is a noop) to interoperate with CVS 1.5 to 1.9 clients. */
REQ_LINE("UseUnchanged", serve_enable_unchanged, rq_enableme),
- REQ_LINE("Unchanged", serve_unchanged, rq_optional),
+
+ REQ_LINE("Unchanged", serve_unchanged, rq_essential),
REQ_LINE("Notify", serve_notify, rq_optional),
REQ_LINE("Questionable", serve_questionable, rq_optional),
REQ_LINE("Case", serve_case, rq_optional),
REQ_LINE("Argument", serve_argument, rq_essential),
REQ_LINE("Argumentx", serve_argumentx, rq_essential),
REQ_LINE("Global_option", serve_global_option, rq_optional),
+ REQ_LINE("Gzip-stream", serve_gzip_stream, rq_optional),
REQ_LINE("Set", serve_set, rq_optional),
+#ifdef ENCRYPTION
+#ifdef HAVE_KERBEROS
+ REQ_LINE("Kerberos-encrypt", serve_kerberos_encrypt, rq_optional),
+#endif
+#endif
REQ_LINE("expand-modules", serve_expand_modules, rq_optional),
REQ_LINE("ci", serve_ci, rq_essential),
REQ_LINE("co", serve_co, rq_essential),
@@ -3946,11 +3789,20 @@ serve_valid_requests (arg)
struct request *rq;
if (print_pending_error ())
return;
- printf ("Valid-requests");
+ buf_output0 (buf_to_net, "Valid-requests");
for (rq = requests; rq->name != NULL; rq++)
+ {
if (rq->func != NULL)
- printf (" %s", rq->name);
- printf ("\nok\n");
+ {
+ buf_append_char (buf_to_net, ' ');
+ buf_output0 (buf_to_net, rq->name);
+ }
+ }
+ buf_output0 (buf_to_net, "\nok\n");
+
+ /* The client is waiting for the list of valid requests, so we
+ must send the output now. */
+ buf_flush (buf_to_net, 1);
}
#ifdef sun
@@ -3962,10 +3814,10 @@ static int command_pid_is_dead;
static void wait_sig (sig)
int sig;
{
- int status;
- pid_t r = wait (&status);
- if (r == command_pid)
- command_pid_is_dead++;
+ int status;
+ pid_t r = wait (&status);
+ if (r == command_pid)
+ command_pid_is_dead++;
}
#endif
@@ -3974,104 +3826,135 @@ server_cleanup (sig)
int sig;
{
/* Do "rm -rf" on the temp directory. */
- int len;
- char *cmd;
- char *temp_dir;
+ int status;
+ int save_noexec;
+
+ if (buf_to_net != NULL)
+ {
+ /* FIXME: If this is not the final call from server, this
+ could deadlock, because the client might be blocked writing
+ to us. This should not be a problem in practice, because
+ we do not generate much output when the client is not
+ waiting for it. */
+ set_block (buf_to_net);
+ buf_flush (buf_to_net, 1);
+
+ /* The calls to buf_shutdown are currently only meaningful
+ when we are using compression. First we shut down
+ BUF_FROM_NET. That will pick up the checksum generated
+ when the client shuts down its buffer. Then, after we have
+ generated any final output, we shut down BUF_TO_NET. */
+
+ status = buf_shutdown (buf_from_net);
+ if (status != 0)
+ {
+ error (0, status, "shutting down buffer from client");
+ buf_flush (buf_to_net, 1);
+ }
+ }
if (dont_delete_temp)
+ {
+ if (buf_to_net != NULL)
+ (void) buf_shutdown (buf_to_net);
return;
+ }
/* What a bogus kludge. This disgusting code makes all kinds of
assumptions about SunOS, and is only for a bug in that system.
So only enable it on Suns. */
#ifdef sun
- if (command_pid > 0) {
- /* To avoid crashes on SunOS due to bugs in SunOS tmpfs
- triggered by the use of rename() in RCS, wait for the
- subprocess to die. Unfortunately, this means draining output
- while waiting for it to unblock the signal we sent it. Yuck! */
- int status;
- pid_t r;
-
- signal (SIGCHLD, wait_sig);
- if (sig)
- /* Perhaps SIGTERM would be more correct. But the child
- process will delay the SIGINT delivery until its own
- children have exited. */
- kill (command_pid, SIGINT);
- /* The caller may also have sent a signal to command_pid, so
- always try waiting. First, though, check and see if it's still
- there.... */
+ if (command_pid > 0)
+ {
+ /* To avoid crashes on SunOS due to bugs in SunOS tmpfs
+ triggered by the use of rename() in RCS, wait for the
+ subprocess to die. Unfortunately, this means draining output
+ while waiting for it to unblock the signal we sent it. Yuck! */
+ int status;
+ pid_t r;
+
+ signal (SIGCHLD, wait_sig);
+ if (sig)
+ /* Perhaps SIGTERM would be more correct. But the child
+ process will delay the SIGINT delivery until its own
+ children have exited. */
+ kill (command_pid, SIGINT);
+ /* The caller may also have sent a signal to command_pid, so
+ always try waiting. First, though, check and see if it's still
+ there.... */
do_waitpid:
- r = waitpid (command_pid, &status, WNOHANG);
- if (r == 0)
- ;
- else if (r == command_pid)
- command_pid_is_dead++;
- else if (r == -1)
- switch (errno) {
- case ECHILD:
- command_pid_is_dead++;
- break;
- case EINTR:
- goto do_waitpid;
- }
- else
- /* waitpid should always return one of the above values */
- abort ();
- while (!command_pid_is_dead) {
- struct timeval timeout;
- struct fd_set_wrapper readfds;
- char buf[100];
- int i;
-
- /* Use a non-zero timeout to avoid eating up CPU cycles. */
- timeout.tv_sec = 2;
- timeout.tv_usec = 0;
- readfds = command_fds_to_drain;
- switch (select (max_command_fd + 1, &readfds.fds,
- (fd_set *)0, (fd_set *)0,
- &timeout)) {
- case -1:
- if (errno != EINTR)
+ r = waitpid (command_pid, &status, WNOHANG);
+ if (r == 0)
+ ;
+ else if (r == command_pid)
+ command_pid_is_dead++;
+ else if (r == -1)
+ switch (errno)
+ {
+ case ECHILD:
+ command_pid_is_dead++;
+ break;
+ case EINTR:
+ goto do_waitpid;
+ }
+ else
+ /* waitpid should always return one of the above values */
abort ();
- case 0:
- /* timeout */
- break;
- case 1:
- for (i = 0; i <= max_command_fd; i++)
+ while (!command_pid_is_dead)
+ {
+ struct timeval timeout;
+ struct fd_set_wrapper readfds;
+ char buf[100];
+ int i;
+
+ /* Use a non-zero timeout to avoid eating up CPU cycles. */
+ timeout.tv_sec = 2;
+ timeout.tv_usec = 0;
+ readfds = command_fds_to_drain;
+ switch (select (max_command_fd + 1, &readfds.fds,
+ (fd_set *)0, (fd_set *)0,
+ &timeout))
{
- if (!FD_ISSET (i, &readfds.fds))
- continue;
- /* this fd is non-blocking */
- while (read (i, buf, sizeof (buf)) >= 1)
- ;
+ case -1:
+ if (errno != EINTR)
+ abort ();
+ case 0:
+ /* timeout */
+ break;
+ case 1:
+ for (i = 0; i <= max_command_fd; i++)
+ {
+ if (!FD_ISSET (i, &readfds.fds))
+ continue;
+ /* this fd is non-blocking */
+ while (read (i, buf, sizeof (buf)) >= 1)
+ ;
+ }
+ break;
+ default:
+ abort ();
}
- break;
- default:
- abort ();
}
- }
}
#endif
- /* This might be set by the user in ~/.bashrc, ~/.cshrc, etc. */
- temp_dir = getenv ("TMPDIR");
- if (temp_dir == NULL || temp_dir[0] == '\0')
- temp_dir = "/tmp";
- chdir(temp_dir);
-
- len = strlen (server_temp_dir) + 80;
- cmd = malloc (len);
- if (cmd == NULL)
- {
- printf ("E Cannot delete %s on server; out of memory\n",
- server_temp_dir);
- return;
- }
- sprintf (cmd, "rm -rf %s", server_temp_dir);
- system (cmd);
- free (cmd);
+ CVS_CHDIR (Tmpdir);
+ /* Temporarily clear noexec, so that we clean up our temp directory
+ regardless of it (this could more cleanly be handled by moving
+ the noexec check to all the unlink_file_dir callers from
+ unlink_file_dir itself). */
+ save_noexec = noexec;
+ noexec = 0;
+ /* FIXME? Would be nice to not ignore errors. But what should we do?
+ We could try to do this before we shut down the network connection,
+ and try to notify the client (but the client might not be waiting
+ for responses). We could try something like syslog() or our own
+ log file. */
+ unlink_file_dir (orig_server_temp_dir);
+ noexec = save_noexec;
+
+ if (buf_to_net != NULL)
+ (void) buf_shutdown (buf_to_net);
}
int server_active = 0;
@@ -4094,6 +3977,13 @@ server (argc, argv)
}
/* Ignore argc and argv. They might be from .cvsrc. */
+ buf_to_net = fd_buffer_initialize (STDOUT_FILENO, 0,
+ outbuf_memory_error);
+ buf_from_net = stdio_buffer_initialize (stdin, 1, outbuf_memory_error);
+
+ saved_output = buf_nonio_initialize (outbuf_memory_error);
+ saved_outerr = buf_nonio_initialize (outbuf_memory_error);
+
/* Since we're in the server parent process, error should use the
protocol to report error messages. */
error_use_protocol = 1;
@@ -4125,6 +4015,17 @@ server (argc, argv)
{
printf ("E Fatal server error, aborting.\n\
error ENOMEM Virtual memory exhausted.\n");
+
+ /* I'm doing this manually rather than via error_exit ()
+ because I'm not sure whether we want to call server_cleanup.
+ Needs more investigation.... */
+
+#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 (EXIT_FAILURE);
}
putenv (env);
@@ -4135,46 +4036,115 @@ error ENOMEM Virtual memory exhausted.\n");
{
char *p;
- /* This might be set by the user in ~/.bashrc, ~/.cshrc, etc. */
- char *temp_dir = getenv ("TMPDIR");
- if (temp_dir == NULL || temp_dir[0] == '\0')
- temp_dir = "/tmp";
-
- server_temp_dir = malloc (strlen (temp_dir) + 80);
- if (server_temp_dir == NULL)
+ /* The code which wants to chdir into server_temp_dir is not set
+ up to deal with it being a relative path. So give an error
+ for that case. */
+ if (!isabsolute (Tmpdir))
{
+ pending_error_text = malloc (80 + strlen (Tmpdir));
+ if (pending_error_text == NULL)
+ {
+ pending_error = ENOMEM;
+ }
+ else
+ {
+ sprintf (pending_error_text,
+ "E Value of %s for TMPDIR is not absolute", Tmpdir);
+ }
+ /* FIXME: we would like this error to be persistent, that
+ is, not cleared by print_pending_error. The current client
+ will exit as soon as it gets an error, but the protocol spec
+ does not require a client to do so. */
+ }
+ else
+ {
+ int status;
+
+ server_temp_dir = malloc (strlen (Tmpdir) + 80);
+ if (server_temp_dir == NULL)
+ {
+ /*
+ * Strictly speaking, we're not supposed to output anything
+ * now. But we're about to exit(), give it a try.
+ */
+ printf ("E Fatal server error, aborting.\n\
+error ENOMEM Virtual memory exhausted.\n");
+
+ /* I'm doing this manually rather than via error_exit ()
+ because I'm not sure whether we want to call server_cleanup.
+ Needs more investigation.... */
+
+#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 (EXIT_FAILURE);
+ }
+ strcpy (server_temp_dir, Tmpdir);
+
+ /* Remove a trailing slash from TMPDIR if present. */
+ p = server_temp_dir + strlen (server_temp_dir) - 1;
+ if (*p == '/')
+ *p = '\0';
+
/*
- * Strictly speaking, we're not supposed to output anything
- * now. But we're about to exit(), give it a try.
+ * I wanted to use cvs-serv/PID, but then you have to worry about
+ * the permissions on the cvs-serv directory being right. So
+ * use cvs-servPID.
*/
- printf ("E Fatal server error, aborting.\n\
-error ENOMEM Virtual memory exhausted.\n");
- exit (EXIT_FAILURE);
- }
- strcpy (server_temp_dir, temp_dir);
+ strcat (server_temp_dir, "/cvs-serv");
- /* Remove a trailing slash from TMPDIR if present. */
- p = server_temp_dir + strlen (server_temp_dir) - 1;
- if (*p == '/')
- *p = '\0';
+ p = server_temp_dir + strlen (server_temp_dir);
+ sprintf (p, "%ld", (long) getpid ());
- /*
- * I wanted to use cvs-serv/PID, but then you have to worry about
- * the permissions on the cvs-serv directory being right. So
- * use cvs-servPID.
- */
- strcat (server_temp_dir, "/cvs-serv");
+ orig_server_temp_dir = server_temp_dir;
- p = server_temp_dir + strlen (server_temp_dir);
- sprintf (p, "%ld", (long) getpid ());
+ /* Create the temporary directory, and set the mode to
+ 700, to discourage random people from tampering with
+ it. */
+ status = mkdir_p (server_temp_dir);
+ if (status != 0 && status != EEXIST)
+ {
+ if (alloc_pending (80))
+ strcpy (pending_error_text,
+ "E can't create temporary directory");
+ pending_error = status;
+ }
+#ifndef CHMOD_BROKEN
+ else
+ {
+ if (chmod (server_temp_dir, S_IRWXU) < 0)
+ {
+ int save_errno = errno;
+ if (alloc_pending (80))
+ strcpy (pending_error_text, "\
+E cannot change permissions on temporary directory");
+ pending_error = save_errno;
+ }
+ }
+#endif
+ }
}
+#ifdef SIGHUP
(void) SIG_register (SIGHUP, server_cleanup);
+#endif
+#ifdef SIGINT
(void) SIG_register (SIGINT, server_cleanup);
+#endif
+#ifdef SIGQUIT
(void) SIG_register (SIGQUIT, server_cleanup);
+#endif
+#ifdef SIGPIPE
(void) SIG_register (SIGPIPE, server_cleanup);
+#endif
+#ifdef SIGTERM
(void) SIG_register (SIGTERM, server_cleanup);
-
+#endif
+
/* Now initialize our argument vector (for arguments from the client). */
/* Small for testing. */
@@ -4189,17 +4159,30 @@ error ENOMEM Virtual memory exhausted.\n");
*/
printf ("E Fatal server error, aborting.\n\
error ENOMEM Virtual memory exhausted.\n");
+
+ /* I'm doing this manually rather than via error_exit ()
+ because I'm not sure whether we want to call server_cleanup.
+ Needs more investigation.... */
+
+#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 (EXIT_FAILURE);
}
argument_count = 1;
- argument_vector[0] = "Dummy argument 0";
-
- buf_to_net.data = buf_to_net.last = NULL;
- buf_to_net.fd = STDOUT_FILENO;
- buf_to_net.output = 1;
- buf_to_net.nonblocking = 0;
- buf_to_net.memory_error = outbuf_memory_error;
+ /* This gets printed if the client supports an option which the
+ server doesn't, causing the server to print a usage message.
+ FIXME: probably should be using program_name here.
+ FIXME: just a nit, I suppose, but the usage message the server
+ prints isn't literally true--it suggests "cvs server" followed
+ by options which are for a particular command. Might be nice to
+ say something like "client apparently supports an option not supported
+ by this server" or something like that instead of usage message. */
+ argument_vector[0] = "cvs server";
server_active = 1;
@@ -4207,16 +4190,19 @@ error ENOMEM Virtual memory exhausted.\n");
{
char *cmd, *orig_cmd;
struct request *rq;
+ int status;
- orig_cmd = cmd = read_line (stdin);
- if (cmd == NULL)
- break;
- if (cmd == NO_MEM_ERROR)
+ status = buf_read_line (buf_from_net, &cmd, (int *) NULL);
+ if (status == -2)
{
- printf ("E Fatal server error, aborting.\n\
+ buf_output0 (buf_to_net, "E Fatal server error, aborting.\n\
error ENOMEM Virtual memory exhausted.\n");
break;
}
+ if (status != 0)
+ break;
+
+ orig_cmd = cmd;
for (rq = requests; rq->name != NULL; ++rq)
if (strncmp (cmd, rq->name, strlen (rq->name)) == 0)
{
@@ -4238,7 +4224,12 @@ error ENOMEM Virtual memory exhausted.\n");
if (rq->name == NULL)
{
if (!print_pending_error ())
- printf ("error unrecognized request `%s'\n", cmd);
+ {
+ buf_output0 (buf_to_net, "error unrecognized request `");
+ buf_output0 (buf_to_net, cmd);
+ buf_append_char (buf_to_net, '\'');
+ buf_append_char (buf_to_net, '\n');
+ }
}
free (orig_cmd);
}
@@ -4247,52 +4238,118 @@ error ENOMEM Virtual memory exhausted.\n");
}
-#ifdef AUTH_SERVER_SUPPORT
+#if defined (HAVE_KERBEROS) || defined (AUTH_SERVER_SUPPORT)
+static void switch_to_user PROTO((const char *));
-extern char *crypt PROTO((const char *, const char *));
+static void
+switch_to_user (username)
+ const char *username;
+{
+ struct passwd *pw;
+
+ pw = getpwnam (username);
+ if (pw == NULL)
+ {
+ printf ("E Fatal error, aborting.\n\
+error 0 %s: no such user\n", username);
+ /* I'm doing this manually rather than via error_exit ()
+ because I'm not sure whether we want to call server_cleanup.
+ Needs more investigation.... */
+
+#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 (EXIT_FAILURE);
+ }
+
+#if HAVE_INITGROUPS
+ initgroups (pw->pw_name, pw->pw_gid);
+#endif /* HAVE_INITGROUPS */
-/* This was test code, which we may need again. */
-#if 0
- /* If we were invoked this way, then stdin comes from the
- client and stdout/stderr writes to it. */
- int c;
- while ((c = getc (stdin)) != EOF && c != '*')
+#ifdef SETXID_SUPPORT
+ /* honor the setgid bit iff set*/
+ if (getgid() != getegid())
{
- printf ("%c", toupper (c));
- fflush (stdout);
+ setgid (getegid ());
}
- exit (0);
-#endif /* 1/0 */
+ else
+#else
+ {
+ setgid (pw->pw_gid);
+ }
+#endif
+
+ setuid (pw->pw_uid);
+ /* We don't want our umask to change file modes. The modes should
+ be set by the modes used in the repository, and by the umask of
+ the client. */
+ umask (0);
+
+#if HAVE_PUTENV
+ /* Set LOGNAME and USER in the environment, in case they are
+ already set to something else. */
+ {
+ char *env;
+
+ env = xmalloc (sizeof "LOGNAME=" + strlen (username));
+ (void) sprintf (env, "LOGNAME=%s", username);
+ (void) putenv (env);
+
+ env = xmalloc (sizeof "USER=" + strlen (username));
+ (void) sprintf (env, "USER=%s", username);
+ (void) putenv (env);
+ }
+#endif /* HAVE_PUTENV */
+}
+#endif
+
+#ifdef AUTH_SERVER_SUPPORT
+
+extern char *crypt PROTO((const char *, const char *));
/*
* 0 means no entry found for this user.
* 1 means entry found and password matches.
* 2 means entry found, but password does not match.
+ *
+ * If success, host_user_ptr will be set to point at the system
+ * username (i.e., the "real" identity, which may or may not be the
+ * CVS username) of this user; caller may free this. Global
+ * CVS_Username will point at an allocated copy of cvs username (i.e.,
+ * the username argument below).
*/
-int
+static int
check_repository_password (username, password, repository, host_user_ptr)
char *username, *password, *repository, **host_user_ptr;
{
int retval = 0;
FILE *fp;
char *filename;
- char *linebuf;
+ char *linebuf = NULL;
+ size_t linebuf_len;
int found_it = 0;
int namelen;
+ /* We don't use CVSroot_directory because it hasn't been set yet
+ * -- our `repository' argument came from the authentication
+ * protocol, not the regular CVS protocol.
+ */
+
filename = xmalloc (strlen (repository)
+ 1
- + strlen ("CVSROOT")
+ + strlen (CVSROOTADM)
+ 1
- + strlen ("passwd")
+ + strlen (CVSROOTADM_PASSWD)
+ 1);
- strcpy (filename, repository);
- strcat (filename, "/CVSROOT");
- strcat (filename, "/passwd");
-
- fp = fopen (filename, "r");
+ (void) sprintf (filename, "%s/%s/%s", repository,
+ CVSROOTADM, CVSROOTADM_PASSWD);
+
+ fp = CVS_FOPEN (filename, "r");
if (fp == NULL)
{
if (!existence_error (errno))
@@ -4302,27 +4359,14 @@ check_repository_password (username, password, repository, host_user_ptr)
/* Look for a relevant line -- one with this user's name. */
namelen = strlen (username);
- while (1)
+ while (getline (&linebuf, &linebuf_len, fp) >= 0)
{
- linebuf = read_line(fp);
- if (linebuf == NULL)
- {
- free (linebuf);
- break;
- }
- if (linebuf == NO_MEM_ERROR)
- {
- error (0, errno, "out of memory");
- break;
- }
if ((strncmp (linebuf, username, namelen) == 0)
&& (linebuf[namelen] == ':'))
{
found_it = 1;
break;
}
- free (linebuf);
-
}
if (ferror (fp))
error (0, errno, "cannot read %s", filename);
@@ -4332,16 +4376,25 @@ check_repository_password (username, password, repository, host_user_ptr)
/* If found_it != 0, then linebuf contains the information we need. */
if (found_it)
{
- char *found_password;
+ char *found_password, *host_user_tmp;
strtok (linebuf, ":");
found_password = strtok (NULL, ": \n");
- *host_user_ptr = strtok (NULL, ": \n");
- if (*host_user_ptr == NULL) *host_user_ptr = username;
+ host_user_tmp = strtok (NULL, ": \n");
+ if (host_user_tmp == NULL)
+ host_user_tmp = username;
+
if (strcmp (found_password, crypt (password, found_password)) == 0)
+ {
+ /* Give host_user_ptr permanent storage. */
+ *host_user_ptr = xstrdup (host_user_tmp);
retval = 1;
+ }
else
- retval = 2;
+ {
+ *host_user_ptr = NULL;
+ retval = 2;
+ }
}
else
{
@@ -4350,18 +4403,20 @@ check_repository_password (username, password, repository, host_user_ptr)
}
free (filename);
+ if (linebuf)
+ free (linebuf);
return retval;
}
/* Return a hosting username if password matches, else NULL. */
-char *
+static char *
check_password (username, password, repository)
char *username, *password, *repository;
{
int rc;
- char *host_user;
+ char *host_user = NULL;
/* First we see if this user has a password in the CVS-specific
password file. If so, that's enough to authenticate with. If
@@ -4370,229 +4425,760 @@ check_password (username, password, repository)
rc = check_repository_password (username, password, repository,
&host_user);
+ if (rc == 2)
+ return NULL;
+
+ /* else */
+
if (rc == 1)
- return host_user;
- else if (rc == 2)
- return 0;
+ {
+ /* host_user already set by reference, so just return. */
+ goto handle_return;
+ }
else if (rc == 0)
{
/* No cvs password found, so try /etc/passwd. */
+ const char *found_passwd = NULL;
+#ifdef HAVE_GETSPNAM
+ struct spwd *pw;
+
+ pw = getspnam (username);
+ if (pw != NULL)
+ {
+ found_passwd = pw->sp_pwdp;
+ }
+#else
struct passwd *pw;
- char *found_passwd;
pw = getpwnam (username);
+ if (pw != NULL)
+ {
+ found_passwd = pw->pw_passwd;
+ }
+#endif
+
if (pw == NULL)
- {
+ {
printf ("E Fatal error, aborting.\n\
error 0 %s: no such user\n", username);
+
+ /* I'm doing this manually rather than via error_exit ()
+ because I'm not sure whether we want to call server_cleanup.
+ Needs more investigation.... */
+
+#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 (EXIT_FAILURE);
}
- found_passwd = pw->pw_passwd;
-
+
if (found_passwd && *found_passwd)
- return ((! strcmp (found_passwd, crypt (password, found_passwd)))
- ? username : NULL);
+ {
+ host_user = ((! strcmp (found_passwd,
+ crypt (password, found_passwd)))
+ ? username : NULL);
+ goto handle_return;
+ }
else if (password && *password)
- return username;
+ {
+ host_user = username;
+ goto handle_return;
+ }
else
- return NULL;
+ {
+ host_user = NULL;
+ goto handle_return;
+ }
}
else
{
/* Something strange happened. We don't know what it was, but
we certainly won't grant authorization. */
- return NULL;
+ host_user = NULL;
+ goto handle_return;
+ }
+
+handle_return:
+ if (host_user)
+ {
+ /* Set CVS_Username here, in allocated space.
+ It might or might not be the same as host_user. */
+ CVS_Username = xmalloc (strlen (username) + 1);
+ strcpy (CVS_Username, username);
}
-}
+ return host_user;
+}
/* Read username and password from client (i.e., stdin).
If correct, then switch to run as that user and send an ACK to the
client via stdout, else send NACK and die. */
void
-authenticate_connection ()
+pserver_authenticate_connection ()
{
- char tmp[PATH_MAX];
- char repository[PATH_MAX];
- char username[PATH_MAX];
- char password[PATH_MAX];
- char *host_user;
- char *descrambled_password;
- struct passwd *pw;
- int verify_and_exit = 0;
-
- /* The Authentication Protocol. Client sends:
- *
- * BEGIN AUTH REQUEST\n
- * <REPOSITORY>\n
- * <USERNAME>\n
- * <PASSWORD>\n
- * END AUTH REQUEST\n
- *
- * Server uses above information to authenticate, then sends
- *
- * I LOVE YOU\n
- *
- * if it grants access, else
- *
- * I HATE YOU\n
- *
- * if it denies access (and it exits if denying).
- *
- * When the client is "cvs login", the user does not desire actual
- * repository access, but would like to confirm the password with
- * the server. In this case, the start and stop strings are
- *
- * BEGIN VERIFICATION REQUEST\n
- *
- * and
- *
- * END VERIFICATION REQUEST\n
- *
- * On a verification request, the server's responses are the same
- * (with the obvious semantics), but it exits immediately after
- * sending the response in both cases.
- *
- * Why is the repository sent? Well, note that the actual
- * client/server protocol can't start up until authentication is
- * successful. But in order to perform authentication, the server
- * needs to look up the password in the special CVS passwd file,
- * before trying /etc/passwd. So the client transmits the
- * repository as part of the "authentication protocol". The
- * repository will be redundantly retransmitted later, but that's no
- * big deal.
- */
-
- /* Since we're in the server parent process, error should use the
- protocol to report error messages. */
- error_use_protocol = 1;
-
- /* Make sure the protocol starts off on the right foot... */
- fgets (tmp, PATH_MAX, stdin);
- if (strcmp (tmp, "BEGIN VERIFICATION REQUEST\n") == 0)
- verify_and_exit = 1;
- else if (strcmp (tmp, "BEGIN AUTH REQUEST\n") != 0)
- error (1, 0, "bad auth protocol start: %s", tmp);
-
- /* Get the three important pieces of information in order. */
- fgets (repository, PATH_MAX, stdin);
- fgets (username, PATH_MAX, stdin);
- fgets (password, PATH_MAX, stdin);
-
- /* Make them pure. */
- strip_trailing_newlines (repository);
- strip_trailing_newlines (username);
- strip_trailing_newlines (password);
-
- /* ... and make sure the protocol ends on the right foot. */
- fgets (tmp, PATH_MAX, stdin);
- if (strcmp (tmp,
- verify_and_exit ?
- "END VERIFICATION REQUEST\n" : "END AUTH REQUEST\n")
- != 0)
- {
- error (1, 0, "bad auth protocol end: %s", tmp);
- }
-
- /* We need the real cleartext before we hash it. */
- descrambled_password = descramble (password);
- host_user = check_password (username, descrambled_password, repository);
- if (host_user)
- {
- printf ("I LOVE YOU\n");
- fflush (stdout);
- memset (descrambled_password, 0, strlen (descrambled_password));
- free (descrambled_password);
- }
- else
- {
- printf ("I HATE YOU\n");
- fflush (stdout);
- memset (descrambled_password, 0, strlen (descrambled_password));
- free (descrambled_password);
- exit (EXIT_FAILURE);
- }
-
- /* Don't go any farther if we're just responding to "cvs login". */
- if (verify_and_exit)
- exit (0);
-
- /* Switch to run as this user. */
- pw = getpwnam (host_user);
- if (pw == NULL)
- {
- error (1, 0,
- "fatal error, aborting.\nerror 0 %s: no such user\n",
- username);
- }
-
-#if HAVE_INITGROUPS
- initgroups (pw->pw_name, pw->pw_gid);
-#endif /* HAVE_INITGROUPS */
+ char *tmp = NULL;
+ size_t tmp_allocated = 0;
+ char *repository = NULL;
+ size_t repository_allocated = 0;
+ char *username = NULL;
+ size_t username_allocated = 0;
+ char *password = NULL;
+ size_t password_allocated = 0;
- setgid (pw->pw_gid);
- setuid (pw->pw_uid);
- /* Inhibit access by randoms. Don't want people randomly
- changing our temporary tree before we check things in. */
- umask (077);
-
-#if HAVE_PUTENV
- /* Set LOGNAME and USER in the environment, in case they are
- already set to something else. */
- {
- char *env;
-
- env = xmalloc (sizeof "LOGNAME=" + strlen (username));
- (void) sprintf (env, "LOGNAME=%s", username);
- (void) putenv (env);
-
- env = xmalloc (sizeof "USER=" + strlen (username));
- (void) sprintf (env, "USER=%s", username);
- (void) putenv (env);
- }
-#endif /* HAVE_PUTENV */
+ char *host_user;
+ char *descrambled_password;
+ int verify_and_exit = 0;
+
+ /* The Authentication Protocol. Client sends:
+ *
+ * BEGIN AUTH REQUEST\n
+ * <REPOSITORY>\n
+ * <USERNAME>\n
+ * <PASSWORD>\n
+ * END AUTH REQUEST\n
+ *
+ * Server uses above information to authenticate, then sends
+ *
+ * I LOVE YOU\n
+ *
+ * if it grants access, else
+ *
+ * I HATE YOU\n
+ *
+ * if it denies access (and it exits if denying).
+ *
+ * When the client is "cvs login", the user does not desire actual
+ * repository access, but would like to confirm the password with
+ * the server. In this case, the start and stop strings are
+ *
+ * BEGIN VERIFICATION REQUEST\n
+ *
+ * and
+ *
+ * END VERIFICATION REQUEST\n
+ *
+ * On a verification request, the server's responses are the same
+ * (with the obvious semantics), but it exits immediately after
+ * sending the response in both cases.
+ *
+ * Why is the repository sent? Well, note that the actual
+ * client/server protocol can't start up until authentication is
+ * successful. But in order to perform authentication, the server
+ * needs to look up the password in the special CVS passwd file,
+ * before trying /etc/passwd. So the client transmits the
+ * repository as part of the "authentication protocol". The
+ * repository will be redundantly retransmitted later, but that's no
+ * big deal.
+ */
+
+#ifdef SO_KEEPALIVE
+ /* Set SO_KEEPALIVE on the socket, so that we don't hang forever
+ if the client dies while we are waiting for input. */
+ {
+ int on = 1;
+
+ (void) setsockopt (STDIN_FILENO, SOL_SOCKET, SO_KEEPALIVE,
+ (char *) &on, sizeof on);
+ }
+#endif
+
+ /* Make sure the protocol starts off on the right foot... */
+ if (getline (&tmp, &tmp_allocated, stdin) < 0)
+ /* FIXME: what? We could try writing error/eof, but chances
+ are the network connection is dead bidirectionally. log it
+ somewhere? */
+ ;
+
+ if (strcmp (tmp, "BEGIN VERIFICATION REQUEST\n") == 0)
+ verify_and_exit = 1;
+ else if (strcmp (tmp, "BEGIN AUTH REQUEST\n") != 0)
+ error (1, 0, "bad auth protocol start: %s", tmp);
+
+ /* Get the three important pieces of information in order. */
+ /* See above comment about error handling. */
+ getline (&repository, &repository_allocated, stdin);
+ getline (&username, &username_allocated, stdin);
+ getline (&password, &password_allocated, stdin);
+
+ /* Make them pure. */
+ strip_trailing_newlines (repository);
+ strip_trailing_newlines (username);
+ strip_trailing_newlines (password);
+
+ /* ... and make sure the protocol ends on the right foot. */
+ /* See above comment about error handling. */
+ getline (&tmp, &tmp_allocated, stdin);
+ if (strcmp (tmp,
+ verify_and_exit ?
+ "END VERIFICATION REQUEST\n" : "END AUTH REQUEST\n")
+ != 0)
+ {
+ error (1, 0, "bad auth protocol end: %s", tmp);
+ }
+
+ /* We need the real cleartext before we hash it. */
+ descrambled_password = descramble (password);
+ host_user = check_password (username, descrambled_password, repository);
+ memset (descrambled_password, 0, strlen (descrambled_password));
+ free (descrambled_password);
+ if (host_user)
+ {
+ printf ("I LOVE YOU\n");
+ fflush (stdout);
+ }
+ else
+ {
+ printf ("I HATE YOU\n");
+ fflush (stdout);
+ /* I'm doing this manually rather than via error_exit ()
+ because I'm not sure whether we want to call server_cleanup.
+ Needs more investigation.... */
+
+#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 (EXIT_FAILURE);
+ }
+
+ /* Don't go any farther if we're just responding to "cvs login". */
+ if (verify_and_exit)
+ {
+#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);
+ }
+
+ /* Set Pserver_Repos so that we can check later that the same
+ repository is sent in later client/server protocol. */
+ Pserver_Repos = xmalloc (strlen (repository) + 1);
+ strcpy (Pserver_Repos, repository);
+
+ /* Switch to run as this user. */
+ switch_to_user (host_user);
+ free (tmp);
+ free (repository);
+ free (username);
+ free (password);
}
#endif /* AUTH_SERVER_SUPPORT */
+#ifdef HAVE_KERBEROS
+void
+kserver_authenticate_connection ()
+{
+ int status;
+ char instance[INST_SZ];
+ struct sockaddr_in peer;
+ struct sockaddr_in laddr;
+ int len;
+ KTEXT_ST ticket;
+ AUTH_DAT auth;
+ char version[KRB_SENDAUTH_VLEN];
+ char user[ANAME_SZ];
+
+ strcpy (instance, "*");
+ len = sizeof peer;
+ if (getpeername (STDIN_FILENO, (struct sockaddr *) &peer, &len) < 0
+ || getsockname (STDIN_FILENO, (struct sockaddr *) &laddr,
+ &len) < 0)
+ {
+ printf ("E Fatal error, aborting.\n\
+error %s getpeername or getsockname failed\n", strerror (errno));
+#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 (EXIT_FAILURE);
+ }
+
+#ifdef SO_KEEPALIVE
+ /* Set SO_KEEPALIVE on the socket, so that we don't hang forever
+ if the client dies while we are waiting for input. */
+ {
+ int on = 1;
+
+ (void) setsockopt (STDIN_FILENO, SOL_SOCKET, SO_KEEPALIVE,
+ (char *) &on, sizeof on);
+ }
+#endif
+
+ status = krb_recvauth (KOPT_DO_MUTUAL, STDIN_FILENO, &ticket, "rcmd",
+ instance, &peer, &laddr, &auth, "", sched,
+ version);
+ if (status != KSUCCESS)
+ {
+ printf ("E Fatal error, aborting.\n\
+error 0 kerberos: %s\n", krb_get_err_text(status));
+#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 (EXIT_FAILURE);
+ }
+
+ memcpy (kblock, auth.session, sizeof (C_Block));
+
+ /* Get the local name. */
+ status = krb_kntoln (&auth, user);
+ if (status != KSUCCESS)
+ {
+ printf ("E Fatal error, aborting.\n\
+error 0 kerberos: can't get local name: %s\n", krb_get_err_text(status));
+#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 (EXIT_FAILURE);
+ }
+
+ /* Switch to run as this user. */
+ switch_to_user (user);
+}
+#endif /* HAVE_KERBEROS */
+
#endif /* SERVER_SUPPORT */
+#if defined (CLIENT_SUPPORT) || defined (SERVER_SUPPORT)
+
+/* This global variable is non-zero if the user requests encryption on
+ the command line. */
+int cvsencrypt;
+
+#ifdef ENCRYPTION
+
+#ifdef HAVE_KERBEROS
+
+/* An encryption interface using Kerberos. This is built on top of
+ the buffer structure. We encrypt using a big endian two byte count
+ field followed by a block of encrypted data. */
+
+/* This structure is the closure field of a Kerberos encryption
+ buffer. */
+
+struct krb_encrypt_buffer
+{
+ /* The underlying buffer. */
+ struct buffer *buf;
+ /* The Kerberos key schedule. */
+ Key_schedule sched;
+ /* The Kerberos DES block. */
+ C_Block block;
+ /* For an input buffer, we may have to buffer up data here. */
+ /* This is non-zero if the buffered data is decrypted. Otherwise,
+ the buffered data is encrypted, and starts with the two byte
+ count. */
+ int clear;
+ /* The amount of buffered data. */
+ int holdsize;
+ /* The buffer allocated to hold the data. */
+ char *holdbuf;
+ /* The size of holdbuf. */
+ int holdbufsize;
+ /* If clear is set, we need another data pointer to track where we
+ are in holdbuf. If clear is zero, then this pointer is not
+ used. */
+ char *holddata;
+};
+
+static int krb_encrypt_buffer_input PROTO((void *, char *, int, int, int *));
+static int krb_encrypt_buffer_output PROTO((void *, const char *, int, int *));
+static int krb_encrypt_buffer_flush PROTO((void *));
+static int krb_encrypt_buffer_block PROTO((void *, int));
+static int krb_encrypt_buffer_shutdown PROTO((void *));
+
+/* Create an encryption buffer. */
+
+struct buffer *
+krb_encrypt_buffer_initialize (buf, input, sched, block, memory)
+ struct buffer *buf;
+ int input;
+ Key_schedule sched;
+ C_Block block;
+ void (*memory) PROTO((struct buffer *));
+{
+ struct krb_encrypt_buffer *kb;
+
+ kb = (struct krb_encrypt_buffer *) xmalloc (sizeof *kb);
+ memset (kb, 0, sizeof *kb);
+
+ kb->buf = buf;
+ memcpy (kb->sched, sched, sizeof (Key_schedule));
+ memcpy (kb->block, block, sizeof (C_Block));
+ if (input)
+ {
+ /* We add some space to the buffer to hold the length. */
+ kb->holdbufsize = BUFFER_DATA_SIZE + 16;
+ kb->holdbuf = xmalloc (kb->holdbufsize);
+ }
+
+ return buf_initialize (input ? krb_encrypt_buffer_input : NULL,
+ input ? NULL : krb_encrypt_buffer_output,
+ input ? NULL : krb_encrypt_buffer_flush,
+ krb_encrypt_buffer_block,
+ krb_encrypt_buffer_shutdown,
+ memory,
+ kb);
+}
+
+/* Input data from a Kerberos encryption buffer. */
+
+static int
+krb_encrypt_buffer_input (closure, data, need, size, got)
+ void *closure;
+ char *data;
+ int need;
+ int size;
+ int *got;
+{
+ struct krb_encrypt_buffer *kb = (struct krb_encrypt_buffer *) closure;
+
+ *got = 0;
+
+ if (kb->holdsize > 0 && kb->clear)
+ {
+ int copy;
+
+ copy = kb->holdsize;
+
+ if (copy > size)
+ {
+ memcpy (data, kb->holddata, size);
+ kb->holdsize -= size;
+ kb->holddata += size;
+ *got = size;
+ return 0;
+ }
+
+ memcpy (data, kb->holddata, copy);
+ kb->holdsize = 0;
+ kb->clear = 0;
+
+ data += copy;
+ need -= copy;
+ size -= copy;
+ *got = copy;
+ }
+
+ while (need > 0 || *got == 0)
+ {
+ int get, status, nread, count, dcount;
+ char *bytes;
+ char stackoutbuf[BUFFER_DATA_SIZE + 16];
+ char *outbuf;
+
+ /* If we don't already have the two byte count, get it. */
+ if (kb->holdsize < 2)
+ {
+ get = 2 - kb->holdsize;
+ status = buf_read_data (kb->buf, get, &bytes, &nread);
+ if (status != 0)
+ {
+ /* buf_read_data can return -2, but a buffer input
+ function is only supposed to return -1, 0, or an
+ error code. */
+ if (status == -2)
+ status = ENOMEM;
+ return status;
+ }
+
+ if (nread == 0)
+ {
+ /* The buffer is in nonblocking mode, and we didn't
+ manage to read anything. */
+ return 0;
+ }
+
+ if (get == 1)
+ kb->holdbuf[1] = bytes[0];
+ else
+ {
+ kb->holdbuf[0] = bytes[0];
+ if (nread < 2)
+ {
+ /* We only got one byte, but we needed two. Stash
+ the byte we got, and try again. */
+ kb->holdsize = 1;
+ continue;
+ }
+ kb->holdbuf[1] = bytes[1];
+ }
+ kb->holdsize = 2;
+ }
+
+ /* Read the encrypted block of data. */
+
+ count = (((kb->holdbuf[0] & 0xff) << 8)
+ + (kb->holdbuf[1] & 0xff));
+
+ if (count + 2 > kb->holdbufsize)
+ {
+ char *n;
+
+ /* This should be impossible, since we should have
+ allocated space for the largest possible block in the
+ initialize function. However, we handle it just in
+ case something changes in the future, so that a current
+ server can handle a later client. */
+
+ n = realloc (kb->holdbuf, count + 2);
+ if (n == NULL)
+ {
+ (*kb->buf->memory_error) (kb->buf);
+ return ENOMEM;
+ }
+ kb->holdbuf = n;
+ kb->holdbufsize = count + 2;
+ }
+
+ get = count - (kb->holdsize - 2);
+
+ status = buf_read_data (kb->buf, get, &bytes, &nread);
+ if (status != 0)
+ {
+ /* buf_read_data can return -2, but a buffer input
+ function is only supposed to return -1, 0, or an error
+ code. */
+ if (status == -2)
+ status = ENOMEM;
+ return status;
+ }
+
+ if (nread == 0)
+ {
+ /* We did not get any data. Presumably the buffer is in
+ nonblocking mode. */
+ return 0;
+ }
+
+ /* FIXME: We could complicate the code here to avoid this
+ memcpy in the common case of kb->holdsize == 2 && nread ==
+ get. */
+ memcpy (kb->holdbuf + kb->holdsize, bytes, nread);
+ kb->holdsize += nread;
+
+ if (nread < get)
+ {
+ /* We did not get all the data we need. buf_read_data
+ does not promise to return all the bytes requested, so
+ we must try again. */
+ continue;
+ }
+
+ /* We have a complete encrypted block of COUNT bytes at
+ KB->HOLDBUF + 2. Decrypt it. */
+
+ if (count <= sizeof stackoutbuf)
+ outbuf = stackoutbuf;
+ else
+ {
+ /* I believe this is currently impossible, but we handle
+ it for the benefit of future client changes. */
+ outbuf = malloc (count);
+ if (outbuf == NULL)
+ {
+ (*kb->buf->memory_error) (kb->buf);
+ return ENOMEM;
+ }
+ }
+
+ des_cbc_encrypt ((C_Block *) (kb->holdbuf + 2), (C_Block *) outbuf,
+ count, kb->sched, &kb->block, 0);
+
+ /* The first two bytes in the decrypted buffer are the real
+ (unaligned) length. */
+ dcount = ((outbuf[0] & 0xff) << 8) + (outbuf[1] & 0xff);
+
+ if (((dcount + 2 + 7) & ~7) != count)
+ error (1, 0, "Decryption failure");
+
+ if (dcount > size)
+ {
+ /* We have too much data for the buffer. We need to save
+ some of it for the next call. */
+
+ memcpy (data, outbuf + 2, size);
+ *got += size;
+
+ kb->holdsize = dcount - size;
+ memcpy (kb->holdbuf, outbuf + 2 + size, dcount - size);
+ kb->holddata = kb->holdbuf;
+ kb->clear = 1;
+
+ if (outbuf != stackoutbuf)
+ free (outbuf);
+
+ return 0;
+ }
+
+ memcpy (data, outbuf + 2, dcount);
+
+ if (outbuf != stackoutbuf)
+ free (outbuf);
+
+ kb->holdsize = 0;
+
+ data += dcount;
+ need -= dcount;
+ size -= dcount;
+ *got += dcount;
+ }
+
+ return 0;
+}
+
+/* Output data to a Kerberos encryption buffer. */
+
+static int
+krb_encrypt_buffer_output (closure, data, have, wrote)
+ void *closure;
+ const char *data;
+ int have;
+ int *wrote;
+{
+ struct krb_encrypt_buffer *kb = (struct krb_encrypt_buffer *) closure;
+ char inbuf[BUFFER_DATA_SIZE + 16];
+ char outbuf[BUFFER_DATA_SIZE + 16];
+ int aligned;
+
+ if (have > BUFFER_DATA_SIZE)
+ {
+ /* It would be easy to malloc a buffer, but I don't think this
+ case can ever arise. */
+ abort ();
+ }
+
+ inbuf[0] = (have >> 8) & 0xff;
+ inbuf[1] = have & 0xff;
+ memcpy (inbuf + 2, data, have);
+
+ /* For security against a known plaintext attack, we should
+ initialize any padding bytes to random values. Instead, we
+ just pick up whatever is on the stack, which is at least better
+ than using zero. */
+
+ /* Align (have + 2) (plus 2 for the count) to an 8 byte boundary. */
+ aligned = (have + 2 + 7) & ~7;
+
+ /* We use des_cbc_encrypt rather than krb_mk_priv because the
+ latter sticks a timestamp in the block, and krb_rd_priv expects
+ that timestamp to be within five minutes of the current time.
+ Given the way the CVS server buffers up data, that can easily
+ fail over a long network connection. We trust krb_recvauth to
+ guard against a replay attack. */
+
+ des_cbc_encrypt ((C_Block *) inbuf, (C_Block *) (outbuf + 2), aligned,
+ kb->sched, &kb->block, 1);
+
+ outbuf[0] = (aligned >> 8) & 0xff;
+ outbuf[1] = aligned & 0xff;
+
+ /* FIXME: It would be more efficient to get des_cbc_encrypt to put
+ its output directly into a buffer_data structure, which we
+ could then append to kb->buf. That would save a memcpy. */
+
+ buf_output (kb->buf, outbuf, aligned + 2);
+
+ *wrote = have;
+
+ /* We will only be here because buf_send_output was called on the
+ encryption buffer. That means that we should now call
+ buf_send_output on the underlying buffer. */
+ return buf_send_output (kb->buf);
+}
+
+/* Flush data to a Kerberos encryption buffer. */
+
+static int
+krb_encrypt_buffer_flush (closure)
+ void *closure;
+{
+ struct krb_encrypt_buffer *kb = (struct krb_encrypt_buffer *) closure;
+
+ /* Flush the underlying buffer. Note that if the original call to
+ buf_flush passed 1 for the BLOCK argument, then the buffer will
+ already have been set into blocking mode, so we should always
+ pass 0 here. */
+ return buf_flush (kb->buf, 0);
+}
+
+/* The block routine for a Kerberos encryption buffer. */
+
+static int
+krb_encrypt_buffer_block (closure, block)
+ void *closure;
+ int block;
+{
+ struct krb_encrypt_buffer *kb = (struct krb_encrypt_buffer *) closure;
+
+ if (block)
+ return set_block (kb->buf);
+ else
+ return set_nonblock (kb->buf);
+}
+
+/* Shut down a Kerberos encryption buffer. */
+
+static int
+krb_encrypt_buffer_shutdown (closure)
+ void *closure;
+{
+ struct krb_encrypt_buffer *kb = (struct krb_encrypt_buffer *) closure;
+
+ return buf_shutdown (kb->buf);
+}
+
+#endif /* HAVE_KERBEROS */
+#endif /* ENCRYPTION */
+#endif /* defined (CLIENT_SUPPORT) || defined (SERVER_SUPPORT) */
+
/* Output LEN bytes at STR. If LEN is zero, then output up to (not including)
- the first '\0' byte. Should not be called from the server parent process
- (yet at least, in the future it might be extended so that works). */
+ the first '\0' byte. */
void
cvs_output (str, len)
- char *str;
+ const char *str;
size_t len;
{
if (len == 0)
len = strlen (str);
- if (error_use_protocol)
- /* Eventually we'll probably want to make it so this case works,
- but for now, callers who want to output something with
- error_use_protocol in effect can just printf the "M foo"
- themselves. */
- abort ();
#ifdef SERVER_SUPPORT
- if (server_active)
+ if (error_use_protocol)
{
- buf_output (&saved_output, str, len);
- buf_copy_lines (&protocol, &saved_output, 'M');
- buf_send_counted (&protocol);
+ buf_output (saved_output, str, len);
+ buf_copy_lines (buf_to_net, saved_output, 'M');
+ }
+ else if (server_active)
+ {
+ buf_output (saved_output, str, len);
+ buf_copy_lines (protocol, saved_output, 'M');
+ buf_send_counted (protocol);
}
else
#endif
{
size_t written;
size_t to_write = len;
- char *p = str;
+ const char *p = str;
while (to_write > 0)
{
- written = fwrite (str, 1, to_write, stdout);
+ written = fwrite (p, 1, to_write, stdout);
if (written == 0)
break;
p += written;
@@ -4605,34 +5191,39 @@ cvs_output (str, len)
void
cvs_outerr (str, len)
- char *str;
+ const char *str;
size_t len;
{
if (len == 0)
len = strlen (str);
- if (error_use_protocol)
- /* Eventually we'll probably want to make it so this case works,
- but for now, callers who want to output something with
- error_use_protocol in effect can just printf the "E foo"
- themselves. */
- abort ();
#ifdef SERVER_SUPPORT
- if (server_active)
+ if (error_use_protocol)
{
- buf_output (&saved_outerr, str, len);
- buf_copy_lines (&protocol, &saved_outerr, 'E');
- buf_send_counted (&protocol);
+ buf_output (saved_outerr, str, len);
+ buf_copy_lines (buf_to_net, saved_outerr, 'E');
+ }
+ else if (server_active)
+ {
+ buf_output (saved_outerr, str, len);
+ buf_copy_lines (protocol, saved_outerr, 'E');
+ buf_send_counted (protocol);
}
else
#endif
{
size_t written;
size_t to_write = len;
- char *p = str;
+ const char *p = str;
+
+ /* Make sure that output appears in order if stdout and stderr
+ point to the same place. For the server case this is taken
+ care of by the fact that saved_outerr always holds less
+ than a line. */
+ fflush (stdout);
while (to_write > 0)
{
- written = fwrite (str, 1, to_write, stderr);
+ written = fwrite (p, 1, to_write, stderr);
if (written == 0)
break;
p += written;
@@ -4640,3 +5231,52 @@ cvs_outerr (str, len)
}
}
}
+
+/* Flush stderr. stderr is normally flushed automatically, of course,
+ but this function is used to flush information from the server back
+ to the client. */
+
+void
+cvs_flusherr ()
+{
+#ifdef SERVER_SUPPORT
+ if (error_use_protocol)
+ {
+ /* Flush what we can to the network, but don't block. */
+ buf_flush (buf_to_net, 0);
+ }
+ else if (server_active)
+ {
+ /* Send a special count to tell the parent to flush. */
+ buf_send_special_count (protocol, -1);
+ }
+ else
+#endif
+ fflush (stderr);
+}
+
+/* Make it possible for the user to see what has been written to
+ stdout (it is up to the implementation to decide exactly how far it
+ should go to ensure this). */
+
+void
+cvs_flushout ()
+{
+#ifdef SERVER_SUPPORT
+ if (error_use_protocol)
+ {
+ /* Flush what we can to the network, but don't block. */
+ buf_flush (buf_to_net, 0);
+ }
+ else if (server_active)
+ {
+ /* Just do nothing. This is because the code which
+ cvs_flushout replaces, setting stdout to line buffering in
+ main.c, didn't get called in the server child process. But
+ in the future it is quite plausible that we'll want to make
+ this case work analogously to cvs_flusherr. */
+ }
+ else
+#endif
+ fflush (stdout);
+}
diff --git a/contrib/cvs/src/server.h b/contrib/cvs/src/server.h
index 30ddb8c..cbda7a5 100644
--- a/contrib/cvs/src/server.h
+++ b/contrib/cvs/src/server.h
@@ -21,6 +21,9 @@ extern int server_expanding;
/* Run the server. */
extern int server PROTO((int argc, char **argv));
+/* See server.c for description. */
+extern void server_pathname_check PROTO ((char *));
+
/* We have a new Entries line for a file. TAG or DATE can be NULL. */
extern void server_register
PROTO((char *name, char *version, char *timestamp,
@@ -49,19 +52,30 @@ extern void server_checked_in
extern void server_copy_file
PROTO((char *file, char *update_dir, char *repository, char *newfile));
-/*
- * We just successfully updated FILE (bare filename, no directory).
- * REPOSITORY is the directory for the repository. This is called
- * after server_register or server_scratch, in the latter case the
- * file is to be removed. UPDATED indicates whether the file is now
- * up to date (SERVER_UPDATED, yes, SERVER_MERGED, no, SERVER_PATCHED,
- * yes, but file is a diff from user version to repository version).
- */
-enum server_updated_arg4 {SERVER_UPDATED, SERVER_MERGED, SERVER_PATCHED};
+/* Send the appropriate responses for a file described by FILE,
+ UPDATE_DIR, REPOSITORY, and VERS. FILE_INFO is the result of
+ statting the file, or NULL if it hasn't been statted yet. This is
+ called after server_register or server_scratch. In the latter case
+ the file is to be removed (and vers can be NULL). In the former
+ case, vers must be non-NULL, and UPDATED indicates whether the file
+ is now up to date (SERVER_UPDATED, yes, SERVER_MERGED, no,
+ SERVER_PATCHED, yes, but file is a diff from user version to
+ repository version, SERVER_RCS_DIFF, yes, like SERVER_PATCHED but
+ with an RCS style diff). */
+enum server_updated_arg4
+{
+ SERVER_UPDATED,
+ SERVER_MERGED,
+ SERVER_PATCHED,
+ SERVER_RCS_DIFF
+};
extern void server_updated
- PROTO((char *file, char *update_dir, char *repository,
- enum server_updated_arg4 updated, struct stat *,
- unsigned char *checksum));
+ PROTO((struct file_info *finfo, Vers_TS *vers,
+ enum server_updated_arg4 updated, struct stat *,
+ unsigned char *checksum));
+
+/* Whether we should send RCS format patches. */
+extern int server_use_rcs_diff PROTO((void));
/* Set the Entries.Static flag. */
extern void server_set_entstat PROTO((char *update_dir, char *repository));
@@ -70,14 +84,18 @@ extern void server_clear_entstat PROTO((char *update_dir, char *repository));
/* Set or clear a per-directory sticky tag or date. */
extern void server_set_sticky PROTO((char *update_dir, char *repository,
- char *tag,
- char *date));
+ char *tag, char *date, int nonbranch));
/* Send Template response. */
extern void server_template PROTO ((char *, char *));
extern void server_update_entries
PROTO((char *file, char *update_dir, char *repository,
- enum server_updated_arg4 updated));
+ enum server_updated_arg4 updated));
+
+/* Pointer to a malloc'd string which is the directory which
+ the server should prepend to the pathnames which it sends
+ to the client. */
+extern char *server_dir;
enum progs {PROG_CHECKIN, PROG_UPDATE};
extern void server_prog PROTO((char *, char *, enum progs));
@@ -134,5 +152,3 @@ struct request
/* Table of requests ending with an entry with a NULL name. */
extern struct request requests[];
-
-extern int use_unchanged;
diff --git a/contrib/cvs/src/status.c b/contrib/cvs/src/status.c
index 277da0c..67b71be 100644
--- a/contrib/cvs/src/status.c
+++ b/contrib/cvs/src/status.c
@@ -10,8 +10,10 @@
#include "cvs.h"
-static Dtype status_dirproc PROTO((char *dir, char *repos, char *update_dir));
-static int status_fileproc PROTO((struct file_info *finfo));
+static Dtype status_dirproc PROTO ((void *callerdat, char *dir,
+ char *repos, char *update_dir,
+ List *entries));
+static int status_fileproc PROTO ((void *callerdat, struct file_info *finfo));
static int tag_list_proc PROTO((Node * p, void *closure));
static int local = 0;
@@ -39,7 +41,7 @@ status (argc, argv)
usage (status_usage);
optind = 1;
- while ((c = getopt (argc, argv, "vlR")) != -1)
+ while ((c = getopt (argc, argv, "+vlR")) != -1)
{
switch (c)
{
@@ -75,9 +77,13 @@ status (argc, argv)
send_arg("-l");
send_file_names (argc, argv, SEND_EXPAND_WILD);
- /* XXX This should only need to send file info; the file
- contents themselves will not be examined. */
- send_files (argc, argv, local, 0);
+ /* Note that by setting SEND_NO_CONTENTS, we do prevent the
+ server from updating our timestamp if the timestamp is
+ unchanged and the file is unmodified. And I think it is a
+ user-visible thing in that case (shows "locally modified"
+ instead of "up to date" I would think). But the speed seems
+ to be worth it. */
+ send_files (argc, argv, local, 0, SEND_NO_CONTENTS);
send_to_server ("status\012", 0);
err = get_responses_and_close ();
@@ -87,9 +93,10 @@ status (argc, argv)
#endif
/* start the recursion processor */
- err = start_recursion (status_fileproc, (FILESDONEPROC) NULL, status_dirproc,
- (DIRLEAVEPROC) NULL, argc, argv, local,
- W_LOCAL, 0, 1, (char *) NULL, 1, 0);
+ err = start_recursion (status_fileproc, (FILESDONEPROC) NULL,
+ status_dirproc, (DIRLEAVEPROC) NULL, NULL,
+ argc, argv, local,
+ W_LOCAL, 0, 1, (char *) NULL, 1);
return (err);
}
@@ -99,16 +106,17 @@ status (argc, argv)
*/
/* ARGSUSED */
static int
-status_fileproc (finfo)
+status_fileproc (callerdat, finfo)
+ void *callerdat;
struct file_info *finfo;
{
Ctype status;
char *sstat;
Vers_TS *vers;
- status = Classify_File (finfo->file, (char *) NULL, (char *) NULL, (char *) NULL,
- 1, 0, finfo->repository, finfo->entries, finfo->rcs, &vers,
- finfo->update_dir, 0);
+ status = Classify_File (finfo, (char *) NULL, (char *) NULL, (char *) NULL,
+ 1, 0, &vers, 0);
+ sstat = "Classify Error";
switch (status)
{
case T_UNKNOWN:
@@ -123,6 +131,9 @@ status_fileproc (finfo)
break;
#endif
case T_CONFLICT:
+ /* I _think_ that "unresolved" is correct; that if it has
+ been resolved then the status will change. But I'm not
+ sure about that. */
sstat = "Unresolved Conflict";
break;
case T_ADDED:
@@ -133,7 +144,7 @@ status_fileproc (finfo)
break;
case T_MODIFIED:
if (vers->ts_conflict)
- sstat = "Unresolved Conflict";
+ sstat = "File had conflicts on merge";
else
sstat = "Locally Modified";
break;
@@ -146,34 +157,66 @@ status_fileproc (finfo)
case T_NEEDS_MERGE:
sstat = "Needs Merge";
break;
- default:
- sstat = "Classify Error";
+ case T_TITLE:
+ /* I don't think this case can occur here. Just print
+ "Classify Error". */
break;
}
- (void) printf ("===================================================================\n");
+ cvs_output ("\
+===================================================================\n", 0);
if (vers->ts_user == NULL)
- (void) printf ("File: no file %s\t\tStatus: %s\n\n", finfo->file, sstat);
+ {
+ cvs_output ("File: no file ", 0);
+ cvs_output (finfo->file, 0);
+ cvs_output ("\t\tStatus: ", 0);
+ cvs_output (sstat, 0);
+ cvs_output ("\n\n", 0);
+ }
else
- (void) printf ("File: %-17s\tStatus: %s\n\n", finfo->file, sstat);
+ {
+ char *buf;
+ buf = xmalloc (strlen (finfo->file) + strlen (sstat) + 80);
+ sprintf (buf, "File: %-17s\tStatus: %s\n\n", finfo->file, sstat);
+ cvs_output (buf, 0);
+ free (buf);
+ }
if (vers->vn_user == NULL)
- (void) printf (" Working revision:\tNo entry for %s\n", finfo->file);
+ {
+ cvs_output (" Working revision:\tNo entry for ", 0);
+ cvs_output (finfo->file, 0);
+ cvs_output ("\n", 0);
+ }
else if (vers->vn_user[0] == '0' && vers->vn_user[1] == '\0')
- (void) printf (" Working revision:\tNew file!\n");
+ cvs_output (" Working revision:\tNew file!\n", 0);
#ifdef SERVER_SUPPORT
else if (server_active)
- (void) printf (" Working revision:\t%s\n", vers->vn_user);
+ {
+ cvs_output (" Working revision:\t", 0);
+ cvs_output (vers->vn_user, 0);
+ cvs_output ("\n", 0);
+ }
#endif
else
- (void) printf (" Working revision:\t%s\t%s\n", vers->vn_user,
- vers->ts_rcs);
+ {
+ cvs_output (" Working revision:\t", 0);
+ cvs_output (vers->vn_user, 0);
+ cvs_output ("\t", 0);
+ cvs_output (vers->ts_rcs, 0);
+ cvs_output ("\n", 0);
+ }
if (vers->vn_rcs == NULL)
- (void) printf (" Repository revision:\tNo revision control file\n");
+ cvs_output (" Repository revision:\tNo revision control file\n", 0);
else
- (void) printf (" Repository revision:\t%s\t%s\n", vers->vn_rcs,
- vers->srcfile->path);
+ {
+ cvs_output (" Repository revision:\t", 0);
+ cvs_output (vers->vn_rcs, 0);
+ cvs_output ("\t", 0);
+ cvs_output (vers->srcfile->path, 0);
+ cvs_output ("\n", 0);
+ }
if (vers->entdata)
{
@@ -183,24 +226,33 @@ status_fileproc (finfo)
if (edata->tag)
{
if (vers->vn_rcs == NULL)
- (void) printf (
- " Sticky Tag:\t\t%s - MISSING from RCS file!\n",
- edata->tag);
+ {
+ cvs_output (" Sticky Tag:\t\t", 0);
+ cvs_output (edata->tag, 0);
+ cvs_output (" - MISSING from RCS file!\n", 0);
+ }
else
{
if (isdigit (edata->tag[0]))
- (void) printf (" Sticky Tag:\t\t%s\n", edata->tag);
+ {
+ cvs_output (" Sticky Tag:\t\t", 0);
+ cvs_output (edata->tag, 0);
+ cvs_output ("\n", 0);
+ }
else
{
char *branch = NULL;
-
+
if (RCS_isbranch (finfo->rcs, edata->tag))
branch = RCS_whatbranch(finfo->rcs, edata->tag);
- (void) printf (" Sticky Tag:\t\t%s (%s: %s)\n",
- edata->tag,
- branch ? "branch" : "revision",
- branch ? branch : vers->vn_rcs);
+ cvs_output (" Sticky Tag:\t\t", 0);
+ cvs_output (edata->tag, 0);
+ cvs_output (" (", 0);
+ cvs_output (branch ? "branch" : "revision", 0);
+ cvs_output (": ", 0);
+ cvs_output (branch ? branch : vers->vn_rcs, 0);
+ cvs_output (")\n", 0);
if (branch)
free (branch);
@@ -208,34 +260,42 @@ status_fileproc (finfo)
}
}
else if (!really_quiet)
- (void) printf (" Sticky Tag:\t\t(none)\n");
+ cvs_output (" Sticky Tag:\t\t(none)\n", 0);
if (edata->date)
- (void) printf (" Sticky Date:\t\t%s\n", edata->date);
+ {
+ cvs_output (" Sticky Date:\t\t", 0);
+ cvs_output (edata->date, 0);
+ cvs_output ("\n", 0);
+ }
else if (!really_quiet)
- (void) printf (" Sticky Date:\t\t(none)\n");
+ cvs_output (" Sticky Date:\t\t(none)\n", 0);
if (edata->options && edata->options[0])
- (void) printf (" Sticky Options:\t%s\n", edata->options);
+ {
+ cvs_output (" Sticky Options:\t", 0);
+ cvs_output (edata->options, 0);
+ cvs_output ("\n", 0);
+ }
else if (!really_quiet)
- (void) printf (" Sticky Options:\t(none)\n");
+ cvs_output (" Sticky Options:\t(none)\n", 0);
if (long_format && vers->srcfile)
{
List *symbols = RCS_symbols(vers->srcfile);
- (void) printf ("\n Existing Tags:\n");
+ cvs_output ("\n Existing Tags:\n", 0);
if (symbols)
{
xrcsnode = finfo->rcs;
(void) walklist (symbols, tag_list_proc, NULL);
}
else
- (void) printf ("\tNo Tags Exist\n");
+ cvs_output ("\tNo Tags Exist\n", 0);
}
}
- (void) printf ("\n");
+ cvs_output ("\n", 0);
freevers_ts (&vers);
return (0);
}
@@ -245,10 +305,12 @@ status_fileproc (finfo)
*/
/* ARGSUSED */
static Dtype
-status_dirproc (dir, repos, update_dir)
+status_dirproc (callerdat, dir, repos, update_dir, entries)
+ void *callerdat;
char *dir;
char *repos;
char *update_dir;
+ List *entries;
{
if (!quiet)
error (0, 0, "Examining %s", update_dir);
@@ -264,13 +326,18 @@ tag_list_proc (p, closure)
void *closure;
{
char *branch = NULL;
+ char *buf;
if (RCS_isbranch (xrcsnode, p->key))
branch = RCS_whatbranch(xrcsnode, p->key) ;
- (void) printf ("\t%-25.25s\t(%s: %s)\n", p->key,
- branch ? "branch" : "revision",
- branch ? branch : p->data);
+ buf = xmalloc (80 + strlen (p->key)
+ + (branch ? strlen (branch) : strlen (p->data)));
+ sprintf (buf, "\t%-25s\t(%s: %s)\n", p->key,
+ branch ? "branch" : "revision",
+ branch ? branch : p->data);
+ cvs_output (buf, 0);
+ free (buf);
if (branch)
free (branch);
diff --git a/contrib/cvs/src/subr.c b/contrib/cvs/src/subr.c
index 8ed9177..6a88849 100644
--- a/contrib/cvs/src/subr.c
+++ b/contrib/cvs/src/subr.c
@@ -9,6 +9,7 @@
*/
#include "cvs.h"
+#include "getline.h"
extern char *getlogin ();
@@ -55,6 +56,43 @@ xrealloc (ptr, bytes)
return (cp);
}
+/* Two constants which tune expand_string. Having MIN_INCR as large
+ as 1024 might waste a bit of memory, but it shouldn't be too bad
+ (CVS used to allocate arrays of, say, 3000, PATH_MAX (8192, often),
+ or other such sizes). Probably anything which is going to allocate
+ memory which is likely to get as big as MAX_INCR shouldn't be doing
+ it in one block which must be contiguous, but since getrcskey does
+ so, we might as well limit the wasted memory to MAX_INCR or so
+ bytes. */
+
+#define MIN_INCR 1024
+#define MAX_INCR (2*1024*1024)
+
+/* *STRPTR is a pointer returned from malloc (or NULL), pointing to *N
+ characters of space. Reallocate it so that points to at least
+ NEWSIZE bytes of space. Gives a fatal error if out of memory;
+ if it returns it was successful. */
+void
+expand_string (strptr, n, newsize)
+ char **strptr;
+ size_t *n;
+ size_t newsize;
+{
+ if (*n < newsize)
+ {
+ while (*n < newsize)
+ {
+ if (*n < MIN_INCR)
+ *n += MIN_INCR;
+ else if (*n > MAX_INCR)
+ *n += MAX_INCR;
+ else
+ *n *= 2;
+ }
+ *strptr = xrealloc (*strptr, *n);
+ }
+}
+
/*
* Duplicate a string, calling xmalloc to allocate some dynamic space
*/
@@ -76,15 +114,57 @@ void
strip_trailing_newlines (str)
char *str;
{
- int len;
- len = strlen (str) - 1;
+ int len;
+ len = strlen (str) - 1;
- while (str[len] == '\n')
- str[len--] = '\0';
+ while (str[len] == '\n')
+ str[len--] = '\0';
}
+/* Return the number of levels that path ascends above where it starts.
+ For example:
+ "../../foo" -> 2
+ "foo/../../bar" -> 1
+ */
+/* FIXME: Should be using ISDIRSEP, last_component, or some other
+ mechanism which is more general than just looking at slashes,
+ particularly for the client.c caller. The server.c caller might
+ want something different, so be careful. */
+int
+pathname_levels (path)
+ char *path;
+{
+ char *p;
+ char *q;
+ int level;
+ int max_level;
+
+ max_level = 0;
+ p = path;
+ level = 0;
+ do
+ {
+ q = strchr (p, '/');
+ if (q != NULL)
+ ++q;
+ if (p[0] == '.' && p[1] == '.' && (p[2] == '\0' || p[2] == '/'))
+ {
+ --level;
+ if (-level > max_level)
+ max_level = -level;
+ }
+ else if (p[0] == '.' && (p[1] == '\0' || p[1] == '/'))
+ ;
+ else
+ ++level;
+ p = q;
+ } while (p != NULL);
+ return max_level;
+}
+
+
/*
- * Recover the space allocated by Find_Names() and line2argv()
+ * Recover the space allocated by line2argv()
*/
void
free_names (pargc, argv)
@@ -97,26 +177,42 @@ free_names (pargc, argv)
{ /* only do through *pargc */
free (argv[i]);
}
+ free (argv);
*pargc = 0; /* and set it to zero when done */
}
-/*
- * Convert a line into argc/argv components and return the result in the
- * arguments as passed. Use free_names() to return the memory allocated here
- * back to the free pool.
- */
+/* Convert LINE into arguments separated by space and tab. Set *ARGC
+ to the number of arguments found, and (*ARGV)[0] to the first argument,
+ (*ARGV)[1] to the second, etc. *ARGV is malloc'd and so are each of
+ (*ARGV)[0], (*ARGV)[1], ... Use free_names() to return the memory
+ allocated here back to the free pool. */
void
line2argv (pargc, argv, line)
int *pargc;
- char **argv;
+ char ***argv;
char *line;
{
char *cp;
+ /* Could make a case for size_t or some other unsigned type, but
+ we'll stick with int to avoid signed/unsigned warnings when
+ comparing with *pargc. */
+ int argv_allocated;
+
+ /* Small for testing. */
+ /* argv_allocated must be at least 3 because at some places
+ (e.g. checkout_proc) cvs alters argv[2]. */
+ argv_allocated = 4;
+ *argv = (char **) xmalloc (argv_allocated * sizeof (**argv));
*pargc = 0;
for (cp = strtok (line, " \t"); cp; cp = strtok ((char *) NULL, " \t"))
{
- argv[*pargc] = xstrdup (cp);
+ if (*pargc == argv_allocated)
+ {
+ argv_allocated *= 2;
+ *argv = xrealloc (*argv, argv_allocated * sizeof (**argv));
+ }
+ (*argv)[*pargc] = xstrdup (cp);
(*pargc)++;
}
}
@@ -192,9 +288,10 @@ gca (rev1, rev2)
char *rev2;
{
int dots;
- char gca[PATH_MAX];
+ char *gca;
char *p[2];
int j[2];
+ char *retval;
if (rev1 == NULL || rev2 == NULL)
{
@@ -202,6 +299,11 @@ gca (rev1, rev2)
abort();
}
+ /* The greatest common ancestor will have no more dots, and numbers
+ of digits for each component no greater than the arguments. Therefore
+ this string will be big enough. */
+ gca = xmalloc (strlen (rev1) + strlen (rev2) + 100);
+
/* walk the strings, reading the common parts. */
gca[0] = '\0';
p[0] = rev1;
@@ -289,7 +391,9 @@ gca (rev1, rev2)
*s = '\0';
}
- return (xstrdup (gca));
+ retval = xstrdup (gca);
+ free (gca);
+ return retval;
}
/*
@@ -316,3 +420,39 @@ make_message_rcslegal (message)
return message;
}
+
+/* Does the file FINFO contain conflict markers? The whole concept
+ of looking at the contents of the file to figure out whether there are
+ unresolved conflicts is kind of bogus (people do want to manage files
+ which contain those patterns not as conflict markers), but for now it
+ is what we do. */
+int
+file_has_markers (finfo)
+ struct file_info *finfo;
+{
+ FILE *fp;
+ char *line = NULL;
+ size_t line_allocated = 0;
+ int result;
+
+ result = 0;
+ fp = CVS_FOPEN (finfo->file, "r");
+ if (fp == NULL)
+ error (1, errno, "cannot open %s", finfo->fullname);
+ while (getline (&line, &line_allocated, fp) > 0)
+ {
+ if (strncmp (line, RCS_MERGE_PAT, sizeof RCS_MERGE_PAT - 1) == 0)
+ {
+ result = 1;
+ goto out;
+ }
+ }
+ if (ferror (fp))
+ error (0, errno, "cannot read %s", finfo->fullname);
+out:
+ if (fclose (fp) < 0)
+ error (0, errno, "cannot close %s", finfo->fullname);
+ if (line != NULL)
+ free (line);
+ return result;
+}
diff --git a/contrib/cvs/src/tag.c b/contrib/cvs/src/tag.c
index 2e30009..9c49da5 100644
--- a/contrib/cvs/src/tag.c
+++ b/contrib/cvs/src/tag.c
@@ -14,15 +14,22 @@
#include "cvs.h"
#include "savecwd.h"
-static int check_fileproc PROTO((struct file_info *finfo));
-static int check_filesdoneproc PROTO((int err, char *repos, char *update_dir));
+static int check_fileproc PROTO ((void *callerdat, struct file_info *finfo));
+static int check_filesdoneproc PROTO ((void *callerdat, int err,
+ char *repos, char *update_dir,
+ List *entries));
static int pretag_proc PROTO((char *repository, char *filter));
static void masterlist_delproc PROTO((Node *p));
static void tag_delproc PROTO((Node *p));
static int pretag_list_proc PROTO((Node *p, void *closure));
-static Dtype tag_dirproc PROTO((char *dir, char *repos, char *update_dir));
-static int tag_fileproc PROTO((struct file_info *finfo));
+static Dtype tag_dirproc PROTO ((void *callerdat, char *dir,
+ char *repos, char *update_dir,
+ List *entries));
+static int tag_fileproc PROTO ((void *callerdat, struct file_info *finfo));
+static int tag_filesdoneproc PROTO ((void *callerdat, int err,
+ char *repos, char *update_dir,
+ List *entries));
static char *numtag;
static char *date = NULL;
@@ -32,6 +39,7 @@ static int branch_mode; /* make an automagic "branch" tag */
static int local; /* recursive by default */
static int force_tag_match = 1; /* force tag to match by default */
static int force_tag_move; /* don't force tag to move by default */
+static int check_uptodate; /* no uptodate-check by default */
struct tag_info
{
@@ -51,19 +59,20 @@ static List *tlist;
static const char *const tag_usage[] =
{
- "Usage: %s %s [-lRF] [-b] [-d] [-r tag|-D date] tag [files...]\n",
+ "Usage: %s %s [-lRF] [-b] [-d] [-c] [-r tag|-D date] tag [files...]\n",
"\t-l\tLocal directory only, not recursive.\n",
"\t-R\tProcess directories recursively.\n",
- "\t-d\tDelete the given Tag.\n",
+ "\t-d\tDelete the given tag.\n",
"\t-[rD]\tExisting tag or date.\n",
- "\t-f\tForce a head revision if tag etc not found.\n",
+ "\t-f\tForce a head revision if specified tag not found.\n",
"\t-b\tMake the tag a \"branch\" tag, allowing concurrent development.\n",
- "\t-F\tMove tag if it already exists\n",
+ "\t-F\tMove tag if it already exists.\n",
+ "\t-c\tCheck that working files are unmodified.\n",
NULL
};
int
-tag (argc, argv)
+cvstag (argc, argv)
int argc;
char **argv;
{
@@ -74,7 +83,7 @@ tag (argc, argv)
usage (tag_usage);
optind = 1;
- while ((c = getopt (argc, argv, "FQqlRdr:D:bf")) != -1)
+ while ((c = getopt (argc, argv, "+FQqlRcdr:D:bf")) != -1)
{
switch (c)
{
@@ -98,6 +107,9 @@ tag (argc, argv)
case 'd':
delete_flag = 1;
break;
+ case 'c':
+ check_uptodate = 1;
+ break;
case 'r':
numtag = optarg;
break;
@@ -144,10 +156,14 @@ tag (argc, argv)
ign_setup ();
+ if (!force_tag_match)
+ send_arg ("-f");
if (local)
send_arg("-l");
if (delete_flag)
send_arg("-d");
+ if (check_uptodate)
+ send_arg("-c");
if (branch_mode)
send_arg("-b");
if (force_tag_move)
@@ -161,10 +177,14 @@ tag (argc, argv)
send_arg (symtag);
send_file_names (argc, argv, SEND_EXPAND_WILD);
- /* FIXME: We shouldn't have to send current files, but I'm not sure
- whether it works. So send the files --
- it's slower but it works. */
- send_files (argc, argv, local, 0);
+
+ /* SEND_NO_CONTENTS has a mildly bizarre interaction with
+ check_uptodate; if the timestamp is modified but the file
+ is unmodified, the check will fail, only to have "cvs diff"
+ show no differences (and one must do "update" or something to
+ reset the client's notion of the timestamp). */
+
+ send_files (argc, argv, local, 0, SEND_NO_CONTENTS);
send_to_server ("tag\012", 0);
return get_responses_and_close ();
}
@@ -178,9 +198,9 @@ tag (argc, argv)
mtlist = getlist();
err = start_recursion (check_fileproc, check_filesdoneproc,
- (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL,
+ (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL, NULL,
argc, argv, local, W_LOCAL, 0, 1,
- (char *) NULL, 1, 0);
+ (char *) NULL, 1);
if (err)
{
@@ -188,9 +208,9 @@ tag (argc, argv)
}
/* start the recursion processor */
- err = start_recursion (tag_fileproc, (FILESDONEPROC) NULL, tag_dirproc,
- (DIRLEAVEPROC) NULL, argc, argv, local,
- W_LOCAL, 0, 1, (char *) NULL, 1, 0);
+ err = start_recursion (tag_fileproc, tag_filesdoneproc, tag_dirproc,
+ (DIRLEAVEPROC) NULL, NULL, argc, argv, local,
+ W_LOCAL, 0, 0, (char *) NULL, 1);
dellist(&mtlist);
return (err);
}
@@ -199,13 +219,25 @@ tag (argc, argv)
/* All we do here is add it to our list */
static int
-check_fileproc (finfo)
+check_fileproc (callerdat, finfo)
+ void *callerdat;
struct file_info *finfo;
{
char *xdir;
Node *p;
Vers_TS *vers;
+ if (check_uptodate)
+ {
+ Ctype status = Classify_File (finfo, (char *) NULL, (char *) NULL,
+ (char *) NULL, 1, 0, &vers, 0);
+ if ((status != T_UPTODATE) && (status != T_CHECKOUT))
+ {
+ error (0, 0, "%s is locally modified", finfo->fullname);
+ return (1);
+ }
+ }
+
if (finfo->update_dir[0] == '\0')
xdir = ".";
else
@@ -234,22 +266,22 @@ check_fileproc (finfo)
p->key = xstrdup (finfo->file);
p->type = UPDATE;
p->delproc = tag_delproc;
- vers = Version_TS (finfo->repository, (char *) NULL, (char *) NULL,
- (char *) NULL, finfo->file, 0, 0,
- finfo->entries, finfo->rcs);
+ vers = Version_TS (finfo, NULL, NULL, NULL, 0, 0);
if (vers->srcfile == NULL)
{
if (!really_quiet)
error (0, 0, "nothing known about %s", finfo->file);
return (1);
}
- p->data = RCS_getversion(vers->srcfile, numtag, date, force_tag_match, 0);
+ p->data = RCS_getversion(vers->srcfile, numtag, date, force_tag_match,
+ (int *) NULL);
if (p->data != NULL)
{
int addit = 1;
char *oversion;
- oversion = RCS_getversion (vers->srcfile, symtag, (char *) NULL, 1, 0);
+ oversion = RCS_getversion (vers->srcfile, symtag, (char *) NULL, 1,
+ (int *) NULL);
if (oversion == NULL)
{
if (delete_flag)
@@ -281,10 +313,12 @@ check_fileproc (finfo)
}
static int
-check_filesdoneproc(err, repos, update_dir)
+check_filesdoneproc (callerdat, err, repos, update_dir, entries)
+ void *callerdat;
int err;
char *repos;
char *update_dir;
+ List *entries;
{
int n;
Node *p;
@@ -389,7 +423,8 @@ pretag_list_proc(p, closure)
*/
/* ARGSUSED */
static int
-tag_fileproc (finfo)
+tag_fileproc (callerdat, finfo)
+ void *callerdat;
struct file_info *finfo;
{
char *version, *oversion;
@@ -398,15 +433,26 @@ tag_fileproc (finfo)
Vers_TS *vers;
int retcode = 0;
- vers = Version_TS (finfo->repository, (char *) NULL, (char *) NULL, (char *) NULL,
- finfo->file, 0, 0, finfo->entries, finfo->rcs);
+ /* Lock the directory if it is not already locked. We can't rely
+ on tag_dirproc because it won't handle the case where the user
+ specifies a list of files on the command line. */
+ /* We do not need to acquire a full write lock for the tag operation:
+ the revisions are obtained from the working directory, so we do not
+ require consistency across the entire repository. However, we do
+ need to prevent simultaneous tag operations from interfering with
+ each other. Therefore, we write lock each directory as we enter
+ it, and unlock it as we leave it. */
+ lock_dir_for_write (finfo->repository);
+
+ vers = Version_TS (finfo, NULL, NULL, NULL, 0, 0);
if ((numtag != NULL) || (date != NULL))
{
nversion = RCS_getversion(vers->srcfile,
numtag,
date,
- force_tag_match, 0);
+ force_tag_match,
+ (int *) NULL);
if (nversion == NULL)
{
freevers_ts (&vers);
@@ -425,7 +471,8 @@ tag_fileproc (finfo)
* "rcs" to remove the tag... trust me.
*/
- version = RCS_getversion (vers->srcfile, symtag, (char *) NULL, 1, 0);
+ version = RCS_getversion (vers->srcfile, symtag, (char *) NULL, 1,
+ (int *) NULL);
if (version == NULL || vers->srcfile == NULL)
{
freevers_ts (&vers);
@@ -433,7 +480,7 @@ tag_fileproc (finfo)
}
free (version);
- if ((retcode = RCS_deltag(vers->srcfile->path, symtag, 1)) != 0)
+ if ((retcode = RCS_deltag(vers->srcfile, symtag, 1)) != 0)
{
if (!quiet)
error (0, retcode == -1 ? errno : 0,
@@ -446,7 +493,9 @@ tag_fileproc (finfo)
/* warm fuzzies */
if (!really_quiet)
{
- (void) printf ("D %s\n", finfo->fullname);
+ cvs_output ("D ", 2);
+ cvs_output (finfo->fullname, 0);
+ cvs_output ("\n", 1);
}
freevers_ts (&vers);
@@ -501,7 +550,8 @@ tag_fileproc (finfo)
* module -- which I have found to be a typical tagging operation.
*/
rev = branch_mode ? RCS_magicrev (vers->srcfile, version) : version;
- oversion = RCS_getversion (vers->srcfile, symtag, (char *) NULL, 1, 0);
+ oversion = RCS_getversion (vers->srcfile, symtag, (char *) NULL, 1,
+ (int *) NULL);
if (oversion != NULL)
{
int isbranch = RCS_isbranch (finfo->rcs, symtag);
@@ -520,12 +570,19 @@ tag_fileproc (finfo)
if (!force_tag_move)
{
/* we're NOT going to move the tag */
- (void) printf ("W %s", finfo->fullname);
-
- (void) printf (" : %s already exists on %s %s",
- symtag, isbranch ? "branch" : "version", oversion);
- (void) printf (" : NOT MOVING tag to %s %s\n",
- branch_mode ? "branch" : "version", rev);
+ cvs_output ("W ", 2);
+ cvs_output (finfo->fullname, 0);
+ cvs_output (" : ", 0);
+ cvs_output (symtag, 0);
+ cvs_output (" already exists on ", 0);
+ cvs_output (isbranch ? "branch" : "version", 0);
+ cvs_output (" ", 0);
+ cvs_output (oversion, 0);
+ cvs_output (" : NOT MOVING tag to ", 0);
+ cvs_output (branch_mode ? "branch" : "version", 0);
+ cvs_output (" ", 0);
+ cvs_output (rev, 0);
+ cvs_output ("\n", 1);
free (oversion);
freevers_ts (&vers);
return (0);
@@ -533,7 +590,7 @@ tag_fileproc (finfo)
free (oversion);
}
- if ((retcode = RCS_settag(vers->srcfile->path, symtag, rev)) != 0)
+ if ((retcode = RCS_settag(vers->srcfile, symtag, rev)) != 0)
{
error (1, retcode == -1 ? errno : 0,
"failed to set tag %s to revision %s in %s",
@@ -545,7 +602,9 @@ tag_fileproc (finfo)
/* more warm fuzzies */
if (!really_quiet)
{
- (void) printf ("T %s\n", finfo->fullname);
+ cvs_output ("T ", 2);
+ cvs_output (finfo->fullname, 0);
+ cvs_output ("\n", 1);
}
if (nversion != NULL)
@@ -556,15 +615,32 @@ tag_fileproc (finfo)
return (0);
}
+/* Clear any lock we may hold on the current directory. */
+
+static int
+tag_filesdoneproc (callerdat, err, repos, update_dir, entries)
+ void *callerdat;
+ int err;
+ char *repos;
+ char *update_dir;
+ List *entries;
+{
+ Lock_Cleanup ();
+
+ return (err);
+}
+
/*
* Print a warm fuzzy message
*/
/* ARGSUSED */
static Dtype
-tag_dirproc (dir, repos, update_dir)
+tag_dirproc (callerdat, dir, repos, update_dir, entries)
+ void *callerdat;
char *dir;
char *repos;
char *update_dir;
+ List *entries;
{
if (!quiet)
error (0, 0, "%s %s", delete_flag ? "Untagging" : "Tagging", update_dir);
@@ -584,18 +660,15 @@ struct val_args {
int found;
};
-/* Pass as a static until we get around to fixing start_recursion to pass along
- a void * where we can stash it. */
-static struct val_args *val_args_static;
-
-static int val_fileproc PROTO ((struct file_info *finfo));
+static int val_fileproc PROTO ((void *callerdat, struct file_info *finfo));
static int
-val_fileproc (finfo)
+val_fileproc (callerdat, finfo)
+ void *callerdat;
struct file_info *finfo;
{
RCSNode *rcsdata;
- struct val_args *args = val_args_static;
+ struct val_args *args = (struct val_args *)callerdat;
char *tag;
if ((rcsdata = finfo->rcs) == NULL)
@@ -603,7 +676,7 @@ val_fileproc (finfo)
W_REPOS | W_ATTIC. */
return 0;
- tag = RCS_gettag (rcsdata, args->name, 1, 0);
+ tag = RCS_gettag (rcsdata, args->name, 1, (int *) NULL);
if (tag != NULL)
{
/* FIXME: should find out a way to stop the search at this point. */
@@ -613,13 +686,15 @@ val_fileproc (finfo)
return 0;
}
-static Dtype val_direntproc PROTO ((char *, char *, char *));
+static Dtype val_direntproc PROTO ((void *, char *, char *, char *, List *));
static Dtype
-val_direntproc (dir, repository, update_dir)
+val_direntproc (callerdat, dir, repository, update_dir, entries)
+ void *callerdat;
char *dir;
char *repository;
char *update_dir;
+ List *entries;
{
/* This is not quite right--it doesn't get right the case of "cvs
update -d -r foobar" where foobar is a tag which exists only in
@@ -672,12 +747,18 @@ Numeric tag %s contains characters other than digits and '.'", name);
return;
}
+ /* Special tags are always valid. */
+ if (strcmp (name, TAG_BASE) == 0
+ || strcmp (name, TAG_HEAD) == 0)
+ return;
+
mytag.dptr = name;
mytag.dsize = strlen (name);
- valtags_filename = xmalloc (strlen (CVSroot) + sizeof CVSROOTADM
- + sizeof CVSROOTADM_HISTORY + 20);
- strcpy (valtags_filename, CVSroot);
+ valtags_filename = xmalloc (strlen (CVSroot_directory)
+ + sizeof CVSROOTADM
+ + sizeof CVSROOTADM_VALTAGS + 20);
+ strcpy (valtags_filename, CVSroot_directory);
strcat (valtags_filename, "/");
strcat (valtags_filename, CVSROOTADM);
strcat (valtags_filename, "/");
@@ -709,11 +790,15 @@ Numeric tag %s contains characters other than digits and '.'", name);
/* We didn't find the tag in val-tags, so look through all the RCS files
to see whether it exists there. Yes, this is expensive, but there
is no other way to cope with a tag which might have been created
- by an old version of CVS, from before val-tags was invented. */
+ by an old version of CVS, from before val-tags was invented.
+
+ Since we need this code anyway, we also use it to create
+ entries in val-tags in general (that is, the val-tags entry
+ will get created the first time the tag is used, not when the
+ tag is created). */
the_val_args.name = name;
the_val_args.found = 0;
- val_args_static = &the_val_args;
which = W_REPOS | W_ATTIC;
@@ -724,16 +809,17 @@ Numeric tag %s contains characters other than digits and '.'", name);
else
{
if (save_cwd (&cwd))
- exit (EXIT_FAILURE);
- if (chdir (repository) < 0)
+ error_exit ();
+ if ( CVS_CHDIR (repository) < 0)
error (1, errno, "cannot change to %s directory", repository);
}
}
err = start_recursion (val_fileproc, (FILESDONEPROC) NULL,
val_direntproc, (DIRLEAVEPROC) NULL,
+ (void *)&the_val_args,
argc, argv, local, which, aflag,
- 1, NULL, 1, 0);
+ 1, NULL, 1);
if (repository != NULL && repository[0] != '\0')
{
if (restore_cwd (&cwd, NULL))
@@ -779,3 +865,36 @@ Numeric tag %s contains characters other than digits and '.'", name);
}
free (valtags_filename);
}
+
+/*
+ * Check whether a join tag is valid. This is just like
+ * tag_check_valid, but we must stop before the colon if there is one.
+ */
+
+void
+tag_check_valid_join (join_tag, argc, argv, local, aflag, repository)
+ char *join_tag;
+ int argc;
+ char **argv;
+ int local;
+ int aflag;
+ char *repository;
+{
+ char *c, *s;
+
+ c = xstrdup (join_tag);
+ s = strchr (c, ':');
+ if (s != NULL)
+ {
+ if (isdigit (join_tag[0]))
+ error (1, 0,
+ "Numeric join tag %s may not contain a date specifier",
+ join_tag);
+
+ *s = '\0';
+ }
+
+ tag_check_valid (c, argc, argv, local, aflag, repository);
+
+ free (c);
+}
diff --git a/contrib/cvs/src/update.c b/contrib/cvs/src/update.c
index 2478316..4b7022a 100644
--- a/contrib/cvs/src/update.c
+++ b/contrib/cvs/src/update.c
@@ -34,43 +34,55 @@
*/
#include "cvs.h"
+#include "savecwd.h"
#ifdef SERVER_SUPPORT
#include "md5.h"
#endif
#include "watch.h"
#include "fileattr.h"
#include "edit.h"
+#include "getline.h"
-static int checkout_file PROTO((char *file, char *repository, List *entries,
- RCSNode *rcsnode, Vers_TS *vers_ts, char *update_dir));
+static int checkout_file PROTO ((struct file_info *finfo, Vers_TS *vers_ts,
+ int adding));
#ifdef SERVER_SUPPORT
-static int patch_file PROTO((char *file, char *repository, List *entries,
- RCSNode*rcsnode, Vers_TS *vers_ts, char *update_dir,
- int *docheckout, struct stat *file_info,
- unsigned char *checksum));
+static int patch_file PROTO ((struct file_info *finfo,
+ Vers_TS *vers_ts,
+ int *docheckout, struct stat *file_info,
+ unsigned char *checksum));
+static void patch_file_write PROTO ((void *, const char *, size_t));
#endif
-static int isemptydir PROTO((char *dir));
-static int merge_file PROTO((char *file, char *repository, List *entries,
- Vers_TS *vers, char *update_dir));
-static int scratch_file PROTO((char *file, char *repository, List * entries,
- char *update_dir));
-static Dtype update_dirent_proc PROTO((char *dir, char *repository, char *update_dir));
-static int update_dirleave_proc PROTO((char *dir, int err, char *update_dir));
-static int update_fileproc PROTO ((struct file_info *));
-static int update_filesdone_proc PROTO((int err, char *repository,
- char *update_dir));
+static int merge_file PROTO ((struct file_info *finfo, Vers_TS *vers));
+static int scratch_file PROTO((struct file_info *finfo));
+static Dtype update_dirent_proc PROTO ((void *callerdat, char *dir,
+ char *repository, char *update_dir,
+ List *entries));
+static int update_dirleave_proc PROTO ((void *callerdat, char *dir,
+ int err, char *update_dir,
+ List *entries));
+static int update_fileproc PROTO ((void *callerdat, struct file_info *));
+static int update_filesdone_proc PROTO ((void *callerdat, int err,
+ char *repository, char *update_dir,
+ List *entries));
static int write_letter PROTO((char *file, int letter, char *update_dir));
#ifdef SERVER_SUPPORT
-static void join_file PROTO((char *file, RCSNode *rcsnode, Vers_TS *vers_ts,
- char *update_dir, List *entries, char *repository));
+static void join_file PROTO ((struct file_info *finfo, Vers_TS *vers_ts));
#else
-static void join_file PROTO((char *file, RCSNode *rcsnode, Vers_TS *vers_ts,
- char *update_dir, List *entries));
+static void join_file PROTO ((struct file_info *finfo, Vers_TS *vers_ts));
#endif
static char *options = NULL;
static char *tag = NULL;
static char *date = NULL;
+/* This is a bit of a kludge. We call WriteTag at the beginning
+ before we know whether nonbranch is set or not. And then at the
+ end, once we have the right value for nonbranch, we call WriteTag
+ again. I don't know whether the first call is necessary or not.
+ rewrite_tag is nonzero if we are going to have to make that second
+ call. */
+static int rewrite_tag;
+static int nonbranch;
+
static char *join_rev1, *date_rev1;
static char *join_rev2, *date_rev2;
static int aflag = 0;
@@ -80,6 +92,7 @@ static int update_prune_dirs = 0;
static int pipeout = 0;
#ifdef SERVER_SUPPORT
static int patches = 0;
+static int rcs_diff_patches = 0;
#endif
static List *ignlist = (List *) NULL;
static time_t last_register_time;
@@ -93,10 +106,10 @@ static const char *const update_usage[] =
"\t-f\tForce a head revision match if tag/date not found.\n",
"\t-l\tLocal directory only, no recursion.\n",
"\t-R\tProcess directories recursively.\n",
- "\t-p\tSend updates to standard output.\n",
+ "\t-p\tSend updates to standard output (avoids stickiness).\n",
"\t-k kopt\tUse RCS kopt -k option on checkout.\n",
- "\t-r rev\tUpdate using specified revision/tag.\n",
- "\t-D date\tSet date to update from.\n",
+ "\t-r rev\tUpdate using specified revision/tag (is sticky).\n",
+ "\t-D date\tSet date to update from (is sticky).\n",
"\t-j rev\tMerge in changes made between current revision and rev.\n",
"\t-I ign\tMore files to ignore (! to reset).\n",
"\t-W spec\tWrappers specification line.\n",
@@ -123,7 +136,7 @@ update (argc, argv)
/* parse the args */
optind = 1;
- while ((c = getopt (argc, argv, "ApPflRQqduk:r:D:j:I:W:")) != -1)
+ while ((c = getopt (argc, argv, "+ApPflRQqduk:r:D:j:I:W:")) != -1)
{
switch (c)
{
@@ -188,7 +201,10 @@ update (argc, argv)
case 'u':
#ifdef SERVER_SUPPORT
if (server_active)
+ {
patches = 1;
+ rcs_diff_patches = server_use_rcs_diff ();
+ }
else
#endif
usage (update_usage);
@@ -205,9 +221,12 @@ update (argc, argv)
#ifdef CLIENT_SUPPORT
if (client_active)
{
+ int pass;
+
/* The first pass does the regular update. If we receive at least
one patch which failed, we do a second pass and just fetch
those files whose patches failed. */
+ pass = 1;
do
{
int status;
@@ -228,37 +247,37 @@ update (argc, argv)
send_arg("-P");
client_prune_dirs = update_prune_dirs;
option_with_arg ("-r", tag);
+ if (options && options[0] != '\0')
+ send_arg (options);
if (date)
client_senddate (date);
if (join_rev1)
option_with_arg ("-j", join_rev1);
if (join_rev2)
option_with_arg ("-j", join_rev2);
+ wrap_send ();
/* If the server supports the command "update-patches", that means
that it knows how to handle the -u argument to update, which
means to send patches instead of complete files. */
if (failed_patches == NULL)
{
- struct request *rq;
-
- for (rq = requests; rq->name != NULL; rq++)
- {
- if (strcmp (rq->name, "update-patches") == 0)
- {
- if (rq->status == rq_supported)
- {
- send_arg("-u");
- }
- break;
- }
- }
+#ifndef DONT_USE_PATCH
+ /* Systems which don't have the patch program ported to them
+ will want to define DONT_USE_PATCH; then CVS won't try to
+ invoke patch. */
+ if (supported_request ("update-patches"))
+ send_arg ("-u");
+#endif
}
if (failed_patches == NULL)
{
send_file_names (argc, argv, SEND_EXPAND_WILD);
- send_files (argc, argv, local, aflag);
+ /* If noexec, probably could be setting SEND_NO_CONTENTS.
+ Same caveats as for "cvs status" apply. */
+ send_files (argc, argv, local, aflag,
+ update_build_dirs ? SEND_BUILD_DIRS : 0);
}
else
{
@@ -267,8 +286,8 @@ update (argc, argv)
(void) printf ("%s client: refetching unpatchable files\n",
program_name);
- if (toplevel_wd[0] != '\0'
- && chdir (toplevel_wd) < 0)
+ if (toplevel_wd != NULL
+ && CVS_CHDIR (toplevel_wd) < 0)
{
error (1, errno, "could not chdir to %s", toplevel_wd);
}
@@ -277,7 +296,7 @@ update (argc, argv)
(void) unlink_file (failed_patches[i]);
send_file_names (failed_patches_count, failed_patches, 0);
send_files (failed_patches_count, failed_patches, local,
- aflag);
+ aflag, update_build_dirs ? SEND_BUILD_DIRS : 0);
}
failed_patches = NULL;
@@ -286,9 +305,27 @@ update (argc, argv)
send_to_server ("update\012", 0);
status = get_responses_and_close ();
- if (status != 0)
+
+ /* If there are any conflicts, the server will return a
+ non-zero exit status. If any patches failed, we still
+ want to run the update again. We use a pass count to
+ avoid an endless loop. */
+
+ /* Notes: (1) assuming that status != 0 implies a
+ potential conflict is the best we can cleanly do given
+ the current protocol. I suppose that trying to
+ re-fetch in cases where there was a more serious error
+ is probably more or less harmless, but it isn't really
+ ideal. (2) it would be nice to have a testsuite case for the
+ conflict-and-patch-failed case. */
+
+ if (status != 0
+ && (failed_patches == NULL || pass > 1))
+ {
return status;
+ }
+ ++pass;
} while (failed_patches != NULL);
return 0;
@@ -297,8 +334,10 @@ update (argc, argv)
if (tag != NULL)
tag_check_valid (tag, argc, argv, local, aflag, "");
- /* FIXME: We don't call tag_check_valid on join_rev1 and join_rev2
- yet (make sure to handle ':' correctly if we do, though). */
+ if (join_rev1 != NULL)
+ tag_check_valid_join (join_rev1, argc, argv, local, aflag, "");
+ if (join_rev2 != NULL)
+ tag_check_valid_join (join_rev2, argc, argv, local, aflag, "");
/*
* If we are updating the entire directory (for real) and building dirs
@@ -320,11 +359,10 @@ update (argc, argv)
/* keep the CVS/Tag file current with the specified arguments */
if (aflag || tag || date)
{
- WriteTag ((char *) NULL, tag, date);
-#ifdef SERVER_SUPPORT
- if (server_active)
- server_set_sticky (".", Name_Repository (NULL, NULL), tag, date);
-#endif
+ WriteTag ((char *) NULL, tag, date, 0,
+ ".", Name_Repository (NULL, NULL));
+ rewrite_tag = 1;
+ nonbranch = 0;
}
}
@@ -402,9 +440,9 @@ do_update (argc, argv, xoptions, xtag, xdate, xforce, local, xbuild, xaflag,
/* call the recursion processor */
err = start_recursion (update_fileproc, update_filesdone_proc,
- update_dirent_proc, update_dirleave_proc,
+ update_dirent_proc, update_dirleave_proc, NULL,
argc, argv, local, which, aflag, 1,
- preload_update_dir, 1, 0);
+ preload_update_dir, 1);
/* see if we need to sleep before returning */
if (last_register_time)
@@ -431,16 +469,36 @@ do_update (argc, argv, xoptions, xtag, xdate, xforce, local, xbuild, xaflag,
* appropriate magic for checkout
*/
static int
-update_fileproc (finfo)
+update_fileproc (callerdat, finfo)
+ void *callerdat;
struct file_info *finfo;
{
int retval;
Ctype status;
Vers_TS *vers;
+ int resurrecting;
+
+ resurrecting = 0;
+
+ status = Classify_File (finfo, tag, date, options, force_tag_match,
+ aflag, &vers, pipeout);
+
+ /* Keep track of whether TAG is a branch tag.
+ Note that if it is a branch tag in some files and a nonbranch tag
+ in others, treat it as a nonbranch tag. It is possible that case
+ should elicit a warning or an error. */
+ if (rewrite_tag
+ && tag != NULL
+ && finfo->rcs != NULL)
+ {
+ char *rev = RCS_getversion (finfo->rcs, tag, NULL, 1, NULL);
+ if (rev != NULL
+ && !RCS_nodeisbranch (finfo->rcs, tag))
+ nonbranch = 1;
+ if (rev != NULL)
+ free (rev);
+ }
- status = Classify_File (finfo->file, tag, date, options, force_tag_match,
- aflag, finfo->repository, finfo->entries, finfo->rcs, &vers,
- finfo->update_dir, pipeout);
if (pipeout)
{
/*
@@ -469,8 +527,7 @@ update_fileproc (finfo)
#ifdef SERVER_SUPPORT
case T_PATCH: /* needs patch */
#endif
- retval = checkout_file (finfo->file, finfo->repository, finfo->entries, finfo->rcs,
- vers, finfo->update_dir);
+ retval = checkout_file (finfo, vers, 0);
break;
default: /* can't ever happen :-) */
@@ -504,11 +561,10 @@ update_fileproc (finfo)
if (wrap_merge_is_copy (finfo->file))
/* Should we be warning the user that we are
* overwriting the user's copy of the file? */
- retval = checkout_file (finfo->file, finfo->repository, finfo->entries,
- finfo->rcs, vers, finfo->update_dir);
+ retval =
+ checkout_file (finfo, vers, 0);
else
- retval = merge_file (finfo->file, finfo->repository, finfo->entries,
- vers, finfo->update_dir);
+ retval = merge_file (finfo, vers);
}
break;
case T_MODIFIED: /* locally modified */
@@ -538,22 +594,11 @@ update_fileproc (finfo)
if (retcode)
{
- /*
- * If the timestamps differ, look for Conflict
- * indicators to see if 'C' anyway.
- */
- run_setup ("%s", GREP);
- run_arg (RCS_MERGE_PAT);
- run_arg (finfo->file);
- retcode = run_exec (RUN_TTY, DEVNULL,
- RUN_TTY,RUN_NORMAL);
- if (retcode == -1)
- {
- error (1, errno,
- "fork failed while examining conflict in `%s'",
- finfo->fullname);
- }
+ /* The timestamps differ. But if there are conflict
+ markers print 'C' anyway. */
+ retcode = !file_has_markers (finfo);
}
+
if (!retcode)
{
(void) write_letter (finfo->file, 'C', finfo->update_dir);
@@ -578,15 +623,17 @@ update_fileproc (finfo)
struct stat file_info;
unsigned char checksum[16];
- retval = patch_file (finfo->file, finfo->repository, finfo->entries, finfo->rcs,
- vers, finfo->update_dir, &docheckout,
+ retval = patch_file (finfo,
+ vers, &docheckout,
&file_info, checksum);
if (! docheckout)
{
if (server_active && retval == 0)
- server_updated (finfo->file, finfo->update_dir, finfo->repository,
- SERVER_PATCHED, &file_info,
- checksum);
+ server_updated (finfo, vers,
+ (rcs_diff_patches
+ ? SERVER_RCS_DIFF
+ : SERVER_PATCHED),
+ &file_info, checksum);
break;
}
}
@@ -597,11 +644,10 @@ update_fileproc (finfo)
/* Fall through. */
#endif
case T_CHECKOUT: /* needs checkout */
- retval = checkout_file (finfo->file, finfo->repository, finfo->entries, finfo->rcs,
- vers, finfo->update_dir);
+ retval = checkout_file (finfo, vers, 0);
#ifdef SERVER_SUPPORT
if (server_active && retval == 0)
- server_updated (finfo->file, finfo->update_dir, finfo->repository,
+ server_updated (finfo, vers,
SERVER_UPDATED, (struct stat *) NULL,
(unsigned char *) NULL);
#endif
@@ -613,12 +659,16 @@ update_fileproc (finfo)
retval = write_letter (finfo->file, 'R', finfo->update_dir);
break;
case T_REMOVE_ENTRY: /* needs to be un-registered */
- retval = scratch_file (finfo->file, finfo->repository, finfo->entries, finfo->update_dir);
+ retval = scratch_file (finfo);
#ifdef SERVER_SUPPORT
if (server_active && retval == 0)
- server_updated (finfo->file, finfo->update_dir, finfo->repository,
+ {
+ if (vers->ts_user == NULL)
+ server_scratch_entry_only ();
+ server_updated (finfo, vers,
SERVER_UPDATED, (struct stat *) NULL,
(unsigned char *) NULL);
+ }
#endif
break;
default: /* can't ever happen :-) */
@@ -631,11 +681,7 @@ update_fileproc (finfo)
/* only try to join if things have gone well thus far */
if (retval == 0 && join_rev1)
-#ifdef SERVER_SUPPORT
- join_file (finfo->file, finfo->rcs, vers, finfo->update_dir, finfo->entries, finfo->repository);
-#else
- join_file (finfo->file, finfo->rcs, vers, finfo->update_dir, finfo->entries);
-#endif
+ join_file (finfo, vers);
/* if this directory has an ignore list, add this file to it */
if (ignlist)
@@ -665,15 +711,23 @@ update_ignproc (file, dir)
/* ARGSUSED */
static int
-update_filesdone_proc (err, repository, update_dir)
+update_filesdone_proc (callerdat, err, repository, update_dir, entries)
+ void *callerdat;
int err;
char *repository;
char *update_dir;
+ List *entries;
{
+ if (rewrite_tag)
+ {
+ WriteTag (NULL, tag, date, nonbranch, update_dir, repository);
+ rewrite_tag = 0;
+ }
+
/* if this directory has an ignore list, process it then free it */
if (ignlist)
{
- ignore_files (ignlist, update_dir, update_ignproc);
+ ignore_files (ignlist, entries, update_dir, update_ignproc);
dellist (&ignlist);
}
@@ -694,7 +748,7 @@ update_filesdone_proc (err, repository, update_dir)
{
/* If there is no CVS/Root file, add one */
if (!isfile (CVSADM_ROOT))
- Create_Root( (char *) NULL, CVSroot );
+ Create_Root ((char *) NULL, CVSroot_original);
}
return (err);
@@ -709,18 +763,20 @@ update_filesdone_proc (err, repository, update_dir)
* recursion code should skip this directory.
*/
static Dtype
-update_dirent_proc (dir, repository, update_dir)
+update_dirent_proc (callerdat, dir, repository, update_dir, entries)
+ void *callerdat;
char *dir;
char *repository;
char *update_dir;
+ List *entries;
{
if (ignore_directory (update_dir))
- {
+ {
/* print the warm fuzzy message */
if (!quiet)
error (0, 0, "Ignoring %s", update_dir);
return R_SKIP_ALL;
- }
+ }
if (!isdir (dir))
{
@@ -738,7 +794,13 @@ update_dirent_proc (dir, repository, update_dir)
{
/* otherwise, create the dir and appropriate adm files */
make_directory (dir);
- Create_Admin (dir, update_dir, repository, tag, date);
+ Create_Admin (dir, update_dir, repository, tag, date,
+ /* This is a guess. We will rewrite it later
+ via WriteTag. */
+ 0);
+ rewrite_tag = 1;
+ nonbranch = 0;
+ Subdir_Register (entries, (char *) NULL, dir);
}
}
/* Do we need to check noexec here? */
@@ -773,8 +835,9 @@ update_dirent_proc (dir, repository, update_dir)
{
if (update_build_dirs)
{
- char tmp[PATH_MAX];
+ char *tmp;
+ tmp = xmalloc (strlen (dir) + sizeof (CVSADM_ENTSTAT) + 10);
(void) sprintf (tmp, "%s/%s", dir, CVSADM_ENTSTAT);
if (unlink_file (tmp) < 0 && ! existence_error (errno))
error (1, errno, "cannot remove file %s", tmp);
@@ -782,16 +845,15 @@ update_dirent_proc (dir, repository, update_dir)
if (server_active)
server_clear_entstat (update_dir, repository);
#endif
+ free (tmp);
}
/* keep the CVS/Tag file current with the specified arguments */
if (aflag || tag || date)
{
- WriteTag (dir, tag, date);
-#ifdef SERVER_SUPPORT
- if (server_active)
- server_set_sticky (update_dir, repository, tag, date);
-#endif
+ WriteTag (dir, tag, date, 0, update_dir, repository);
+ rewrite_tag = 1;
+ nonbranch = 0;
}
/* initialize the ignore list for this directory */
@@ -812,75 +874,157 @@ update_dirent_proc (dir, repository, update_dir)
*/
/* ARGSUSED */
static int
-update_dirleave_proc (dir, err, update_dir)
+update_dirleave_proc (callerdat, dir, err, update_dir, entries)
+ void *callerdat;
char *dir;
int err;
char *update_dir;
+ List *entries;
{
FILE *fp;
/* run the update_prog if there is one */
+ /* FIXME: should be checking for errors from CVS_FOPEN and printing
+ them if not existence_error. */
if (err == 0 && !pipeout && !noexec &&
- (fp = fopen (CVSADM_UPROG, "r")) != NULL)
+ (fp = CVS_FOPEN (CVSADM_UPROG, "r")) != NULL)
{
char *cp;
char *repository;
- char line[MAXLINELEN];
+ char *line = NULL;
+ size_t line_allocated = 0;
repository = Name_Repository ((char *) NULL, update_dir);
- if (fgets (line, sizeof (line), fp) != NULL)
+ if (getline (&line, &line_allocated, fp) >= 0)
{
if ((cp = strrchr (line, '\n')) != NULL)
*cp = '\0';
run_setup ("%s %s", line, repository);
- (void) printf ("%s %s: Executing '", program_name, command_name);
+ cvs_output (program_name, 0);
+ cvs_output (" ", 1);
+ cvs_output (command_name, 0);
+ cvs_output (": Executing '", 0);
run_print (stdout);
- (void) printf ("'\n");
+ cvs_output ("'\n", 0);
(void) run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL);
}
- (void) fclose (fp);
+ else if (ferror (fp))
+ error (0, errno, "cannot read %s", CVSADM_UPROG);
+ else
+ error (0, 0, "unexpected end of file on %s", CVSADM_UPROG);
+
+ if (fclose (fp) < 0)
+ error (0, errno, "cannot close %s", CVSADM_UPROG);
+ if (line != NULL)
+ free (line);
free (repository);
}
- /* FIXME: chdir ("..") loses with symlinks. */
- /* Prune empty dirs on the way out - if necessary */
- (void) chdir ("..");
- if (update_prune_dirs && isemptydir (dir))
+ if (strchr (dir, '/') == NULL)
{
- /* I'm not sure the existence_error is actually possible (except
- in cases where we really should print a message), but since
- this code used to ignore all errors, I'll play it safe. */
- if (unlink_file_dir (dir) < 0 && !existence_error (errno))
- error (0, errno, "cannot remove %s directory", dir);
+ /* FIXME: chdir ("..") loses with symlinks. */
+ /* Prune empty dirs on the way out - if necessary */
+ (void) CVS_CHDIR ("..");
+ if (update_prune_dirs && isemptydir (dir, 0))
+ {
+ /* I'm not sure the existence_error is actually possible (except
+ in cases where we really should print a message), but since
+ this code used to ignore all errors, I'll play it safe. */
+ if (unlink_file_dir (dir) < 0 && !existence_error (errno))
+ error (0, errno, "cannot remove %s directory", dir);
+ Subdir_Deregister (entries, (char *) NULL, dir);
+ }
}
return (err);
}
-/*
- * Returns 1 if the argument directory is completely empty, other than the
- * existence of the CVS directory entry. Zero otherwise.
- */
+static int isremoved PROTO ((Node *, void *));
+
+/* Returns 1 if the file indicated by node has been removed. */
static int
-isemptydir (dir)
+isremoved (node, closure)
+ Node *node;
+ void *closure;
+{
+ Entnode *entdata = (Entnode*) node->data;
+
+ /* If the first character of the version is a '-', the file has been
+ removed. */
+ return (entdata->version && entdata->version[0] == '-') ? 1 : 0;
+}
+
+/* Returns 1 if the argument directory is completely empty, other than the
+ existence of the CVS directory entry. Zero otherwise. If MIGHT_NOT_EXIST
+ and the directory doesn't exist, then just return 0. */
+int
+isemptydir (dir, might_not_exist)
char *dir;
+ int might_not_exist;
{
DIR *dirp;
struct dirent *dp;
- if ((dirp = opendir (dir)) == NULL)
+ if ((dirp = CVS_OPENDIR (dir)) == NULL)
{
- error (0, 0, "cannot open directory %s for empty check", dir);
+ if (might_not_exist && existence_error (errno))
+ return 0;
+ error (0, errno, "cannot open directory %s for empty check", dir);
return (0);
}
+ errno = 0;
while ((dp = readdir (dirp)) != NULL)
{
- if (strcmp (dp->d_name, ".") != 0 && strcmp (dp->d_name, "..") != 0 &&
- strcmp (dp->d_name, CVSADM) != 0)
+ if (strcmp (dp->d_name, ".") != 0
+ && strcmp (dp->d_name, "..") != 0)
{
- (void) closedir (dirp);
- return (0);
+ if (strcmp (dp->d_name, CVSADM) != 0)
+ {
+ /* An entry other than the CVS directory. The directory
+ is certainly not empty. */
+ (void) closedir (dirp);
+ return (0);
+ }
+ else
+ {
+ /* The CVS directory entry. We don't have to worry about
+ this unless the Entries file indicates that files have
+ been removed, but not committed, in this directory.
+ (Removing the directory would prevent people from
+ comitting the fact that they removed the files!) */
+ List *l;
+ int files_removed;
+ struct saved_cwd cwd;
+
+ if (save_cwd (&cwd))
+ error_exit ();
+
+ if (CVS_CHDIR (dir) < 0)
+ error (1, errno, "cannot change directory to %s", dir);
+ l = Entries_Open (0);
+ files_removed = walklist (l, isremoved, 0);
+ Entries_Close (l);
+
+ if (restore_cwd (&cwd, NULL))
+ error_exit ();
+ free_cwd (&cwd);
+
+ if (files_removed != 0)
+ {
+ /* There are files that have been removed, but not
+ committed! Do not consider the directory empty. */
+ (void) closedir (dirp);
+ return (0);
+ }
+ }
}
+ errno = 0;
+ }
+ if (errno != 0)
+ {
+ error (0, errno, "cannot read directory %s", dir);
+ (void) closedir (dirp);
+ return (0);
}
(void) closedir (dirp);
return (1);
@@ -890,31 +1034,26 @@ isemptydir (dir)
* scratch the Entries file entry associated with a file
*/
static int
-scratch_file (file, repository, entries, update_dir)
- char *file;
- char *repository;
- List *entries;
- char *update_dir;
+scratch_file (finfo)
+ struct file_info *finfo;
{
- history_write ('W', update_dir, "", file, repository);
- Scratch_Entry (entries, file);
- (void) unlink_file (file);
+ history_write ('W', finfo->update_dir, "", finfo->file, finfo->repository);
+ Scratch_Entry (finfo->entries, finfo->file);
+ if (unlink_file (finfo->file) < 0 && ! existence_error (errno))
+ error (0, errno, "unable to remove %s", finfo->fullname);
return (0);
}
/*
- * check out a file - essentially returns the result of the fork on "co".
+ * Check out a file.
*/
static int
-checkout_file (file, repository, entries, rcsnode, vers_ts, update_dir)
- char *file;
- char *repository;
- List *entries;
- RCSNode *rcsnode;
+checkout_file (finfo, vers_ts, adding)
+ struct file_info *finfo;
Vers_TS *vers_ts;
- char *update_dir;
+ int adding;
{
- char backup[PATH_MAX];
+ char *backup;
int set_time, retval = 0;
int retcode = 0;
int status;
@@ -923,11 +1062,17 @@ checkout_file (file, repository, entries, rcsnode, vers_ts, update_dir)
/* don't screw with backup files if we're going to stdout */
if (!pipeout)
{
- (void) sprintf (backup, "%s/%s%s", CVSADM, CVSPREFIX, file);
- if (isfile (file))
- rename_file (file, backup);
+ backup = xmalloc (strlen (finfo->file)
+ + sizeof (CVSADM)
+ + sizeof (CVSPREFIX)
+ + 10);
+ (void) sprintf (backup, "%s/%s%s", CVSADM, CVSPREFIX, finfo->file);
+ if (isfile (finfo->file))
+ rename_file (finfo->file, backup);
else
- (void) unlink_file (backup);
+ /* If -f/-t wrappers are being used to wrap up a directory,
+ then backup might be a directory instead of just a file. */
+ (void) unlink_file_dir (backup);
}
file_is_dead = RCS_isdead (vers_ts->srcfile, vers_ts->vn_rcs);
@@ -941,75 +1086,36 @@ checkout_file (file, repository, entries, rcsnode, vers_ts, update_dir)
{
if (!quiet)
{
- (void) fprintf (stderr, "\
-===================================================================\n");
- if (update_dir[0])
- (void) fprintf (stderr, "Checking out %s/%s\n",
- update_dir, file);
- else
- (void) fprintf (stderr, "Checking out %s\n", file);
- (void) fprintf (stderr, "RCS: %s\n", vers_ts->srcfile->path);
- (void) fprintf (stderr, "VERS: %s\n", vers_ts->vn_rcs);
- (void) fprintf (stderr, "***************\n");
+ cvs_outerr ("\
+===================================================================\n\
+Checking out ", 0);
+ cvs_outerr (finfo->fullname, 0);
+ cvs_outerr ("\n\
+RCS: ", 0);
+ cvs_outerr (vers_ts->srcfile->path, 0);
+ cvs_outerr ("\n\
+VERS: ", 0);
+ cvs_outerr (vers_ts->vn_rcs, 0);
+ cvs_outerr ("\n***************\n", 0);
}
}
- status = RCS_checkout (vers_ts->srcfile->path,
- pipeout ? NULL : file, vers_ts->vn_tag,
- vers_ts->options, RUN_TTY, 0, 0);
+ status = RCS_checkout (vers_ts->srcfile,
+ pipeout ? NULL : finfo->file,
+ vers_ts->vn_rcs, vers_ts->vn_tag,
+ vers_ts->options, RUN_TTY,
+ (RCSCHECKOUTPROC) NULL, (void *) NULL);
}
if (file_is_dead || status == 0)
{
if (!pipeout)
{
Vers_TS *xvers_ts;
- int resurrecting;
-
- resurrecting = 0;
-
- if (file_is_dead && joining())
- {
- if (RCS_getversion (vers_ts->srcfile, join_rev1,
- date_rev1, 1, 0)
- || (join_rev2 != NULL &&
- RCS_getversion (vers_ts->srcfile, join_rev2,
- date_rev2, 1, 0)))
- {
- /* when joining, we need to get dead files checked
- out. Try harder. */
- /* I think that RCS_FLAGS_FORCE is here only because
- passing -f to co used to enable checking out
- a dead revision in the old version of death
- support which used a hacked RCS instead of using
- the RCS state. */
- retcode = RCS_checkout (vers_ts->srcfile->path, file,
- vers_ts->vn_rcs,
- vers_ts->options, RUN_TTY,
- RCS_FLAGS_FORCE, 0);
- if (retcode != 0)
- {
- error (retcode == -1 ? 1 : 0,
- retcode == -1 ? errno : 0,
- "could not check out %s", file);
- (void) unlink_file (backup);
- return (retcode);
- }
- file_is_dead = 0;
- resurrecting = 1;
- }
- else
- {
- /* If the file is dead and does not contain either of
- the join revisions, then we don't want to check it
- out. */
- return 0;
- }
- }
if (cvswrite == TRUE
&& !file_is_dead
- && !fileattr_get (file, "_watched"))
- xchmod (file, 1);
+ && !fileattr_get (finfo->file, "_watched"))
+ xchmod (finfo->file, 1);
{
/* A newly checked out file is never under the spell
@@ -1020,11 +1126,11 @@ checkout_file (file, repository, entries, rcsnode, vers_ts, update_dir)
struct addremove_args args;
- editor_set (file, getcaller (), NULL);
+ editor_set (finfo->file, getcaller (), NULL);
memset (&args, 0, sizeof args);
args.remove_temp = 1;
- watch_modify_watchers (file, &args);
+ watch_modify_watchers (finfo->file, &args);
}
/* set the time from the RCS file iff it was unknown before */
@@ -1036,10 +1142,10 @@ checkout_file (file, repository, entries, rcsnode, vers_ts, update_dir)
else
set_time = 0;
- wrap_fromcvs_process_file (file);
+ wrap_fromcvs_process_file (finfo->file);
- xvers_ts = Version_TS (repository, options, tag, date, file,
- force_tag_match, set_time, entries, rcsnode);
+ xvers_ts = Version_TS (finfo, options, tag, date,
+ force_tag_match, set_time);
if (strcmp (xvers_ts->options, "-V4") == 0)
xvers_ts->options[0] = '\0';
@@ -1049,31 +1155,31 @@ checkout_file (file, repository, entries, rcsnode, vers_ts, update_dir)
{
if (xvers_ts->vn_user != NULL)
{
- if (update_dir[0] == '\0')
- error (0, 0,
- "warning: %s is not (any longer) pertinent",
- file);
- else
- error (0, 0,
- "warning: %s/%s is not (any longer) pertinent",
- update_dir, file);
+ error (0, 0,
+ "warning: %s is not (any longer) pertinent",
+ finfo->fullname);
}
- Scratch_Entry (entries, file);
- if (unlink_file (file) < 0 && ! existence_error (errno))
+ Scratch_Entry (finfo->entries, finfo->file);
+#ifdef SERVER_SUPPORT
+ if (server_active && xvers_ts->ts_user == NULL)
+ server_scratch_entry_only ();
+#endif
+ /* FIXME: Rather than always unlink'ing, and ignoring the
+ existence_error, we should do the unlink only if
+ vers_ts->ts_user is non-NULL. Then there would be no
+ need to ignore an existence_error (for example, if the
+ user removes the file while we are running). */
+ if (unlink_file (finfo->file) < 0 && ! existence_error (errno))
{
- if (update_dir[0] == '\0')
- error (0, errno, "cannot remove %s", file);
- else
- error (0, errno, "cannot remove %s/%s", update_dir,
- file);
+ error (0, errno, "cannot remove %s", finfo->fullname);
}
}
else
- Register (entries, file,
- resurrecting ? "0" : xvers_ts->vn_rcs,
- xvers_ts->ts_user, xvers_ts->options,
- xvers_ts->tag, xvers_ts->date,
- (char *)0); /* Clear conflict flag on fresh checkout */
+ Register (finfo->entries, finfo->file,
+ adding ? "0" : xvers_ts->vn_rcs,
+ xvers_ts->ts_user, xvers_ts->options,
+ xvers_ts->tag, xvers_ts->date,
+ (char *)0); /* Clear conflict flag on fresh checkout */
/* fix up the vers structure, in case it is used by join */
if (join_rev1)
@@ -1088,14 +1194,14 @@ checkout_file (file, repository, entries, rcsnode, vers_ts, update_dir)
/* If this is really Update and not Checkout, recode history */
if (strcmp (command_name, "update") == 0)
- history_write ('U', update_dir, xvers_ts->vn_rcs, file,
- repository);
+ history_write ('U', finfo->update_dir, xvers_ts->vn_rcs, finfo->file,
+ finfo->repository);
freevers_ts (&xvers_ts);
if (!really_quiet && !file_is_dead)
{
- write_letter (file, 'U', update_dir);
+ write_letter (finfo->file, 'U', finfo->update_dir);
}
}
}
@@ -1104,165 +1210,190 @@ checkout_file (file, repository, entries, rcsnode, vers_ts, update_dir)
int old_errno = errno; /* save errno value over the rename */
if (!pipeout && isfile (backup))
- rename_file (backup, file);
+ rename_file (backup, finfo->file);
error (retcode == -1 ? 1 : 0, retcode == -1 ? old_errno : 0,
- "could not check out %s", file);
+ "could not check out %s", finfo->fullname);
retval = retcode;
}
if (!pipeout)
- (void) unlink_file (backup);
+ {
+ /* If -f/-t wrappers are being used to wrap up a directory,
+ then backup might be a directory instead of just a file. */
+ (void) unlink_file_dir (backup);
+ free (backup);
+ }
return (retval);
}
#ifdef SERVER_SUPPORT
-/* Patch a file. Runs rcsdiff. This is only done when running as the
+
+/* This structure is used to pass information between patch_file and
+ patch_file_write. */
+
+struct patch_file_data
+{
+ /* File name, for error messages. */
+ const char *filename;
+ /* File to which to write. */
+ FILE *fp;
+ /* Whether to compute the MD5 checksum. */
+ int compute_checksum;
+ /* Data structure for computing the MD5 checksum. */
+ struct MD5Context context;
+ /* Set if the file has a final newline. */
+ int final_nl;
+};
+
+/* Patch a file. Runs diff. This is only done when running as the
* server. The hope is that the diff will be smaller than the file
* itself.
*/
static int
-patch_file (file, repository, entries, rcsnode, vers_ts, update_dir,
- docheckout, file_info, checksum)
- char *file;
- char *repository;
- List *entries;
- RCSNode *rcsnode;
+patch_file (finfo, vers_ts, docheckout, file_info, checksum)
+ struct file_info *finfo;
Vers_TS *vers_ts;
- char *update_dir;
int *docheckout;
struct stat *file_info;
unsigned char *checksum;
{
- char backup[PATH_MAX];
- char file1[PATH_MAX];
- char file2[PATH_MAX];
+ char *backup;
+ char *file1;
+ char *file2;
int retval = 0;
int retcode = 0;
int fail;
FILE *e;
+ struct patch_file_data data;
*docheckout = 0;
- if (pipeout || joining ())
+ if (noexec || pipeout || joining ())
{
*docheckout = 1;
return 0;
}
- (void) sprintf (backup, "%s/%s%s", CVSADM, CVSPREFIX, file);
- if (isfile (file))
- rename_file (file, backup);
+ /* If this file has been marked as being binary, then never send a
+ patch. */
+ if (strcmp (vers_ts->options, "-kb") == 0)
+ {
+ *docheckout = 1;
+ return 0;
+ }
+
+ backup = xmalloc (strlen (finfo->file)
+ + sizeof (CVSADM)
+ + sizeof (CVSPREFIX)
+ + 10);
+ (void) sprintf (backup, "%s/%s%s", CVSADM, CVSPREFIX, finfo->file);
+ if (isfile (finfo->file))
+ rename_file (finfo->file, backup);
else
(void) unlink_file (backup);
-
- (void) sprintf (file1, "%s/%s%s-1", CVSADM, CVSPREFIX, file);
- (void) sprintf (file2, "%s/%s%s-2", CVSADM, CVSPREFIX, file);
+
+ file1 = xmalloc (strlen (finfo->file)
+ + sizeof (CVSADM)
+ + sizeof (CVSPREFIX)
+ + 10);
+ (void) sprintf (file1, "%s/%s%s-1", CVSADM, CVSPREFIX, finfo->file);
+ file2 = xmalloc (strlen (finfo->file)
+ + sizeof (CVSADM)
+ + sizeof (CVSPREFIX)
+ + 10);
+ (void) sprintf (file2, "%s/%s%s-2", CVSADM, CVSPREFIX, finfo->file);
fail = 0;
/* We need to check out both revisions first, to see if either one
has a trailing newline. Because of this, we don't use rcsdiff,
but just use diff. */
- if (noexec)
- retcode = 0;
- else
- retcode = RCS_checkout (vers_ts->srcfile->path, NULL,
- vers_ts->vn_user,
- vers_ts->options, file1, 0, 0);
- if (retcode != 0)
- fail = 1;
- else
- {
- e = fopen (file1, "r");
- if (e == NULL)
- fail = 1;
- else
- {
- if (fseek (e, (long) -1, SEEK_END) == 0
- && getc (e) != '\n')
- {
- fail = 1;
- }
- fclose (e);
- }
- }
+
+ e = CVS_FOPEN (file1, "w");
+ if (e == NULL)
+ error (1, errno, "cannot open %s", file1);
+
+ data.filename = file1;
+ data.fp = e;
+ data.final_nl = 0;
+ data.compute_checksum = 0;
+
+ retcode = RCS_checkout (vers_ts->srcfile, (char *) NULL,
+ vers_ts->vn_user, (char *) NULL,
+ vers_ts->options, RUN_TTY,
+ patch_file_write, (void *) &data);
+
+ if (fclose (e) < 0)
+ error (1, errno, "cannot close %s", file1);
+
+ if (retcode != 0 || ! data.final_nl)
+ fail = 1;
if (! fail)
{
- /* Check it out into file, and then move to file2, so that we
- can get the right modes into *FILE_INFO. We can't check it
- out directly into file2 because co doesn't understand how
- to do that. */
- retcode = RCS_checkout (vers_ts->srcfile->path, file,
- vers_ts->vn_rcs,
- vers_ts->options, RUN_TTY, 0, 0);
- if (retcode != 0)
- fail = 1;
- else
- {
- if (!isreadable (file))
- {
- /* File is dead. */
- fail = 1;
- }
- else
- {
- rename_file (file, file2);
- if (cvswrite == TRUE
- && !fileattr_get (file, "_watched"))
- xchmod (file2, 1);
- e = fopen (file2, "r");
- if (e == NULL)
- fail = 1;
- else
- {
- struct MD5Context context;
- int nl;
- unsigned char buf[8192];
- unsigned len;
+ e = CVS_FOPEN (file2, "w");
+ if (e == NULL)
+ error (1, errno, "cannot open %s", file2);
- nl = 0;
+ data.filename = file2;
+ data.fp = e;
+ data.final_nl = 0;
+ data.compute_checksum = 1;
+ MD5Init (&data.context);
- /* Compute the MD5 checksum and make sure there is
- a trailing newline. */
- MD5Init (&context);
- while ((len = fread (buf, 1, sizeof buf, e)) != 0)
- {
- nl = buf[len - 1] == '\n';
- MD5Update (&context, buf, len);
- }
- MD5Final (checksum, &context);
+ retcode = RCS_checkout (vers_ts->srcfile, (char *) NULL,
+ vers_ts->vn_rcs, (char *) NULL,
+ vers_ts->options, RUN_TTY,
+ patch_file_write, (void *) &data);
- if (ferror (e) || ! nl)
- {
- fail = 1;
- }
+ if (fclose (e) < 0)
+ error (1, errno, "cannot close %s", file2);
- fclose (e);
- }
- }
- }
+ if (retcode != 0 || ! data.final_nl)
+ fail = 1;
+ else
+ MD5Final (checksum, &data.context);
}
retcode = 0;
if (! fail)
{
- /* FIXME: This whole thing with diff/patch is rather more
- convoluted than necessary (lots of forks and execs, need to
- worry about versions of diff and patch, etc.). Also, we
- send context lines which aren't needed (in the rare case in
- which the diff doesn't apply, the checksum would catches it).
- Solution perhaps is to librarify the RCS routines which apply
- deltas or something equivalent. */
- /* This is -c, not -u, because we have no way of knowing which
- DIFF is in use. */
- run_setup ("%s -c %s %s", DIFF, file1, file2);
+ const char *diff_options;
+
+ /* FIXME: It might be better to come up with a diff library
+ which can be shared with the diffutils. */
+ /* If the client does not support the Rcs-diff command, we
+ send a context diff, and the client must invoke patch.
+ That approach was problematical for various reasons. The
+ new approach only requires running diff in the server; the
+ client can handle everything without invoking an external
+ program. */
+ if (! rcs_diff_patches)
+ {
+ /* We use -c, not -u, because we have no way of knowing
+ which DIFF is in use. */
+ diff_options = "-c";
+ }
+ else
+ {
+ /* FIXME: We should use -a if diff supports it. We should
+ probably just copy over most or all of the diff
+ handling in the RCS configure script. */
+ /* IMHO, we shouldn't copy over anything which even
+ vaguely resembles the RCS configure script. That kind of
+ thing tends to be ugly, slow, and fragile. It also is a
+ a support headache for CVS to behave differently in subtle
+ ways based on whether it was installed correctly. Instead we
+ should come up with a diff library. -kingdon, Apr 1997. */
+ diff_options = "-n";
+ }
+ run_setup ("%s %s %s %s", DIFF, diff_options, file1, file2);
/* A retcode of 0 means no differences. 1 means some differences. */
- if ((retcode = run_exec (RUN_TTY, file, RUN_TTY, RUN_NORMAL)) != 0
+ if ((retcode = run_exec (RUN_TTY, finfo->file, RUN_TTY, RUN_NORMAL)) != 0
&& retcode != 1)
{
fail = 1;
@@ -1273,10 +1404,24 @@ patch_file (file, repository, entries, rcsnode, vers_ts, update_dir,
char buf[sizeof BINARY];
unsigned int c;
+ /* Stat the original RCS file, and then adjust it the way
+ that RCS_checkout would. FIXME: This is an abstraction
+ violation. */
+ if (CVS_STAT (vers_ts->srcfile->path, file_info) < 0)
+ error (1, errno, "could not stat %s", vers_ts->srcfile->path);
+ if (chmod (finfo->file,
+ file_info->st_mode & ~(S_IWRITE | S_IWGRP | S_IWOTH))
+ < 0)
+ error (0, errno, "cannot change mode of file %s", finfo->file);
+ if (cvswrite == TRUE
+ && !fileattr_get (finfo->file, "_watched"))
+ xchmod (finfo->file, 1);
+
/* Check the diff output to make sure patch will be handle it. */
- e = fopen (file, "r");
+ e = CVS_FOPEN (finfo->file, "r");
if (e == NULL)
- error (1, errno, "could not open diff output file %s", file);
+ error (1, errno, "could not open diff output file %s",
+ finfo->fullname);
c = fread (buf, 1, sizeof BINARY - 1, e);
buf[c] = '\0';
if (strcmp (buf, BINARY) == 0)
@@ -1295,28 +1440,28 @@ patch_file (file, repository, entries, rcsnode, vers_ts, update_dir,
/* This stuff is just copied blindly from checkout_file. I
don't really know what it does. */
- xvers_ts = Version_TS (repository, options, tag, date, file,
- force_tag_match, 0, entries, rcsnode);
+ xvers_ts = Version_TS (finfo, options, tag, date,
+ force_tag_match, 0);
if (strcmp (xvers_ts->options, "-V4") == 0)
xvers_ts->options[0] = '\0';
- Register (entries, file, xvers_ts->vn_rcs,
+ Register (finfo->entries, finfo->file, xvers_ts->vn_rcs,
xvers_ts->ts_user, xvers_ts->options,
xvers_ts->tag, xvers_ts->date, NULL);
- if (stat (file2, file_info) < 0)
- error (1, errno, "could not stat %s", file2);
+ if (CVS_STAT (finfo->file, file_info) < 0)
+ error (1, errno, "could not stat %s", finfo->file);
/* If this is really Update and not Checkout, recode history */
if (strcmp (command_name, "update") == 0)
- history_write ('P', update_dir, xvers_ts->vn_rcs, file,
- repository);
+ history_write ('P', finfo->update_dir, xvers_ts->vn_rcs, finfo->file,
+ finfo->repository);
freevers_ts (&xvers_ts);
if (!really_quiet)
{
- write_letter (file, 'P', update_dir);
+ write_letter (finfo->file, 'P', finfo->update_dir);
}
}
else
@@ -1324,11 +1469,11 @@ patch_file (file, repository, entries, rcsnode, vers_ts, update_dir,
int old_errno = errno; /* save errno value over the rename */
if (isfile (backup))
- rename_file (backup, file);
+ rename_file (backup, finfo->file);
if (retcode != 0 && retcode != 1)
error (retcode == -1 ? 1 : 0, retcode == -1 ? old_errno : 0,
- "could not diff %s", file);
+ "could not diff %s", finfo->fullname);
*docheckout = 1;
retval = retcode;
@@ -1338,9 +1483,34 @@ patch_file (file, repository, entries, rcsnode, vers_ts, update_dir,
(void) unlink_file (file1);
(void) unlink_file (file2);
+ free (backup);
+ free (file1);
+ free (file2);
return (retval);
}
-#endif
+
+/* Write data to a file. Record whether the last byte written was a
+ newline. Optionally compute a checksum. This is called by
+ patch_file via RCS_checkout. */
+
+static void
+patch_file_write (callerdat, buffer, len)
+ void *callerdat;
+ const char *buffer;
+ size_t len;
+{
+ struct patch_file_data *data = (struct patch_file_data *) callerdat;
+
+ if (fwrite (buffer, 1, len, data->fp) != len)
+ error (1, errno, "cannot write %s", data->filename);
+
+ data->final_nl = (buffer[len - 1] == '\n');
+
+ if (data->compute_checksum)
+ MD5Update (&data->context, buffer, len);
+}
+
+#endif /* SERVER_SUPPORT */
/*
* Several of the types we process only print a bit of information consisting
@@ -1373,17 +1543,14 @@ write_letter (file, letter, update_dir)
* Do all the magic associated with a file which needs to be merged
*/
static int
-merge_file (file, repository, entries, vers, update_dir)
- char *file;
- char *repository;
- List *entries;
+merge_file (finfo, vers)
+ struct file_info *finfo;
Vers_TS *vers;
- char *update_dir;
{
- char user[PATH_MAX];
- char backup[PATH_MAX];
+ char *backup;
int status;
int retcode = 0;
+ int retval;
/*
* The users currently modified file is moved to a backup file name
@@ -1392,26 +1559,58 @@ merge_file (file, repository, entries, vers, update_dir)
* is the version of the file that the user was most up-to-date with
* before the merge.
*/
- (void) sprintf (backup, "%s%s.%s", BAKPREFIX, file, vers->vn_user);
- if (update_dir[0])
- (void) sprintf (user, "%s/%s", update_dir, file);
- else
- (void) strcpy (user, file);
+ backup = xmalloc (strlen (finfo->file)
+ + strlen (vers->vn_user)
+ + sizeof (BAKPREFIX)
+ + 10);
+ (void) sprintf (backup, "%s%s.%s", BAKPREFIX, finfo->file, vers->vn_user);
(void) unlink_file (backup);
- copy_file (file, backup);
- xchmod (file, 1);
+ copy_file (finfo->file, backup);
+ xchmod (finfo->file, 1);
+
+ if (strcmp (vers->options, "-kb") == 0)
+ {
+ /* For binary files, a merge is always a conflict. We give the
+ user the two files, and let them resolve it. It is possible
+ that we should require a "touch foo" or similar step before
+ we allow a checkin. */
+ status = checkout_file (finfo, vers, 0);
+#ifdef SERVER_SUPPORT
+ /* Send the new contents of the file before the message. If we
+ wanted to be totally correct, we would have the client write
+ the message only after the file has safely been written. */
+ if (server_active)
+ {
+ server_copy_file (finfo->file, finfo->update_dir,
+ finfo->repository, backup);
+ server_updated (finfo, vers, SERVER_MERGED,
+ (struct stat *) NULL, (unsigned char *) NULL);
+ }
+#endif
+ error (0, 0, "binary file needs merge");
+ error (0, 0, "revision %s from repository is now in %s",
+ vers->vn_rcs, finfo->fullname);
+ error (0, 0, "file from working directory is now in %s", backup);
+ write_letter (finfo->file, 'C', finfo->update_dir);
+
+ history_write ('C', finfo->update_dir, vers->vn_rcs, finfo->file,
+ finfo->repository);
+ retval = 0;
+ goto out;
+ }
status = RCS_merge(vers->srcfile->path,
vers->options, vers->vn_user, vers->vn_rcs);
if (status != 0 && status != 1)
{
error (0, status == -1 ? errno : 0,
- "could not merge revision %s of %s", vers->vn_user, user);
+ "could not merge revision %s of %s", vers->vn_user, finfo->fullname);
error (status == -1 ? 1 : 0, 0, "restoring %s from backup file %s",
- user, backup);
- rename_file (backup, file);
- return (1);
+ finfo->fullname, backup);
+ rename_file (backup, finfo->file);
+ retval = 1;
+ goto out;
}
if (strcmp (vers->options, "-V4") == 0)
@@ -1421,8 +1620,8 @@ merge_file (file, repository, entries, vers, update_dir)
char *cp = 0;
if (status)
- cp = time_stamp (file);
- Register (entries, file, vers->vn_rcs, vers->ts_rcs, vers->options,
+ cp = time_stamp (finfo->file);
+ Register (finfo->entries, finfo->file, vers->vn_rcs, vers->ts_rcs, vers->options,
vers->tag, vers->date, cp);
if (cp)
free (cp);
@@ -1442,40 +1641,48 @@ merge_file (file, repository, entries, vers, update_dir)
the message only after the file has safely been written. */
if (server_active)
{
- server_copy_file (file, update_dir, repository, backup);
- server_updated (file, update_dir, repository, SERVER_MERGED,
+ server_copy_file (finfo->file, finfo->update_dir, finfo->repository,
+ backup);
+ server_updated (finfo, vers, SERVER_MERGED,
(struct stat *) NULL, (unsigned char *) NULL);
}
#endif
- if (!noexec && !xcmp (backup, file))
+ if (!noexec && !xcmp (backup, finfo->file))
{
printf ("%s already contains the differences between %s and %s\n",
- user, vers->vn_user, vers->vn_rcs);
- history_write ('G', update_dir, vers->vn_rcs, file, repository);
- return (0);
+ finfo->fullname, vers->vn_user, vers->vn_rcs);
+ history_write ('G', finfo->update_dir, vers->vn_rcs, finfo->file,
+ finfo->repository);
+ retval = 0;
+ goto out;
}
if (status == 1)
{
if (!noexec)
- error (0, 0, "conflicts found in %s", user);
+ error (0, 0, "conflicts found in %s", finfo->fullname);
- write_letter (file, 'C', update_dir);
+ write_letter (finfo->file, 'C', finfo->update_dir);
- history_write ('C', update_dir, vers->vn_rcs, file, repository);
+ history_write ('C', finfo->update_dir, vers->vn_rcs, finfo->file, finfo->repository);
}
else if (retcode == -1)
{
- error (1, errno, "fork failed while examining update of %s", user);
+ error (1, errno, "fork failed while examining update of %s",
+ finfo->fullname);
}
else
{
- write_letter (file, 'M', update_dir);
- history_write ('G', update_dir, vers->vn_rcs, file, repository);
+ write_letter (finfo->file, 'M', finfo->update_dir);
+ history_write ('G', finfo->update_dir, vers->vn_rcs, finfo->file,
+ finfo->repository);
}
- return (0);
+ retval = 0;
+ out:
+ free (backup);
+ return retval;
}
/*
@@ -1483,20 +1690,11 @@ merge_file (file, repository, entries, vers, update_dir)
* (-j option)
*/
static void
-#ifdef SERVER_SUPPORT
-join_file (file, rcsnode, vers, update_dir, entries, repository)
- char *repository;
-#else
-join_file (file, rcsnode, vers, update_dir, entries)
-#endif
- char *file;
- RCSNode *rcsnode;
+join_file (finfo, vers)
+ struct file_info *finfo;
Vers_TS *vers;
- char *update_dir;
- List *entries;
{
- char user[PATH_MAX];
- char backup[PATH_MAX];
+ char *backup;
char *options;
int status;
@@ -1512,24 +1710,23 @@ join_file (file, rcsnode, vers, update_dir, entries)
jdate1 = date_rev1;
jdate2 = date_rev2;
- if (wrap_merge_is_copy (file))
+ if (wrap_merge_is_copy (finfo->file))
{
- /* FIXME: Should be including update_dir in message. */
error (0, 0,
- "Cannot merge %s because it is a merge-by-copy file.", file);
+ "Cannot merge %s because it is a merge-by-copy file.",
+ finfo->fullname);
return;
}
- /* determine if we need to do anything at all */
+ /* Determine if we need to do anything at all. */
if (vers->srcfile == NULL ||
vers->srcfile->path == NULL)
{
return;
}
- /* in all cases, use two revs. */
-
- /* if only one rev is specified, it becomes the second rev */
+ /* If only one join revision is specified, it becomes the second
+ revision. */
if (jrev2 == NULL)
{
jrev2 = jrev1;
@@ -1538,219 +1735,282 @@ join_file (file, rcsnode, vers, update_dir, entries)
jdate1 = NULL;
}
- /* The file in the working directory doesn't exist in CVS/Entries.
- FIXME: Shouldn't this case result in additional processing (if
- the file was added going from rev1 to rev2, then do the equivalent
- of a "cvs add")? (yes; easier said than done.. :-) */
- if (vers->vn_user == NULL)
+ /* Convert the second revision, walking branches and dates. */
+ rev2 = RCS_getversion (vers->srcfile, jrev2, jdate2, 1, (int *) NULL);
+
+ /* If this is a merge of two revisions, get the first revision.
+ If only one join tag was specified, then the first revision is
+ the greatest common ancestor of the second revision and the
+ working file. */
+ if (jrev1 != NULL)
+ rev1 = RCS_getversion (vers->srcfile, jrev1, jdate1, 1, (int *) NULL);
+ else
{
- /* No merge possible YET. */
- if (jdate2 != NULL)
- error (0, 0,
- "file %s is present in revision %s as of %s",
- file, jrev2, jdate2);
+ /* Note that we use vn_rcs here, since vn_user may contain a
+ special string such as "-nn". */
+ if (vers->vn_rcs == NULL)
+ rev1 = NULL;
+ else if (rev2 == NULL)
+ {
+ /* This means that the file never existed on the branch.
+ It does not mean that the file was removed on the
+ branch: that case is represented by a dead rev2. If
+ the file never existed on the branch, then we have
+ nothing to merge, so we just return. */
+ return;
+ }
else
- error (0, 0,
- "file %s is present in revision %s",
- file, jrev2);
- return;
+ rev1 = gca (vers->vn_rcs, rev2);
}
- /* Fix for bug CVS/193:
- * Used to dump core if the file had been removed on the current branch.
- */
- if (strcmp(vers->vn_user, "0") == 0)
+ /* Handle a nonexistent or dead merge target. */
+ if (rev2 == NULL || RCS_isdead (vers->srcfile, rev2))
{
- error(0, 0,
- "file %s has been deleted",
- file);
- return;
- }
+ char *mrev;
+
+ if (rev2 != NULL)
+ free (rev2);
- /* convert the second rev spec, walking branches and dates. */
+ /* If the first revision doesn't exist either, then there is
+ no change between the two revisions, so we don't do
+ anything. */
+ if (rev1 == NULL || RCS_isdead (vers->srcfile, rev1))
+ {
+ if (rev1 != NULL)
+ free (rev1);
+ return;
+ }
- rev2 = RCS_getversion (vers->srcfile, jrev2, jdate2, 1, 0);
- if (rev2 == NULL)
- {
- if (!quiet)
+ /* If we are merging two revisions, then the file was removed
+ between the first revision and the second one. In this
+ case we want to mark the file for removal.
+
+ If we are merging one revision, then the file has been
+ removed between the greatest common ancestor and the merge
+ revision. From the perspective of the branch on to which
+ we ar emerging, which may be the trunk, either 1) the file
+ does not currently exist on the target, or 2) the file has
+ not been modified on the target branch since the greatest
+ common ancestor, or 3) the file has been modified on the
+ target branch since the greatest common ancestor. In case
+ 1 there is nothing to do. In case 2 we mark the file for
+ removal. In case 3 we have a conflict.
+
+ Note that the handling is slightly different depending upon
+ whether one or two join targets were specified. If two
+ join targets were specified, we don't check whether the
+ file was modified since a given point. My reasoning is
+ that if you ask for an explicit merge between two tags,
+ then you want to merge in whatever was changed between
+ those two tags. If a file was removed between the two
+ tags, then you want it to be removed. However, if you ask
+ for a merge of a branch, then you want to merge in all
+ changes which were made on the branch. If a file was
+ removed on the branch, that is a change to the file. If
+ the file was also changed on the main line, then that is
+ also a change. These two changes--the file removal and the
+ modification--must be merged. This is a conflict. */
+
+ /* If the user file is dead, or does not exist, or has been
+ marked for removal, then there is nothing to do. */
+ if (vers->vn_user == NULL
+ || vers->vn_user[0] == '-'
+ || RCS_isdead (vers->srcfile, vers->vn_user))
+ {
+ if (rev1 != NULL)
+ free (rev1);
+ return;
+ }
+
+ /* If the user file has been marked for addition, or has been
+ locally modified, then we have a conflict which we can not
+ resolve. No_Difference will already have been called in
+ this case, so comparing the timestamps is sufficient to
+ determine whether the file is locally modified. */
+ if (strcmp (vers->vn_user, "0") == 0
+ || (vers->ts_user != NULL
+ && strcmp (vers->ts_user, vers->ts_rcs) != 0))
{
if (jdate2 != NULL)
error (0, 0,
- "cannot find revision %s as of %s in file %s",
- jrev2, jdate2, file);
+ "file %s is locally modified, but has been removed in revision %s as of %s",
+ finfo->fullname, jrev2, jdate2);
else
error (0, 0,
- "cannot find revision %s in file %s",
- jrev2, file);
+ "file %s is locally modified, but has been removed in revision %s",
+ finfo->fullname, jrev2);
+
+ /* FIXME: Should we arrange to return a non-zero exit
+ status? */
+
+ if (rev1 != NULL)
+ free (rev1);
+
+ return;
}
+
+ /* If only one join tag was specified, and the user file has
+ been changed since the greatest common ancestor (rev1),
+ then there is a conflict we can not resolve. See above for
+ the rationale. */
+ if (join_rev2 == NULL
+ && strcmp (rev1, vers->vn_user) != 0)
+ {
+ if (jdate2 != NULL)
+ error (0, 0,
+ "file %s has been modified, but has been removed in revision %s as of %s",
+ finfo->fullname, jrev2, jdate2);
+ else
+ error (0, 0,
+ "file %s has been modified, but has been removed in revision %s",
+ finfo->fullname, jrev2);
+
+ /* FIXME: Should we arrange to return a non-zero exit
+ status? */
+
+ if (rev1 != NULL)
+ free (rev1);
+
+ return;
+ }
+
+ if (rev1 != NULL)
+ free (rev1);
+
+ /* The user file exists and has not been modified. Mark it
+ for removal. FIXME: If we are doing a checkout, this has
+ the effect of first checking out the file, and then
+ removing it. It would be better to just register the
+ removal. */
+#ifdef SERVER_SUPPORT
+ if (server_active)
+ {
+ server_scratch (finfo->file);
+ server_updated (finfo, vers, SERVER_UPDATED, (struct stat *) NULL,
+ (unsigned char *) NULL);
+ }
+#endif
+ mrev = xmalloc (strlen (vers->vn_user) + 2);
+ sprintf (mrev, "-%s", vers->vn_user);
+ Register (finfo->entries, finfo->file, mrev, vers->ts_rcs,
+ vers->options, vers->tag, vers->date, vers->ts_conflict);
+ free (mrev);
+ /* We need to check existence_error here because if we are
+ running as the server, and the file is up to date in the
+ working directory, the client will not have sent us a copy. */
+ if (unlink_file (finfo->file) < 0 && ! existence_error (errno))
+ error (0, errno, "cannot remove file %s", finfo->fullname);
+#ifdef SERVER_SUPPORT
+ if (server_active)
+ server_checked_in (finfo->file, finfo->update_dir,
+ finfo->repository);
+#endif
+ if (! really_quiet)
+ error (0, 0, "scheduling %s for removal", finfo->fullname);
+
return;
}
- /* skip joining identical revs */
- if (strcmp (rev2, vers->vn_user) == 0)
+ /* If the target of the merge is the same as the working file
+ revision, then there is nothing to do. */
+ if (vers->vn_user != NULL && strcmp (rev2, vers->vn_user) == 0)
{
- /* No merge necessary. */
+ if (rev1 != NULL)
+ free (rev1);
free (rev2);
return;
}
- if (jrev1 == NULL)
+ /* If rev1 is dead or does not exist, then the file was added
+ between rev1 and rev2. */
+ if (rev1 == NULL || RCS_isdead (vers->srcfile, rev1))
{
- char *tst;
- /* if the first rev is missing, then it is implied to be the
- greatest common ancestor of both the join rev, and the
- checked out rev. */
-
- /* FIXME: What is this check for '!' about? If it is legal to
- have '!' in the first character of vn_user, it isn't
- documented at struct vers_ts in cvs.h. */
- tst = vers->vn_user;
- if (*tst == '!')
- {
- /* file was dead. merge anyway and pretend it's been
- added. */
- ++tst;
- Register (entries, file, "0", vers->ts_user, vers->options,
- vers->tag, (char *) 0, (char *) 0);
- }
- rev1 = gca (tst, rev2);
- if (rev1 == NULL)
- {
- /* this should not be possible */
- error (0, 0, "bad gca");
- abort();
- }
+ if (rev1 != NULL)
+ free (rev1);
+ free (rev2);
- tst = RCS_gettag (vers->srcfile, rev2, 1, 0);
- if (tst == NULL)
+ /* If the file does not exist in the working directory, then
+ we can just check out the new revision and mark it for
+ addition. */
+ if (vers->vn_user == NULL)
{
- /* this should not be possible. */
- error (0, 0, "cannot find gca");
- abort();
- }
+ Vers_TS *xvers;
- free (tst);
+ xvers = Version_TS (finfo, vers->options, jrev2, jdate2, 1, 0);
+
+ /* FIXME: If checkout_file fails, we should arrange to
+ return a non-zero exit status. */
+ status = checkout_file (finfo, xvers, 1);
+
+#ifdef SERVER_SUPPORT
+ if (server_active && status == 0)
+ server_updated (finfo, xvers,
+ SERVER_UPDATED, (struct stat *) NULL,
+ (unsigned char *) NULL);
+#endif
+
+ freevers_ts (&xvers);
- /* these two cases are noops */
- if (strcmp (rev1, rev2) == 0)
- {
- free (rev1);
- free (rev2);
return;
}
+
+ /* The file currently exists in the working directory, so we
+ have a conflict which we can not resolve. Note that this
+ is true even if the file is marked for addition or removal. */
+
+ if (jdate2 != NULL)
+ error (0, 0,
+ "file %s exists, but has been added in revision %s as of %s",
+ finfo->fullname, jrev2, jdate2);
+ else
+ error (0, 0,
+ "file %s exists, but has been added in revision %s",
+ finfo->fullname, jrev2);
+
+ return;
}
- else
- {
- /* otherwise, convert the first rev spec, walking branches and
- dates. */
- rev1 = RCS_getversion (vers->srcfile, jrev1, jdate1, 1, 0);
- if (rev1 == NULL)
- {
- if (!quiet) {
- if (jdate1 != NULL)
- error (0, 0,
- "cannot find revision %s as of %s in file %s",
- jrev1, jdate1, file);
- else
- error (0, 0,
- "cannot find revision %s in file %s",
- jrev1, file);
- }
- return;
- }
+ /* If the two merge revisions are the same, then there is nothing
+ to do. */
+ if (strcmp (rev1, rev2) == 0)
+ {
+ free (rev1);
+ free (rev2);
+ return;
}
- /* do the join */
+ /* If there is no working file, then we can't do the merge. */
+ if (vers->vn_user == NULL)
+ {
+ free (rev1);
+ free (rev2);
-#if 0
- dome {
- /* special handling when two revisions are specified */
- if (join_rev1 && join_rev2)
- {
- rev = RCS_getversion (vers->srcfile, join_rev2, date_rev2, 1, 0);
- if (rev == NULL)
- {
- if (!quiet && date_rev2 == NULL)
- error (0, 0,
- "cannot find revision %s in file %s", join_rev2, file);
- return;
- }
-
- baserev = RCS_getversion (vers->srcfile, join_rev1, date_rev1, 1, 0);
- if (baserev == NULL)
- {
- if (!quiet && date_rev1 == NULL)
- error (0, 0,
- "cannot find revision %s in file %s", join_rev1, file);
- free (rev);
- return;
- }
-
- /*
- * nothing to do if:
- * second revision matches our BASE revision (vn_user) &&
- * both revisions are on the same branch
- */
- if (strcmp (vers->vn_user, rev) == 0 &&
- numdots (baserev) == numdots (rev))
- {
- /* might be the same branch. take a real look */
- char *dot = strrchr (baserev, '.');
- int len = (dot - baserev) + 1;
-
- if (strncmp (baserev, rev, len) == 0)
- return;
- }
- }
+ if (jdate2 != NULL)
+ error (0, 0,
+ "file %s is present in revision %s as of %s",
+ finfo->fullname, jrev2, jdate2);
else
- {
- rev = RCS_getversion (vers->srcfile, join_rev1, date_rev1, 1, 0);
- if (rev == NULL)
- return;
- if (strcmp (rev, vers->vn_user) == 0) /* no merge necessary */
- {
- free (rev);
- return;
- }
-
- baserev = RCS_whatbranch (file, join_rev1, rcsnode);
- if (baserev)
- {
- char *cp;
-
- /* we get a branch -- turn it into a revision, or NULL if trunk */
- if ((cp = strrchr (baserev, '.')) == NULL)
- {
- free (baserev);
- baserev = (char *) NULL;
- }
- else
- *cp = '\0';
- }
- }
- if (baserev && strcmp (baserev, rev) == 0)
- {
- /* they match -> nothing to do */
- free (rev);
- free (baserev);
- return;
- }
- }
-#endif
+ error (0, 0,
+ "file %s is present in revision %s",
+ finfo->fullname, jrev2);
- /* OK, so we have two revisions; continue on */
+ /* FIXME: Should we arrange to return a non-zero exit status? */
+
+ return;
+ }
#ifdef SERVER_SUPPORT
- if (server_active && !isreadable (file))
+ if (server_active && !isreadable (finfo->file))
{
int retcode;
/* The file is up to date. Need to check out the current contents. */
- retcode = RCS_checkout (vers->srcfile->path, "", vers->vn_user, NULL,
- RUN_TTY, 0, 0);
+ retcode = RCS_checkout (vers->srcfile, finfo->file,
+ vers->vn_user, (char *) NULL,
+ (char *) NULL, RUN_TTY,
+ (RCSCHECKOUTPROC) NULL, (void *) NULL);
if (retcode != 0)
error (1, retcode == -1 ? errno : 0,
- "failed to check out %s file", file);
+ "failed to check out %s file", finfo->fullname);
}
#endif
@@ -1761,15 +2021,15 @@ join_file (file, rcsnode, vers, update_dir, entries)
* is the version of the file that the user was most up-to-date with
* before the merge.
*/
- (void) sprintf (backup, "%s%s.%s", BAKPREFIX, file, vers->vn_user);
- if (update_dir[0])
- (void) sprintf (user, "%s/%s", update_dir, file);
- else
- (void) strcpy (user, file);
+ backup = xmalloc (strlen (finfo->file)
+ + strlen (vers->vn_user)
+ + sizeof (BAKPREFIX)
+ + 10);
+ (void) sprintf (backup, "%s%s.%s", BAKPREFIX, finfo->file, vers->vn_user);
(void) unlink_file (backup);
- copy_file (file, backup);
- xchmod (file, 1);
+ copy_file (finfo->file, backup);
+ xchmod (finfo->file, 1);
options = vers->options;
#ifdef HAVE_RCS5
@@ -1783,10 +2043,10 @@ join_file (file, rcsnode, vers, update_dir, entries)
if (status != 0 && status != 1)
{
error (0, status == -1 ? errno : 0,
- "could not merge revision %s of %s", rev2, user);
+ "could not merge revision %s of %s", rev2, finfo->fullname);
error (status == -1 ? 1 : 0, 0, "restoring %s from backup file %s",
- user, backup);
- rename_file (backup, file);
+ finfo->fullname, backup);
+ rename_file (backup, finfo->file);
}
free (rev1);
free (rev2);
@@ -1806,8 +2066,9 @@ join_file (file, rcsnode, vers, update_dir, entries)
char *cp = 0;
if (status)
- cp = time_stamp (file);
- Register (entries, file, vers->vn_rcs, vers->ts_rcs, vers->options,
+ cp = time_stamp (finfo->file);
+ Register (finfo->entries, finfo->file,
+ vers->vn_rcs, vers->ts_rcs, vers->options,
vers->tag, vers->date, cp);
if (cp)
free(cp);
@@ -1816,11 +2077,13 @@ join_file (file, rcsnode, vers, update_dir, entries)
#ifdef SERVER_SUPPORT
if (server_active)
{
- server_copy_file (file, update_dir, repository, backup);
- server_updated (file, update_dir, repository, SERVER_MERGED,
+ server_copy_file (finfo->file, finfo->update_dir, finfo->repository,
+ backup);
+ server_updated (finfo, vers, SERVER_MERGED,
(struct stat *) NULL, (unsigned char *) NULL);
}
#endif
+ free (backup);
}
int
diff --git a/contrib/cvs/src/update.h b/contrib/cvs/src/update.h
index bad6562..ba71310 100644
--- a/contrib/cvs/src/update.h
+++ b/contrib/cvs/src/update.h
@@ -8,14 +8,11 @@
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ GNU General Public License for more details. */
int do_update PROTO((int argc, char *argv[], char *xoptions, char *xtag,
char *xdate, int xforce, int local, int xbuild,
int xaflag, int xprune, int xpipeout, int which,
char *xjoin_rev1, char *xjoin_rev2, char *preload_update_dir));
int joining PROTO((void));
+extern int isemptydir PROTO ((char *dir, int might_not_exist));
diff --git a/contrib/cvs/src/vers_ts.c b/contrib/cvs/src/vers_ts.c
index 34983a1..03a0036 100644
--- a/contrib/cvs/src/vers_ts.c
+++ b/contrib/cvs/src/vers_ts.c
@@ -9,7 +9,7 @@
#include "cvs.h"
#ifdef SERVER_SUPPORT
-static void time_stamp_server PROTO((char *, Vers_TS *));
+static void time_stamp_server PROTO((char *, Vers_TS *, Entnode *));
#endif
/*
@@ -18,22 +18,19 @@ static void time_stamp_server PROTO((char *, Vers_TS *));
* the current source control file - preparsed for our pleasure.
*/
Vers_TS *
-Version_TS (repository, options, tag, date, user, force_tag_match,
- set_time, entries, rcs)
- char *repository;
+Version_TS (finfo, options, tag, date, force_tag_match, set_time)
+ struct file_info *finfo;
char *options;
char *tag;
char *date;
- char *user;
int force_tag_match;
int set_time;
- List *entries;
- RCSNode *rcs;
{
Node *p;
RCSNode *rcsdata;
Vers_TS *vers_ts;
struct stickydirtag *sdtp;
+ Entnode *entdata;
/* get a new Vers_TS struct */
vers_ts = (Vers_TS *) xmalloc (sizeof (Vers_TS));
@@ -44,40 +41,51 @@ Version_TS (repository, options, tag, date, user, force_tag_match,
* if entries is NULL, there is no entries file so don't bother trying to
* look it up (used by checkout -P)
*/
- if (entries == NULL)
+ if (finfo->entries == NULL)
{
sdtp = NULL;
p = NULL;
}
else
{
- p = findnode_fn (entries, user);
- sdtp = (struct stickydirtag *) entries->list->data; /* list-private */
+ p = findnode_fn (finfo->entries, finfo->file);
+ sdtp = (struct stickydirtag *) finfo->entries->list->data; /* list-private */
}
+ entdata = NULL;
if (p != NULL)
{
- Entnode *entdata = (Entnode *) p->data;
+ entdata = (Entnode *) p->data;
- vers_ts->vn_user = xstrdup (entdata->version);
- vers_ts->ts_rcs = xstrdup (entdata->timestamp);
- vers_ts->ts_conflict = xstrdup (entdata->conflict);
- if (!tag)
- {
- if (!(sdtp && sdtp->aflag))
- vers_ts->tag = xstrdup (entdata->tag);
- }
- if (!date)
- {
- if (!(sdtp && sdtp->aflag))
- vers_ts->date = xstrdup (entdata->date);
- }
- if (!options || (options && *options == '\0'))
+#ifdef SERVER_SUPPORT
+ /* An entries line with "D" in the timestamp indicates that the
+ client sent Is-modified without sending Entry. So we want to
+ use the entries line for the sole purpose of telling
+ time_stamp_server what is up; we don't want the rest of CVS
+ to think there is an entries line. */
+ if (strcmp (entdata->timestamp, "D") != 0)
+#endif
{
- if (!(sdtp && sdtp->aflag))
- vers_ts->options = xstrdup (entdata->options);
+ vers_ts->vn_user = xstrdup (entdata->version);
+ vers_ts->ts_rcs = xstrdup (entdata->timestamp);
+ vers_ts->ts_conflict = xstrdup (entdata->conflict);
+ if (!tag)
+ {
+ if (!(sdtp && sdtp->aflag))
+ vers_ts->tag = xstrdup (entdata->tag);
+ }
+ if (!date)
+ {
+ if (!(sdtp && sdtp->aflag))
+ vers_ts->date = xstrdup (entdata->date);
+ }
+ if (!options || (options && *options == '\0'))
+ {
+ if (!(sdtp && sdtp->aflag))
+ vers_ts->options = xstrdup (entdata->options);
+ }
+ vers_ts->entdata = entdata;
}
- vers_ts->entdata = entdata;
}
/*
@@ -88,15 +96,13 @@ Version_TS (repository, options, tag, date, user, force_tag_match,
vers_ts->options = xstrdup (options);
else if (!vers_ts->options)
{
- if (sdtp && sdtp->aflag == 0)
- vers_ts->options = xstrdup (sdtp->options);
- else if (rcs != NULL)
+ if (finfo->rcs != NULL)
{
/* If no keyword expansion was specified on command line,
use whatever was in the rcs file (if there is one). This
is how we, if we are the server, tell the client whether
a file is binary. */
- char *rcsexpand = RCS_getexpand (rcs);
+ char *rcsexpand = RCS_getexpand (finfo->rcs);
if (rcsexpand != NULL)
{
vers_ts->options = xmalloc (strlen (rcsexpand) + 3);
@@ -120,19 +126,22 @@ Version_TS (repository, options, tag, date, user, force_tag_match,
else if (!vers_ts->entdata && (sdtp && sdtp->aflag == 0))
{
if (!vers_ts->tag)
+ {
vers_ts->tag = xstrdup (sdtp->tag);
+ vers_ts->nonbranch = sdtp->nonbranch;
+ }
if (!vers_ts->date)
vers_ts->date = xstrdup (sdtp->date);
}
/* Now look up the info on the source controlled file */
- if (rcs != NULL)
+ if (finfo->rcs != NULL)
{
- rcsdata = rcs;
+ rcsdata = finfo->rcs;
rcsdata->refcount++;
}
- else if (repository != NULL)
- rcsdata = RCS_parse (user, repository);
+ else if (finfo->repository != NULL)
+ rcsdata = RCS_parse (finfo->file, finfo->repository);
else
rcsdata = NULL;
@@ -148,21 +157,17 @@ Version_TS (repository, options, tag, date, user, force_tag_match,
}
else
{
+ int simple;
+
vers_ts->vn_rcs = RCS_getversion (rcsdata, vers_ts->tag,
- vers_ts->date, force_tag_match, 1);
+ vers_ts->date, force_tag_match,
+ &simple);
if (vers_ts->vn_rcs == NULL)
vers_ts->vn_tag = NULL;
+ else if (simple)
+ vers_ts->vn_tag = xstrdup (vers_ts->tag);
else
- {
- char *colon = strchr (vers_ts->vn_rcs, ':');
- if (colon)
- {
- vers_ts->vn_tag = xstrdup (colon+1);
- *colon = '\0';
- }
- else
- vers_ts->vn_tag = xstrdup (vers_ts->vn_rcs);
- }
+ vers_ts->vn_tag = xstrdup (vers_ts->vn_rcs);
}
/*
@@ -178,19 +183,19 @@ Version_TS (repository, options, tag, date, user, force_tag_match,
if (vers_ts->vn_rcs &&
(t.actime = t.modtime = RCS_getrevtime (rcsdata,
vers_ts->vn_rcs, (char *) 0, 0)) != -1)
- (void) utime (user, &t);
+ (void) utime (finfo->file, &t);
}
}
/* get user file time-stamp in ts_user */
- if (entries != (List *) NULL)
+ if (finfo->entries != (List *) NULL)
{
#ifdef SERVER_SUPPORT
if (server_active)
- time_stamp_server (user, vers_ts);
+ time_stamp_server (finfo->file, vers_ts, entdata);
else
#endif
- vers_ts->ts_user = time_stamp (user);
+ vers_ts->ts_user = time_stamp (finfo->file);
}
return (vers_ts);
@@ -205,50 +210,44 @@ Version_TS (repository, options, tag, date, user, force_tag_match,
#define mark_unchanged(V) ((V)->ts_user = xstrdup ((V)->ts_rcs))
static void
-time_stamp_server (file, vers_ts)
+time_stamp_server (file, vers_ts, entdata)
char *file;
Vers_TS *vers_ts;
+ Entnode *entdata;
{
struct stat sb;
char *cp;
- if (stat (file, &sb) < 0)
+ if ( CVS_STAT (file, &sb) < 0)
{
if (! existence_error (errno))
error (1, errno, "cannot stat temp file");
- if (use_unchanged)
- {
- /* Missing file means lost or unmodified; check entries
- file to see which.
- XXX FIXME - If there's no entries file line, we
- wouldn't be getting the file at all, so consider it
- lost. I don't know that that's right, but it's not
- clear to me that either choice is. Besides, would we
- have an RCS string in that case anyways? */
- if (vers_ts->entdata == NULL)
- mark_lost (vers_ts);
- else if (vers_ts->entdata->timestamp
- && vers_ts->entdata->timestamp[0] == '=')
- mark_unchanged (vers_ts);
- else
- mark_lost (vers_ts);
- }
- else
- {
- /* Missing file in the temp directory means that the file
- was not modified. */
+ /* Missing file means lost or unmodified; check entries
+ file to see which.
+
+ XXX FIXME - If there's no entries file line, we
+ wouldn't be getting the file at all, so consider it
+ lost. I don't know that that's right, but it's not
+ clear to me that either choice is. Besides, would we
+ have an RCS string in that case anyways? */
+ if (entdata == NULL)
+ mark_lost (vers_ts);
+ else if (entdata->timestamp
+ && entdata->timestamp[0] == '=')
mark_unchanged (vers_ts);
- }
+ else if (entdata->timestamp != NULL
+ && (entdata->timestamp[0] == 'M'
+ || entdata->timestamp[0] == 'D')
+ && entdata->timestamp[1] == '\0')
+ vers_ts->ts_user = xstrdup ("Is-modified");
+ else
+ mark_lost (vers_ts);
}
else if (sb.st_mtime == 0)
{
- if (use_unchanged)
- /* We shouldn't reach this case any more! */
- abort ();
-
- /* Special code used by server.c to indicate the file was lost. */
- mark_lost (vers_ts);
+ /* We shouldn't reach this case any more! */
+ abort ();
}
else
{
@@ -290,7 +289,7 @@ time_stamp (file)
char *cp;
char *ts;
- if (stat (file, &sb) < 0)
+ if ( CVS_STAT (file, &sb) < 0)
{
ts = NULL;
}
diff --git a/contrib/cvs/src/version.c b/contrib/cvs/src/version.c
index 4848e82..606c43d 100644
--- a/contrib/cvs/src/version.c
+++ b/contrib/cvs/src/version.c
@@ -12,7 +12,7 @@
#include "cvs.h"
-char *version_string = "\nConcurrent Versions System (CVS) 1.8.1";
+char *version_string = "\nConcurrent Versions System (CVS) 1.9.9";
#ifdef CLIENT_SUPPORT
#ifdef SERVER_SUPPORT
diff --git a/contrib/cvs/src/watch.c b/contrib/cvs/src/watch.c
index 0873489..9bb50d0 100644
--- a/contrib/cvs/src/watch.c
+++ b/contrib/cvs/src/watch.c
@@ -8,11 +8,7 @@
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ GNU General Public License for more details. */
#include "cvs.h"
#include "edit.h"
@@ -21,10 +17,11 @@
const char *const watch_usage[] =
{
- "Usage: %s %s [on|off|add|remove] [-l] [-a action] [files...]\n",
+ "Usage: %s %s [on|off|add|remove] [-lR] [-a action] [files...]\n",
"on/off: turn on/off read-only checkouts of files\n",
"add/remove: add or remove notification on actions\n",
"-l (on/off/add/remove): Local directory only, not recursive\n",
+ "-R (on/off/add/remove): Process directories recursively\n",
"-a (add/remove): Specify what actions, one of\n",
" edit,unedit,commit,all,none\n",
NULL
@@ -215,23 +212,28 @@ watch_modify_watchers (file, what)
free (mynewattr);
}
-static int addremove_fileproc PROTO ((struct file_info *finfo));
+static int addremove_fileproc PROTO ((void *callerdat,
+ struct file_info *finfo));
static int
-addremove_fileproc (finfo)
+addremove_fileproc (callerdat, finfo)
+ void *callerdat;
struct file_info *finfo;
{
watch_modify_watchers (finfo->file, &the_args);
return 0;
}
-static int addremove_filesdoneproc PROTO ((int, char *, char *));
+static int addremove_filesdoneproc PROTO ((void *, int, char *, char *,
+ List *));
static int
-addremove_filesdoneproc (err, repository, update_dir)
+addremove_filesdoneproc (callerdat, err, repository, update_dir, entries)
+ void *callerdat;
int err;
char *repository;
char *update_dir;
+ List *entries;
{
if (the_args.setting_default)
watch_modify_watchers (NULL, &the_args);
@@ -255,13 +257,16 @@ watch_addremove (argc, argv)
the_args.edit = 0;
the_args.unedit = 0;
optind = 1;
- while ((c = getopt (argc, argv, "la:")) != -1)
+ while ((c = getopt (argc, argv, "+lRa:")) != -1)
{
switch (c)
{
case 'l':
local = 1;
break;
+ case 'R':
+ local = 0;
+ break;
case 'a':
a_omitted = 0;
if (strcmp (optarg, "edit") == 0)
@@ -332,10 +337,7 @@ watch_addremove (argc, argv)
send_arg ("none");
}
send_file_names (argc, argv, SEND_EXPAND_WILD);
- /* FIXME: We shouldn't have to send current files, but I'm not sure
- whether it works. So send the files --
- it's slower but it works. */
- send_files (argc, argv, local, 0);
+ send_files (argc, argv, local, 0, SEND_NO_CONTENTS);
send_to_server (the_args.adding ?
"watch-add\012" : "watch-remove\012",
0);
@@ -348,11 +350,11 @@ watch_addremove (argc, argv)
lock_tree_for_write (argc, argv, local, 0);
err = start_recursion (addremove_fileproc, addremove_filesdoneproc,
- (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL,
+ (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL, NULL,
argc, argv, local, W_LOCAL, 0, 0, (char *)NULL,
- 1, 0);
+ 1);
- lock_tree_cleanup ();
+ Lock_Cleanup ();
return err;
}
@@ -412,14 +414,18 @@ watch (argc, argv)
static const char *const watchers_usage[] =
{
- "Usage: %s %s [files...]\n",
+ "Usage: %s %s [-lR] [files...]\n",
+ "\t-l\tProcess this directory only (not recursive).\n",
+ "\t-R\tProcess directories recursively.\n",
NULL
};
-static int watchers_fileproc PROTO ((struct file_info *finfo));
+static int watchers_fileproc PROTO ((void *callerdat,
+ struct file_info *finfo));
static int
-watchers_fileproc (finfo)
+watchers_fileproc (callerdat, finfo)
+ void *callerdat;
struct file_info *finfo;
{
char *them;
@@ -480,13 +486,16 @@ watchers (argc, argv)
usage (watchers_usage);
optind = 1;
- while ((c = getopt (argc, argv, "l")) != -1)
+ while ((c = getopt (argc, argv, "+lR")) != -1)
{
switch (c)
{
case 'l':
local = 1;
break;
+ case 'R':
+ local = 0;
+ break;
case '?':
default:
usage (watchers_usage);
@@ -505,17 +514,14 @@ watchers (argc, argv)
if (local)
send_arg ("-l");
send_file_names (argc, argv, SEND_EXPAND_WILD);
- /* FIXME: We shouldn't have to send current files, but I'm not sure
- whether it works. So send the files --
- it's slower but it works. */
- send_files (argc, argv, local, 0);
+ send_files (argc, argv, local, 0, SEND_NO_CONTENTS);
send_to_server ("watchers\012", 0);
return get_responses_and_close ();
}
#endif /* CLIENT_SUPPORT */
return start_recursion (watchers_fileproc, (FILESDONEPROC) NULL,
- (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL,
+ (DIRENTPROC) NULL, (DIRLEAVEPROC) NULL, NULL,
argc, argv, local, W_LOCAL, 0, 1, (char *)NULL,
- 1, 0);
+ 1);
}
diff --git a/contrib/cvs/src/watch.h b/contrib/cvs/src/watch.h
index d279c71..fa34ef5 100644
--- a/contrib/cvs/src/watch.h
+++ b/contrib/cvs/src/watch.h
@@ -8,11 +8,7 @@
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ GNU General Public License for more details. */
extern const char *const watch_usage[];
diff --git a/contrib/cvs/src/wrapper.c b/contrib/cvs/src/wrapper.c
index 8a6ff94..13e7e43 100644
--- a/contrib/cvs/src/wrapper.c
+++ b/contrib/cvs/src/wrapper.c
@@ -1,4 +1,15 @@
+/* This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details. */
+
#include "cvs.h"
+#include "getline.h"
/*
Original Author: athan@morgan.com <Andrew C. Athan> 2/1/94
@@ -22,6 +33,7 @@
-f from cvs filter value: path to filter
-t to cvs filter value: path to filter
-m update methodology value: MERGE or COPY
+ -k default -k rcs option to use on import or add
and value is a single-quote delimited value.
@@ -34,7 +46,7 @@ typedef struct {
char *wildCard;
char *tocvsFilter;
char *fromcvsFilter;
- char *conflictHook;
+ char *rcsOption;
WrapMergeMethod mergeMethod;
} WrapperEntry;
@@ -44,7 +56,16 @@ static WrapperEntry **wrap_saved_list=NULL;
static int wrap_size=0;
static int wrap_count=0;
static int wrap_tempcount=0;
+
+/* FIXME: wrap_saved_count is never set to any non-zero value.
+ wrap_name_has and wrap_matching_entry should be using
+ wrap_tempcount instead. I believe the consequence of this is that
+ .cvswrappers files are ignored (that was my own experience when I
+ tried to use one). If this bug is fixed, would be nice to write a
+ sanity.sh testcase for .cvswrappers files. */
+
static int wrap_saved_count=0;
+
static int wrap_saved_tempcount=0;
#define WRAPPER_GROW 8
@@ -58,27 +79,81 @@ void wrap_restore_saved PROTO((void));
void wrap_setup()
{
- char file[PATH_MAX];
struct passwd *pw;
- /* Then add entries found in repository, if it exists */
- (void) sprintf (file, "%s/%s/%s", CVSroot, CVSROOTADM, CVSROOTADM_WRAPPER);
- if (isfile (file)){
- wrap_add_file(file,0);
+#ifdef CLIENT_SUPPORT
+ if (!client_active)
+#endif
+ {
+ char *file;
+
+ file = xmalloc (strlen (CVSroot_directory)
+ + sizeof (CVSROOTADM)
+ + sizeof (CVSROOTADM_WRAPPER)
+ + 10);
+ /* Then add entries found in repository, if it exists. */
+ (void) sprintf (file, "%s/%s/%s", CVSroot_directory, CVSROOTADM,
+ CVSROOTADM_WRAPPER);
+ if (isfile (file))
+ {
+ wrap_add_file(file,0);
+ }
+ free (file);
}
- /* Then add entries found in home dir, (if user has one) and file exists */
- if ((pw = (struct passwd *) getpwuid (getuid ())) && pw->pw_dir){
+ /* Then add entries found in home dir, (if user has one) and file
+ exists. (FIXME: I think this probably should be using
+ get_homedir, i.e. $HOME). */
+ if ((pw = (struct passwd *) getpwuid (getuid ())) && pw->pw_dir)
+ {
+ char *file;
+
+ file = xmalloc (strlen (pw->pw_dir) + sizeof (CVSDOTWRAPPER) + 10);
(void) sprintf (file, "%s/%s", pw->pw_dir, CVSDOTWRAPPER);
- if (isfile (file)){
+ if (isfile (file))
+ {
wrap_add_file (file, 0);
}
+ free (file);
}
- /* Then add entries found in CVSWRAPPERS environment variable. */
+ /* Then add entries found in CVSWRAPPERS environment variable. */
wrap_add (getenv (WRAPPER_ENV), 0);
}
+#ifdef CLIENT_SUPPORT
+/* Send -W arguments for the wrappers to the server. The command must
+ be one that accepts them (e.g. update, import). */
+void
+wrap_send ()
+{
+ int i;
+
+ for (i = 0; i < wrap_count + wrap_tempcount; ++i)
+ {
+ if (wrap_list[i]->tocvsFilter != NULL
+ || wrap_list[i]->fromcvsFilter != NULL)
+ /* For greater studliness we would print the offending option
+ and (more importantly) where we found it. */
+ error (0, 0, "\
+-t and -f wrapper options are not supported remotely; ignored");
+ if (wrap_list[i]->mergeMethod == WRAP_COPY)
+ /* For greater studliness we would print the offending option
+ and (more importantly) where we found it. */
+ error (0, 0, "\
+-m wrapper option is not supported remotely; ignored");
+ if (wrap_list[i]->rcsOption != NULL)
+ {
+ send_to_server ("Argument -W\012Argument ", 0);
+ send_to_server (wrap_list[i]->wildCard, 0);
+ send_to_server (" -k '", 0);
+ send_to_server (wrap_list[i]->rcsOption, 0);
+ send_to_server ("'\012", 0);
+ }
+ }
+}
+#endif /* CLIENT_SUPPORT */
+
/*
* Open a file and read lines, feeding each line to a line parser. Arrange
* for keeping a temporary list of wrappers at the end, if the "temp"
@@ -90,17 +165,28 @@ wrap_add_file (file, temp)
int temp;
{
FILE *fp;
- char line[1024];
-
- wrap_restore_saved();
- wrap_kill_temp();
-
- /* load the file */
- if (!(fp = fopen (file, "r")))
+ char *line = NULL;
+ size_t line_allocated = 0;
+
+ wrap_restore_saved ();
+ wrap_kill_temp ();
+
+ /* Load the file. */
+ fp = CVS_FOPEN (file, "r");
+ if (fp == NULL)
+ {
+ if (!existence_error (errno))
+ error (0, errno, "cannot open %s", file);
return;
- while (fgets (line, sizeof (line), fp))
+ }
+ while (getline (&line, &line_allocated, fp) >= 0)
wrap_add (line, temp);
- (void) fclose (fp);
+ if (line)
+ free (line);
+ if (ferror (fp))
+ error (0, errno, "cannot read %s", file);
+ if (fclose (fp) == EOF)
+ error (0, errno, "cannot close %s", file);
}
void
@@ -132,13 +218,13 @@ void
wrap_free_entry_internal(e)
WrapperEntry *e;
{
- free(e->wildCard);
- if(e->tocvsFilter)
- free(e->tocvsFilter);
- if(e->fromcvsFilter)
- free(e->fromcvsFilter);
- if(e->conflictHook)
- free(e->conflictHook);
+ free (e->wildCard);
+ if (e->tocvsFilter)
+ free (e->tocvsFilter);
+ if (e->fromcvsFilter)
+ free (e->fromcvsFilter);
+ if (e->rcsOption)
+ free (e->rcsOption);
}
void
@@ -208,7 +294,15 @@ wrap_add (line, isTemp)
for(temp=++line;*line && (*line!='\'' || line[-1]=='\\');++line)
;
- if(line==temp+1)
+ /* This used to "break;" (ignore the option) if there was a
+ single character between the single quotes (I'm guessing
+ that was accidental). Now it "break;"s if there are no
+ characters. I'm not sure either behavior is particularly
+ necessary--the current options might not require ''
+ arguments, but surely some future option legitimately
+ might. Also I'm not sure that ignoring the option is a
+ swift way to handle syntax errors in general. */
+ if (line==temp)
break;
ctemp=*line;
@@ -232,21 +326,19 @@ wrap_add (line, isTemp)
if (!e.tocvsFilter)
error (1, 0, "Correct above errors first");
break;
- case 'c':
- if(e.conflictHook)
- free(e.conflictHook);
- /* FIXME: error message should say where the bad value
- came from. */
- e.conflictHook=expand_path (temp, "<wrapper>", 0);
- if (!e.conflictHook)
- error (1, 0, "Correct above errors first");
- break;
case 'm':
+ /* FIXME: look into whether this option is still relevant given
+ the 24 Jun 96 change to merge_file. */
if(*temp=='C' || *temp=='c')
e.mergeMethod=WRAP_COPY;
else
e.mergeMethod=WRAP_MERGE;
break;
+ case 'k':
+ if (e.rcsOption)
+ free (e.rcsOption);
+ e.rcsOption = xstrdup (temp);
+ break;
default:
break;
}
@@ -281,8 +373,8 @@ wrap_add_entry(e, temp)
wrap_list[x]->wildCard=e->wildCard;
wrap_list[x]->fromcvsFilter=e->fromcvsFilter;
wrap_list[x]->tocvsFilter=e->tocvsFilter;
- wrap_list[x]->conflictHook=e->conflictHook;
wrap_list[x]->mergeMethod=e->mergeMethod;
+ wrap_list[x]->rcsOption = e->rcsOption;
}
/* Return 1 if the given filename is a wrapper filename */
@@ -303,8 +395,8 @@ wrap_name_has (name,has)
case WRAP_FROMCVS:
temp=wrap_list[x]->fromcvsFilter;
break;
- case WRAP_CONFLICT:
- temp=wrap_list[x]->conflictHook;
+ case WRAP_RCSOPTION:
+ temp = wrap_list[x]->rcsOption;
break;
default:
abort ();
@@ -317,7 +409,9 @@ wrap_name_has (name,has)
return (0);
}
-WrapperEntry *
+static WrapperEntry *wrap_matching_entry PROTO ((const char *));
+
+static WrapperEntry *
wrap_matching_entry (name)
const char *name;
{
@@ -329,17 +423,46 @@ wrap_matching_entry (name)
return (WrapperEntry *)NULL;
}
+/* Return the RCS options for FILENAME in a newly malloc'd string. If
+ ASFLAG, then include "-k" at the beginning (e.g. "-kb"), otherwise
+ just give the option itself (e.g. "b"). */
+char *
+wrap_rcsoption (filename, asflag)
+ const char *filename;
+ int asflag;
+{
+ WrapperEntry *e = wrap_matching_entry (filename);
+ char *buf;
+
+ if (e == NULL || e->rcsOption == NULL || (*e->rcsOption == '\0'))
+ return NULL;
+
+ buf = xmalloc (strlen (e->rcsOption) + 3);
+ if (asflag)
+ {
+ strcpy (buf, "-k");
+ strcat (buf, e->rcsOption);
+ }
+ else
+ {
+ strcpy (buf, e->rcsOption);
+ }
+ return buf;
+}
+
char *
wrap_tocvs_process_file(fileName)
const char *fileName;
{
WrapperEntry *e=wrap_matching_entry(fileName);
- static char buf[L_tmpnam+1];
+ static char *buf = NULL;
if(e==NULL || e->tocvsFilter==NULL)
return NULL;
- tmpnam(buf);
+ if (buf != NULL)
+ free (buf);
+ buf = cvs_temp_name ();
run_setup(e->tocvsFilter,fileName,buf);
run_exec(RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL|RUN_REALLY );
@@ -358,17 +481,16 @@ wrap_merge_is_copy (fileName)
return 1;
}
-char *
+void
wrap_fromcvs_process_file(fileName)
const char *fileName;
{
WrapperEntry *e=wrap_matching_entry(fileName);
- static char buf[PATH_MAX];
if(e==NULL || e->fromcvsFilter==NULL)
- return NULL;
+ return;
run_setup(e->fromcvsFilter,fileName);
run_exec(RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL );
- return buf;
+ return;
}
diff --git a/contrib/cvs/src/zlib.c b/contrib/cvs/src/zlib.c
new file mode 100644
index 0000000..02ad70c
--- /dev/null
+++ b/contrib/cvs/src/zlib.c
@@ -0,0 +1,429 @@
+/* zlib.c --- interface to the zlib compression library
+ Ian Lance Taylor <ian@cygnus.com>
+
+ This file is part of GNU CVS.
+
+ GNU CVS is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details. */
+
+/* The routines in this file are the interface between the CVS
+ client/server support and the zlib compression library. */
+
+#include <assert.h>
+#include "cvs.h"
+#include "buffer.h"
+
+#if defined (SERVER_SUPPORT) || defined (CLIENT_SUPPORT)
+
+#include "zlib.h"
+
+/* OS/2 doesn't have EIO. FIXME: this whole notion of turning
+ a different error into EIO strikes me as pretty dubious. */
+#if !defined (EIO)
+#define EIO EBADPOS
+#endif
+
+/* The compression interface is built upon the buffer data structure.
+ We provide a buffer type which compresses or decompresses the data
+ which passes through it. An input buffer decompresses the data
+ read from an underlying buffer, and an output buffer compresses the
+ data before writing it to an underlying buffer. */
+
+/* This structure is the closure field of the buffer. */
+
+struct compress_buffer
+{
+ /* The underlying buffer. */
+ struct buffer *buf;
+ /* The compression information. */
+ z_stream zstr;
+};
+
+static void compress_error PROTO((int, int, z_stream *, const char *));
+static int compress_buffer_input PROTO((void *, char *, int, int, int *));
+static int compress_buffer_output PROTO((void *, const char *, int, int *));
+static int compress_buffer_flush PROTO((void *));
+static int compress_buffer_block PROTO((void *, int));
+static int compress_buffer_shutdown_input PROTO((void *));
+static int compress_buffer_shutdown_output PROTO((void *));
+
+/* Report an error from one of the zlib functions. */
+
+static void
+compress_error (status, zstatus, zstr, msg)
+ int status;
+ int zstatus;
+ z_stream *zstr;
+ const char *msg;
+{
+ int hold_errno;
+ const char *zmsg;
+ char buf[100];
+
+ hold_errno = errno;
+
+ zmsg = zstr->msg;
+ if (zmsg == NULL)
+ {
+ sprintf (buf, "error %d", zstatus);
+ zmsg = buf;
+ }
+
+ error (status,
+ zstatus == Z_ERRNO ? hold_errno : 0,
+ "%s: %s", msg, zmsg);
+}
+
+/* Create a compression buffer. */
+
+struct buffer *
+compress_buffer_initialize (buf, input, level, memory)
+ struct buffer *buf;
+ int input;
+ int level;
+ void (*memory) PROTO((struct buffer *));
+{
+ struct compress_buffer *n;
+ int zstatus;
+
+ n = (struct compress_buffer *) xmalloc (sizeof *n);
+ memset (n, 0, sizeof *n);
+
+ n->buf = buf;
+
+ if (input)
+ zstatus = inflateInit (&n->zstr);
+ else
+ zstatus = deflateInit (&n->zstr, level);
+ if (zstatus != Z_OK)
+ compress_error (1, zstatus, &n->zstr, "compression initialization");
+
+ /* There may already be data buffered on BUF. For an output
+ buffer, this is OK, because these routines will just use the
+ buffer routines to append data to the (uncompressed) data
+ already on BUF. An input buffer expects to handle a single
+ buffer_data of buffered input to be uncompressed, so that is OK
+ provided there is only one buffer. At present that is all
+ there ever will be; if this changes, compress_buffer_input must
+ be modified to handle multiple input buffers. */
+ assert (! input || buf->data == NULL || buf->data->next == NULL);
+
+ return buf_initialize (input ? compress_buffer_input : NULL,
+ input ? NULL : compress_buffer_output,
+ input ? NULL : compress_buffer_flush,
+ compress_buffer_block,
+ (input
+ ? compress_buffer_shutdown_input
+ : compress_buffer_shutdown_output),
+ memory,
+ n);
+}
+
+/* Input data from a compression buffer. */
+
+static int
+compress_buffer_input (closure, data, need, size, got)
+ void *closure;
+ char *data;
+ int need;
+ int size;
+ int *got;
+{
+ struct compress_buffer *cb = (struct compress_buffer *) closure;
+ struct buffer_data *bd;
+
+ if (cb->buf->input == NULL)
+ abort ();
+
+ /* We use a single buffer_data structure to buffer up data which
+ the z_stream structure won't use yet. We can safely store this
+ on cb->buf->data, because we never call the buffer routines on
+ cb->buf; we only call the buffer input routine, since that
+ gives us the semantics we want. As noted in
+ compress_buffer_initialize, the buffer_data structure may
+ already exist, and hold data which was already read and
+ buffered before the decompression began. */
+ bd = cb->buf->data;
+ if (bd == NULL)
+ {
+ bd = ((struct buffer_data *) malloc (sizeof (struct buffer_data)));
+ if (bd == NULL)
+ return -2;
+ bd->text = (char *) malloc (BUFFER_DATA_SIZE);
+ if (bd->text == NULL)
+ {
+ free (bd);
+ return -2;
+ }
+ bd->bufp = bd->text;
+ bd->size = 0;
+ cb->buf->data = bd;
+ }
+
+ cb->zstr.avail_out = size;
+ cb->zstr.next_out = (Bytef *) data;
+
+ while (1)
+ {
+ int zstatus, sofar, status, nread;
+
+ /* First try to inflate any data we already have buffered up.
+ This is useful even if we don't have any buffered data,
+ because there may be data buffered inside the z_stream
+ structure. */
+
+ cb->zstr.avail_in = bd->size;
+ cb->zstr.next_in = (Bytef *) bd->bufp;
+
+ do
+ {
+ zstatus = inflate (&cb->zstr, Z_NO_FLUSH);
+ if (zstatus == Z_STREAM_END)
+ break;
+ if (zstatus != Z_OK && zstatus != Z_BUF_ERROR)
+ {
+ compress_error (0, zstatus, &cb->zstr, "inflate");
+ return EIO;
+ }
+ } while (cb->zstr.avail_in > 0
+ && cb->zstr.avail_out > 0);
+
+ bd->size = cb->zstr.avail_in;
+ bd->bufp = (char *) cb->zstr.next_in;
+
+ if (zstatus == Z_STREAM_END)
+ return -1;
+
+ /* If we have obtained NEED bytes, then return, unless NEED is
+ zero and we haven't obtained anything at all. If NEED is
+ zero, we will keep reading from the underlying buffer until
+ we either can't read anything, or we have managed to
+ inflate at least one byte. */
+ sofar = size - cb->zstr.avail_out;
+ if (sofar > 0 && sofar >= need)
+ break;
+
+ /* All our buffered data should have been processed at this
+ point. */
+ assert (bd->size == 0);
+
+ /* This will work well in the server, because this call will
+ do an unblocked read and fetch all the available data. In
+ the client, this will read a single byte from the stdio
+ stream, which will cause us to call inflate once per byte.
+ It would be more efficient if we could make a call which
+ would fetch all the available bytes, and at least one byte. */
+
+ status = (*cb->buf->input) (cb->buf->closure, bd->text,
+ need > 0 ? 1 : 0,
+ BUFFER_DATA_SIZE, &nread);
+ if (status != 0)
+ return status;
+
+ /* If we didn't read anything, then presumably the buffer is
+ in nonblocking mode, and we should just get out now with
+ whatever we've inflated. */
+ if (nread == 0)
+ {
+ assert (need == 0);
+ break;
+ }
+
+ bd->bufp = bd->text;
+ bd->size = nread;
+ }
+
+ *got = size - cb->zstr.avail_out;
+
+ return 0;
+}
+
+/* Output data to a compression buffer. */
+
+static int
+compress_buffer_output (closure, data, have, wrote)
+ void *closure;
+ const char *data;
+ int have;
+ int *wrote;
+{
+ struct compress_buffer *cb = (struct compress_buffer *) closure;
+
+ cb->zstr.avail_in = have;
+ cb->zstr.next_in = (unsigned char *) data;
+
+ while (cb->zstr.avail_in > 0)
+ {
+ char buffer[BUFFER_DATA_SIZE];
+ int zstatus;
+
+ cb->zstr.avail_out = BUFFER_DATA_SIZE;
+ cb->zstr.next_out = (unsigned char *) buffer;
+
+ zstatus = deflate (&cb->zstr, Z_NO_FLUSH);
+ if (zstatus != Z_OK)
+ {
+ compress_error (0, zstatus, &cb->zstr, "deflate");
+ return EIO;
+ }
+
+ if (cb->zstr.avail_out != BUFFER_DATA_SIZE)
+ buf_output (cb->buf, buffer,
+ BUFFER_DATA_SIZE - cb->zstr.avail_out);
+ }
+
+ *wrote = have;
+
+ /* We will only be here because buf_send_output was called on the
+ compression buffer. That means that we should now call
+ buf_send_output on the underlying buffer. */
+ return buf_send_output (cb->buf);
+}
+
+/* Flush a compression buffer. */
+
+static int
+compress_buffer_flush (closure)
+ void *closure;
+{
+ struct compress_buffer *cb = (struct compress_buffer *) closure;
+
+ cb->zstr.avail_in = 0;
+ cb->zstr.next_in = NULL;
+
+ while (1)
+ {
+ char buffer[BUFFER_DATA_SIZE];
+ int zstatus;
+
+ cb->zstr.avail_out = BUFFER_DATA_SIZE;
+ cb->zstr.next_out = (unsigned char *) buffer;
+
+ zstatus = deflate (&cb->zstr, Z_SYNC_FLUSH);
+
+ /* The deflate function will return Z_BUF_ERROR if it can't do
+ anything, which in this case means that all data has been
+ flushed. */
+ if (zstatus == Z_BUF_ERROR)
+ break;
+
+ if (zstatus != Z_OK)
+ {
+ compress_error (0, zstatus, &cb->zstr, "deflate flush");
+ return EIO;
+ }
+
+ if (cb->zstr.avail_out != BUFFER_DATA_SIZE)
+ buf_output (cb->buf, buffer,
+ BUFFER_DATA_SIZE - cb->zstr.avail_out);
+
+ /* If the deflate function did not fill the output buffer,
+ then all data has been flushed. */
+ if (cb->zstr.avail_out > 0)
+ break;
+ }
+
+ /* Now flush the underlying buffer. Note that if the original
+ call to buf_flush passed 1 for the BLOCK argument, then the
+ buffer will already have been set into blocking mode, so we
+ should always pass 0 here. */
+ return buf_flush (cb->buf, 0);
+}
+
+/* The block routine for a compression buffer. */
+
+static int
+compress_buffer_block (closure, block)
+ void *closure;
+ int block;
+{
+ struct compress_buffer *cb = (struct compress_buffer *) closure;
+
+ if (block)
+ return set_block (cb->buf);
+ else
+ return set_nonblock (cb->buf);
+}
+
+/* Shut down an input buffer. */
+
+static int
+compress_buffer_shutdown_input (closure)
+ void *closure;
+{
+ struct compress_buffer *cb = (struct compress_buffer *) closure;
+ int zstatus;
+
+ /* Pick up any trailing data, such as the checksum. */
+ while (1)
+ {
+ int status, nread;
+ char buf[100];
+
+ status = compress_buffer_input (cb, buf, 0, sizeof buf, &nread);
+ if (status == -1)
+ break;
+ if (status != 0)
+ return status;
+ }
+
+ zstatus = inflateEnd (&cb->zstr);
+ if (zstatus != Z_OK)
+ {
+ compress_error (0, zstatus, &cb->zstr, "inflateEnd");
+ return EIO;
+ }
+
+ return buf_shutdown (cb->buf);
+}
+
+/* Shut down an output buffer. */
+
+static int
+compress_buffer_shutdown_output (closure)
+ void *closure;
+{
+ struct compress_buffer *cb = (struct compress_buffer *) closure;
+ int zstatus, status;
+
+ do
+ {
+ char buffer[BUFFER_DATA_SIZE];
+
+ cb->zstr.avail_out = BUFFER_DATA_SIZE;
+ cb->zstr.next_out = (unsigned char *) buffer;
+
+ zstatus = deflate (&cb->zstr, Z_FINISH);
+ if (zstatus != Z_OK && zstatus != Z_STREAM_END)
+ {
+ compress_error (0, zstatus, &cb->zstr, "deflate finish");
+ return EIO;
+ }
+
+ if (cb->zstr.avail_out != BUFFER_DATA_SIZE)
+ buf_output (cb->buf, buffer,
+ BUFFER_DATA_SIZE - cb->zstr.avail_out);
+ } while (zstatus != Z_STREAM_END);
+
+ zstatus = deflateEnd (&cb->zstr);
+ if (zstatus != Z_OK)
+ {
+ compress_error (0, zstatus, &cb->zstr, "deflateEnd");
+ return EIO;
+ }
+
+ status = buf_flush (cb->buf, 1);
+ if (status != 0)
+ return status;
+
+ return buf_shutdown (cb->buf);
+}
+
+#endif /* defined (SERVER_SUPPORT) || defined (CLIENT_SUPPORT) */
OpenPOWER on IntegriCloud