xref: /openbsd-src/gnu/usr.bin/cvs/doc/cvsclient.texi (revision b2ea75c1b17e1a9a339660e7ed45cd24946b230e)
1\input texinfo @c -*- texinfo -*-
2
3@setfilename cvsclient.info
4@include CVSvn.texi
5
6@dircategory Programming
7@direntry
8* cvsclient: (cvsclient).      The CVS client/server protocol.
9@end direntry
10
11@node Top
12@top CVS Client/Server
13
14This document describes the client/server protocol used by CVS.  It does
15not describe how to use or administer client/server CVS; see the regular
16CVS manual for that.  This is version @value{CVSVN} of the protocol
17specification---@xref{Introduction}, for more on what this version number
18means.
19
20@menu
21* Introduction::      What is CVS and what is the client/server protocol for?
22* Goals::             Basic design decisions, requirements, scope, etc.
23* Connection and Authentication::  Various ways to connect to the server
24* Password scrambling::  Scrambling used by pserver
25* Protocol::          Complete description of the protocol
26* Protocol Notes::    Possible enhancements, limitations, etc. of the protocol
27@end menu
28
29@node Introduction
30@chapter Introduction
31
32CVS is a version control system (with some additional configuration
33management functionality).  It maintains a central @dfn{repository}
34which stores files (often source code), including past versions,
35information about who modified them and when, and so on.  People who
36wish to look at or modify those files, known as @dfn{developers}, use
37CVS to @dfn{check out} a @dfn{working directory} from the repository, to
38@dfn{check in} new versions of files to the repository, and other
39operations such as viewing the modification history of a file.  If
40developers are connected to the repository by a network, particularly a
41slow or flaky one, the most efficient way to use the network is with the
42CVS-specific protocol described in this document.
43
44Developers, using the machine on which they store their working
45directory, run the CVS @dfn{client} program.  To perform operations
46which cannot be done locally, it connects to the CVS @dfn{server}
47program, which maintains the repository.  For more information on how
48to connect see @ref{Connection and Authentication}.
49
50This document describes the CVS protocol.  Unfortunately, it does not
51yet completely document one aspect of the protocol---the detailed
52operation of each CVS command and option---and one must look at the CVS
53user documentation, @file{cvs.texinfo}, for that information.  The
54protocol is non-proprietary (anyone who wants to is encouraged to
55implement it) and an implementation, known as CVS, is available under
56the GNU Public License.  The CVS distribution, containing this
57implementation, @file{cvs.texinfo}, and a copy (possibly more or less up
58to date than what you are reading now) of this document,
59@file{cvsclient.texi}, can be found at the usual GNU FTP sites, with a
60filename such as @file{cvs-@var{version}.tar.gz}.
61
62This is version @value{CVSVN} of the protocol specification.  This
63version number is intended only to aid in distinguishing different
64versions of this specification.  Although the specification is currently
65maintained in conjunction with the CVS implementation, and carries the
66same version number, it also intends to document what is involved with
67interoperating with other implementations (such as other versions of
68CVS); see @ref{Requirements}.  This version number should not be used
69by clients or servers to determine what variant of the protocol to
70speak; they should instead use the @code{valid-requests} and
71@code{Valid-responses} mechanism (@pxref{Protocol}), which is more
72flexible.
73
74@node Goals
75@chapter Goals
76
77@itemize @bullet
78@item
79Do not assume any access to the repository other than via this protocol.
80It does not depend on NFS, rdist, etc.
81
82@item
83Providing a reliable transport is outside this protocol.  The protocol
84expects a reliable transport that is transparent (that is, there is no
85translation of characters, including characters such as such as
86linefeeds or carriage returns), and can transmit all 256 octets (for
87example for proper handling of binary files, compression, and
88encryption).  The encoding of characters specified by the protocol (the
89names of requests and so on) is the invariant ISO 646 character set (a
90subset of most popular character sets including ASCII and others).  For
91more details on running the protocol over the TCP reliable transport,
92see @ref{Connection and Authentication}.
93
94@item
95Security and authentication are handled outside this protocol (but see
96below about @samp{cvs kserver} and @samp{cvs pserver}).
97
98@item
99The protocol makes it possible for updates to be atomic with respect to
100checkins; that is if someone commits changes to several files in one cvs
101command, then an update by someone else would either get all the
102changes, or none of them.  The current @sc{cvs} server can't do this,
103but that isn't the protocol's fault.
104
105@item
106The protocol is, with a few exceptions, transaction-based.  That is, the
107client sends all its requests (without waiting for server responses),
108and then waits for the server to send back all responses (without
109waiting for further client requests).  This has the advantage of
110minimizing network turnarounds and the disadvantage of sometimes
111transferring more data than would be necessary if there were a richer
112interaction.  Another, more subtle, advantage is that there is no need
113for the protocol to provide locking for features such as making checkins
114atomic with respect to updates.  Any such locking can be handled
115entirely by the server.  A good server implementation (such as the
116current @sc{cvs} server) will make sure that it does not have any such
117locks in place whenever it is waiting for communication with the client;
118this prevents one client on a slow or flaky network from interfering
119with the work of others.
120
121@item
122It is a general design goal to provide only one way to do a given
123operation (where possible).  For example, implementations have no choice
124about whether to terminate lines with linefeeds or some other
125character(s), and request and response names are case-sensitive.  This
126is to enhance interoperability.  If a protocol allows more than one way
127to do something, it is all too easy for some implementations to support
128only some of them (perhaps accidentally).
129@c I vaguely remember reading, probably in an RFC, about the problems
130@c that were caused when some people decided that SMTP should accept
131@c other line termination (in the message ("DATA")?) than CRLF.  However, I
132@c can't seem to track down the reference.
133@end itemize
134
135@node Connection and Authentication
136@chapter How to Connect to and Authenticate Oneself to the CVS server
137
138Connection and authentication occurs before the CVS protocol itself is
139started.  There are several ways to connect.
140
141@table @asis
142@item server
143If the client has a way to execute commands on the server, and provide
144input to the commands and output from them, then it can connect that
145way.  This could be the usual rsh (port 514) protocol, Kerberos rsh,
146SSH, or any similar mechanism.  The client may allow the user to specify
147the name of the server program; the default is @code{cvs}.  It is
148invoked with one argument, @code{server}.  Once it invokes the server,
149the client proceeds to start the cvs protocol.
150
151@item kserver
152The kerberized server listens on a port (in the current implementation,
153by having inetd call "cvs kserver") which defaults to 1999.  The client
154connects, sends the usual kerberos authentication information, and then
155starts the cvs protocol.  Note: port 1999 is officially registered for
156another use, and in any event one cannot register more than one port for
157CVS, so GSS-API (see below) is recommended instead of kserver as a way
158to support kerberos.
159
160@item pserver
161The name @dfn{pserver} is somewhat confusing.  It refers to both a
162generic framework which allows the CVS protocol to support several
163authentication mechanisms, and a name for a specific mechanism which
164transfers a username and a cleartext password.  Servers need not support
165all mechanisms, and in fact servers will typically want to support only
166those mechanisms which meet the relevant security needs.
167
168The pserver server listens on a port (in the current
169implementation, by having inetd call "cvs pserver") which defaults to
1702401 (this port is officially registered).  The client
171connects, and sends the following:
172
173@itemize @bullet
174@item
175the string @samp{BEGIN AUTH REQUEST}, a linefeed,
176@item
177the cvs root, a linefeed,
178@item
179the username, a linefeed,
180@item
181the password trivially encoded (see @ref{Password scrambling}), a
182linefeed,
183@item
184the string @samp{END AUTH REQUEST}, and a linefeed.
185@end itemize
186
187The client must send the
188identical string for cvs root both here and later in the
189@code{Root} request of the cvs
190protocol itself.  Servers are encouraged to enforce this restriction.
191The possible server responses (each of which is followed by a linefeed)
192are the following.  Note that although there is a small similarity
193between this authentication protocol and the cvs protocol, they are
194separate.
195
196@table @code
197@item I LOVE YOU
198The authentication is successful.  The client proceeds with the cvs
199protocol itself.
200
201@item I HATE YOU
202The authentication fails.  After sending this response, the server may
203close the connection.  It is up to the server to decide whether to give
204this response, which is generic, or a more specific response using
205@samp{E} and/or @samp{error}.
206
207@item E @var{text}
208Provide a message for the user.  After this reponse, the authentication
209protocol continues with another response.  Typically the server will
210provide a series of @samp{E} responses followed by @samp{error}.
211Compatibility note: @sc{cvs} 1.9.10 and older clients will print
212@code{unrecognized auth response} and @var{text}, and then exit, upon
213receiving this response.
214
215@item error @var{code} @var{text}
216The authentication fails.  After sending this response, the server may
217close the connection.  The @var{code} is a code describing why it
218failed, intended for computer consumption.  The only code currently
219defined is @samp{0} which is nonspecific, but clients must silently
220treat any unrecognized codes as nonspecific.
221The @var{text} should be supplied to the
222user.  Compatibility note: @sc{cvs} 1.9.10 and older clients will print
223@code{unrecognized auth response} and @var{text}, and then exit, upon
224receiving this response.
225Note that @var{text} for this response, or the @var{text} in an @code{E}
226response, is not designed for machine parsing.  More vigorous use of
227@var{code}, or future extensions, will be needed to prove a cleaner
228machine-parseable indication of what the error was.
229@end table
230
231@c If you are thinking of putting samp or code around BEGIN AUTH REQUEST
232@c and friends, watch for overfull hboxes.
233If the client wishes to merely authenticate without starting the cvs
234protocol, the procedure is the same, except BEGIN AUTH REQUEST is
235replaced with BEGIN VERIFICATION REQUEST, END AUTH REQUEST
236is replaced with END VERIFICATION REQUEST, and upon receipt of
237I LOVE YOU the connection is closed rather than continuing.
238
239Another mechanism is GSSAPI authentication.  GSSAPI is a
240generic interface to security services such as kerberos.  GSSAPI is
241specified in RFC2078 (GSSAPI version 2) and RFC1508 (GSSAPI version 1);
242we are not aware of differences between the two which affect the
243protocol in incompatible ways, so we make no attempt to specify one
244version or the other.
245The procedure here is to start with @samp{BEGIN
246GSSAPI REQUEST}.  GSSAPI authentication information is then exchanged
247between the client and the server.  Each packet of information consists
248of a two byte big endian length, followed by that many bytes of data.
249After the GSSAPI authentication is complete, the server continues with
250the responses described above (@samp{I LOVE YOU}, etc.).
251
252@item future possibilities
253There are a nearly unlimited number of ways to connect and authenticate.
254One might want to allow access based on IP address (similar to the usual
255rsh protocol but with different/no restrictions on ports < 1024), to
256adopt mechanisms such as Pluggable Authentication Modules (PAM), to
257allow users to run their own servers under their own usernames without
258root access, or any number of other possibilities.  The way to add
259future mechanisms, for the most part, should be to continue to use port
2602401, but to use different strings in place of @samp{BEGIN AUTH
261REQUEST}.
262@end table
263
264@node Password scrambling
265@chapter Password scrambling algorithm
266
267The pserver authentication protocol, as described in @ref{Connection and
268Authentication}, trivially encodes the passwords.  This is only to
269prevent inadvertent compromise; it provides no protection against even a
270relatively unsophisticated attacker.  For comparison, HTTP Basic
271Authentication (as described in RFC2068) uses BASE64 for a similar
272purpose.  CVS uses its own algorithm, described here.
273
274The scrambled password starts with @samp{A}, which serves to identify
275the scrambling algorithm in use.  After that follows a single octet for
276each character in the password, according to a fixed encoding.  The
277values are shown here, with the encoded values in decimal.  Control
278characters, space, and characters outside the invariant ISO 646
279character set are not shown; such characters are not recommended for use
280in passwords.  There is a long discussion of character set issues in
281@ref{Protocol Notes}.
282
283@example
284        0 111           P 125           p  58
285! 120   1  52   A  57   Q  55   a 121   q 113
286"  53   2  75   B  83   R  54   b 117   r  32
287        3 119   C  43   S  66   c 104   s  90
288        4  49   D  46   T 124   d 101   t  44
289% 109   5  34   E 102   U 126   e 100   u  98
290&  72   6  82   F  40   V  59   f  69   v  60
291' 108   7  81   G  89   W  47   g  73   w  51
292(  70   8  95   H  38   X  92   h  99   x  33
293)  64   9  65   I 103   Y  71   i  63   y  97
294*  76   : 112   J  45   Z 115   j  94   z  62
295+  67   ;  86   K  50           k  93
296, 116   < 118   L  42           l  39
297-  74   = 110   M 123           m  37
298.  68   > 122   N  91           n  61
299/  87   ? 105   O  35   _  56   o  48
300@end example
301
302@node Protocol
303@chapter The CVS client/server protocol
304
305In the following, @samp{\n} refers to a linefeed and @samp{\t} refers to
306a horizontal tab; @dfn{requests} are what the client sends and
307@dfn{responses} are what the server sends.  In general, the connection is
308governed by the client---the server does not send responses without
309first receiving requests to do so; see @ref{Response intro} for more
310details of this convention.
311
312It is typical, early in the connection, for the client to transmit a
313@code{Valid-responses} request, containing all the responses it
314supports, followed by a @code{valid-requests} request, which elicits
315from the server a @code{Valid-requests} response containing all the
316requests it understands.  In this way, the client and server each find
317out what the other supports before exchanging large amounts of data
318(such as file contents).
319
320@c Hmm, having 3 sections in this menu makes a certain amount of sense
321@c but that structure gets lost in the printed manual (not sure about
322@c HTML).  Perhaps there is a better way.
323@menu
324
325General protocol conventions:
326
327* Entries Lines::                   Transmitting RCS data
328* File Modes::                      Read, write, execute, and possibly more...
329* Filenames::                       Conventions regarding filenames
330* File transmissions::              How file contents are transmitted
331* Strings::                         Strings in various requests and responses
332* Dates::                           Times and dates
333
334The protocol itself:
335
336* Request intro::                   General conventions relating to requests
337* Requests::                        List of requests
338* Response intro::                  General conventions relating to responses
339* Response pathnames::              The "pathname" in responses
340* Responses::                       List of responses
341* Text tags::                       More details about the MT response
342
343An example session, and some further observations:
344
345* Example::                         A conversation between client and server
346* Requirements::                    Things not to omit from an implementation
347* Obsolete::                        Former protocol features
348@end menu
349
350@node Entries Lines
351@section Entries Lines
352
353Entries lines are transmitted as:
354
355@example
356/ @var{name} / @var{version} / @var{conflict} / @var{options} / @var{tag_or_date}
357@end example
358
359@var{tag_or_date} is either @samp{T} @var{tag} or @samp{D} @var{date}
360or empty.  If it is followed by a slash, anything after the slash
361shall be silently ignored.
362
363@var{version} can be empty, or start with @samp{0} or @samp{-}, for no
364user file, new user file, or user file to be removed, respectively.
365
366@c FIXME: should distinguish sender and receiver behavior here; the
367@c "anything else" and "does not start with" are intended for future
368@c expansion, and we should specify a sender behavior.
369@var{conflict}, if it starts with @samp{+}, indicates that the file had
370conflicts in it.  The rest of @var{conflict} is @samp{=} if the
371timestamp matches the file, or anything else if it doesn't.  If
372@var{conflict} does not start with a @samp{+}, it is silently ignored.
373
374@var{options} signifies the keyword expansion options (for example
375@samp{-ko}).  In an @code{Entry} request, this indicates the options
376that were specified with the file from the previous file updating
377response (@pxref{Response intro}, for a list of file updating
378responses); if the client is specifying the @samp{-k} or @samp{-A}
379option to @code{update}, then it is the server which figures out what
380overrides what.
381
382@node File Modes
383@section File Modes
384
385A mode is any number of repetitions of
386
387@example
388@var{mode-type} = @var{data}
389@end example
390
391separated by @samp{,}.
392
393@var{mode-type} is an identifier composed of alphanumeric characters.
394Currently specified: @samp{u} for user, @samp{g} for group, @samp{o}
395for other (see below for discussion of whether these have their POSIX
396meaning or are more loose).  Unrecognized values of @var{mode-type}
397are silently ignored.
398
399@var{data} consists of any data not containing @samp{,}, @samp{\0} or
400@samp{\n}.  For @samp{u}, @samp{g}, and @samp{o} mode types, data
401consists of alphanumeric characters, where @samp{r} means read, @samp{w}
402means write, @samp{x} means execute, and unrecognized letters are
403silently ignored.
404
405The two most obvious ways in which the mode matters are: (1) is it
406writeable?  This is used by the developer communication features, and
407is implemented even on OS/2 (and could be implemented on DOS), whose
408notion of mode is limited to a readonly bit. (2) is it executable?
409Unix CVS users need CVS to store this setting (for shell scripts and
410the like).  The current CVS implementation on unix does a little bit
411more than just maintain these two settings, but it doesn't really have
412a nice general facility to store or version control the mode, even on
413unix, much less across operating systems with diverse protection
414features.  So all the ins and outs of what the mode means across
415operating systems haven't really been worked out (e.g. should the VMS
416port use ACLs to get POSIX semantics for groups?).
417
418@node Filenames
419@section Conventions regarding transmission of file names
420
421In most contexts, @samp{/} is used to separate directory and file
422names in filenames, and any use of other conventions (for example,
423that the user might type on the command line) is converted to that
424form.  The only exceptions might be a few cases in which the server
425provides a magic cookie which the client then repeats verbatim, but as
426the server has not yet been ported beyond unix, the two rules provide
427the same answer (and what to do if future server ports are operating
428on a repository like e:/foo or CVS_ROOT:[FOO.BAR] has not been
429carefully thought out).
430
431Characters outside the invariant ISO 646 character set should be avoided
432in filenames.  This restriction may need to be relaxed to allow for
433characters such as @samp{[} and @samp{]} (see above about non-unix
434servers); this has not been carefully considered (and currently
435implementations probably use whatever character sets that the operating
436systems they are running on allow, and/or that users specify).  Of
437course the most portable practice is to restrict oneself further, to the
438POSIX portable filename character set as specified in POSIX.1.
439
440@node File transmissions
441@section File transmissions
442
443File contents (noted below as @var{file transmission}) can be sent in
444one of two forms.  The simpler form is a number of bytes, followed by a
445linefeed, followed by the specified number of bytes of file contents.
446These are the entire contents of the specified file.  Second, if both
447client and server support @samp{gzip-file-contents}, a @samp{z} may
448precede the length, and the `file contents' sent are actually compressed
449with @samp{gzip} (RFC1952/1951) compression.  The length specified is
450that of the compressed version of the file.
451
452In neither case are the file content followed by any additional data.
453The transmission of a file will end with a linefeed iff that file (or its
454compressed form) ends with a linefeed.
455
456The encoding of file contents depends on the value for the @samp{-k}
457option.  If the file is binary (as specified by the @samp{-kb} option in
458the appropriate place), then it is just a certain number of octets, and
459the protocol contributes nothing towards determining the encoding (using
460the file name is one widespread, if not universally popular, mechanism).
461If the file is text (not binary), then the file is sent as a series of
462lines, separated by linefeeds.  If the keyword expansion is set to
463something other than @samp{-ko}, then it is expected that the file
464conform to the RCS expectations regarding keyword expansion---in
465particular, that it is in a character set such as ASCII in which 0x24 is
466a dollar sign (@samp{$}).
467
468@node Strings
469@section Strings
470
471In various contexts, for example the @code{Argument} request and the
472@code{M} response, one transmits what is essentially an arbitrary
473string.  Often this will have been supplied by the user (for example,
474the @samp{-m} option to the @code{ci} request).  The protocol has no
475mechanism to specify the character set of such strings; it would be
476fairly safe to stick to the invariant ISO 646 character set but the
477existing practice is probably to just transmit whatever the user
478specifies, and hope that everyone involved agrees which character set is
479in use, or sticks to a common subset.
480
481@node Dates
482@section Dates
483
484The protocol contains times and dates in various places.
485
486For the @samp{-D} option to the @code{annotate}, @code{co}, @code{diff},
487@code{export}, @code{history}, @code{rdiff}, @code{rtag}, @code{tag},
488and @code{update} requests, the server should support two formats:
489
490@example
49126 May 1997 13:01:40 -0000  ; @r{RFC 822 as modified by RFC 1123}
4925/26/1997 13:01:40 GMT    ; @r{traditional}
493@end example
494
495The former format is preferred; the latter however is sent by the CVS
496command line client (versions 1.5 through at least 1.9).
497
498For the @samp{-d} option to the @code{log} request, servers should at
499least support RFC 822/1123 format.  Clients are encouraged to use this
500format too (the command line CVS client, version 1.10 and older, just passed
501along the date format specified by the user, however).
502
503The @code{Mod-time} response and @code{Checkin-time} request use RFC
504822/1123 format (see the descriptions of that response and request for
505details).
506
507For @code{Notify}, see the description of that request.
508
509@node Request intro
510@section Request intro
511
512By convention, requests which begin with a capital letter do not elicit
513a response from the server, while all others do -- save one.  The
514exception is @samp{gzip-file-contents}.  Unrecognized requests will
515always elicit a response from the server, even if that request begins
516with a capital letter.
517
518The term @dfn{command} means a request which expects a response (except
519@code{valid-requests}).  The general model is that the client transmits
520a great number of requests, but nothing happens until the very end when
521the client transmits a command.  Although the intention is that
522transmitting several commands in one connection should be legal,
523existing servers probably have some bugs with some combinations of more
524than one command, and so clients may find it necessary to make several
525connections in some cases.  This should be thought of as a workaround
526rather than a desired attribute of the protocol.
527
528@node Requests
529@section Requests
530
531Here are the requests:
532
533@table @code
534@item Root @var{pathname} \n
535Response expected: no.  Tell the server which @code{CVSROOT} to use.
536Note that @var{pathname} is a local directory and @emph{not} a fully
537qualified @code{CVSROOT} variable.  @var{pathname} must
538already exist; if creating a new root, use the @code{init} request, not
539@code{Root}.  @var{pathname} does not include the hostname of the
540server, how to access the server, etc.; by the time the CVS protocol is
541in use, connection, authentication, etc., are already taken care of.
542
543The @code{Root} request must be sent only once, and it must be sent
544before any requests other than @code{Valid-responses},
545@code{valid-requests}, @code{UseUnchanged}, @code{Set},
546@code{Global_option}, @code{init}, @code{noop}, or @code{version}.
547
548@item Valid-responses @var{request-list} \n
549Response expected: no.
550Tell the server what responses the client will accept.
551request-list is a space separated list of tokens.
552The @code{Root} request need not have been previously sent.
553
554@item valid-requests \n
555Response expected: yes.
556Ask the server to send back a @code{Valid-requests} response.
557The @code{Root} request need not have been previously sent.
558
559@item Directory @var{local-directory} \n
560Additional data: @var{repository} \n.  Response expected: no.
561Tell the server what directory to use.  The @var{repository} should be a
562directory name from a previous server response.  Note that
563this both gives a default for @code{Entry} and @code{Modified} and
564also for @code{ci} and the other commands; normal usage is to send
565@code{Directory} for each directory in which there will be an
566@code{Entry} or @code{Modified}, and then a final @code{Directory}
567for the original directory, then the command.
568The @var{local-directory} is relative to
569the top level at which the command is occurring (i.e. the last
570@code{Directory} which is sent before the command);
571to indicate that top level, @samp{.} should be sent for
572@var{local-directory}.
573
574Here is an example of where a client gets @var{repository} and
575@var{local-directory}.  Suppose that there is a module defined by
576
577@example
578moddir 1dir
579@end example
580
581That is, one can check out @code{moddir} and it will take @code{1dir} in
582the repository and check it out to @code{moddir} in the working
583directory.  Then an initial check out could proceed like this:
584
585@example
586C: Root /home/kingdon/zwork/cvsroot
587. . .
588C: Argument moddir
589C: Directory .
590C: /home/kingdon/zwork/cvsroot
591C: co
592S: Clear-sticky moddir/
593S: /home/kingdon/zwork/cvsroot/1dir/
594. . .
595S: ok
596@end example
597
598In this example the response shown is @code{Clear-sticky}, but it could
599be another response instead.  Note that it returns two pathnames.
600The first one, @file{moddir/}, indicates the working
601directory to check out into.  The second one, ending in @file{1dir/},
602indicates the directory to pass back to the server in a subsequent
603@code{Directory} request.  For example, a subsequent @code{update}
604request might look like:
605
606@example
607C: Directory moddir
608C: /home/kingdon/zwork/cvsroot/1dir
609. . .
610C: update
611@end example
612
613For a given @var{local-directory}, the repository will be the same for
614each of the responses, so one can use the repository from whichever
615response is most convenient.  Typically a client will store the
616repository along with the sources for each @var{local-directory}, use
617that same setting whenever operating on that @var{local-directory}, and
618not update the setting as long as the @var{local-directory} exists.
619
620A client is free to rename a @var{local-directory} at any time (for
621example, in response to an explicit user request).  While it is true
622that the server supplies a @var{local-directory} to the client, as noted
623above, this is only the default place to put the directory.  Of course,
624the various @code{Directory} requests for a single command (for example,
625@code{update} or @code{ci} request) should name a particular directory
626with the same @var{local-directory}.
627
628Each @code{Directory} request specifies a brand-new
629@var{local-directory} and @var{repository}; that is,
630@var{local-directory} and @var{repository} are never relative to paths
631specified in any previous @code{Directory} request.
632
633Here's a more complex example, in which we request an update of a
634working directory which has been checked out from multiple places in the
635repository.
636
637@example
638C: Argument dir1
639C: Directory dir1
640C: /home/foo/repos/mod1
641. . .
642C: Argument dir2
643C: Directory dir2
644C: /home/foo/repos/mod2
645. . .
646C: Argument dir3
647C: Directory dir3/subdir3
648C: /home/foo/repos/mod3
649. . .
650C: update
651@end example
652
653While directories @code{dir1} and @code{dir2} will be handled in similar
654fashion to the other examples given above, @code{dir3} is slightly
655different from the server's standpoint.  Notice that module @code{mod3}
656is actually checked out into @code{dir3/subdir3}, meaning that directory
657@code{dir3} is either empty or does not contain data checked out from
658this repository.
659
660The above example will work correctly in @sc{cvs} 1.10.1 and later.  The
661server will descend the tree starting from all directories mentioned in
662@code{Argument} requests and update those directories specifically
663mentioned in @code{Directory} requests.
664
665Previous versions of @sc{cvs} (1.10 and earlier) do not behave the same
666way.  While the descent of the tree begins at all directories mentioned
667in @code{Argument} requests, descent into subdirectories only occurs if
668a directory has been mentioned in a @code{Directory} request.
669Therefore, the above example would succeed in updating @code{dir1} and
670@code{dir2}, but would skip @code{dir3} because that directory was not
671specifically mentioned in a @code{Directory} request.  A functional
672version of the above that would run on a 1.10 or earlier server is as
673follows:
674
675@example
676C: Argument dir1
677C: Directory dir1
678C: /home/foo/repos/mod1
679. . .
680C: Argument dir2
681C: Directory dir2
682C: /home/foo/repos/mod2
683. . .
684C: Argument dir3
685C: Directory dir3
686C: /home/foo/repos/.
687. . .
688C: Directory dir3/subdir3
689C: /home/foo/repos/mod3
690. . .
691C: update
692@end example
693
694Note the extra @code{Directory dir3} request.  It might be better to use
695@code{Emptydir} as the repository for the @code{dir3} directory, but the
696above will certainly work.
697
698One more peculiarity of the 1.10 and earlier protocol is the ordering of
699@code{Directory} arguments.  In order for a subdirectory to be
700registered correctly for descent by the recursion processor, its parent
701must be sent first.  For example, the following would not work to update
702@code{dir3/subdir3}:
703
704@example
705. . .
706C: Argument dir3
707C: Directory dir3/subdir3
708C: /home/foo/repos/mod3
709. . .
710C: Directory dir3
711C: /home/foo/repos/.
712. . .
713C: update
714@end example
715
716The implementation of the server in 1.10 and earlier writes the
717administration files for a given directory at the time of the
718@code{Directory} request.  It also tries to register the directory with
719its parent to mark it for recursion.  In the above example, at the time
720@code{dir3/subdir3} is created, the physical directory for @code{dir3}
721will be created on disk, but the administration files will not have been
722created.  Therefore, when the server tries to register
723@code{dir3/subdir3} for recursion, the operation will silently fail
724because the administration files do not yet exist for @code{dir3}.
725
726@item Max-dotdot @var{level} \n
727Response expected: no.
728Tell the server that @var{level} levels of directories above the
729directory which @code{Directory} requests are relative to will be
730needed.  For example, if the client is planning to use a
731@code{Directory} request for @file{../../foo}, it must send a
732@code{Max-dotdot} request with a @var{level} of at least 2.
733@code{Max-dotdot} must be sent before the first @code{Directory}
734request.
735
736@item Static-directory \n
737Response expected: no.  Tell the server that the directory most recently
738specified with @code{Directory} should not have
739additional files checked out unless explicitly requested.  The client
740sends this if the @code{Entries.Static} flag is set, which is controlled
741by the @code{Set-static-directory} and @code{Clear-static-directory}
742responses.
743
744@item Sticky @var{tagspec} \n
745Response expected: no.  Tell the server that the directory most recently
746specified with @code{Directory} has a sticky tag or date @var{tagspec}.
747The first character of @var{tagspec} is @samp{T} for a tag, @samp{D}
748for a date, or some other character supplied by a Set-sticky response
749from a previous request to the server.  The remainder of @var{tagspec}
750contains the actual tag or date, again as supplied by Set-sticky.
751
752The server should remember @code{Static-directory} and @code{Sticky}
753requests for a particular directory; the client need not resend them
754each time it sends a @code{Directory} request for a given directory.
755However, the server is not obliged to remember them beyond the context
756of a single command.
757
758@item Checkin-prog @var{program} \n
759Response expected: no.  Tell the server that the directory most recently
760specified with @code{Directory} has a checkin program @var{program}.
761Such a program would have been previously set with the
762@code{Set-checkin-prog} response.
763
764@item Update-prog @var{program} \n
765Response expected: no.  Tell the server that the directory most recently
766specified with @code{Directory} has an update program @var{program}.
767Such a program would have been previously set with the
768@code{Set-update-prog} response.
769
770@item Entry @var{entry-line} \n
771Response expected: no.  Tell the server what version of a file is on the
772local machine.  The name in @var{entry-line} is a name relative to the
773directory most recently specified with @code{Directory}.  If the user
774is operating on only some files in a directory, @code{Entry} requests
775for only those files need be included.  If an @code{Entry} request is
776sent without @code{Modified}, @code{Is-modified}, or @code{Unchanged},
777it means the file is
778lost (does not exist in the working directory).  If both @code{Entry}
779and one of @code{Modified}, @code{Is-modified}, or @code{Unchanged} are
780sent for the same file, @code{Entry} must be sent first.  For a
781given file, one can send @code{Modified}, @code{Is-modified}, or
782@code{Unchanged}, but not more than one of these three.
783
784@item Kopt @var{option} \n
785This indicates to the server which keyword expansion options to use for
786the file specified by the next @code{Modified} or @code{Is-modified}
787request (for example @samp{-kb} for a binary file).  This is similar to
788@code{Entry}, but is used for a file for which there is no entries line.
789Typically this will be a file being added via an @code{add} or
790@code{import} request.  The client may not send both @code{Kopt} and
791@code{Entry} for the same file.
792
793@item Checkin-time @var{time} \n
794For the file specified by the next @code{Modified} request, use
795@var{time} as the time of the checkin.  The @var{time} is in the format
796specified by RFC822 as modified by RFC1123.  The client may specify any
797timezone it chooses; servers will want to convert that to their own
798timezone as appropriate.  An example of this format is:
799
800@example
80126 May 1997 13:01:40 -0400
802@end example
803
804There is no requirement that the client and server clocks be
805synchronized.  The client just sends its recommendation for a timestamp
806(based on file timestamps or whatever), and the server should just believe
807it (this means that the time might be in the future, for example).
808
809Note that this is not a general-purpose way to tell the server about the
810timestamp of a file; that would be a separate request (if there are
811servers which can maintain timestamp and time of checkin separately).
812
813This request should affect the @code{import} request, and may optionally
814affect the @code{ci} request or other relevant requests if any.
815
816@item Modified @var{filename} \n
817Response expected: no.  Additional data: mode, \n, file transmission.
818Send the server a copy of one locally modified file.  @var{filename} is
819a file within the most recent directory sent with @code{Directory}; it
820must not contain @samp{/}.  If
821the user is operating on only some files in a directory, only those
822files need to be included.  This can also be sent without @code{Entry},
823if there is no entry for the file.
824
825@item Is-modified @var{filename} \n
826Response expected: no.  Additional data: none.  Like @code{Modified},
827but used if the server only needs
828to know whether the file is modified, not the contents.
829
830The commands which can take @code{Is-modified} instead of
831@code{Modified} with no known change in behavior are: @code{admin},
832@code{diff} (if and only if two @samp{-r} or @samp{-D} options are
833specified), @code{watch-on}, @code{watch-off}, @code{watch-add},
834@code{watch-remove}, @code{watchers}, @code{editors},
835@code{log}, and @code{annotate}.
836
837For the @code{status} command, one can send @code{Is-modified} but if
838the client is using imperfect mechanisms such as timestamps to determine
839whether to consider a file modified, then the behavior will be
840different.  That is, if one sends @code{Modified}, then the server will
841actually compare the contents of the file sent and the one it derives
842from to determine whether the file is genuinely modified.  But if one
843sends @code{Is-modified}, then the server takes the client's word for
844it.  A similar situation exists for @code{tag}, if the @samp{-c} option
845is specified.
846
847Commands for which @code{Modified} is necessary are @code{co},
848@code{ci}, @code{update}, and @code{import}.
849
850Commands which do not need to inform the server about a working
851directory, and thus should not be sending either @code{Modified} or
852@code{Is-modified}: @code{rdiff}, @code{rtag}, @code{history},
853@code{init}, and @code{release}.
854
855Commands for which further investigation is warranted are:
856@code{remove}, @code{add}, and @code{export}.  Pending such
857investigation, the more conservative course of action is to stick to
858@code{Modified}.
859
860@item Unchanged @var{filename} \n
861Response expected: no.  Tell the server that @var{filename} has not been
862modified in the checked out directory.  The @var{filename} is
863a file within the most recent directory sent with @code{Directory}; it
864must not contain @samp{/}.
865
866@item UseUnchanged \n
867Response expected: no.  To specify the version of the protocol described
868in this document, servers must support this request (although it need
869not do anything) and clients must issue it.
870The @code{Root} request need not have been previously sent.
871
872@item Notify @var{filename} \n
873Response expected: no.
874Tell the server that an @code{edit} or @code{unedit} command has taken
875place.  The server needs to send a @code{Notified} response, but such
876response is deferred until the next time that the server is sending
877responses.
878The @var{filename} is a file within the most recent directory sent with
879@code{Directory}; it must not contain @samp{/}.
880Additional data:
881@example
882@var{notification-type} \t @var{time} \t @var{clienthost} \t
883@var{working-dir} \t @var{watches} \n
884@end example
885where @var{notification-type} is @samp{E} for edit, @samp{U} for
886unedit, undefined behavior if @samp{C}, and all other letters should be
887silently ignored for future expansion.
888@var{time} is the time at which the edit or unedit took place, in a
889user-readable format of the client's choice (the server should treat the
890time as an opaque string rather than interpreting it).
891@c Might be useful to specify a format, but I don't know if we want to
892@c specify the status quo (ISO C asctime() format plus timezone) without
893@c offering the option of ISO8601 and/or RFC822/1123 (see cvs.texinfo
894@c for much much more on date formats).
895@var{clienthost} is the name of the host on which the edit or unedit
896took place, and @var{working-dir} is the pathname of the working
897directory where the edit or unedit took place.  @var{watches} are the
898temporary watches, zero or more of the following characters in the
899following order: @samp{E} for edit, @samp{U} for unedit, @samp{C} for
900commit, and all other letters should be silently ignored for future
901expansion.  If @var{notification-type} is @samp{E} the temporary watches
902are set; if it is @samp{U} they are cleared.
903If @var{watches} is followed by \t then the
904\t and the rest of the line should be ignored, for future expansion.
905
906The @var{time}, @var{clienthost}, and @var{working-dir} fields may not
907contain the characters @samp{+}, @samp{,}, @samp{>}, @samp{;}, or @samp{=}.
908
909Note that a client may be capable of performing an @code{edit} or
910@code{unedit} operation without connecting to the server at that time,
911and instead connecting to the server when it is convenient (for example,
912when a laptop is on the net again) to send the @code{Notify} requests.
913Even if a client is capable of deferring notifications, it should
914attempt to send them immediately (one can send @code{Notify} requests
915together with a @code{noop} request, for example), unless perhaps if
916it can know that a connection would be impossible.
917
918@item Questionable @var{filename} \n
919Response expected: no.  Additional data: no.  Tell the server to check
920whether @var{filename} should be ignored, and if not, next time the
921server sends responses, send (in a @code{M} response) @samp{?} followed
922by the directory and filename.  @var{filename} must not contain
923@samp{/}; it needs to be a file in the directory named by the most
924recent @code{Directory} request.
925@c FIXME: the bit about not containing / is true of most of the
926@c requests, but isn't documented and should be.
927
928@item Case \n
929Response expected: no.  Tell the server that filenames should be matched
930in a case-insensitive fashion.  Note that this is not the primary
931mechanism for achieving case-insensitivity; for the most part the client
932keeps track of the case which the server wants to use and takes care to
933always use that case regardless of what the user specifies.  For example
934the filenames given in @code{Entry} and @code{Modified} requests for the
935same file must match in case regardless of whether the @code{Case}
936request is sent.  The latter mechanism is more general (it could also be
937used for 8.3 filenames, VMS filenames with more than one @samp{.}, and
938any other situation in which there is a predictable mapping between
939filenames in the working directory and filenames in the protocol), but
940there are some situations it cannot handle (ignore patterns, or
941situations where the user specifies a filename and the client does not
942know about that file).
943
944@item Argument @var{text} \n
945Response expected: no.
946Save argument for use in a subsequent command.  Arguments
947accumulate until an argument-using command is given, at which point
948they are forgotten.
949
950@item Argumentx @var{text} \n
951Response expected: no.  Append \n followed by text to the current
952argument being saved.
953
954@item Global_option @var{option} \n
955Response expected: no.
956Transmit one of the global options @samp{-q}, @samp{-Q}, @samp{-l},
957@samp{-t}, @samp{-r}, or @samp{-n}.  @var{option} must be one of those
958strings, no variations (such as combining of options) are allowed.  For
959graceful handling of @code{valid-requests}, it is probably better to
960make new global options separate requests, rather than trying to add
961them to this request.
962The @code{Root} request need not have been previously sent.
963
964@item Gzip-stream @var{level} \n
965Response expected: no.
966Use zlib (RFC 1950/1951) compression to compress all further communication
967between the client and the server.  After this request is sent, all
968further communication must be compressed.  All further data received
969from the server will also be compressed.  The @var{level} argument
970suggests to the server the level of compression that it should apply; it
971should be an integer between 1 and 9, inclusive, where a higher number
972indicates more compression.
973
974@item Kerberos-encrypt \n
975Response expected: no.
976Use Kerberos encryption to encrypt all further communication between the
977client and the server.  This will only work if the connection was made
978over Kerberos in the first place.  If both the @code{Gzip-stream} and
979the @code{Kerberos-encrypt} requests are used, the
980@code{Kerberos-encrypt} request should be used first.  This will make
981the client and server encrypt the compressed data, as opposed to
982compressing the encrypted data.  Encrypted data is generally
983incompressible.
984
985Note that this request does not fully prevent an attacker from hijacking
986the connection, in the sense that it does not prevent hijacking the
987connection between the initial authentication and the
988@code{Kerberos-encrypt} request.
989
990@item Gssapi-encrypt \n
991Response expected: no.
992Use GSSAPI encryption to encrypt all further communication between the
993client and the server.  This will only work if the connection was made
994over GSSAPI in the first place.  See @code{Kerberos-encrypt}, above, for
995the relation between @code{Gssapi-encrypt} and @code{Gzip-stream}.
996
997Note that this request does not fully prevent an attacker from hijacking
998the connection, in the sense that it does not prevent hijacking the
999connection between the initial authentication and the
1000@code{Gssapi-encrypt} request.
1001
1002@item Gssapi-authenticate \n
1003Response expected: no.
1004Use GSSAPI authentication to authenticate all further communication
1005between the client and the server.  This will only work if the
1006connection was made over GSSAPI in the first place.  Encrypted data is
1007automatically authenticated, so using both @code{Gssapi-authenticate}
1008and @code{Gssapi-encrypt} has no effect beyond that of
1009@code{Gssapi-encrypt}.  Unlike encrypted data, it is reasonable to
1010compress authenticated data.
1011
1012Note that this request does not fully prevent an attacker from hijacking
1013the connection, in the sense that it does not prevent hijacking the
1014connection between the initial authentication and the
1015@code{Gssapi-authenticate} request.
1016
1017@item Set @var{variable}=@var{value} \n
1018Response expected: no.
1019Set a user variable @var{variable} to @var{value}.
1020The @code{Root} request need not have been previously sent.
1021
1022@item expand-modules \n
1023Response expected: yes.  Expand the modules which are specified in the
1024arguments.  Returns the data in @code{Module-expansion} responses.  Note
1025that the server can assume that this is checkout or export, not rtag or
1026rdiff; the latter do not access the working directory and thus have no
1027need to expand modules on the client side.
1028
1029Expand may not be the best word for what this request does.  It does not
1030necessarily tell you all the files contained in a module, for example.
1031Basically it is a way of telling you which working directories the
1032server needs to know about in order to handle a checkout of the
1033specified modules.
1034
1035For example, suppose that the server has a module defined by
1036
1037@example
1038aliasmodule -a 1dir
1039@end example
1040
1041That is, one can check out @code{aliasmodule} and it will take
1042@code{1dir} in the repository and check it out to @code{1dir} in the
1043working directory.  Now suppose the client already has this module
1044checked out and is planning on using the @code{co} request to update it.
1045Without using @code{expand-modules}, the client would have two bad
1046choices: it could either send information about @emph{all} working
1047directories under the current directory, which could be unnecessarily
1048slow, or it could be ignorant of the fact that @code{aliasmodule} stands
1049for @code{1dir}, and neglect to send information for @code{1dir}, which
1050would lead to incorrect operation.
1051@c Those don't really seem like the only two options.  I mean, what
1052@c about keeping track of the correspondence from when we first checked
1053@c out a fresh directory?  Not that the CVS client does this, or that
1054@c I've really thought about whether it would be a good idea...
1055
1056With @code{expand-modules}, the client would first ask for the module to
1057be expanded:
1058
1059@example
1060C: Root /home/kingdon/zwork/cvsroot
1061. . .
1062C: Argument aliasmodule
1063C: Directory .
1064C: /home/kingdon/zwork/cvsroot
1065C: expand-modules
1066S: Module-expansion 1dir
1067S: ok
1068@end example
1069
1070and then it knows to check the @file{1dir} directory and send
1071requests such as @code{Entry} and @code{Modified} for the files in that
1072directory.
1073
1074@item ci \n
1075@itemx diff \n
1076@itemx tag \n
1077@itemx status \n
1078@itemx admin \n
1079@itemx history \n
1080@itemx watchers \n
1081@itemx editors \n
1082@itemx annotate \n
1083Response expected: yes.  Actually do a cvs command.  This uses any
1084previous @code{Argument}, @code{Directory}, @code{Entry}, or
1085@code{Modified} requests, if they have been sent.  The
1086last @code{Directory} sent specifies the working directory at the time
1087of the operation.  No provision is made for any input from the user.
1088This means that @code{ci} must use a @code{-m} argument if it wants to
1089specify a log message.
1090
1091@item log \n
1092Response expected: yes.  Show information for past revisions.  This uses
1093any previous @code{Directory}, @code{Entry}, or @code{Modified}
1094requests, if they have been sent.  The last @code{Directory} sent
1095specifies the working directory at the time of the operation.  Also uses
1096previous @code{Argument}'s of which the canonical forms are the
1097following (@sc{cvs} 1.10 and older clients sent what the user specified,
1098but clients are encouraged to use the canonical forms and other forms
1099are deprecated):
1100
1101@table @code
1102@item -b, -h, -l, -N, -R, -t
1103These options go by themselves, one option per @code{Argument} request.
1104
1105@item -d @var{date1}<@var{date2}
1106Select revisions between @var{date1} and @var{date2}.  Either date
1107may be omitted in which case there is no date limit at that end of the
1108range (clients may specify dates such as 1 Jan 1970 or 1 Jan 2038 for
1109similar purposes but this is problematic as it makes assumptions about
1110what dates the server supports).  Dates are in RFC822/1123 format.  The
1111@samp{-d} is one @code{Argument} request and the date range is a second
1112one.
1113
1114@item -d @var{date1}<=@var{date2}
1115Likewise but compare dates for equality.
1116
1117@item -d @var{singledate}
1118Select the single, latest revision dated @var{singledate} or earlier.
1119
1120To include several date ranges and/or singledates, repeat the @samp{-d}
1121option as many times as necessary.
1122
1123@item -r@var{rev1}:@var{rev2}
1124@itemx -r@var{branch}
1125@itemx -r@var{branch}.
1126@itemx -r
1127Specify revisions (note that @var{rev1} or @var{rev2} can be omitted, or
1128can refer to branches).  Send both the @samp{-r} and the revision
1129information in a single @code{Argument} request.  To include several
1130revision selections, repeat the @samp{-r} option.
1131
1132@item -s @var{state}
1133@itemx -w
1134@itemx -w@var{login}
1135Select on states or users.  To include more than one state or user,
1136repeat the option.  Send the @samp{-s} option as a separate argument
1137from the state being selected.  Send the @samp{-w} option as part of the
1138same argument as the user being selected.
1139@end table
1140
1141@item co \n
1142Response expected: yes.  Get files from the repository.  This uses any
1143previous @code{Argument}, @code{Directory}, @code{Entry}, or
1144@code{Modified} requests, if they have been sent.  Arguments to this
1145command are module names; the client cannot know what directories they
1146correspond to except by (1) just sending the @code{co} request, and then
1147seeing what directory names the server sends back in its responses, and
1148(2) the @code{expand-modules} request.
1149
1150@item export \n
1151Response expected: yes.  Get files from the repository.  This uses any
1152previous @code{Argument}, @code{Directory}, @code{Entry}, or
1153@code{Modified} requests, if they have been sent.  Arguments to this
1154command are module names, as described for the @code{co} request.  The
1155intention behind this command is that a client can get sources from a
1156server without storing CVS information about those sources.  That is, a
1157client probably should not count on being able to take the entries line
1158returned in the @code{Created} response from an @code{export} request
1159and send it in a future @code{Entry} request.  Note that the entries
1160line in the @code{Created} response must indicate whether the file is
1161binary or text, so the client can create it correctly.
1162
1163@item rdiff \n
1164@itemx rtag \n
1165Response expected: yes.  Actually do a cvs command.  This uses any
1166previous @code{Argument} requests, if they have been sent.  The client
1167should not send @code{Directory}, @code{Entry}, or @code{Modified}
1168requests for this command; they are not used.  Arguments to these
1169commands are module names, as described for @code{co}.
1170
1171@item init @var{root-name} \n
1172Response expected: yes.  If it doesn't already exist, create a @sc{cvs}
1173repository @var{root-name}.  Note that @var{root-name} is a local
1174directory and @emph{not} a fully qualified @code{CVSROOT} variable.
1175The @code{Root} request need not have been previously sent.
1176
1177@item update \n
1178Response expected: yes.  Actually do a @code{cvs update} command.  This
1179uses any previous @code{Argument}, @code{Directory}, @code{Entry},
1180or @code{Modified} requests, if they have been sent.  The
1181last @code{Directory} sent specifies the working directory at the time
1182of the operation.  The @code{-I} option is not used--files which the
1183client can decide whether to ignore are not mentioned and the client
1184sends the @code{Questionable} request for others.
1185
1186@item import \n
1187Response expected: yes.  Actually do a @code{cvs import} command.  This
1188uses any previous @code{Argument}, @code{Directory}, @code{Entry}, or
1189@code{Modified} requests, if they have been sent.  The
1190last @code{Directory} sent specifies the working directory at the time
1191of the operation - unlike most commands, the repository field of each
1192@code{Directory} request is ignored (it merely must point somewhere
1193within the root).  The files to be imported are sent in @code{Modified}
1194requests (files which the client knows should be ignored are not sent;
1195the server must still process the CVSROOT/cvsignore file unless -I ! is
1196sent).  A log message must have been specified with a @code{-m}
1197argument.
1198
1199@item add \n
1200Response expected: yes.  Add a file or directory.  This uses any
1201previous @code{Argument}, @code{Directory}, @code{Entry}, or
1202@code{Modified} requests, if they have been sent.  The
1203last @code{Directory} sent specifies the working directory at the time
1204of the operation.
1205
1206To add a directory, send the directory to be added using
1207@code{Directory} and @code{Argument} requests.  For example:
1208
1209@example
1210C: Root /u/cvsroot
1211. . .
1212C: Argument nsdir
1213C: Directory nsdir
1214C: /u/cvsroot/1dir/nsdir
1215C: Directory .
1216C: /u/cvsroot/1dir
1217C: add
1218S: M Directory /u/cvsroot/1dir/nsdir added to the repository
1219S: ok
1220@end example
1221
1222You will notice that the server does not signal to the client in any
1223particular way that the directory has been successfully added.  The
1224client is supposed to just assume that the directory has been added and
1225update its records accordingly.  Note also that adding a directory is
1226immediate; it does not wait until a @code{ci} request as files do.
1227
1228To add a file, send the file to be added using a @code{Modified}
1229request.  For example:
1230
1231@example
1232C: Argument nfile
1233C: Directory .
1234C: /u/cvsroot/1dir
1235C: Modified nfile
1236C: u=rw,g=r,o=r
1237C: 6
1238C: hello
1239C: add
1240S: E cvs server: scheduling file `nfile' for addition
1241S: Mode u=rw,g=r,o=r
1242S: Checked-in ./
1243S: /u/cvsroot/1dir/nfile
1244S: /nfile/0///
1245S: E cvs server: use 'cvs commit' to add this file permanently
1246S: ok
1247@end example
1248
1249Note that the file has not been added to the repository; the only effect
1250of a successful @code{add} request, for a file, is to supply the client
1251with a new entries line containing @samp{0} to indicate an added file.
1252In fact, the client probably could perform this operation without
1253contacting the server, although using @code{add} does cause the server
1254to perform a few more checks.
1255
1256The client sends a subsequent @code{ci} to actually add the file to the
1257repository.
1258
1259Another quirk of the @code{add} request is that with CVS 1.9 and older,
1260a pathname specified in
1261an @code{Argument} request cannot contain @samp{/}.  There is no good
1262reason for this restriction, and in fact more recent CVS servers don't
1263have it.
1264But the way to interoperate with the older servers is to ensure that
1265all @code{Directory} requests for @code{add} (except those used to add
1266directories, as described above), use @samp{.} for
1267@var{local-directory}.  Specifying another string for
1268@var{local-directory} may not get an error, but it will get you strange
1269@code{Checked-in} responses from the buggy servers.
1270
1271@item remove \n
1272Response expected: yes.  Remove a file.  This uses any
1273previous @code{Argument}, @code{Directory}, @code{Entry}, or
1274@code{Modified} requests, if they have been sent.  The
1275last @code{Directory} sent specifies the working directory at the time
1276of the operation.
1277
1278Note that this request does not actually do anything to the repository;
1279the only effect of a successful @code{remove} request is to supply the
1280client with a new entries line containing @samp{-} to indicate a removed
1281file.  In fact, the client probably could perform this operation without
1282contacting the server, although using @code{remove} may cause the server
1283to perform a few more checks.
1284
1285The client sends a subsequent @code{ci} request to actually record the
1286removal in the repository.
1287
1288@item watch-on \n
1289@itemx watch-off \n
1290@itemx watch-add \n
1291@itemx watch-remove \n
1292Response expected: yes.  Actually do the @code{cvs watch on}, @code{cvs
1293watch off}, @code{cvs watch add}, and @code{cvs watch remove} commands,
1294respectively.  This uses any previous @code{Argument},
1295@code{Directory}, @code{Entry}, or @code{Modified}
1296requests, if they have been sent.  The last @code{Directory} sent
1297specifies the working directory at the time of the operation.
1298
1299@item release \n
1300Response expected: yes.  Note that a @code{cvs release} command has
1301taken place and update the history file accordingly.
1302
1303@item noop \n
1304Response expected: yes.  This request is a null command in the sense
1305that it doesn't do anything, but merely (as with any other requests
1306expecting a response) sends back any responses pertaining to pending
1307errors, pending @code{Notified} responses, etc.
1308The @code{Root} request need not have been previously sent.
1309
1310@item update-patches \n
1311Response expected: yes.
1312This request does not actually do anything.  It is used as a signal that
1313the server is able to generate patches when given an @code{update}
1314request.  The client must issue the @code{-u} argument to @code{update}
1315in order to receive patches.
1316
1317@item gzip-file-contents @var{level} \n
1318Response expected: no.  Note that this request does not follow the
1319response convention stated above.  @code{Gzip-stream} is suggested
1320instead of @code{gzip-file-contents} as it gives better compression; the
1321only reason to implement the latter is to provide compression with
1322@sc{cvs} 1.8 and earlier.  The @code{gzip-file-contents} request asks
1323the server to compress files it sends to the client using @code{gzip}
1324(RFC1952/1951) compression, using the specified level of compression.
1325If this request is not made, the server must not compress files.
1326
1327This is only a hint to the server.  It may still decide (for example, in
1328the case of very small files, or files that already appear to be
1329compressed) not to do the compression.  Compression is indicated by a
1330@samp{z} preceding the file length.
1331
1332Availability of this request in the server indicates to the client that
1333it may compress files sent to the server, regardless of whether the
1334client actually uses this request.
1335
1336@item wrapper-sendme-rcsOptions \n
1337Response expected: yes.
1338Request that the server transmit mappings from filenames to keyword
1339expansion modes in @code{Wrapper-rcsOption} responses.
1340
1341@item version \n
1342Response expected: yes.
1343Request that the server transmit its version message.
1344The @code{Root} request need not have been previously sent.
1345
1346@item @var{other-request} @var{text} \n
1347Response expected: yes.
1348Any unrecognized request expects a response, and does not
1349contain any additional data.  The response will normally be something like
1350@samp{error  unrecognized request}, but it could be a different error if
1351a previous request which doesn't expect a response produced an error.
1352@end table
1353
1354When the client is done, it drops the connection.
1355
1356@node Response intro
1357@section Introduction to Responses
1358
1359After a command which expects a response, the server sends however many
1360of the following responses are appropriate.  The server should not send
1361data at other times (the current implementation may violate this
1362principle in a few minor places, where the server is printing an error
1363message and exiting---this should be investigated further).
1364
1365Any set of responses always ends with @samp{error} or @samp{ok}.  This
1366indicates that the response is over.
1367
1368@c "file updating response" and "file update modifying response" are
1369@c lame terms (mostly because they are so awkward).  Any better ideas?
1370The responses @code{Checked-in}, @code{New-entry}, @code{Updated},
1371@code{Created}, @code{Update-existing}, @code{Merged}, and
1372@code{Patched} are refered to as @dfn{file updating} responses, because
1373they change the status of a file in the working directory in some way.
1374The responses @code{Mode}, @code{Mod-time}, and @code{Checksum} are
1375referred to as @dfn{file update modifying} responses because they modify
1376the next file updating response.  In no case shall a file update
1377modifying response apply to a file updating response other than the next
1378one.  Nor can the same file update modifying response occur twice for
1379a given file updating response (if servers diagnose this problem, it may
1380aid in detecting the case where clients send an update modifying
1381response without following it by a file updating response).
1382
1383@node Response pathnames
1384@section The "pathname" in responses
1385
1386Many of the responses contain something called @var{pathname}.
1387@c FIXME: should better document when the specified repository needs to
1388@c end in "/.".
1389The name is somewhat misleading; it actually indicates a pair of
1390pathnames.  First, a local directory name
1391relative to the directory in which the command was given (i.e. the last
1392@code{Directory} before the command).  Then a linefeed and a repository
1393name.  Then
1394a slash and the filename (without a @samp{,v} ending).
1395For example, for a file @file{i386.mh}
1396which is in the local directory @file{gas.clean/config} and for which
1397the repository is @file{/rel/cvsfiles/devo/gas/config}:
1398
1399@example
1400gas.clean/config/
1401/rel/cvsfiles/devo/gas/config/i386.mh
1402@end example
1403
1404If the server wants to tell the client to create a directory, then it
1405merely uses the directory in any response, as described above, and the
1406client should create the directory if it does not exist.  Note that this
1407should only be done one directory at a time, in order to permit the
1408client to correctly store the repository for each directory.  Servers
1409can use requests such as @code{Clear-sticky},
1410@code{Clear-static-directory}, or any other requests, to create
1411directories.
1412@c FIXME: Need example here of how "repository" needs to be sent for
1413@c each directory, and cannot be correctly deduced from, say, the most
1414@c deeply nested directory.
1415
1416Some server
1417implementations may poorly distinguish between a directory which should
1418not exist and a directory which contains no files; in order to refrain
1419from creating empty directories a client should both send the @samp{-P}
1420option to @code{update} or @code{co}, and should also detect the case in
1421which the server asks to create a directory but not any files within it
1422(in that case the client should remove the directory or refrain from
1423creating it in the first place).  Note that servers could clean this up
1424greatly by only telling the client to create directories if the
1425directory in question should exist, but until servers do this, clients
1426will need to offer the @samp{-P} behavior described above.
1427
1428@node Responses
1429@section Responses
1430
1431Here are the responses:
1432
1433@table @code
1434@item Valid-requests @var{request-list} \n
1435Indicate what requests the server will accept.  @var{request-list}
1436is a space separated list of tokens.  If the server supports sending
1437patches, it will include @samp{update-patches} in this list.  The
1438@samp{update-patches} request does not actually do anything.
1439
1440@item Checked-in @var{pathname} \n
1441Additional data: New Entries line, \n.  This means a file @var{pathname}
1442has been successfully operated on (checked in, added, etc.).  name in
1443the Entries line is the same as the last component of @var{pathname}.
1444
1445@item New-entry @var{pathname} \n
1446Additional data: New Entries line, \n.  Like @code{Checked-in}, but the
1447file is not up to date.
1448
1449@item Updated @var{pathname} \n
1450Additional data: New Entries line, \n, mode, \n, file transmission.  A
1451new copy of the file is enclosed.  This is used for a new revision of an
1452existing file, or for a new file, or for any other case in which the
1453local (client-side) copy of the file needs to be updated, and after
1454being updated it will be up to date.  If any directory in pathname does
1455not exist, create it.  This response is not used if @code{Created} and
1456@code{Update-existing} are supported.
1457
1458@item Created @var{pathname} \n
1459This is just like @code{Updated} and takes the same additional data, but
1460is used only if no @code{Entry}, @code{Modified}, or
1461@code{Unchanged} request has been sent for the file in question.  The
1462distinction between @code{Created} and @code{Update-existing} is so
1463that the client can give an error message in several cases: (1) there is
1464a file in the working directory, but not one for which @code{Entry},
1465@code{Modified}, or @code{Unchanged} was sent (for example, a file which
1466was ignored, or a file for which @code{Questionable} was sent), (2)
1467there is a file in the working directory whose name differs from the one
1468mentioned in @code{Created} in ways that the client is unable to use to
1469distinguish files.  For example, the client is case-insensitive and the
1470names differ only in case.
1471
1472@item Update-existing @var{pathname} \n
1473This is just like @code{Updated} and takes the same additional data, but
1474is used only if a @code{Entry}, @code{Modified}, or @code{Unchanged}
1475request has been sent for the file in question.
1476
1477This response, or @code{Merged}, indicates that the server has
1478determined that it is OK to overwrite the previous contents of the file
1479specified by @var{pathname}.  Provided that the client has correctly
1480sent @code{Modified} or @code{Is-modified} requests for a modified file,
1481and the file was not modified while CVS was running, the server can
1482ensure that a user's modifications are not lost.
1483
1484@item Merged @var{pathname} \n
1485This is just like @code{Updated} and takes the same additional data,
1486with the one difference that after the new copy of the file is enclosed,
1487it will still not be up to date.  Used for the results of a merge, with
1488or without conflicts.
1489
1490It is useful to preserve an copy of what the file looked like before the
1491merge.  This is basically handled by the server; before sending
1492@code{Merged} it will send a @code{Copy-file} response.  For example, if
1493the file is @file{aa} and it derives from revision 1.3, the
1494@code{Copy-file} response will tell the client to copy @file{aa} to
1495@file{.#aa.1.3}.  It is up to the client to decide how long to keep this
1496file around; traditionally clients have left it around forever, thus
1497letting the user clean it up as desired.  But another answer, such as
1498until the next commit, might be preferable.
1499
1500@item Rcs-diff @var{pathname} \n
1501This is just like @code{Updated} and takes the same additional data,
1502with the one difference that instead of sending a new copy of the file,
1503the server sends an RCS change text.  This change text is produced by
1504@samp{diff -n} (the GNU diff @samp{-a} option may also be used).  The
1505client must apply this change text to the existing file.  This will only
1506be used when the client has an exact copy of an earlier revision of a
1507file.  This response is only used if the @code{update} command is given
1508the @samp{-u} argument.
1509
1510@item Patched @var{pathname} \n
1511This is just like @code{Rcs-diff} and takes the same additional data,
1512except that it sends a standard patch rather than an RCS change text.
1513The patch is produced by @samp{diff -c} for @sc{cvs} 1.6 and later (see
1514POSIX.2 for a description of this format), or @samp{diff -u} for
1515previous versions of @sc{cvs}; clients are encouraged to accept either
1516format.  Like @code{Rcs-diff}, this response is only used if the
1517@code{update} command is given the @samp{-u} argument.
1518
1519The @code{Patched} response is deprecated in favor of the
1520@code{Rcs-diff} response.  However, older clients (CVS 1.9 and earlier)
1521only support @code{Patched}.
1522
1523@item Mode @var{mode} \n
1524This @var{mode} applies to the next file mentioned in
1525@code{Checked-in}.  @code{Mode} is a file update modifying response
1526as described in @ref{Response intro}.
1527
1528@item Mod-time @var{time} \n
1529Set the modification time of the next file sent to @var{time}.
1530@code{Mod-time} is a file update modifying response
1531as described in @ref{Response intro}.
1532The
1533@var{time} is in the format specified by RFC822 as modified by RFC1123.
1534The server may specify any timezone it chooses; clients will want to
1535convert that to their own timezone as appropriate.  An example of this
1536format is:
1537
1538@example
153926 May 1997 13:01:40 -0400
1540@end example
1541
1542There is no requirement that the client and server clocks be
1543synchronized.  The server just sends its recommendation for a timestamp
1544(based on its own clock, presumably), and the client should just believe
1545it (this means that the time might be in the future, for example).
1546
1547If the server does not send @code{Mod-time} for a given file, the client
1548should pick a modification time in the usual way (usually, just let the
1549operating system set the modification time to the time that the CVS
1550command is running).
1551
1552@item Checksum @var{checksum}\n
1553The @var{checksum} applies to the next file sent (that is,
1554@code{Checksum} is a file update modifying response
1555as described in @ref{Response intro}).
1556In the case of
1557@code{Patched}, the checksum applies to the file after being patched,
1558not to the patch itself.  The client should compute the checksum itself,
1559after receiving the file or patch, and signal an error if the checksums
1560do not match.  The checksum is the 128 bit MD5 checksum represented as
156132 hex digits (MD5 is described in RFC1321).
1562This response is optional, and is only used if the
1563client supports it (as judged by the @code{Valid-responses} request).
1564
1565@item Copy-file @var{pathname} \n
1566Additional data: @var{newname} \n.  Copy file @var{pathname} to
1567@var{newname} in the same directory where it already is.  This does not
1568affect @code{CVS/Entries}.
1569
1570This can optionally be implemented as a rename instead of a copy.  The
1571only use for it which currently has been identified is prior to a
1572@code{Merged} response as described under @code{Merged}.  Clients can
1573probably assume that is how it is being used, if they want to worry
1574about things like how long to keep the @var{newname} file around.
1575
1576@item Removed @var{pathname} \n
1577The file has been removed from the repository (this is the case where
1578cvs prints @samp{file foobar.c is no longer pertinent}).
1579
1580@item Remove-entry @var{pathname} \n
1581The file needs its entry removed from @code{CVS/Entries}, but the file
1582itself is already gone (this happens in response to a @code{ci} request
1583which involves committing the removal of a file).
1584
1585@item Set-static-directory @var{pathname} \n
1586This instructs the client to set the @code{Entries.Static} flag, which
1587it should then send back to the server in a @code{Static-directory}
1588request whenever the directory is operated on.  @var{pathname} ends in a
1589slash; its purpose is to specify a directory, not a file within a
1590directory.
1591
1592@item Clear-static-directory @var{pathname} \n
1593Like @code{Set-static-directory}, but clear, not set, the flag.
1594
1595@item Set-sticky @var{pathname} \n
1596Additional data: @var{tagspec} \n.  Tell the client to set a sticky tag
1597or date, which should be supplied with the @code{Sticky} request for
1598future operations.  @var{pathname} ends in a slash; its purpose is to
1599specify a directory, not a file within a directory.  The client should
1600store @var{tagspec} and pass it back to the server as-is, to allow for
1601future expansion.  The first character of @var{tagspec} is @samp{T} for
1602a tag, @samp{D} for a date, or something else for future expansion.  The
1603remainder of @var{tagspec} contains the actual tag or date.
1604
1605@item Clear-sticky @var{pathname} \n
1606Clear any sticky tag or date set by @code{Set-sticky}.
1607
1608@item Template @var{pathname} \n
1609Additional data: file transmission (note: compressed file transmissions
1610are not supported).  @var{pathname} ends in a slash; its purpose is to
1611specify a directory, not a file within a directory.  Tell the client to
1612store the file transmission as the template log message, and then use
1613that template in the future when prompting the user for a log message.
1614
1615@item Set-checkin-prog @var{dir} \n
1616Additional data: @var{prog} \n.  Tell the client to set a checkin
1617program, which should be supplied with the @code{Checkin-prog} request
1618for future operations.
1619
1620@item Set-update-prog @var{dir} \n
1621Additional data: @var{prog} \n.  Tell the client to set an update
1622program, which should be supplied with the @code{Update-prog} request
1623for future operations.
1624
1625@item Notified @var{pathname} \n
1626Indicate to the client that the notification for @var{pathname} has been
1627done.  There should be one such response for every @code{Notify}
1628request; if there are several @code{Notify} requests for a single file,
1629the requests should be processed in order; the first @code{Notified}
1630response pertains to the first @code{Notify} request, etc.
1631
1632@item Module-expansion @var{pathname} \n
1633Return a file or directory
1634which is included in a particular module.  @var{pathname} is relative
1635to cvsroot, unlike most pathnames in responses.  @var{pathname} should
1636be used to look and see whether some or all of the module exists on
1637the client side; it is not necessarily suitable for passing as an
1638argument to a @code{co} request (for example, if the modules file
1639contains the @samp{-d} option, it will be the directory specified with
1640@samp{-d}, not the name of the module).
1641
1642@item Wrapper-rcsOption @var{pattern} -k '@var{option}' \n
1643Transmit to the client a filename pattern which implies a certain
1644keyword expansion mode.  The @var{pattern} is a wildcard pattern (for
1645example, @samp{*.exe}.  The @var{option} is @samp{b} for binary, and so
1646on.  Note that although the syntax happens to resemble the syntax in
1647certain CVS configuration files, it is more constrained; there must be
1648exactly one space between @var{pattern} and @samp{-k} and exactly one
1649space between @samp{-k} and @samp{'}, and no string is permitted in
1650place of @samp{-k} (extensions should be done with new responses, not by
1651extending this one, for graceful handling of @code{Valid-responses}).
1652
1653@item M @var{text} \n
1654A one-line message for the user.
1655Note that the format of @var{text} is not designed for machine parsing.
1656Although sometimes scripts and clients will have little choice, the
1657exact text which is output is subject to vary at the discretion of the
1658server and the example output given in this document is just that,
1659example output.  Servers are encouraged to use the @samp{MT} response,
1660and future versions of this document will hopefully standardize more of
1661the @samp{MT} tags; see @ref{Text tags}.
1662
1663@item Mbinary \n
1664Additional data: file transmission (note: compressed file transmissions
1665are not supported).  This is like @samp{M}, except the contents of the
1666file transmission are binary and should be copied to standard output
1667without translation to local text file conventions.  To transmit a text
1668file to standard output, servers should use a series of @samp{M} requests.
1669
1670@item E @var{text} \n
1671Same as @code{M} but send to stderr not stdout.
1672
1673@item F \n
1674@c FIXME: The second sentence, defining "flush", is somewhat off the top
1675@c of my head.  Is there some text we can steal from ANSI C or someplace
1676@c which is more carefully thought out?
1677Flush stderr.  That is, make it possible for the user to see what has
1678been written to stderr (it is up to the implementation to decide exactly
1679how far it should go to ensure this).
1680
1681@item MT @var{tagname} @var{data} \n
1682
1683This response provides for tagged text.  It is similar to
1684SGML/HTML/XML in that the data is structured and a naive application
1685can also make some sense of it without understanding the structure.
1686The syntax is not SGML-like, however, in order to fit into the CVS
1687protocol better and (more importantly) to make it easier to parse,
1688especially in a language like perl or awk.
1689
1690The @var{tagname} can have several forms.  If it starts with @samp{a}
1691to @samp{z} or @samp{A} to @samp{Z}, then it represents tagged text.
1692If the implementation recognizes @var{tagname}, then it may interpret
1693@var{data} in some particular fashion.  If the implementation does not
1694recognize @var{tagname}, then it should simply treat @var{data} as
1695text to be sent to the user (similar to an @samp{M} response).  There
1696are two tags which are general purpose.  The @samp{text} tag is
1697similar to an unrecognized tag in that it provides text which will
1698ordinarily be sent to the user.  The @samp{newline} tag is used
1699without @var{data} and indicates that a newline will ordinarily be
1700sent to the user (there is no provision for embedding newlines in the
1701@var{data} of other tagged text responses).
1702
1703If @var{tagname} starts with @samp{+} it indicates a start tag and if
1704it starts with @samp{-} it indicates an end tag.  The remainder of
1705@var{tagname} should be the same for matching start and end tags, and
1706tags should be nested (for example one could have tags in the
1707following order @code{+bold} @code{+italic} @code{text} @code{-italic}
1708@code{-bold} but not @code{+bold} @code{+italic} @code{text}
1709@code{-bold} @code{-italic}).  A particular start and end tag may be
1710documented to constrain the tagged text responses which are valid
1711between them.
1712
1713Note that if @var{data} is present there will always be exactly one
1714space between @var{tagname} and @var{data}; if there is more than one
1715space, then the spaces beyond the first are part of @var{data}.
1716
1717Here is an example of some tagged text responses.  Note that there is
1718a trailing space after @samp{Checking in} and @samp{initial revision:}
1719and there are two trailing spaces after @samp{<--}.  Such trailing
1720spaces are, of course, part of @var{data}.
1721
1722@example
1723MT +checking-in
1724MT text Checking in
1725MT fname gz.tst
1726MT text ;
1727MT newline
1728MT rcsfile /home/kingdon/zwork/cvsroot/foo/gz.tst,v
1729MT text   <--
1730MT fname gz.tst
1731MT newline
1732MT text initial revision:
1733MT init-rev 1.1
1734MT newline
1735MT text done
1736MT newline
1737MT -checking-in
1738@end example
1739
1740If the client does not support the @samp{MT} response, the same
1741responses might be sent as:
1742
1743@example
1744M Checking in gz.tst;
1745M /home/kingdon/zwork/cvsroot/foo/gz.tst,v  <--  gz.tst
1746M initial revision: 1.1
1747M done
1748@end example
1749
1750For a list of specific tags, see @ref{Text tags}.
1751
1752@item error @var{errno-code} @samp{ } @var{text} \n
1753The command completed with an error.  @var{errno-code} is a symbolic
1754error code (e.g. @code{ENOENT}); if the server doesn't support this
1755feature, or if it's not appropriate for this particular message, it just
1756omits the errno-code (in that case there are two spaces after
1757@samp{error}).  Text is an error message such as that provided by
1758strerror(), or any other message the server wants to use.
1759The @var{text} is like the @code{M} response, in the sense that it is
1760not particularly intended to be machine-parsed; servers may wish to
1761print an error message with @code{MT} responses, and then issue a
1762@code{error} response without @var{text} (although it should be noted
1763that @code{MT} currently has no way of flagging the output as intended
1764for standard error, the way that the @code{E} response does).
1765
1766@item ok \n
1767The command completed successfully.
1768@end table
1769
1770@node Text tags
1771@section Tags for the MT tagged text response
1772
1773The @code{MT} response, as described in @ref{Responses}, offers a
1774way for the server to send tagged text to the client.  This section
1775describes specific tags.  The intention is to update this section as
1776servers add new tags.
1777
1778In the following descriptions, @code{text} and @code{newline} tags are
1779omitted.  Such tags contain information which is intended for users (or
1780to be discarded), and are subject to change at the whim of the server.
1781To avoid being vulnerable to such whim, clients should look for the tags
1782listed here, not @code{text}, @code{newline}, or other tags.
1783
1784The following tag means to indicate to the user that a file has been
1785updated.  It is more or less redundant with the @code{Created} and
1786@code{Update-existing} responses, but we don't try to specify here
1787whether it occurs in exactly the same circumstances as @code{Created}
1788and @code{Update-existing}.  The @var{name} is the pathname of the file
1789being updated relative to the directory in which the command is
1790occurring (that is, the last @code{Directory} request which is sent
1791before the command).
1792
1793@example
1794MT +updated
1795MT fname @var{name}
1796MT -updated
1797@end example
1798
1799The @code{importmergecmd} tag is used when doing an import which has
1800conflicts.  The client can use it to report how to merge in the newly
1801imported changes.  The @var{count} is the number of conflicts.  The
1802newly imported changes can be merged by running the following command:
1803@smallexample
1804cvs checkout -j @var{tag1} -j @var{tag2} @var{repository}
1805@end smallexample
1806
1807@example
1808MT +importmergecmd
1809MT conflicts @var{count}
1810MT mergetag1 @var{tag1}
1811MT mergetag2 @var{tag2}
1812MT repository @var{repository}
1813MT -importmergecmd
1814@end example
1815
1816@node Example
1817@section Example
1818
1819@c The C:/S: convention is in imitation of RFC1869 (and presumably
1820@c other RFC's).  In other formatting concerns, we might want to think
1821@c about whether there is an easy way to provide RFC1543 formatting
1822@c (without negating the advantages of texinfo), and whether we should
1823@c use RFC2234 BNF (I fear that would be less clear than
1824@c what we do now, however).  Plus what about RFC2119 terminology (MUST,
1825@c SHOULD, &c) or ISO terminology (shall, should, or whatever they are)?
1826Here is an example; lines are prefixed by @samp{C: } to indicate the
1827client sends them or @samp{S: } to indicate the server sends them.
1828
1829The client starts by connecting, sending the root, and completing the
1830protocol negotiation.  In actual practice the lists of valid responses
1831and requests would be longer.
1832@c The reason that we artificially shorten the lists is to avoid phony
1833@c line breaks.  Any better solutions?
1834@c Other than that, this exchange is taken verbatim from the data
1835@c exchanged by CVS (as of Nov 1996).  That is why some of the requests and
1836@c reponses are not quite what you would pick for pedagogical purposes.
1837
1838@example
1839C: Root /u/cvsroot
1840C: Valid-responses ok error Checked-in M E
1841C: valid-requests
1842S: Valid-requests Root Directory Entry Modified Argument Argumentx ci co
1843S: ok
1844C: UseUnchanged
1845@end example
1846
1847The client wants to check out the @code{supermunger} module into a fresh
1848working directory.  Therefore it first expands the @code{supermunger}
1849module; this step would be omitted if the client was operating on a
1850directory rather than a module.
1851@c Why does it send Directory here?  The description of expand-modules
1852@c doesn't really say much of anything about what use, if any, it makes of
1853@c Directory and similar requests sent previously.
1854
1855@example
1856C: Argument supermunger
1857C: Directory .
1858C: /u/cvsroot
1859C: expand-modules
1860@end example
1861
1862The server replies that the @code{supermunger} module expands to the
1863directory @code{supermunger} (the simplest case):
1864
1865@example
1866S: Module-expansion supermunger
1867S: ok
1868@end example
1869
1870The client then proceeds to check out the directory.  The fact that it
1871sends only a single @code{Directory} request which specifies @samp{.}
1872for the working directory means that there is not already a
1873@code{supermunger} directory on the client.
1874@c What is -N doing here?
1875
1876@example
1877C: Argument -N
1878C: Argument supermunger
1879C: Directory .
1880C: /u/cvsroot
1881C: co
1882@end example
1883
1884The server replies with the requested files.  In this example, there is
1885only one file, @file{mungeall.c}.  The @code{Clear-sticky} and
1886@code{Clear-static-directory} requests are sent by the current
1887implementation but they have no effect because the default is for those
1888settings to be clear when a directory is newly created.
1889
1890@example
1891S: Clear-sticky supermunger/
1892S: /u/cvsroot/supermunger/
1893S: Clear-static-directory supermunger/
1894S: /u/cvsroot/supermunger/
1895S: E cvs server: Updating supermunger
1896S: M U supermunger/mungeall.c
1897S: Created supermunger/
1898S: /u/cvsroot/supermunger/mungeall.c
1899S: /mungeall.c/1.1///
1900S: u=rw,g=r,o=r
1901S: 26
1902S: int mein () @{ abort (); @}
1903S: ok
1904@end example
1905
1906The current client implementation would break the connection here and make a
1907new connection for the next command.  However, the protocol allows it
1908to keep the connection open and continue, which is what we show here.
1909
1910After the user modifies the file and instructs the client to check it
1911back in.  The client sends arguments to specify the log message and file
1912to check in:
1913
1914@example
1915C: Argument -m
1916C: Argument Well, you see, it took me hours and hours to find
1917C: Argumentx this typo and I searched and searched and eventually
1918C: Argumentx had to ask John for help.
1919C: Argument mungeall.c
1920@end example
1921
1922It also sends information about the contents of the working directory,
1923including the new contents of the modified file.  Note that the user has
1924changed into the @file{supermunger} directory before executing this
1925command; the top level directory is a user-visible concept because the
1926server should print filenames in @code{M} and @code{E} responses
1927relative to that directory.
1928@c We are waving our hands about the order of the requests.  "Directory"
1929@c and "Argument" can be in any order, but this probably isn't specified
1930@c very well.
1931
1932@example
1933C: Directory .
1934C: /u/cvsroot/supermunger
1935C: Entry /mungeall.c/1.1///
1936C: Modified mungeall.c
1937C: u=rw,g=r,o=r
1938C: 26
1939C: int main () @{ abort (); @}
1940@end example
1941
1942And finally, the client issues the checkin command (which makes use of
1943the data just sent):
1944
1945@example
1946C: ci
1947@end example
1948
1949And the server tells the client that the checkin succeeded:
1950
1951@example
1952S: M Checking in mungeall.c;
1953S: E /u/cvsroot/supermunger/mungeall.c,v  <--  mungeall.c
1954S: E new revision: 1.2; previous revision: 1.1
1955S: E done
1956S: Mode u=rw,g=r,o=r
1957S: Checked-in ./
1958S: /u/cvsroot/supermunger/mungeall.c
1959S: /mungeall.c/1.2///
1960S: ok
1961@end example
1962
1963@node Requirements
1964@section Required versus optional parts of the protocol
1965
1966The following are part of every known implementation of the CVS protocol
1967(except obsolete, pre-1.5, versions of CVS) and it is considered
1968reasonable behavior to completely fail to work if you are connected with
1969an implementation which attempts to not support them.  Requests:
1970@code{Root}, @code{Valid-responses}, @code{valid-requests},
1971@code{Directory}, @code{Entry}, @code{Modified}, @code{Unchanged},
1972@code{Argument}, @code{Argumentx}, @code{ci}, @code{co}, @code{update}.
1973Responses: @code{ok}, @code{error}, @code{Valid-requests},
1974@code{Checked-in}, @code{Updated}, @code{Merged}, @code{Removed},
1975@code{M}, @code{E}.
1976
1977A server need not implement @code{Repository}, but in order to interoperate
1978with CVS 1.5 through 1.9 it must claim to implement it (in
1979@code{Valid-requests}).  The client will not actually send the request.
1980
1981@node Obsolete
1982@section Obsolete protocol elements
1983
1984This section briefly describes protocol elements which are obsolete.
1985There is no attempt to document them in full detail.
1986
1987There was a @code{Repository} request which was like @code{Directory}
1988except it only provided @var{repository}, and the local directory was
1989assumed to be similarly named.
1990
1991If the @code{UseUnchanged} request was not sent, there was a @code{Lost}
1992request which was sent to indicate that a file did not exist in the
1993working directory, and the meaning of sending @code{Entries} without
1994@code{Lost} or @code{Modified} was different.  All current clients (CVS
19951.5 and later) will send @code{UseUnchanged} if it is supported.
1996
1997@node Protocol Notes
1998@chapter Notes on the Protocol
1999
2000A number of enhancements are possible.  Also see the file @sc{todo} in
2001the @sc{cvs} source distribution, which has further ideas concerning
2002various aspects of @sc{cvs}, some of which impact the protocol.
2003Similarly, the @code{http://www.cvshome.org} site, in particular the
2004@cite{Development} pages.
2005
2006@itemize @bullet
2007@item
2008The @code{Modified} request could be speeded up by sending diffs rather
2009than entire files.  The client would need some way to keep the version
2010of the file which was originally checked out; probably requiring the use
2011of "cvs edit" in this case is the most sensible course (the "cvs edit"
2012could be handled by a package like VC for emacs).  This would also allow
2013local operation of @code{cvs diff} without arguments.
2014
2015@item
2016The fact that @code{pserver} requires an extra network turnaround in
2017order to perform authentication would be nice to avoid.  This relates to
2018the issue of reporting errors; probably the clean solution is to defer
2019the error until the client has issued a request which expects a
2020response.  To some extent this might relate to the next item (in terms
2021of how easy it is to skip a whole bunch of requests until we get to one
2022that expects a response).  I know that the kerberos code doesn't wait in
2023this fashion, but that probably can cause network deadlocks and perhaps
2024future problems running over a transport which is more transaction
2025oriented than TCP.  On the other hand I'm not sure it is wise to make
2026the client conduct a lengthy upload only to find there is an
2027authentication failure.
2028
2029@item
2030The protocol uses an extra network turnaround for protocol negotiation
2031(@code{valid-requests}).  It might be nice to avoid this by having the
2032client be able to send requests and tell the server to ignore them if
2033they are unrecognized (different requests could produce a fatal error if
2034unrecognized).  To do this there should be a standard syntax for
2035requests.  For example, perhaps all future requests should be a single
2036line, with mechanisms analogous to @code{Argumentx}, or several requests
2037working together, to provide greater amounts of information.  Or there
2038might be a standard mechanism for counted data (analogous to that used
2039by @code{Modified}) or continuation lines (like a generalized
2040@code{Argumentx}).  It would be useful to compare what HTTP is planning
2041in this area; last I looked they were contemplating something called
2042Protocol Extension Protocol but I haven't looked at the relevant IETF
2043documents in any detail.  Obviously, we want something as simple as
2044possible (but no simpler).
2045
2046@item
2047The scrambling algorithm in the CVS client and server actually support
2048more characters than those documented in @ref{Password scrambling}.
2049Someday we are going to either have to document them all (but this is
2050not as easy as it may look, see below), or (gradually and with adequate
2051process) phase out the support for other characters in the CVS
2052implementation.  This business of having the feature partly undocumented
2053isn't a desirable state long-term.
2054
2055The problem with documenting other characters is that unless we know
2056what character set is in use, there is no way to make a password
2057portable from one system to another.  For example, a with a circle on
2058top might have different encodings in different character sets.
2059
2060It @emph{almost} works to say that the client picks an arbitrary,
2061unknown character set (indeed, having the CVS client know what character
2062set the user has in mind is a hard problem otherwise), and scrambles
2063according to a certain octet<->octet mapping.  There are two problems
2064with this.  One is that the protocol has no way to transmit character 10
2065decimal (linefeed), and the current server and clients have no way to
2066handle 0 decimal (NUL).  This may cause problems with certain multibyte
2067character sets, in which octets 10 and 0 will appear in the middle of
2068other characters.  The other problem, which is more minor and possibly
2069not worth worrying about, is that someone can type a password on one
2070system and then go to another system which uses a different encoding for
2071the same characters, and have their password not work.
2072
2073The restriction to the ISO646 invariant subset is the best approach for
2074strings which are not particularly significant to users.  Passwords are
2075visible enough that this is somewhat doubtful as applied here.  ISO646
2076does, however, have the virtue (!?) of offending everyone.  It is easy
2077to say "But the $ is right on people's keyboards!  Surely we can't
2078forbid that".  From a human factors point of view, that makes quite a
2079bit of sense.  The contrary argument, of course, is that a with a circle
2080on top, or some of the characters poorly handled by Unicode, are on
2081@emph{someone}'s keyboard.
2082
2083@end itemize
2084
2085@bye
2086