<?xml version="1.0"?>
<!DOCTYPE webpage
  PUBLIC "-//NetBSD//DTD Website-based NetBSD Extension//EN"
	 "http://www.NetBSD.org/XML/htdocs/lang/share/xml/website-netbsd.dtd">

<webpage id="developers-commit-guidelines">
<config param="desc" value="NetBSD Commit Guidelines"/>
<config param="cvstag" value="$NetBSD: commit-guidelines.xml,v 1.6 2006/11/05 19:18:13 heinz Exp $"/>
<config param="rcsdate" value="$Date: 2006/11/05 19:18:13 $"/>
<head>
<title>NetBSD Commit Guidelines</title>
</head>

<sect1 id="guidelines">

<title>
  The following Commit Guidelines define the Project's standards for making
  commits to the source tree:
</title>

<orderedlist>
  <listitem>
    <sect2 id="know-thy-code">
      <title>Commit only code you are familiar with.</title>
      <para>
        If you are not sure if the code you plan to commit is acceptable
        (e. g. when taking code that was submitted with a problem report),
	ask a developer who is familiar with that part of the system for
	review. If you're new to the Project, check with your sponsor.
      </para>
    </sect2>
   </listitem>

   <listitem>
    <sect2 id="tainted">
      <title>Do not commit tainted code to the repository.</title>
      <para>
	If you commit code that was not written by yourself, double check
	that the license on that code permits import into the NetBSD source
	repository, and permits free distribution. Check with the author(s)
	of the code, make sure that they were the sole author of the code
	and verify with them that they did not copy any other code.
      </para>
    </sect2>
   </listitem>

   <listitem>
    <sect2 id="repository">
      <title>Do not commit code from foreign trees.</title>
      <para>
	Do not commit code from a tree checked out from anywhere but from
	cvs.NetBSD.org.  Note that all developers have access to the private
	<ulink url="restricted.html#rsync">rsync-over-ssh service on
	cvs.NetBSD.org</ulink>.
      </para>
    </sect2>
   </listitem>

   <listitem>
    <sect2 id="intrusive">
      <title>
	The more intrusive your changes are the higher is the level of
	required prior approval.
      </title>
      <itemizedlist>
        <listitem>
          <para>
	    "Obvious" fixes can be committed without any prior discussion
	    or review. (The definition of "obvious" in the GCC Project is:
	    "could not possibly cause anyone to object." We adopt this
	    definition here)
	  </para>
	</listitem>
	<listitem>
	  <para>
	    All other (i. e. "non-obvious") fixes <emphasis>should</emphasis>
	    have a review.
	  </para>
	</listitem>
	<listitem>
	  <para>
	    Implementing (significant) new features requires a prior
	    discussion on an appropriate technical mailing list.
	  </para>
	</listitem>
	<listitem>
	  <para>
	    Changing existing interfaces in libraries or in the kernel
	    requires prior approval by Core.
	  </para>
	</listitem>
      </itemizedlist>
    </sect2>
   </listitem>
   <listitem>
    <sect2 id="tested">
      <title>Commit only code that you have tested.</title>
	<para>
	  Make sure that your code actually works as expected, by
	  compiling and running the code that is affected by your change
	  with your system's tools. If you changed a man page, make sure
	  that groff/nroff creates the formatted man page you expect.
	</para>
	<para>
	  For normal commits (to the trunk), test that your code works
	  on -current. Prior to requesting a pull-up to a branch, test
	  the very changes you will request from releng on the respective
	  release branch.
	</para>
     </sect2>
    </listitem>
    <listitem>
      <sect2 id="group">
	<title>Group commits together that are part of the same fix.</title>
	<para>
	  Rototilling a make variable that affects 50 Makefiles should get
          one commit for all of them together.
	</para>
      </sect2>
    </listitem>
    <listitem>
      <sect2 id="separate">
	<title>Each commit should be a separate patch/fix/addition/etc.</title>
	<para>
	  Don't fix 3 bugs with the same commit and roll that into
	  "Fixed some bugs". Fix one, test, commit, rinse, repeat. This
	  makes life infinitely easier for releng to pull up fixes since
	  often not everything applies to a given branch.
	</para>
      </sect2>
    </listitem>
    <listitem>
      <sect2 id="dont-mix">
	<title>
	  Do not mix functionality or bug-fix patches with
	  whitespace/layout updates.
	</title>
        <para>
	  Do those separately (apart from the general requirement that
	  changes be made in such a way that it is easy to discern what
	  each fix did, as described in item 6, there will be pullup
	  issues with largely changed files from trunk->branch when
	  mixing whitespace with functionality fixes).
	</para>
      </sect2>
    </listitem>
    <listitem>
      <sect2 id="document">
	<title>Clearly document your changes in the commit log.</title>
	<para>
	  Detail to some degree what was changed and why. Doesn't need
	  to be a code review/walkthrough but it should be informative
	  to someone reading the log and looking over the diff in 6
	  months. Again "fixed some stuff" or "cvs-1.10.0" isn't
	  acceptable whereas the following example is:
	</para>
	<note><title/>
          "Print useful line number on error while executing .for directive."
        </note>
	<para>
	  If your change fixes a PR, document it with an appropriate
	  message. Using the template <quote>PR category/bug-id</quote> in
	  your commit message will also append it to the respective problem
	  report in our bug database:
	</para>
	<note><title/>
          "Closes PR bin/6666"
        </note>
	<para>
	  If your code has been reviewed by someone else, document this:
	</para>
	<note><title/>
          "Reviewed by &lt;mrg&gt;"
	</note>
	<para>
	  (Please note that a good commit log doesn't relieve the need
	  for good documentation in the program itself.)
	</para>
      </sect2>
    </listitem>
    <listitem>
      <sect2 id="credit">
	<title>Give proper credit.</title>
	<para>
	  If you commit code that had been submitted in a PR, give
	  proper credit, like:
	</para>
	<note><title/>
           "Code submitted in PR lib/393939 by Joe Doe"
	</note>
	<para>
	  Since the commit messages will eventually appear on the
	  source-changes mailing list which is also available via web,
	  specifying the e-mail addresses of the PR submitter should
	  generally be avoided.
	</para>
	<para>
	  If you took code from an other Open Source Project, give
	  credit, like:
	</para>
	<note><title/>
          "From FreeBSD"
	</note>
      </sect2>
    </listitem>
    <listitem>
      <sect2 id="revert">
	<title>Do not revert other developer's commits.</title>
	<para>
	  If you do not agree with another developer's commit, do not
	  revert it on your own. Contact the other developer and explain
	  to him or her the issues you have with his commit. Ask him
	  or her to backout his changes himself.
	</para>
	<para>
	  If no agreement can be reached, contact the Technical
	  Executive Committee &lt;technical-exec@NetBSD.org&gt;, which
	  will serve as mediation authority.
	</para>
      </sect2>
  </listitem>
</orderedlist>

</sect1>

</webpage>
