xref: /openbsd/gnu/usr.bin/cvs/HACKING (revision e77048c1)
1c26070a5StholoHow to write code for CVS
2c26070a5Stholo
3c26070a5Stholo* Compiler options
4c26070a5Stholo
5c26070a5StholoIf you are using GCC, you'll want to configure with -Wall, which can
6c26070a5Stholodetect many programming errors.  This is not the default because it
7c26070a5Stholomight cause spurious warnings, but at least on some machines, there
8c26070a5Stholoshould be no spurious warnings.  For example:
9c26070a5Stholo
10c26070a5Stholo	$ CFLAGS="-g -Wall" ./configure
11c26070a5Stholo
12c26070a5StholoConfigure is not very good at remembering this setting; it will get
13c26070a5Stholowiped out whenever you do a ./config.status --recheck, so you'll need
14c26070a5Stholoto use:
15c26070a5Stholo
16c26070a5Stholo	$ CFLAGS="-g -Wall" ./config.status --recheck
17c26070a5Stholo
18c26070a5Stholo* Indentation style
19c26070a5Stholo
20c26070a5StholoCVS mostly uses a consistent indentation style which looks like this:
21c26070a5Stholo
22c26070a5Stholovoid
23c26070a5Stholofoo (arg)
24c26070a5Stholo    char *arg;
25c26070a5Stholo{
26c26070a5Stholo    if (arg != NULL)
27c26070a5Stholo    {
28c26070a5Stholo	bar (arg);
29c26070a5Stholo	baz (arg);
30c26070a5Stholo    }
312286d8edStholo    switch (c)
322286d8edStholo    {
332286d8edStholo	case 'A':
342286d8edStholo	    aflag = 1;
352286d8edStholo	    break;
362286d8edStholo    }
37c26070a5Stholo}
38c26070a5Stholo
39c26070a5StholoThe file cvs-format.el contains settings for emacs and the NEWS file
40c26070a5Stholocontains a set of options for the indent program which I haven't tried
41c26070a5Stholobut which are correct as far as I know.  You will find some code which
42c26070a5Stholodoes not conform to this indentation style; the plan is to reindent it
43c26070a5Stholoas those sections of the code are changed (one function at a time,
44c26070a5Stholoperhaps).
45c26070a5Stholo
46c26070a5StholoIn a submitted patch it is acceptable to refrain from changing the
47c26070a5Stholoindentation of large blocks of code to minimize the size of the patch;
48c26070a5Stholothe person checking in such a patch should reindent it.
49c26070a5Stholo
50c26070a5Stholo* Portability
51c26070a5Stholo
5250bf276cStholoThe general rule for portability is that it is only worth including
5350bf276cStholoportability cruft for systems on which people are actually testing and
5450bf276cStholousing new CVS releases.  Without testing, CVS will fail to be portable
5550bf276cStholofor any number of unanticipated reasons.
5650bf276cStholo
5750bf276cStholoThe current consequence of that general rule seems to be that if it
5850bf276cStholois in ANSI C and it is in SunOS4 (using /bin/cc), generally it is OK
5950bf276cStholoto use it without ifdefs (for example, assert() and void * as long as
6050bf276cStholoyou add more casts to and from void * than ANSI requires.  But not
6150bf276cStholofunction prototypes).  Such constructs are generally portable enough,
6250bf276cStholoincluding to NT, OS/2, VMS, etc.
63c26070a5Stholo
64c26070a5Stholo* Run-time behaviors
65c26070a5Stholo
66c26070a5StholoUse assert() to check "can't happen" conditions internal to CVS.  We
67c26070a5Stholorealize that there are functions in CVS which instead return NULL or
68c26070a5Stholosome such value (thus confusing the meaning of such a returned value),
69c26070a5Stholobut we want to fix that code.  Of course, bad input data, a corrupt
70c26070a5Stholorepository, bad options, etc., should always print a real error
71c26070a5Stholomessage instead.
72c26070a5Stholo
732286d8edStholoDo not use arbitrary limits (such as PATH_MAX) except perhaps when the
742286d8edStholooperating system or some external interface requires it.  We spent a
752286d8edSthololot of time getting rid of them, and we don't want to put them back.
762286d8edStholoIf you find any that we missed, please report it as with other bugs.
772286d8edStholoIn most cases such code will create security holes (for example, for
782286d8edStholoanonymous readonly access via the CVS protocol, or if a WWW cgi script
792286d8edStholopasses client-supplied arguments to CVS).
8050bf276cStholo
8150bf276cStholoAlthough this is a long-term goal, it also would be nice to move CVS
8250bf276cStholoin the direction of reentrancy.  This reduces the size of the data
8350bf276cStholosegment and will allow a multi-threaded server if that is desirable.
8450bf276cStholoIt is also useful to write the code so that it can be easily be made
8550bf276cStholoreentrant later.  For example, if you need to pass data from a
8650bf276cStholoParse_Info caller to its callproc, you need a static variable.  But
8750bf276cStholouse a single pointer so that when Parse_Info is fixed to pass along a
8850bf276cStholovoid * argument, then the code can easily use that argument.
8950bf276cStholo
90c26070a5Stholo* Coding standards in general
91c26070a5Stholo
92c26070a5StholoGenerally speaking the GNU coding standards are mostly used by CVS
93c26070a5Stholo(but see the exceptions mentioned above, such as indentation style,
94c26070a5Stholoand perhaps an exception or two we haven't mentioned).  This is the
95c26070a5Stholofile standards.text at the GNU FTP sites.
96c26070a5Stholo
9750bf276cStholoFilenames for .c and .h files may contain _ but should not contain -
9850bf276cStholo(the latter causes Visual C++ 2.1 to create makefiles which Visual C++
9950bf276cStholo4.0 cannot use).
10050bf276cStholo
101892c0aadStholo* Writing patches (strategy)
102461cc63eStholo
103461cc63eStholoOnly some kinds of changes are suitable for inclusion in the
104461cc63eStholo"official" CVS.  Bugfixes, where CVS's behavior contradicts the
105461cc63eStholodocumentation and/or expectations that everyone agrees on, should be
106461cc63eStholoOK (strategically).  For features, the desirable attributes are that
107461cc63eStholothe need is clear and that they fit nicely into the architecture of
108892c0aadStholoCVS.  Is it worth the cost (in terms of complexity or any other
109892c0aadStholotradeoffs involved)?  Are there better solutions?
110461cc63eStholo
111892c0aadStholoIf the design is not yet clear (which is true of most features), then
112892c0aadStholothe design is likely to benefit from more work and community input.
113892c0aadStholoMake a list of issues, or write documentation including rationales for
114892c0aadStholohow one would use the feature.  Discuss it with coworkers, a
115892c0aadStholonewsgroup, or a mailing list, and see what other people think.
116892c0aadStholoDistribute some experimental patches and see what people think.  The
117892c0aadStholointention is arrive at some kind of rough community consensus before
118892c0aadStholochanging the "official" CVS.  Features like zlib, encryption, and
119892c0aadStholothe RCS library have benefitted from this process in the past.
120461cc63eStholo
121461cc63eStholoIf longstanding CVS behavior, that people may be relying on, is
122461cc63eStholoclearly deficient, it can be changed, but only slowly and carefully.
123461cc63eStholoFor example, the global -q option was introduced in CVS 1.3 but the
124461cc63eStholocommand -q options, which the global -q replaced, were not removed
125461cc63eStholountil CVS 1.6.
126461cc63eStholo
127892c0aadStholo* Writing patches (tactics)
128c26070a5Stholo
129892c0aadStholoWhen you first distribute a patch it may be suitable to just put forth
130892c0aadStholoa rough patch, or even just an idea.  But before the end of the
131892c0aadStholoprocess the following should exist:
132c26070a5Stholo
133892c0aadStholo  - ChangeLog entry (see the GNU coding standards for details).
134461cc63eStholo
135892c0aadStholo  - Changes to the NEWS file and cvs.texinfo, if the change is a
136892c0aadStholo    user-visible change worth mentioning.
137c26070a5Stholo
138892c0aadStholo  - Somewhere, a description of what the patch fixes (often in
139892c0aadStholo    comments in the code, or maybe the ChangeLog or documentation).
140c26070a5Stholo
141892c0aadStholo  - Most of the time, a test case (see TESTS).  It can be quite
142892c0aadStholo    frustrating to fix a bug only to see it reappear later, and adding
143892c0aadStholo    the case to the testsuite, where feasible, solves this and other
144892c0aadStholo    problems.
145892c0aadStholo
146892c0aadStholoIf you solve several unrelated problems, it is generally easier to
147892c0aadStholoconsider the desirability of the changes if there is a separate patch
148892c0aadStholofor each issue.  Use context diffs or unidiffs for patches.
149892c0aadStholo
150892c0aadStholoInclude words like "I grant permission to distribute this patch under
151892c0aadStholothe terms of the GNU Public License" with your patch.  By sending a
152892c0aadStholopatch to bug-cvs@gnu.org, you implicitly grant this permission.
153892c0aadStholo
154892c0aadStholoSubmitting a patch to bug-cvs is the way to reach the people who have
155892c0aadStholosigned up to receive such submissions (including CVS developers), but
156892c0aadStholothere may or may not be much (or any) response.  If you want to pursue
157892c0aadStholothe matter further, you are probably best off working with the larger
158892c0aadStholoCVS community.  Distribute your patch as widely as desired (mailing
159892c0aadSthololists, newsgroups, web sites, whatever).  Write a web page or other
160892c0aadStholoinformation describing what the patch is for.  It is neither practical
161892c0aadStholonor desirable for all/most contributions to be distributed through the
162892c0aadStholo"official" (whatever that means) mechanisms of CVS releases and CVS
163892c0aadStholodevelopers.  Now, the "official" mechanisms do try to incorporate
164892c0aadStholothose patches which seem most suitable for widespread usage, together
165892c0aadStholowith test cases and documentation.  So if a patch becomes sufficiently
166892c0aadStholopopular in the CVS community, it is likely that one of the CVS
167892c0aadStholodevelopers will eventually try to do something with it.  But dealing
168892c0aadStholowith the CVS developers may be the last step of the process rather
169892c0aadStholothan the first.
170c26070a5Stholo
171c26070a5Stholo* What is the schedule for the next release?
172c26070a5Stholo
173c26070a5StholoThere isn't one.  That is, upcoming releases are not announced (or
174c26070a5Stholoeven hinted at, really) until the feature freeze which is
175c26070a5Stholoapproximately 2 weeks before the final release (at this time test
176c26070a5Stholoreleases start appearing and are announced on info-cvs).  This is
177c26070a5Stholointentional, to avoid a last minute rush to get new features in.
178780d15dfStholo
179780d15dfStholo* Mailing lists
180780d15dfStholo
181780d15dfStholoAnyone can add themselves to the following mailing lists:
182780d15dfStholo
183780d15dfStholo    devel-cvs.  Unless you are accepted as a CVS developer as
184780d15dfStholo      described in the DEVEL-CVS file, you will only be able to
185780d15dfStholo      read this list, not send to it.  The charter of the list is
186780d15dfStholo      also in DEVEL-CVS.
187780d15dfStholo    commit-cvs.  The only messages sent to this list are sent
188780d15dfStholo      automatically, via the CVS `loginfo' mechanism, when someone
189780d15dfStholo      checks something in to the master CVS repository.
190780d15dfStholo    test-results.  The only messages sent to this list are sent
191780d15dfStholo      automatically, daily, by a script which runs "make check"
192780d15dfStholo      and "make remotecheck" on the master CVS sources.
193780d15dfStholoTo subscribe to devel-cvs, commit-cvs, or test-results, send
194*e77048c1Stholoa message to "majordomo@cvshome.org" whose body consists of
195780d15dfStholo"subscribe <list>", where <list> is devel-cvs, commit-cvs or
196780d15dfStholotest-results.
197780d15dfStholo
198780d15dfStholoOne other list related to CVS development is bug-cvs.  This is the
199780d15dfSthololist which users are requested to send bug reports to.  Anyone can
2002286d8edStholosubscribe; to do so send mail to bug-cvs-request@gnu.org.
201780d15dfStholo
202780d15dfStholoOther CVS discussions take place on the info-cvs mailing list
203c71bc7e2Stholo(send mail to info-cvs-request@gnu.org to subscribe) or on
204780d15dfStholothe newsgroup comp.software.config-mgmt.
205