.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.20)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings.  \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote.  \*(C+ will
.\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
.\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
.    ds -- \(*W-
.    ds PI pi
.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
.    ds L" ""
.    ds R" ""
.    ds C` ""
.    ds C' ""
'br\}
.el\{\
.    ds -- \|\(em\|
.    ds PI \(*p
.    ds L" ``
.    ds R" ''
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD.  Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.ie \nF \{\
.    de IX
.    tm Index:\\$1\t\\n%\t"\\$2"
..
.    nr % 0
.    rr F
.\}
.el \{\
.    de IX
..
.\}
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear.  Run.  Save yourself.  No user-serviceable parts.
.    \" fudge factors for nroff and troff
.if n \{\
.    ds #H 0
.    ds #V .8m
.    ds #F .3m
.    ds #[ \f1
.    ds #] \fP
.\}
.if t \{\
.    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
.    ds #V .6m
.    ds #F 0
.    ds #[ \&
.    ds #] \&
.\}
.    \" simple accents for nroff and troff
.if n \{\
.    ds ' \&
.    ds ` \&
.    ds ^ \&
.    ds , \&
.    ds ~ ~
.    ds /
.\}
.if t \{\
.    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
.    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
.    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
.    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
.    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
.    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
.    \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
.    \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
.    \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
.    ds : e
.    ds 8 ss
.    ds o a
.    ds d- d\h'-1'\(ga
.    ds D- D\h'-1'\(hy
.    ds th \o'bp'
.    ds Th \o'LP'
.    ds ae ae
.    ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "PERLGIT 1"
.TH PERLGIT 1 "2013-03-04" "perl v5.16.3" "Perl Programmers Reference Guide"
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
perlgit \- Detailed information about git and the Perl repository
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
This document provides details on using git to develop Perl. If you are
just interested in working on a quick patch, see perlhack first.
This document is intended for people who are regular contributors to
Perl, including those with write access to the git repository.
.SH "CLONING THE REPOSITORY"
.IX Header "CLONING THE REPOSITORY"
All of Perl's source code is kept centrally in a Git repository at
\&\fIperl5.git.perl.org\fR.
.PP
You can make a read-only clone of the repository by running:
.PP
.Vb 1
\&  % git clone git://perl5.git.perl.org/perl.git perl
.Ve
.PP
This uses the git protocol (port 9418).
.PP
If you cannot use the git protocol for firewall reasons, you can also
clone via http, though this is much slower:
.PP
.Vb 1
\&  % git clone http://perl5.git.perl.org/perl.git perl
.Ve
.SH "WORKING WITH THE REPOSITORY"
.IX Header "WORKING WITH THE REPOSITORY"
Once you have changed into the repository directory, you can inspect
it. After a clone the repository will contain a single local branch,
which will be the current branch as well, as indicated by the asterisk.
.PP
.Vb 2
\&  % git branch
\&  * blead
.Ve
.PP
Using the \-a switch to \f(CW\*(C`branch\*(C'\fR will also show the remote tracking
branches in the repository:
.PP
.Vb 5
\&  % git branch \-a
\&  * blead
\&    origin/HEAD
\&    origin/blead
\&  ...
.Ve
.PP
The branches that begin with \*(L"origin\*(R" correspond to the \*(L"git remote\*(R"
that you cloned from (which is named \*(L"origin\*(R"). Each branch on the
remote will be exactly tracked by these branches. You should \s-1NEVER\s0 do
work on these remote tracking branches. You only ever do work in a
local branch. Local branches can be configured to automerge (on pull)
from a designated remote tracking branch. This is the case with the
default branch \f(CW\*(C`blead\*(C'\fR which will be configured to merge from the
remote tracking branch \f(CW\*(C`origin/blead\*(C'\fR.
.PP
You can see recent commits:
.PP
.Vb 1
\&  % git log
.Ve
.PP
And pull new changes from the repository, and update your local
repository (must be clean first)
.PP
.Vb 1
\&  % git pull
.Ve
.PP
Assuming we are on the branch \f(CW\*(C`blead\*(C'\fR immediately after a pull, this
command would be more or less equivalent to:
.PP
.Vb 2
\&  % git fetch
\&  % git merge origin/blead
.Ve
.PP
In fact if you want to update your local repository without touching
your working directory you do:
.PP
.Vb 1
\&  % git fetch
.Ve
.PP
And if you want to update your remote-tracking branches for all defined
remotes simultaneously you can do
.PP
.Vb 1
\&  % git remote update
.Ve
.PP
Neither of these last two commands will update your working directory,
however both will update the remote-tracking branches in your
repository.
.PP
To make a local branch of a remote branch:
.PP
.Vb 1
\&  % git checkout \-b maint\-5.10 origin/maint\-5.10
.Ve
.PP
To switch back to blead:
.PP
.Vb 1
\&  % git checkout blead
.Ve
.SS "Finding out your status"
.IX Subsection "Finding out your status"
The most common git command you will use will probably be
.PP
.Vb 1
\&  % git status
.Ve
.PP
This command will produce as output a description of the current state
of the repository, including modified files and unignored untracked
files, and in addition it will show things like what files have been
staged for the next commit, and usually some useful information about
how to change things. For instance the following:
.PP
.Vb 10
\&  $ git status
\&  # On branch blead
\&  # Your branch is ahead of \*(Aqorigin/blead\*(Aq by 1 commit.
\&  #
\&  # Changes to be committed:
\&  #   (use "git reset HEAD <file>..." to unstage)
\&  #
\&  #       modified:   pod/perlgit.pod
\&  #
\&  # Changed but not updated:
\&  #   (use "git add <file>..." to update what will be committed)
\&  #
\&  #       modified:   pod/perlgit.pod
\&  #
\&  # Untracked files:
\&  #   (use "git add <file>..." to include in what will be committed)
\&  #
\&  #       deliberate.untracked
.Ve
.PP
This shows that there were changes to this document staged for commit,
and that there were further changes in the working directory not yet
staged. It also shows that there was an untracked file in the working
directory, and as you can see shows how to change all of this. It also
shows that there is one commit on the working branch \f(CW\*(C`blead\*(C'\fR which has
not been pushed to the \f(CW\*(C`origin\*(C'\fR remote yet. \fB\s-1NOTE\s0\fR: that this output
is also what you see as a template if you do not provide a message to
\&\f(CW\*(C`git commit\*(C'\fR.
.SS "Patch workflow"
.IX Subsection "Patch workflow"
First, please read perlhack for details on hacking the Perl core.
That document covers many details on how to create a good patch.
.PP
If you already have a Perl repository, you should ensure that you're on
the \fIblead\fR branch, and your repository is up to date:
.PP
.Vb 2
\&  % git checkout blead
\&  % git pull
.Ve
.PP
It's preferable to patch against the latest blead version, since this
is where new development occurs for all changes other than critical bug
fixes. Critical bug fix patches should be made against the relevant
maint branches, or should be submitted with a note indicating all the
branches where the fix should be applied.
.PP
Now that we have everything up to date, we need to create a temporary
new branch for these changes and switch into it:
.PP
.Vb 1
\&  % git checkout \-b orange
.Ve
.PP
which is the short form of
.PP
.Vb 2
\&  % git branch orange
\&  % git checkout orange
.Ve
.PP
Creating a topic branch makes it easier for the maintainers to rebase
or merge back into the master blead for a more linear history. If you
don't work on a topic branch the maintainer has to manually cherry pick
your changes onto blead before they can be applied.
.PP
That'll get you scolded on perl5\-porters, so don't do that. Be Awesome.
.PP
Then make your changes. For example, if Leon Brocard changes his name
to Orange Brocard, we should change his name in the \s-1AUTHORS\s0 file:
.PP
.Vb 1
\&  % perl \-pi \-e \*(Aqs{Leon Brocard}{Orange Brocard}\*(Aq AUTHORS
.Ve
.PP
You can see what files are changed:
.PP
.Vb 7
\&  % git status
\&  # On branch orange
\&  # Changes to be committed:
\&  #   (use "git reset HEAD <file>..." to unstage)
\&  #
\&  #    modified:   AUTHORS
\&  #
.Ve
.PP
And you can see the changes:
.PP
.Vb 10
\&  % git diff
\&  diff \-\-git a/AUTHORS b/AUTHORS
\&  index 293dd70..722c93e 100644
\&  \-\-\- a/AUTHORS
\&  +++ b/AUTHORS
\&  @@ \-541,7 +541,7 @@    Lars Hecking                   <lhecking@nmrc.ucc.ie>
\&   Laszlo Molnar                  <laszlo.molnar@eth.ericsson.se>
\&   Leif Huhn                      <leif@hale.dkstat.com>
\&   Len Johnson                    <lenjay@ibm.net>
\&  \-Leon Brocard                   <acme@astray.com>
\&  +Orange Brocard                 <acme@astray.com>
\&   Les Peters                     <lpeters@aol.net>
\&   Lesley Binks                   <lesley.binks@gmail.com>
\&   Lincoln D. Stein               <lstein@cshl.org>
.Ve
.PP
Now commit your change locally:
.PP
.Vb 3
\&  % git commit \-a \-m \*(AqRename Leon Brocard to Orange Brocard\*(Aq
\&  Created commit 6196c1d: Rename Leon Brocard to Orange Brocard
\&   1 files changed, 1 insertions(+), 1 deletions(\-)
.Ve
.PP
The \f(CW\*(C`\-a\*(C'\fR option is used to include all files that git tracks that you
have changed. If at this time, you only want to commit some of the
files you have worked on, you can omit the \f(CW\*(C`\-a\*(C'\fR and use the command
\&\f(CW\*(C`git\ add\ \f(CIFILE\ ...\f(CW\*(C'\fR before doing the commit. \f(CW\*(C`git\ add\ \-\-interactive\*(C'\fR allows you to even just commit portions of files
instead of all the changes in them.
.PP
The \f(CW\*(C`\-m\*(C'\fR option is used to specify the commit message. If you omit it,
git will open a text editor for you to compose the message
interactively. This is useful when the changes are more complex than
the sample given here, and, depending on the editor, to know that the
first line of the commit message doesn't exceed the 50 character legal
maximum.
.PP
Once you've finished writing your commit message and exited your
editor, git will write your change to disk and tell you something like
this:
.PP
.Vb 2
\&  Created commit daf8e63: explain git status and stuff about remotes
\&   1 files changed, 83 insertions(+), 3 deletions(\-)
.Ve
.PP
If you re-run \f(CW\*(C`git status\*(C'\fR, you should see something like this:
.PP
.Vb 9
\&  % git status
\&  # On branch blead
\&  # Your branch is ahead of \*(Aqorigin/blead\*(Aq by 2 commits.
\&  #
\&  # Untracked files:
\&  #   (use "git add <file>..." to include in what will be committed)
\&  #
\&  #       deliberate.untracked
\&  nothing added to commit but untracked files present (use "git add" to track)
.Ve
.PP
When in doubt, before you do anything else, check your status and read
it carefully, many questions are answered directly by the git status
output.
.PP
You can examine your last commit with:
.PP
.Vb 1
\&  % git show HEAD
.Ve
.PP
and if you are not happy with either the description or the patch
itself you can fix it up by editing the files once more and then issue:
.PP
.Vb 1
\&  % git commit \-a \-\-amend
.Ve
.PP
Now you should create a patch file for all your local changes:
.PP
.Vb 2
\&  % git format\-patch \-M origin..
\&  0001\-Rename\-Leon\-Brocard\-to\-Orange\-Brocard.patch
.Ve
.PP
You should now send an email to
perlbug@perl.org <mailto:perlbug@perl.org> with a description of your
changes, and include this patch file as an attachment. In addition to
being tracked by \s-1RT\s0, mail to perlbug will automatically be forwarded to
perl5\-porters (with manual moderation, so please be patient). You
should only send patches to
perl5\-porters@perl.org <mailto:perl5-porters@perl.org> directly if the
patch is not ready to be applied, but intended for discussion.
.PP
See the next section for how to configure and use git to send these
emails for you.
.PP
If you want to delete your temporary branch, you may do so with:
.PP
.Vb 6
\&  % git checkout blead
\&  % git branch \-d orange
\&  error: The branch \*(Aqorange\*(Aq is not an ancestor of your current HEAD.
\&  If you are sure you want to delete it, run \*(Aqgit branch \-D orange\*(Aq.
\&  % git branch \-D orange
\&  Deleted branch orange.
.Ve
.SS "Committing your changes"
.IX Subsection "Committing your changes"
Assuming that you'd like to commit all the changes you've made as a
single atomic unit, run this command:
.PP
.Vb 1
\&   % git commit \-a
.Ve
.PP
(That \f(CW\*(C`\-a\*(C'\fR tells git to add every file you've changed to this commit.
New files aren't automatically added to your commit when you use
\&\f(CW\*(C`commit \-a\*(C'\fR If you want to add files or to commit some, but not all of
your changes, have a look at the documentation for \f(CW\*(C`git add\*(C'\fR.)
.PP
Git will start up your favorite text editor, so that you can craft a
commit message for your change. See \*(L"Commit message\*(R" in perlhack for more
information about what makes a good commit message.
.PP
Once you've finished writing your commit message and exited your
editor, git will write your change to disk and tell you something like
this:
.PP
.Vb 2
\&  Created commit daf8e63: explain git status and stuff about remotes
\&   1 files changed, 83 insertions(+), 3 deletions(\-)
.Ve
.PP
If you re-run \f(CW\*(C`git status\*(C'\fR, you should see something like this:
.PP
.Vb 9
\&  % git status
\&  # On branch blead
\&  # Your branch is ahead of \*(Aqorigin/blead\*(Aq by 2 commits.
\&  #
\&  # Untracked files:
\&  #   (use "git add <file>..." to include in what will be committed)
\&  #
\&  #       deliberate.untracked
\&  nothing added to commit but untracked files present (use "git add" to track)
.Ve
.PP
When in doubt, before you do anything else, check your status and read
it carefully, many questions are answered directly by the git status
output.
.SS "Using git to send patch emails"
.IX Subsection "Using git to send patch emails"
Please read perlhack first in order to figure out where your patches
should be sent.
.PP
In your ~/git/perl repository, set the destination email to perl's bug
tracker:
.PP
.Vb 1
\&  $ git config sendemail.to perlbug@perl.org
.Ve
.PP
Or maybe perl5\-porters:
.PP
.Vb 1
\&  $ git config sendemail.to perl5\-porters@perl.org
.Ve
.PP
Then you can use git directly to send your patch emails:
.PP
.Vb 1
\&  $ git send\-email 0001\-Rename\-Leon\-Brocard\-to\-Orange\-Brocard.patch
.Ve
.PP
You may need to set some configuration variables for your particular
email service provider. For example, to set your global git config to
send email via a gmail account:
.PP
.Vb 3
\&  $ git config \-\-global sendemail.smtpserver smtp.gmail.com
\&  $ git config \-\-global sendemail.smtpssl 1
\&  $ git config \-\-global sendemail.smtpuser YOURUSERNAME@gmail.com
.Ve
.PP
With this configuration, you will be prompted for your gmail password
when you run 'git send\-email'. You can also configure
\&\f(CW\*(C`sendemail.smtppass\*(C'\fR with your password if you don't care about having
your password in the .gitconfig file.
.SS "A note on derived files"
.IX Subsection "A note on derived files"
Be aware that many files in the distribution are derivative\*(--avoid
patching them, because git won't see the changes to them, and the build
process will overwrite them. Patch the originals instead. Most
utilities (like perldoc) are in this category, i.e. patch
\&\fIutils/perldoc.PL\fR rather than \fIutils/perldoc\fR. Similarly, don't
create patches for files under \f(CW$src_root\fR/ext from their copies found in
\&\f(CW$install_root\fR/lib. If you are unsure about the proper location of a
file that may have gotten copied while building the source
distribution, consult the \f(CW\*(C`MANIFEST\*(C'\fR.
.SS "Cleaning a working directory"
.IX Subsection "Cleaning a working directory"
The command \f(CW\*(C`git clean\*(C'\fR can with varying arguments be used as a
replacement for \f(CW\*(C`make clean\*(C'\fR.
.PP
To reset your working directory to a pristine condition you can do:
.PP
.Vb 1
\&  % git clean \-dxf
.Ve
.PP
However, be aware this will delete \s-1ALL\s0 untracked content. You can use
.PP
.Vb 1
\&  % git clean \-Xf
.Ve
.PP
to remove all ignored untracked files, such as build and test
byproduct, but leave any  manually created files alone.
.PP
If you only want to cancel some uncommitted edits, you can use \f(CW\*(C`git
checkout\*(C'\fR and give it a list of files to be reverted, or \f(CW\*(C`git checkout
\&\-f\*(C'\fR to revert them all.
.PP
If you want to cancel one or several commits, you can use \f(CW\*(C`git reset\*(C'\fR.
.SS "Bisecting"
.IX Subsection "Bisecting"
\&\f(CW\*(C`git\*(C'\fR provides a built-in way to determine which commit should be blamed
for introducing a given bug. \f(CW\*(C`git bisect\*(C'\fR performs a binary search of
history to locate the first failing commit. It is fast, powerful and
flexible, but requires some setup and to automate the process an auxiliary
shell script is needed.
.PP
The core provides a wrapper program, \fIPorting/bisect.pl\fR, which attempts to
simplify as much as possible, making bisecting as simple as running a Perl
one-liner. For example, if you want to know when this became an error:
.PP
.Vb 1
\&    perl \-e \*(Aqmy $a := 2\*(Aq
.Ve
.PP
you simply run this:
.PP
.Vb 1
\&    .../Porting/bisect.pl \-e \*(Aqmy $a := 2;\*(Aq
.Ve
.PP
Using \f(CW\*(C`bisect.pl\*(C'\fR, with one command (and no other files) it's easy to find
out
.IP "\(bu" 4
Which commit caused this example code to break?
.IP "\(bu" 4
Which commit caused this example code to start working?
.IP "\(bu" 4
Which commit added the first file to match this regex?
.IP "\(bu" 4
Which commit removed the last file to match this regex?
.PP
usually without needing to know which versions of perl to use as start and
end revisions, as \fIbisect.pl\fR automatically searches to find the earliest
stable version for which the test case passes. Run
\&\f(CW\*(C`Porting/bisect.pl \-\-help\*(C'\fR for the full documentation, including how to
set the \f(CW\*(C`Configure\*(C'\fR and build time options.
.PP
If you require more flexibility than \fIPorting/bisect.pl\fR has to offer, you'll
need to run \f(CW\*(C`git bisect\*(C'\fR yourself. It's most useful to use \f(CW\*(C`git bisect run\*(C'\fR
to automate the building and testing of perl revisions. For this you'll need
a shell script for \f(CW\*(C`git\*(C'\fR to call to test a particular revision. An example
script is \fIPorting/bisect\-example.sh\fR, which you should copy \fBoutside\fR of
the repository, as the bisect process will reset the state to a clean checkout
as it runs. The instructions below assume that you copied it as \fI~/run\fR and
then edited it as appropriate.
.PP
You first enter in bisect mode with:
.PP
.Vb 1
\&  % git bisect start
.Ve
.PP
For example, if the bug is present on \f(CW\*(C`HEAD\*(C'\fR but wasn't in 5.10.0,
\&\f(CW\*(C`git\*(C'\fR will learn about this when you enter:
.PP
.Vb 3
\&  % git bisect bad
\&  % git bisect good perl\-5.10.0
\&  Bisecting: 853 revisions left to test after this
.Ve
.PP
This results in checking out the median commit between \f(CW\*(C`HEAD\*(C'\fR and
\&\f(CW\*(C`perl\-5.10.0\*(C'\fR. You can then run the bisecting process with:
.PP
.Vb 1
\&  % git bisect run ~/run
.Ve
.PP
When the first bad commit is isolated, \f(CW\*(C`git bisect\*(C'\fR will tell you so:
.PP
.Vb 4
\&  ca4cfd28534303b82a216cfe83a1c80cbc3b9dc5 is first bad commit
\&  commit ca4cfd28534303b82a216cfe83a1c80cbc3b9dc5
\&  Author: Dave Mitchell <davem@fdisolutions.com>
\&  Date:   Sat Feb 9 14:56:23 2008 +0000
\&
\&      [perl #49472] Attributes + Unknown Error
\&      ...
\&
\&  bisect run success
.Ve
.PP
You can peek into the bisecting process with \f(CW\*(C`git bisect log\*(C'\fR and
\&\f(CW\*(C`git bisect visualize\*(C'\fR. \f(CW\*(C`git bisect reset\*(C'\fR will get you out of bisect
mode.
.PP
Please note that the first \f(CW\*(C`good\*(C'\fR state must be an ancestor of the
first \f(CW\*(C`bad\*(C'\fR state. If you want to search for the commit that \fIsolved\fR
some bug, you have to negate your test case (i.e. exit with \f(CW1\fR if \s-1OK\s0
and \f(CW0\fR if not) and still mark the lower bound as \f(CW\*(C`good\*(C'\fR and the
upper as \f(CW\*(C`bad\*(C'\fR. The \*(L"first bad commit\*(R" has then to be understood as
the \*(L"first commit where the bug is solved\*(R".
.PP
\&\f(CW\*(C`git help bisect\*(C'\fR has much more information on how you can tweak your
binary searches.
.SH "Topic branches and rewriting history"
.IX Header "Topic branches and rewriting history"
Individual committers should create topic branches under
\&\fByourname\fR/\fBsome_descriptive_name\fR. Other committers should check
with a topic branch's creator before making any change to it.
.PP
The simplest way to create a remote topic branch that works on all
versions of git is to push the current head as a new branch on the
remote, then check it out locally:
.PP
.Vb 3
\&  $ branch="$yourname/$some_descriptive_name"
\&  $ git push origin HEAD:$branch
\&  $ git checkout \-b $branch origin/$branch
.Ve
.PP
Users of git 1.7 or newer can do it in a more obvious manner:
.PP
.Vb 3
\&  $ branch="$yourname/$some_descriptive_name"
\&  $ git checkout \-b $branch
\&  $ git push origin \-u $branch
.Ve
.PP
If you are not the creator of \fByourname\fR/\fBsome_descriptive_name\fR, you
might sometimes find that the original author has edited the branch's
history. There are lots of good reasons for this. Sometimes, an author
might simply be rebasing the branch onto a newer source point.
Sometimes, an author might have found an error in an early commit which
they wanted to fix before merging the branch to blead.
.PP
Currently the master repository is configured to forbid
non-fast-forward merges. This means that the branches within can not be
rebased and pushed as a single step.
.PP
The only way you will ever be allowed to rebase or modify the history
of a pushed branch is to delete it and push it as a new branch under
the same name. Please think carefully about doing this. It may be
better to sequentially rename your branches so that it is easier for
others working with you to cherry-pick their local changes onto the new
version. (\s-1XXX:\s0 needs explanation).
.PP
If you want to rebase a personal topic branch, you will have to delete
your existing topic branch and push as a new version of it. You can do
this via the following formula (see the explanation about \f(CW\*(C`refspec\*(C'\fR's
in the git push documentation for details) after you have rebased your
branch:
.PP
.Vb 4
\&   # first rebase
\&   $ git checkout $user/$topic
\&   $ git fetch
\&   $ git rebase origin/blead
\&
\&   # then "delete\-and\-push"
\&   $ git push origin :$user/$topic
\&   $ git push origin $user/$topic
.Ve
.PP
\&\fB\s-1NOTE:\s0\fR it is forbidden at the repository level to delete any of the
\&\*(L"primary\*(R" branches. That is any branch matching
\&\f(CW\*(C`m!^(blead|maint|perl)!\*(C'\fR. Any attempt to do so will result in git
producing an error like this:
.PP
.Vb 7
\&    $ git push origin :blead
\&    *** It is forbidden to delete blead/maint branches in this repository
\&    error: hooks/update exited with error code 1
\&    error: hook declined to update refs/heads/blead
\&    To ssh://perl5.git.perl.org/perl
\&     ! [remote rejected] blead (hook declined)
\&     error: failed to push some refs to \*(Aqssh://perl5.git.perl.org/perl\*(Aq
.Ve
.PP
As a matter of policy we do \fBnot\fR edit the history of the blead and
maint\-* branches. If a typo (or worse) sneaks into a commit to blead or
maint\-*, we'll fix it in another commit. The only types of updates
allowed on these branches are \*(L"fast-forward's\*(R", where all history is
preserved.
.PP
Annotated tags in the canonical perl.git repository will never be
deleted or modified. Think long and hard about whether you want to push
a local tag to perl.git before doing so. (Pushing unannotated tags is
not allowed.)
.SS "Grafts"
.IX Subsection "Grafts"
The perl history contains one mistake which was not caught in the
conversion: a merge was recorded in the history between blead and
maint\-5.10 where no merge actually occurred. Due to the nature of git,
this is now impossible to fix in the public repository. You can remove
this mis-merge locally by adding the following line to your
\&\f(CW\*(C`.git/info/grafts\*(C'\fR file:
.PP
.Vb 1
\&  296f12bbbbaa06de9be9d09d3dcf8f4528898a49 434946e0cb7a32589ed92d18008aaa1d88515930
.Ve
.PP
It is particularly important to have this graft line if any bisecting
is done in the area of the \*(L"merge\*(R" in question.
.SH "WRITE ACCESS TO THE GIT REPOSITORY"
.IX Header "WRITE ACCESS TO THE GIT REPOSITORY"
Once you have write access, you will need to modify the \s-1URL\s0 for the
origin remote to enable pushing. Edit \fI.git/config\fR with the
\&\fIgit\-config\fR\|(1) command:
.PP
.Vb 1
\&  % git config remote.origin.url ssh://perl5.git.perl.org/perl.git
.Ve
.PP
You can also set up your user name and e\-mail address. Most people do
this once globally in their \fI~/.gitconfig\fR by doing something like:
.PP
.Vb 2
\&  % git config \-\-global user.name "\*(AEvar Arnfjo\*:r\*(d- Bjarmason"
\&  % git config \-\-global user.email avarab@gmail.com
.Ve
.PP
However if you'd like to override that just for perl then execute then
execute something like the following in \fIperl\fR:
.PP
.Vb 1
\&  % git config user.email avar@cpan.org
.Ve
.PP
It is also possible to keep \f(CW\*(C`origin\*(C'\fR as a git remote, and add a new
remote for ssh access:
.PP
.Vb 1
\&  % git remote add camel perl5.git.perl.org:/perl.git
.Ve
.PP
This allows you to update your local repository by pulling from
\&\f(CW\*(C`origin\*(C'\fR, which is faster and doesn't require you to authenticate, and
to push your changes back with the \f(CW\*(C`camel\*(C'\fR remote:
.PP
.Vb 2
\&  % git fetch camel
\&  % git push camel
.Ve
.PP
The \f(CW\*(C`fetch\*(C'\fR command just updates the \f(CW\*(C`camel\*(C'\fR refs, as the objects
themselves should have been fetched when pulling from \f(CW\*(C`origin\*(C'\fR.
.SH "Accepting a patch"
.IX Header "Accepting a patch"
If you have received a patch file generated using the above section,
you should try out the patch.
.PP
First we need to create a temporary new branch for these changes and
switch into it:
.PP
.Vb 1
\&  % git checkout \-b experimental
.Ve
.PP
Patches that were formatted by \f(CW\*(C`git format\-patch\*(C'\fR are applied with
\&\f(CW\*(C`git am\*(C'\fR:
.PP
.Vb 2
\&  % git am 0001\-Rename\-Leon\-Brocard\-to\-Orange\-Brocard.patch
\&  Applying Rename Leon Brocard to Orange Brocard
.Ve
.PP
If just a raw diff is provided, it is also possible use this two-step
process:
.PP
.Vb 2
\&  % git apply bugfix.diff
\&  % git commit \-a \-m "Some fixing" \-\-author="That Guy <that.guy@internets.com>"
.Ve
.PP
Now we can inspect the change:
.PP
.Vb 4
\&  % git show HEAD
\&  commit b1b3dab48344cff6de4087efca3dbd63548ab5e2
\&  Author: Leon Brocard <acme@astray.com>
\&  Date:   Fri Dec 19 17:02:59 2008 +0000
\&
\&    Rename Leon Brocard to Orange Brocard
\&
\&  diff \-\-git a/AUTHORS b/AUTHORS
\&  index 293dd70..722c93e 100644
\&  \-\-\- a/AUTHORS
\&  +++ b/AUTHORS
\&  @@ \-541,7 +541,7 @@ Lars Hecking                        <lhecking@nmrc.ucc.ie>
\&   Laszlo Molnar                  <laszlo.molnar@eth.ericsson.se>
\&   Leif Huhn                      <leif@hale.dkstat.com>
\&   Len Johnson                    <lenjay@ibm.net>
\&  \-Leon Brocard                   <acme@astray.com>
\&  +Orange Brocard                 <acme@astray.com>
\&   Les Peters                     <lpeters@aol.net>
\&   Lesley Binks                   <lesley.binks@gmail.com>
\&   Lincoln D. Stein               <lstein@cshl.org>
.Ve
.PP
If you are a committer to Perl and you think the patch is good, you can
then merge it into blead then push it out to the main repository:
.PP
.Vb 3
\&  % git checkout blead
\&  % git merge experimental
\&  % git push
.Ve
.PP
If you want to delete your temporary branch, you may do so with:
.PP
.Vb 6
\&  % git checkout blead
\&  % git branch \-d experimental
\&  error: The branch \*(Aqexperimental\*(Aq is not an ancestor of your current HEAD.
\&  If you are sure you want to delete it, run \*(Aqgit branch \-D experimental\*(Aq.
\&  % git branch \-D experimental
\&  Deleted branch experimental.
.Ve
.SS "Committing to blead"
.IX Subsection "Committing to blead"
The 'blead' branch will become the next production release of Perl.
.PP
Before pushing \fIany\fR local change to blead, it's incredibly important
that you do a few things, lest other committers come after you with
pitchforks and torches:
.IP "\(bu" 4
Make sure you have a good commit message. See \*(L"Commit
message\*(R" in perlhack for details.
.IP "\(bu" 4
Run the test suite. You might not think that one typo fix would break a
test file. You'd be wrong. Here's an example of where not running the
suite caused problems. A patch was submitted that added a couple of
tests to an existing .t. It couldn't possibly affect anything else, so
no need to test beyond the single affected .t, right?  But, the
submitter's email address had changed since the last of their
submissions, and this caused other tests to fail. Running the test
target given in the next item would have caught this problem.
.IP "\(bu" 4
If you don't run the full test suite, at least \f(CW\*(C`make test_porting\*(C'\fR.
This will run basic sanity checks. To see which sanity checks, have a
look in \fIt/porting\fR.
.IP "\(bu" 4
If you make any changes that affect miniperl or core routines that have
different code paths for miniperl, be sure to run \f(CW\*(C`make minitest\*(C'\fR.
This will catch problems that even the full test suite will not catch
because it runs a subset of tests under miniperl rather than perl.
.PP
\fIOn merging and rebasing\fR
.IX Subsection "On merging and rebasing"
.PP
Simple, one-off commits pushed to the 'blead' branch should be simple
commits that apply cleanly.  In other words, you should make sure your
work is committed against the current position of blead, so that you can
push back to the master repository without merging.
.PP
Sometimes, blead will move while you're building or testing your
changes.  When this happens, your push will be rejected with a message
like this:
.PP
.Vb 6
\&  To ssh://perl5.git.perl.org/perl.git
\&   ! [rejected]        blead \-> blead (non\-fast\-forward)
\&  error: failed to push some refs to \*(Aqssh://perl5.git.perl.org/perl.git\*(Aq
\&  To prevent you from losing history, non\-fast\-forward updates were rejected
\&  Merge the remote changes (e.g. \*(Aqgit pull\*(Aq) before pushing again.  See the
\&  \*(AqNote about fast\-forwards\*(Aq section of \*(Aqgit push \-\-help\*(Aq for details.
.Ve
.PP
When this happens, you can just \fIrebase\fR your work against the new
position of blead, like this (assuming your remote for the master
repository is \*(L"p5p\*(R"):
.PP
.Vb 2
\&  $ git fetch p5p
\&  $ git rebase p5p/blead
.Ve
.PP
You will see your commits being re-applied, and you will then be able to
push safely.  More information about rebasing can be found in the
documentation for the \fIgit\-rebase\fR\|(1) command.
.PP
For larger sets of commits that only make sense together, or that would
benefit from a summary of the set's purpose, you should use a merge
commit.  You should perform your work on a topic branch, which you should regularly rebase
against blead to ensure that your code is not broken by blead moving.
When you have finished your work, please perform a final rebase and
test.  Linear history is something that gets lost with every
commit on blead, but a final rebase makes the history linear
again, making it easier for future maintainers to see what has
happened.  Rebase as follows (assuming your work was on the
branch \f(CW\*(C`committer/somework\*(C'\fR):
.PP
.Vb 2
\&  $ git checkout committer/somework
\&  $ git rebase blead
.Ve
.PP
Then you can merge it into master like this:
.PP
.Vb 3
\&  $ git checkout blead
\&  $ git merge \-\-no\-ff \-\-no\-commit committer/somework
\&  $ git commit \-a
.Ve
.PP
The switches above deserve explanation.  \f(CW\*(C`\-\-no\-ff\*(C'\fR indicates that even
if all your work can be applied linearly against blead, a merge commit
should still be prepared.  This ensures that all your work will be shown
as a side branch, with all its commits merged into the mainstream blead
by the merge commit.
.PP
\&\f(CW\*(C`\-\-no\-commit\*(C'\fR means that the merge commit will be \fIprepared\fR but not
\&\fIcommitted\fR.  The commit is then actually performed when you run the
next command, which will bring up your editor to describe the commit.
Without \f(CW\*(C`\-\-no\-commit\*(C'\fR, the commit would be made with nearly no useful
message, which would greatly diminish the value of the merge commit as a
placeholder for the work's description.
.PP
When describing the merge commit, explain the purpose of the branch, and
keep in mind that this description will probably be used by the
eventual release engineer when reviewing the next perldelta document.
.SS "Committing to maintenance versions"
.IX Subsection "Committing to maintenance versions"
Maintenance versions should only be altered to add critical bug fixes,
see perlpolicy.
.PP
To commit to a maintenance version of perl, you need to create a local
tracking branch:
.PP
.Vb 1
\&  % git checkout \-\-track \-b maint\-5.005 origin/maint\-5.005
.Ve
.PP
This creates a local branch named \f(CW\*(C`maint\-5.005\*(C'\fR, which tracks the
remote branch \f(CW\*(C`origin/maint\-5.005\*(C'\fR. Then you can pull, commit, merge
and push as before.
.PP
You can also cherry-pick commits from blead and another branch, by
using the \f(CW\*(C`git cherry\-pick\*(C'\fR command. It is recommended to use the
\&\fB\-x\fR option to \f(CW\*(C`git cherry\-pick\*(C'\fR in order to record the \s-1SHA1\s0 of the
original commit in the new commit message.
.PP
Before pushing any change to a maint version, make sure you've
satisfied the steps in \*(L"Committing to blead\*(R" above.
.SS "Merging from a branch via GitHub"
.IX Subsection "Merging from a branch via GitHub"
While we don't encourage the submission of patches via GitHub, that
will still happen. Here is a guide to merging patches from a GitHub
repository.
.PP
.Vb 2
\&  % git remote add avar git://github.com/avar/perl.git
\&  % git fetch avar
.Ve
.PP
Now you can see the differences between the branch and blead:
.PP
.Vb 1
\&  % git diff avar/orange
.Ve
.PP
And you can see the commits:
.PP
.Vb 1
\&  % git log avar/orange
.Ve
.PP
If you approve of a specific commit, you can cherry pick it:
.PP
.Vb 1
\&  % git cherry\-pick 0c24b290ae02b2ab3304f51d5e11e85eb3659eae
.Ve
.PP
Or you could just merge the whole branch if you like it all:
.PP
.Vb 1
\&  % git merge avar/orange
.Ve
.PP
And then push back to the repository:
.PP
.Vb 1
\&  % git push
.Ve
.SS "A note on camel and dromedary"
.IX Subsection "A note on camel and dromedary"
The committers have \s-1SSH\s0 access to the two servers that serve
\&\f(CW\*(C`perl5.git.perl.org\*(C'\fR. One is \f(CW\*(C`perl5.git.perl.org\*(C'\fR itself (\fIcamel\fR),
which is the 'master' repository. The second one is
\&\f(CW\*(C`users.perl5.git.perl.org\*(C'\fR (\fIdromedary\fR), which can be used for
general testing and development. Dromedary syncs the git tree from
camel every few minutes, you should not push there. Both machines also
have a full \s-1CPAN\s0 mirror in /srv/CPAN, please use this. To share files
with the general public, dromedary serves your ~/public_html/ as
\&\f(CW\*(C`http://users.perl5.git.perl.org/~yourlogin/\*(C'\fR
.PP
These hosts have fairly strict firewalls to the outside. Outgoing, only
rsync, ssh and git are allowed. For http and ftp, you can use
http://webproxy:3128 as proxy. Incoming, the firewall tries to detect
attacks and blocks \s-1IP\s0 addresses with suspicious activity. This
sometimes (but very rarely) has false positives and you might get
blocked. The quickest way to get unblocked is to notify the admins.
.PP
These two boxes are owned, hosted, and operated by booking.com. You can
reach the sysadmins in #p5p on irc.perl.org or via mail to
\&\f(CW\*(C`perl5\-porters@perl.org\*(C'\fR.
