This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Adjusted the git config user.name/user.email example for what 99% of users would...
[perl5.git] / pod / perlrepository.pod
CommitLineData
0549aefb
LB
1=for comment
2Consistent formatting of this file is achieved with:
3 perl ./Porting/podtidy pod/perlrepository.pod
4
d7dd28b6
LB
5=head1 NAME
6
7perlrepository - Using the Perl source repository
8
9=head1 SYNOPSIS
10
dc3c3040 11All of Perl's source code is kept centrally in a Git repository at
c26da522
LB
12I<perl5.git.perl.org>. The repository contains many Perl revisions from
13Perl 1 onwards and all the revisions from Perforce, the version control
14system we were using previously. This repository is accessible in
15different ways.
d7dd28b6
LB
16
17The full repository takes up about 80MB of disk space. A check out of
7f4ffa9d 18the blead branch (that is, the main development branch, which contains
6a7cbfe8
LB
19bleadperl, the development version of perl 5) takes up about 160MB of
20disk space (including the repository). A build of bleadperl takes up
21about 200MB (including the repository and the check out).
d7dd28b6
LB
22
23=head1 GETTING ACCESS TO THE REPOSITORY
24
25=head2 READ ACCESS VIA THE WEB
26
dc3c3040
GA
27You may access the repository over the web. This allows you to browse
28the tree, see recent commits, subscribe to RSS feeds for the changes,
29search for particular commits and more. You may access it at:
d7dd28b6
LB
30
31 http://perl5.git.perl.org/perl.git
32
dc3c3040
GA
33A mirror of the repository is found at:
34
35 http://github.com/github/perl
36
d7dd28b6
LB
37=head2 READ ACCESS VIA GIT
38
39You will need a copy of Git for your computer. You can fetch a copy of
40the repository using the Git protocol (which uses port 9418):
41
e0b2b458 42 % git clone git://perl5.git.perl.org/perl.git perl-git
d7dd28b6 43
f755e97d 44This clones the repository and makes a local copy in the F<perl-git>
d7dd28b6
LB
45directory.
46
47If your local network does not allow you to use port 9418, then you can
cf5e7595 48fetch a copy of the repository over HTTP (this is at least 4x slower):
d7dd28b6 49
e0b2b458 50 % git clone http://perl5.git.perl.org/perl.git perl-http
d7dd28b6 51
f755e97d 52This clones the repository and makes a local copy in the F<perl-http>
d7dd28b6
LB
53directory.
54
55=head2 WRITE ACCESS TO THE REPOSITORY
56
6acba58e
LB
57If you are a committer, then you can fetch a copy of the repository
58that you can push back on with:
d7dd28b6 59
e0b2b458 60 % git clone ssh://perl5.git.perl.org/perl.git perl-ssh
d7dd28b6 61
8f718e95 62This clones the repository and makes a local copy in the F<perl-ssh>
d7dd28b6
LB
63directory.
64
c26da522 65If you cloned using the git protocol, which is faster than ssh, then
11ed6e28
AB
66you will need to modify the URL for the origin remote to enable
67pushing. To do that edit F<.git/config> with L<git-config(1)> like
68this:
1a0f15d5 69
e0b2b458 70 % git config remote.origin.url ssh://perl5.git.perl.org/perl.git
d7dd28b6 71
9d77ce3f
AB
72You can also set up your user name and e-mail address. Most people do
73this once globally in their F<~/.gitconfig> by doing something like:
184487f0 74
9d77ce3f
AB
75 % git config --global user.name "Ævar Arnfjörð Bjarmason"
76 % git config --global user.email avarab@gmail.com
77
78However if you'd like to override that just for perl then execute then
79execute something like the following in F<perl-git>:
80
81 % git config user.email avar@cpan.org
184487f0 82
6acba58e
LB
83It is also possible to keep C<origin> as a git remote, and add a new
84remote for ssh access:
f6c12373 85
dc3c3040 86 % git remote add camel perl5.git.perl.org:/perl.git
f6c12373 87
6acba58e 88This allows you to update your local repository by pulling from
f755e97d 89C<origin>, which is faster and doesn't require you to authenticate, and
6acba58e 90to push your changes back with the C<camel> remote:
f6c12373
VP
91
92 % git fetch camel
93 % git push camel
94
6acba58e
LB
95The C<fetch> command just updates the C<camel> refs, as the objects
96themselves should have been fetched when pulling from C<origin>.
f6c12373 97
3482f01a
DK
98=head2 A NOTE ON CAMEL AND DROMEDARY
99
100The committers have SSH access to the two servers that serve
333f8875
VP
101C<perl5.git.perl.org>. One is C<perl5.git.perl.org> itself (I<camel>),
102which is the 'master' repository. The second one is
103C<users.perl5.git.perl.org> (I<dromedary>), which can be used for
104general testing and development. Dromedary syncs the git tree from
105camel every few minutes, you should not push there. Both machines also
3482f01a
DK
106have a full CPAN mirror in /srv/CPAN, please use this. To share files
107with the general public, dromedary serves your ~/public_html/ as
333f8875 108C<http://users.perl5.git.perl.org/~yourlogin/>
b47aa495 109
3482f01a
DK
110These hosts have fairly strict firewalls to the outside. Outgoing, only
111rsync, ssh and git are allowed. For http and ftp, you can use
112http://webproxy:3128 as proxy. Incoming, the firewall tries to detect
113attacks and blocks IP addresses with suspicious activity. This
114sometimes (but very rarely) has false positives and you might get
115blocked. The quickest way to get unblocked is to notify the admins.
116
117These two boxes are owned, hosted, and operated by booking.com. You can
118reach the sysadmins in #p5p on irc.perl.org or via mail to
119C<perl5-porters@perl.org>
120
d7dd28b6
LB
121=head1 OVERVIEW OF THE REPOSITORY
122
6acba58e
LB
123Once you have changed into the repository directory, you can inspect
124it.
d7dd28b6 125
39219fd3 126After a clone the repository will contain a single local branch, which
50eca761 127will be the current branch as well, as indicated by the asterisk.
39219fd3
YO
128
129 % git branch
130 * blead
131
f755e97d 132Using the -a switch to C<branch> will also show the remote tracking
6acba58e 133branches in the repository:
39219fd3 134
d9847473 135 % git branch -a
09081495 136 * blead
d7dd28b6
LB
137 origin/HEAD
138 origin/blead
139 ...
140
6acba58e
LB
141The branches that begin with "origin" correspond to the "git remote"
142that you cloned from (which is named "origin"). Each branch on the
143remote will be exactly tracked by theses branches. You should NEVER do
144work on these remote tracking branches. You only ever do work in a
145local branch. Local branches can be configured to automerge (on pull)
146from a designated remote tracking branch. This is the case with the
147default branch C<blead> which will be configured to merge from the
148remote tracking branch C<origin/blead>.
39219fd3 149
d7dd28b6
LB
150You can see recent commits:
151
c2cf2042 152 % git log
d7dd28b6 153
6acba58e
LB
154And pull new changes from the repository, and update your local
155repository (must be clean first)
d7dd28b6
LB
156
157 % git pull
09081495 158
6acba58e
LB
159Assuming we are on the branch C<blead> immediately after a pull, this
160command would be more or less equivalent to:
39219fd3
YO
161
162 % git fetch
163 % git merge origin/blead
164
6acba58e
LB
165In fact if you want to update your local repository without touching
166your working directory you do:
39219fd3
YO
167
168 % git fetch
169
6acba58e
LB
170And if you want to update your remote-tracking branches for all defined
171remotes simultaneously you can do
39219fd3
YO
172
173 % git remote update
174
6acba58e
LB
175Neither of these last two commands will update your working directory,
176however both will update the remote-tracking branches in your
177repository.
39219fd3 178
09081495
LB
179To switch to another branch:
180
181 % git checkout origin/maint-5.8-dor
182
6051489b
NC
183To make a local branch of a remote branch:
184
185 % git checkout -b maint-5.10 origin/maint-5.10
186
09081495
LB
187To switch back to blead:
188
189 % git checkout blead
c2cf2042 190
39219fd3
YO
191=head2 FINDING OUT YOUR STATUS
192
193The most common git command you will use will probably be
194
195 % git status
196
6acba58e
LB
197This command will produce as output a description of the current state
198of the repository, including modified files and unignored untracked
199files, and in addition it will show things like what files have been
200staged for the next commit, and usually some useful information about
201how to change things. For instance the following:
39219fd3
YO
202
203 $ git status
204 # On branch blead
205 # Your branch is ahead of 'origin/blead' by 1 commit.
206 #
207 # Changes to be committed:
208 # (use "git reset HEAD <file>..." to unstage)
209 #
210 # modified: pod/perlrepository.pod
211 #
212 # Changed but not updated:
213 # (use "git add <file>..." to update what will be committed)
214 #
215 # modified: pod/perlrepository.pod
216 #
217 # Untracked files:
218 # (use "git add <file>..." to include in what will be committed)
219 #
220 # deliberate.untracked
221
6acba58e
LB
222This shows that there were changes to this document staged for commit,
223and that there were further changes in the working directory not yet
224staged. It also shows that there was an untracked file in the working
225directory, and as you can see shows how to change all of this. It also
0549aefb
LB
226shows that there is one commit on the working branch C<blead> which has
227not been pushed to the C<origin> remote yet. B<NOTE>: that this output
228is also what you see as a template if you do not provide a message to
229C<git commit>.
7f6effc7 230
bdaf0bc6
JV
231Assuming that you'd like to commit all the changes you've just made as a
232a single atomic unit, run this command:
233
234 % git commit -a
235
236(That C<-a> tells git to add every file you've changed to this commit.
ea9c0d74
JV
237New files aren't automatically added to your commit when you use C<commit
238-a> If you want to add files or to commit some, but not all of your
239changes, have a look at the documentation for C<git add>.)
bdaf0bc6 240
e9360695 241Git will start up your favorite text editor, so that you can craft a
bdaf0bc6
JV
242commit message for your change. See L</Commit message> below for more
243information about what makes a good commit message.
244
245Once you've finished writing your commit message and exited your editor,
246git will write your change to disk and tell you something like this:
7f6effc7 247
7f6effc7
YO
248 Created commit daf8e63: explain git status and stuff about remotes
249 1 files changed, 83 insertions(+), 3 deletions(-)
250
bdaf0bc6
JV
251
252If you re-run C<git status>, you should see something like this:
7f6effc7
YO
253
254 % git status
255 # On branch blead
256 # Your branch is ahead of 'origin/blead' by 2 commits.
257 #
258 # Untracked files:
259 # (use "git add <file>..." to include in what will be committed)
260 #
261 # deliberate.untracked
262 nothing added to commit but untracked files present (use "git add" to track)
263
39219fd3 264
6acba58e
LB
265When in doubt, before you do anything else, check your status and read
266it carefully, many questions are answered directly by the git status
267output.
39219fd3 268
c2cf2042
LB
269=head1 SUBMITTING A PATCH
270
271If you have a patch in mind for Perl, you should first get a copy of
272the repository:
273
274 % git clone git://perl5.git.perl.org/perl.git perl-git
275
276Then change into the directory:
277
278 % cd perl-git
279
6acba58e
LB
280Alternatively, if you already have a Perl repository, you should ensure
281that you're on the I<blead> branch, and your repository is up to date:
12322d22
A
282
283 % git checkout blead
284 % git pull
285
6a7cbfe8
LB
286It's preferable to patch against the latest blead version, since this
287is where new development occurs for all changes other than critical bug
288fixes. Critical bug fix patches should be made against the relevant
7f4ffa9d
RS
289maint branches, or should be submitted with a note indicating all the
290branches where the fix should be applied.
a44f43ac 291
6acba58e
LB
292Now that we have everything up to date, we need to create a temporary
293new branch for these changes and switch into it:
b1fccde5 294
a9b05323 295 % git checkout -b orange
23f8d33e 296
a9b05323
YO
297which is the short form of
298
b1fccde5
LB
299 % git branch orange
300 % git checkout orange
301
c2cf2042
LB
302Then make your changes. For example, if Leon Brocard changes his name
303to Orange Brocard, we should change his name in the AUTHORS file:
304
305 % perl -pi -e 's{Leon Brocard}{Orange Brocard}' AUTHORS
306
307You can see what files are changed:
308
309 % git status
f755e97d 310 # On branch orange
c2cf2042
LB
311 # Changes to be committed:
312 # (use "git reset HEAD <file>..." to unstage)
313 #
2699d634 314 # modified: AUTHORS
c2cf2042
LB
315 #
316
c2cf2042
LB
317And you can see the changes:
318
319 % git diff
320 diff --git a/AUTHORS b/AUTHORS
321 index 293dd70..722c93e 100644
322 --- a/AUTHORS
323 +++ b/AUTHORS
7df2e4bc 324 @@ -541,7 +541,7 @@ Lars Hecking <lhecking@nmrc.ucc.ie>
c2cf2042
LB
325 Laszlo Molnar <laszlo.molnar@eth.ericsson.se>
326 Leif Huhn <leif@hale.dkstat.com>
327 Len Johnson <lenjay@ibm.net>
328 -Leon Brocard <acme@astray.com>
329 +Orange Brocard <acme@astray.com>
330 Les Peters <lpeters@aol.net>
331 Lesley Binks <lesley.binks@gmail.com>
332 Lincoln D. Stein <lstein@cshl.org>
333
334Now commit your change locally:
335
dc3c3040 336 % git commit -a -m 'Rename Leon Brocard to Orange Brocard'
c2cf2042
LB
337 Created commit 6196c1d: Rename Leon Brocard to Orange Brocard
338 1 files changed, 1 insertions(+), 1 deletions(-)
339
dc3c3040
GA
340You can examine your last commit with:
341
342 % git show HEAD
343
344and if you are not happy with either the description or the patch
c26da522 345itself you can fix it up by editing the files once more and then issue:
dc3c3040
GA
346
347 % git commit -a --amend
348
c2cf2042
LB
349Now you should create a patch file for all your local changes:
350
2af192ee 351 % git format-patch origin
c2cf2042
LB
352 0001-Rename-Leon-Brocard-to-Orange-Brocard.patch
353
354You should now send an email to perl5-porters@perl.org with a
dc3c3040 355description of your changes, and include this patch file as an
333f8875
VP
356attachment. (See the next section for how to configure and use git to
357send these emails for you.)
c2cf2042 358
b1fccde5
LB
359If you want to delete your temporary branch, you may do so with:
360
361 % git checkout blead
362 % git branch -d orange
363 error: The branch 'orange' is not an ancestor of your current HEAD.
364 If you are sure you want to delete it, run 'git branch -D orange'.
365 % git branch -D orange
366 Deleted branch orange.
7df2e4bc 367
2d5f1d01
DG
368=head2 Using git to send patch emails
369
333f8875
VP
370In your ~/git/perl repository, set the destination email to the
371perl5-porters mailing list.
2d5f1d01
DG
372
373 $ git config sendemail.to perl5-porters@perl.org
374
375Then you can use git directly to send your patch emails:
376
377 $ git send-email 0001-Rename-Leon-Brocard-to-Orange-Brocard.patch
378
333f8875
VP
379You may need to set some configuration variables for your particular
380email service provider. For example, to set your global git config to
381send email via a gmail account:
2d5f1d01
DG
382
383 $ git config --global sendemail.smtpserver smtp.gmail.com
384 $ git config --global sendemail.smtpssl 1
385 $ git config --global sendemail.smtpuser YOURUSERNAME@gmail.com
386
333f8875
VP
387With this configuration, you will be prompted for your gmail password
388when you run 'git send-email'. You can also configure
389C<sendemail.smtppass> with your password if you don't care about having
390your password in the .gitconfig file.
2d5f1d01 391
a44f43ac
RGS
392=head2 A note on derived files
393
394Be aware that many files in the distribution are derivative--avoid
0549aefb
LB
395patching them, because git won't see the changes to them, and the build
396process will overwrite them. Patch the originals instead. Most
397utilities (like perldoc) are in this category, i.e. patch
398utils/perldoc.PL rather than utils/perldoc. Similarly, don't create
399patches for files under $src_root/ext from their copies found in
400$install_root/lib. If you are unsure about the proper location of a
401file that may have gotten copied while building the source
402distribution, consult the C<MANIFEST>.
a44f43ac 403
ac1cbfb0
JC
404As a special case, several files are regenerated by 'make regen' if
405your patch alters C<embed.fnc>. These are needed for compilation, but
406are included in the distribution so that you can build perl without
407needing another perl to generate the files. You must test with these
408regenerated files, but it is preferred that you instead note that
409'make regen is needed' in both the email and the commit message, and
410submit your patch without them. If you're submitting a series of
411patches, it might be best to submit the regenerated changes
412immediately after the source-changes that caused them, so as to have
413as little effect as possible on the bisectability of your patchset.
414
6e2cec71 415=for XXX
a44f43ac 416
6e2cec71 417What should we recommend about binary files now? Do we need anything?
a44f43ac
RGS
418
419=head2 Getting your patch accepted
420
bdaf0bc6 421If you are submitting a code patch there are several things that
a44f43ac
RGS
422you need to do.
423
424=over 4
425
bdaf0bc6
JV
426=item Commit message
427
428As you craft each patch you intend to submit to the Perl core, it's
429important to write a good commit message.
430
431Your commit message should start with a description of the problem that
432the patch corrects or new functionality that the patch adds.
433
bdaf0bc6
JV
434As a general rule of thumb, your commit message should let a programmer
435with a reasonable familiarity with the Perl core quickly understand what
436you were trying to do, how you were trying to do it and why the change
437matters to Perl.
438
439=over 4
440
441=item What
442
ac1cbfb0
JC
443Your commit message should describe what part of the Perl core you're
444changing and what you expect your patch to do.
bdaf0bc6
JV
445
446=item Why
447
448Perhaps most importantly, your commit message should describe why the
449change you are making is important. When someone looks at your change
450in six months or six years, your intent should be clear. If you're
451deprecating a feature with the intent of later simplifying another bit
452of code, say so. If you're fixing a performance problem or adding a new
453feature to support some other bit of the core, mention that.
454
455=item How
456
457While it's not necessary for documentation changes, new tests or
458trivial patches, it's often worth explaining how your change works.
459Even if it's clear to you today, it may not be clear to a porter next
460month or next year.
461
462=back
463
ea9c0d74
JV
464A commit message isn't intended to take the place of comments in your
465code. Commit messages should describe the change you made, while code
80a0006a
JV
466comments should describe the current state of the code. If you've just
467implemented a new feature, complete with doc, tests and well-commented
468code, a brief commit message will often suffice. If, however, you've
469just changed a single character deep in the parser or lexer, you might
ea9c0d74
JV
470need to write a small novel to ensure that future readers understand
471what you did and why you did it.
472
a44f43ac
RGS
473=item Comments, Comments, Comments
474
0549aefb
LB
475Be sure to adequately comment your code. While commenting every line
476is unnecessary, anything that takes advantage of side effects of
a44f43ac 477operators, that creates changes that will be felt outside of the
0549aefb
LB
478function being patched, or that others may find confusing should be
479documented. If you are going to err, it is better to err on the side
480of adding too many comments than too few.
a44f43ac
RGS
481
482=item Style
483
0549aefb
LB
484In general, please follow the particular style of the code you are
485patching.
a44f43ac 486
0549aefb
LB
487In particular, follow these general guidelines for patching Perl
488sources:
a44f43ac
RGS
489
490 8-wide tabs (no exceptions!)
491 4-wide indents for code, 2-wide indents for nested CPP #defines
492 try hard not to exceed 79-columns
493 ANSI C prototypes
494 uncuddled elses and "K&R" style for indenting control constructs
495 no C++ style (//) comments
496 mark places that need to be revisited with XXX (and revisit often!)
497 opening brace lines up with "if" when conditional spans multiple
498 lines; should be at end-of-line otherwise
499 in function definitions, name starts in column 0 (return value is on
500 previous line)
501 single space after keywords that are followed by parens, no space
502 between function name and following paren
503 avoid assignments in conditionals, but if they're unavoidable, use
504 extra paren, e.g. "if (a && (b = c)) ..."
505 "return foo;" rather than "return(foo);"
506 "if (!foo) ..." rather than "if (foo == FALSE) ..." etc.
507
508=item Testsuite
509
bdaf0bc6
JV
510If your patch changes code (rather than just changing documentation) you
511should also include one or more test cases which illustrate the bug you're
512fixing or validate the new functionality you're adding. In general,
513you should update an existing test file rather than create a new one.
514
0549aefb
LB
515Your testsuite additions should generally follow these guidelines
516(courtesy of Gurusamy Sarathy <gsar@activestate.com>):
a44f43ac
RGS
517
518 Know what you're testing. Read the docs, and the source.
519 Tend to fail, not succeed.
520 Interpret results strictly.
521 Use unrelated features (this will flush out bizarre interactions).
522 Use non-standard idioms (otherwise you are not testing TIMTOWTDI).
523 Avoid using hardcoded test numbers whenever possible (the
524 EXPECTED/GOT found in t/op/tie.t is much more maintainable,
525 and gives better failure reports).
526 Give meaningful error messages when a test fails.
527 Avoid using qx// and system() unless you are testing for them. If you
528 do use them, make sure that you cover _all_ perl platforms.
529 Unlink any temporary files you create.
530 Promote unforeseen warnings to errors with $SIG{__WARN__}.
531 Be sure to use the libraries and modules shipped with the version
532 being tested, not those that were already installed.
533 Add comments to the code explaining what you are testing for.
534 Make updating the '1..42' string unnecessary. Or make sure that
535 you update it.
536 Test _all_ behaviors of a given operator, library, or function:
537 - All optional arguments
538 - Return values in various contexts (boolean, scalar, list, lvalue)
539 - Use both global and lexical variables
540 - Don't forget the exceptional, pathological cases.
541
542=back
543
7df2e4bc
LB
544=head1 ACCEPTING A PATCH
545
546If you have received a patch file generated using the above section,
547you should try out the patch.
548
549First we need to create a temporary new branch for these changes and
550switch into it:
551
a9b05323 552 % git checkout -b experimental
7df2e4bc 553
6acba58e
LB
554Patches that were formatted by C<git format-patch> are applied with
555C<git am>:
7df2e4bc 556
2af192ee 557 % git am 0001-Rename-Leon-Brocard-to-Orange-Brocard.patch
7df2e4bc
LB
558 Applying Rename Leon Brocard to Orange Brocard
559
6acba58e
LB
560If just a raw diff is provided, it is also possible use this two-step
561process:
09645c26
VP
562
563 % git apply bugfix.diff
dc3c3040 564 % git commit -a -m "Some fixing" --author="That Guy <that.guy@internets.com>"
09645c26 565
7df2e4bc
LB
566Now we can inspect the change:
567
dc3c3040 568 % git show HEAD
7df2e4bc
LB
569 commit b1b3dab48344cff6de4087efca3dbd63548ab5e2
570 Author: Leon Brocard <acme@astray.com>
571 Date: Fri Dec 19 17:02:59 2008 +0000
572
573 Rename Leon Brocard to Orange Brocard
7df2e4bc 574
7df2e4bc
LB
575 diff --git a/AUTHORS b/AUTHORS
576 index 293dd70..722c93e 100644
577 --- a/AUTHORS
578 +++ b/AUTHORS
579 @@ -541,7 +541,7 @@ Lars Hecking <lhecking@nmrc.ucc.ie>
580 Laszlo Molnar <laszlo.molnar@eth.ericsson.se>
581 Leif Huhn <leif@hale.dkstat.com>
582 Len Johnson <lenjay@ibm.net>
583 -Leon Brocard <acme@astray.com>
584 +Orange Brocard <acme@astray.com>
585 Les Peters <lpeters@aol.net>
586 Lesley Binks <lesley.binks@gmail.com>
587 Lincoln D. Stein <lstein@cshl.org>
588
589If you are a committer to Perl and you think the patch is good, you can
75fb7651 590then merge it into blead then push it out to the main repository:
7df2e4bc
LB
591
592 % git checkout blead
d9847473 593 % git merge experimental
75fb7651 594 % git push
7df2e4bc
LB
595
596If you want to delete your temporary branch, you may do so with:
597
598 % git checkout blead
599 % git branch -d experimental
600 error: The branch 'experimental' is not an ancestor of your current HEAD.
601 If you are sure you want to delete it, run 'git branch -D experimental'.
602 % git branch -D experimental
603 Deleted branch experimental.
b0d36535
YO
604
605=head1 CLEANING A WORKING DIRECTORY
606
6acba58e 607The command C<git clean> can with varying arguments be used as a
dc3c3040 608replacement for C<make clean>.
b0d36535
YO
609
610To reset your working directory to a pristine condition you can do:
611
e0b2b458 612 % git clean -dxf
b0d36535
YO
613
614However, be aware this will delete ALL untracked content. You can use
615
e0b2b458 616 % git clean -Xf
b0d36535 617
6acba58e
LB
618to remove all ignored untracked files, such as build and test
619byproduct, but leave any manually created files alone.
b0d36535 620
0549aefb 621If you only want to cancel some uncommitted edits, you can use C<git
c26da522
LB
622checkout> and give it a list of files to be reverted, or C<git checkout
623-f> to revert them all.
f755e97d
RGS
624
625If you want to cancel one or several commits, you can use C<git reset>.
626
d82a90c1
VP
627=head1 BISECTING
628
6acba58e
LB
629C<git> provides a built-in way to determine, with a binary search in
630the history, which commit should be blamed for introducing a given bug.
d82a90c1 631
6acba58e 632Suppose that we have a script F<~/testcase.pl> that exits with C<0>
bdaf0bc6 633when some behaviour is correct, and with C<1> when it's faulty. You need
6acba58e
LB
634an helper script that automates building C<perl> and running the
635testcase:
d82a90c1
VP
636
637 % cat ~/run
638 #!/bin/sh
639 git clean -dxf
640 # If you can use ccache, add -Dcc=ccache\ gcc -Dld=gcc to the Configure line
1d5fe431
MB
641 # if Encode is not needed for the test, you can speed up the bisect by
642 # excluding it from the runs with -Dnoextensions=Encode
c0d1ef72
MB
643 sh Configure -des -Dusedevel -Doptimize="-g"
644 test -f config.sh || exit 125
645 # Correct makefile for newer GNU gcc
646 perl -ni -we 'print unless /<(?:built-in|command)/' makefile x2p/makefile
647 # if you just need miniperl, replace test_prep with miniperl
648 make -j4 test_prep
68814ba4 649 [ -x ./perl ] || exit 125
d82a90c1 650 ./perl -Ilib ~/testcase.pl
c0d1ef72 651 ret=$?
7930c68b 652 [ $ret -gt 127 ] && ret=127
c0d1ef72
MB
653 git clean -dxf
654 exit $ret
d82a90c1 655
6acba58e
LB
656This script may return C<125> to indicate that the corresponding commit
657should be skipped. Otherwise, it returns the status of
658F<~/testcase.pl>.
d82a90c1 659
bdaf0bc6 660You first enter in bisect mode with:
d82a90c1
VP
661
662 % git bisect start
663
6acba58e
LB
664For example, if the bug is present on C<HEAD> but wasn't in 5.10.0,
665C<git> will learn about this when you enter:
d82a90c1
VP
666
667 % git bisect bad
668 % git bisect good perl-5.10.0
669 Bisecting: 853 revisions left to test after this
670
6acba58e 671This results in checking out the median commit between C<HEAD> and
bdaf0bc6 672C<perl-5.10.0>. You can then run the bisecting process with:
d82a90c1
VP
673
674 % git bisect run ~/run
675
676When the first bad commit is isolated, C<git bisect> will tell you so:
677
678 ca4cfd28534303b82a216cfe83a1c80cbc3b9dc5 is first bad commit
679 commit ca4cfd28534303b82a216cfe83a1c80cbc3b9dc5
680 Author: Dave Mitchell <davem@fdisolutions.com>
681 Date: Sat Feb 9 14:56:23 2008 +0000
682
9469eb4a 683 [perl #49472] Attributes + Unknown Error
d82a90c1
VP
684 ...
685
686 bisect run success
687
6acba58e
LB
688You can peek into the bisecting process with C<git bisect log> and
689C<git bisect visualize>. C<git bisect reset> will get you out of bisect
690mode.
d82a90c1 691
6acba58e
LB
692Please note that the first C<good> state must be an ancestor of the
693first C<bad> state. If you want to search for the commit that I<solved>
694some bug, you have to negate your test case (i.e. exit with C<1> if OK
695and C<0> if not) and still mark the lower bound as C<good> and the
696upper as C<bad>. The "first bad commit" has then to be understood as
697the "first commit where the bug is solved".
d82a90c1 698
6acba58e
LB
699C<git help bisect> has much more information on how you can tweak your
700binary searches.
9d68b7ed 701
03050721
LB
702=head1 SUBMITTING A PATCH VIA GITHUB
703
704GitHub is a website that makes it easy to fork and publish projects
705with Git. First you should set up a GitHub account and log in.
706
707Perl's git repository is mirrored on GitHub at this page:
708
709 http://github.com/github/perl/tree/blead
710
711Visit the page and click the "fork" button. This clones the Perl git
712repository for you and provides you with "Your Clone URL" from which
713you should clone:
714
715 % git clone git@github.com:USERNAME/perl.git perl-github
716
bdaf0bc6 717The same patch as above, using github might look like this:
03050721
LB
718
719 % cd perl-github
720 % git remote add upstream git://github.com/github/perl.git
721 % git pull upstream blead
722 % git checkout -b orange
723 % perl -pi -e 's{Leon Brocard}{Orange Brocard}' AUTHORS
dc3c3040 724 % git commit -a -m 'Rename Leon Brocard to Orange Brocard'
03050721
LB
725 % git push origin orange
726
727The orange branch has been pushed to GitHub, so you should now send an
728email to perl5-porters@perl.org with a description of your changes and
729the following information:
730
731 http://github.com/USERNAME/perl/tree/orange
732 git@github.com:USERNAME/perl.git branch orange
733
c26da522
LB
734=head1 MERGING FROM A BRANCH VIA GITHUB
735
736If someone has provided a branch via GitHub and you are a committer,
5c9c28c6 737you should use the following in your perl-ssh directory:
c26da522
LB
738
739 % git remote add dandv git://github.com/dandv/perl.git
740 % git fetch
741
742Now you can see the differences between the branch and blead:
743
744 % git diff dandv/blead
745
746And you can see the commits:
747
748 % git log dandv/blead
749
750If you approve of a specific commit, you can cherry pick it:
751
2bab0636
LB
752 % git cherry-pick 3adac458cb1c1d41af47fc66e67b49c8dec2323f
753
754Or you could just merge the whole branch if you like it all:
755
756 % git merge dandv/blead
c26da522
LB
757
758And then push back to the repository:
759
760 % git push
761
ce2a8773
JV
762
763=head1 TOPIC BRANCHES AND REWRITING HISTORY
764
765Individual committers should create topic branches under
333f8875
VP
766B<yourname>/B<some_descriptive_name>. Other committers should check
767with a topic branch's creator before making any change to it.
ce2a8773
JV
768
769If you are not the creator of B<yourname>/B<some_descriptive_name>, you
770might sometimes find that the original author has edited the branch's
771history. There are lots of good reasons for this. Sometimes, an author
333f8875
VP
772might simply be rebasing the branch onto a newer source point.
773Sometimes, an author might have found an error in an early commit which
774they wanted to fix before merging the branch to blead.
ce2a8773 775
333f8875
VP
776Currently the master repository is configured to forbid
777non-fast-forward merges. This means that the branches within can not
778be rebased and pushed as a single step.
ce2a8773 779
333f8875
VP
780The only way you will ever be allowed to rebase or modify the history
781of a pushed branch is to delete it and push it as a new branch under
782the same name. Please think carefully about doing this. It may be
783better to sequentially rename your branches so that it is easier for
784others working with you to cherry-pick their local changes onto the new
785version. (XXX: needs explanation).
ce2a8773
JV
786
787If you want to rebase a personal topic branch, you will have to delete
2699d634
YO
788your existing topic branch and push as a new version of it. You can do
789this via the following formula (see the explanation about C<refspec>'s
790in the git push documentation for details) after you have rebased your
791branch:
792
793 # first rebase
794 $ git checkout $user/$topic
795 $ git fetch
796 $ git rebase origin/blead
797
798 # then "delete-and-push"
799 $ git push origin :$user/$topic
800 $ git push origin $user/$topic
801
802B<NOTE:> it is forbidden at the repository level to delete any of the
333f8875
VP
803"primary" branches. That is any branch matching
804C<m!^(blead|maint|perl)!>. Any attempt to do so will result in git
805producing an error like this:
2699d634
YO
806
807 $ git push origin :blead
808 *** It is forbidden to delete blead/maint branches in this repository
809 error: hooks/update exited with error code 1
810 error: hook declined to update refs/heads/blead
333f8875 811 To ssh://perl5.git.perl.org/perl
2699d634 812 ! [remote rejected] blead (hook declined)
333f8875 813 error: failed to push some refs to 'ssh://perl5.git.perl.org/perl'
2699d634 814
333f8875
VP
815As a matter of policy we do B<not> edit the history of the blead and
816maint-* branches. If a typo (or worse) sneaks into a commit to blead or
817maint-*, we'll fix it in another commit. The only types of updates
818allowed on these branches are "fast-forward's", where all history is
819preserved.
2699d634 820
333f8875
VP
821Annotated tags in the canonical perl.git repository will never be
822deleted or modified. Think long and hard about whether you want to push
823a local tag to perl.git before doing so. (Pushing unannotated tags is
2699d634 824not allowed.)
ce2a8773 825
9469eb4a 826=head1 COMMITTING TO MAINTENANCE VERSIONS
9d68b7ed 827
7f4ffa9d
RS
828Maintenance versions should only be altered to add critical bug fixes.
829
9d68b7ed
LB
830To commit to a maintenance version of perl, you need to create a local
831tracking branch:
832
833 % git checkout --track -b maint-5.005 origin/maint-5.005
834
0549aefb
LB
835This creates a local branch named C<maint-5.005>, which tracks the
836remote branch C<origin/maint-5.005>. Then you can pull, commit, merge
837and push as before.
b0d36535 838
f755e97d 839You can also cherry-pick commits from blead and another branch, by
0549aefb
LB
840using the C<git cherry-pick> command. It is recommended to use the
841B<-x> option to C<git cherry-pick> in order to record the SHA1 of the
842original commit in the new commit message.
f755e97d 843
e8589bfa
AV
844=head1 GRAFTS
845
846The perl history contains one mistake which was not caught in the
ac036724 847conversion: a merge was recorded in the history between blead and
333f8875
VP
848maint-5.10 where no merge actually occurred. Due to the nature of git,
849this is now impossible to fix in the public repository. You can remove
850this mis-merge locally by adding the following line to your
e8589bfa
AV
851C<.git/info/grafts> file:
852
853 296f12bbbbaa06de9be9d09d3dcf8f4528898a49 434946e0cb7a32589ed92d18008aaa1d88515930
854
855It is particularly important to have this graft line if any bisecting
856is done in the area of the "merge" in question.
857
bdaf0bc6
JV
858
859
f755e97d
RGS
860=head1 SEE ALSO
861
862The git documentation, accessible via C<git help command>.
0549aefb 863