X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/86032e6d69d00cea2f781c52c22e8d7418070b6a..70bd58e99cf8c4f66531ed2261be494f9fe83a00:/pod/perlgit.pod diff --git a/pod/perlgit.pod b/pod/perlgit.pod index 2b00774..000d6ac 100644 --- a/pod/perlgit.pod +++ b/pod/perlgit.pod @@ -107,31 +107,33 @@ 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: - $ git status - # On branch blead - # Your branch is ahead of 'origin/blead' by 1 commit. - # - # Changes to be committed: - # (use "git reset HEAD ..." to unstage) - # - # modified: pod/perlgit.pod - # - # Changed but not updated: - # (use "git add ..." to update what will be committed) - # - # modified: pod/perlgit.pod - # - # Untracked files: - # (use "git add ..." to include in what will be committed) - # - # deliberate.untracked + % git status + On branch blead + Your branch is ahead of 'origin/blead' by 1 commit. + + Changes to be committed: + (use "git reset HEAD ..." to unstage) + + modified: pod/perlgit.pod + + Changes not staged for commit: + (use "git add ..." to update what will be committed) + (use "git checkout -- ..." to discard changes in working + directory) + + modified: pod/perlgit.pod + + Untracked files: + (use "git add ..." to include in what will be committed) + + deliberate.untracked 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 C which has -not been pushed to the C remote yet. B: that this output +not been pushed to the C remote yet. B: This output is also what you see as a template if you do not provide a message to C. @@ -177,35 +179,34 @@ to Orange Brocard, we should change his name in the AUTHORS file: You can see what files are changed: % git status - # On branch orange - # Changes to be committed: - # (use "git reset HEAD ..." to unstage) - # - # modified: AUTHORS - # + On branch orange + Changes to be committed: + (use "git reset HEAD ..." to unstage) + + modified: AUTHORS And you can see the changes: - % git diff - diff --git a/AUTHORS b/AUTHORS - index 293dd70..722c93e 100644 - --- a/AUTHORS - +++ b/AUTHORS - @@ -541,7 +541,7 @@ Lars Hecking - Laszlo Molnar - Leif Huhn - Len Johnson - -Leon Brocard - +Orange Brocard - Les Peters - Lesley Binks - Lincoln D. Stein + % git diff + diff --git a/AUTHORS b/AUTHORS + index 293dd70..722c93e 100644 + --- a/AUTHORS + +++ b/AUTHORS + @@ -541,7 +541,7 @@ Lars Hecking + Laszlo Molnar + Leif Huhn + Len Johnson + -Leon Brocard + +Orange Brocard + Les Peters + Lesley Binks + Lincoln D. Stein Now commit your change locally: - % git commit -a -m 'Rename Leon Brocard to Orange Brocard' - Created commit 6196c1d: Rename Leon Brocard to Orange Brocard - 1 files changed, 1 insertions(+), 1 deletions(-) + % git commit -a -m 'Rename Leon Brocard to Orange Brocard' + Created commit 6196c1d: Rename Leon Brocard to Orange Brocard + 1 files changed, 1 insertions(+), 1 deletions(-) The C<-a> 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 @@ -225,20 +226,20 @@ 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: - Created commit daf8e63: explain git status and stuff about remotes - 1 files changed, 83 insertions(+), 3 deletions(-) + Created commit daf8e63: explain git status and stuff about remotes + 1 files changed, 83 insertions(+), 3 deletions(-) If you re-run C, you should see something like this: - % git status - # On branch blead - # Your branch is ahead of 'origin/blead' by 2 commits. - # - # Untracked files: - # (use "git add ..." to include in what will be committed) - # - # deliberate.untracked - nothing added to commit but untracked files present (use "git add" to track) + % git status + On branch orange + Untracked files: + (use "git add ..." to include in what will be committed) + + deliberate.untracked + + nothing added to commit but untracked files present (use "git add" to + track) When in doubt, before you do anything else, check your status and read it carefully, many questions are answered directly by the git status @@ -255,12 +256,12 @@ itself you can fix it up by editing the files once more and then issue: Now you should create a patch file for all your local changes: - % git format-patch -M origin.. + % git format-patch -M blead.. 0001-Rename-Leon-Brocard-to-Orange-Brocard.patch Or for a lot of changes, e.g. from a topic branch: - % git format-patch --stdout -M origin.. > topic-branch-changes.patch + % git format-patch --stdout -M blead.. > topic-branch-changes.patch You should now send an email to L with a description of your @@ -271,24 +272,24 @@ should only send patches to L directly if the patch is not ready to be applied, but intended for discussion. -See the next section for how to configure and use git to send these -emails for you. +Please do not use git-send-email(1) to send your patch. See L for more information. If you want to delete your temporary branch, you may do so with: - % git checkout blead - % git branch -d orange - error: The branch 'orange' is not an ancestor of your current HEAD. - If you are sure you want to delete it, run 'git branch -D orange'. - % git branch -D orange - Deleted branch orange. + % git checkout blead + % git branch -d orange + error: The branch 'orange' is not an ancestor of your current HEAD. + If you are sure you want to delete it, run 'git branch -D orange'. + % git branch -D orange + Deleted branch orange. =head2 Committing your changes Assuming that you'd like to commit all the changes you've made as a single atomic unit, run this command: - % git commit -a + % git commit -a (That C<-a> tells git to add every file you've changed to this commit. New files aren't automatically added to your commit when you use @@ -303,20 +304,22 @@ 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: - Created commit daf8e63: explain git status and stuff about remotes - 1 files changed, 83 insertions(+), 3 deletions(-) + Created commit daf8e63: explain git status and stuff about remotes + 1 files changed, 83 insertions(+), 3 deletions(-) If you re-run C, you should see something like this: - % git status - # On branch blead - # Your branch is ahead of 'origin/blead' by 2 commits. - # - # Untracked files: - # (use "git add ..." to include in what will be committed) - # - # deliberate.untracked - nothing added to commit but untracked files present (use "git add" to track) + % git status + On branch blead + Your branch is ahead of 'origin/blead' by 2 commits. + (use "git push" to publish your local commits) + Untracked files: + (use "git add ..." to include in what will be committed) + + deliberate.untracked + + nothing added to commit but untracked files present (use "git add" to + track) When in doubt, before you do anything else, check your status and read it carefully, many questions are answered directly by the git status @@ -324,23 +327,27 @@ output. =head2 Sending patch emails -After you've generated your patch you should sent it -to perlbug@perl.org (as discussed L with a normal mail client as an +After you've generated your patch you should send it +to L (as discussed L) with a normal mail client as an attachment, along with a description of the patch. You B use git-send-email(1) to send patches generated with git-format-patch(1). The RT ticketing system living behind -perlbug@perl.org does not respect the inline contents of E-Mails, -sending an inline patch to RT guarantees that your patch will be -destroyed. +L does not respect the inline +contents of E-Mails, sending an inline patch to RT guarantees that your +patch will be destroyed. Someone may download your patch from RT, which will result in the -subject (the first line of the commit message) being omitted. See RT -#74192 and commit a4583001 for an example. Alternatively someone may +subject (the first line of the commit message) being omitted. See +L and +L +for an example. Alternatively someone may apply your patch from RT after it arrived in their mailbox, by which -time RT will have modified the inline content of the message. See RT -#74532 and commit f9bcfeac for a bad example of this failure mode. +time RT will have modified the inline content of the message. See +L and +L +for a bad example of this failure mode. =head2 A note on derived files @@ -349,10 +356,10 @@ 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 F rather than F. Similarly, don't -create patches for files under $src_root/ext from their copies found in -$install_root/lib. If you are unsure about the proper location of a -file that may have gotten copied while building the source -distribution, consult the C. +create patches for files under F<$src_root/ext> from their copies found +in F<$install_root/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. =head2 Cleaning a working directory @@ -368,7 +375,7 @@ However, be aware this will delete ALL untracked content. You can use % git clean -Xf to remove all ignored untracked files, such as build and test -byproduct, but leave any manually created files alone. +byproduct, but leave any manually created files alone. If you only want to cancel some uncommitted edits, you can use C and give it a list of files to be reverted, or C, with one command (and no other files) it's easy to find -out +Using F, with one command (and no other files) it's easy to +find out =over 4 @@ -418,8 +425,8 @@ Which commit removed the last file to match this regex? =back usually without needing to know which versions of perl to use as start and -end revisions, as F automatically searches to find the earliest -stable version for which the test case passes. Run +end revisions, as F automatically searches to find the +earliest stable version for which the test case passes. Run C for the full documentation, including how to set the C and build time options. @@ -474,27 +481,35 @@ the "first commit where the bug is solved". C has much more information on how you can tweak your binary searches. +Following bisection you may wish to configure, build and test perl at +commits identified by the bisection process. Sometimes, particularly +with older perls, C may fail during this process. In this case +you may be able to patch the source code at the older commit point. To +do so, please follow the suggestions provided in +L. + =head2 Topic branches and rewriting history Individual committers should create topic branches under -B/B. Other committers should check -with a topic branch's creator before making any change to it. +B/B: -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: + % branch="$yourname/$some_descriptive_name" + % git checkout -b $branch + ... do local edits, commits etc ... + % git push origin -u $branch - $ branch="$yourname/$some_descriptive_name" - $ git push origin HEAD:$branch - $ git checkout -b $branch origin/$branch +Should you be stuck with an ancient version of git (prior to 1.7), then +C will not have the C<-u> switch, and you have to replace the +last step with the following sequence: -Users of git 1.7 or newer can do it in a more obvious manner: + % git push origin $branch:refs/heads/$branch + % git config branch.$branch.remote origin + % git config branch.$branch.merge refs/heads/$branch - $ branch="$yourname/$some_descriptive_name" - $ git checkout -b $branch - $ git push origin -u $branch +If you want to make changes to someone else's topic branch, you should +check with its creator before making any change to it. -If you are not the creator of B/B, you +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. @@ -518,37 +533,37 @@ this via the following formula (see the explanation about C's in the git push documentation for details) after you have rebased your branch: - # first rebase - $ git checkout $user/$topic - $ git fetch - $ git rebase origin/blead + # 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 + # then "delete-and-push" + % git push origin :$user/$topic + % git push origin $user/$topic B it is forbidden at the repository level to delete any of the "primary" branches. That is any branch matching C. Any attempt to do so will result in git producing an error like this: - $ 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 'ssh://perl5.git.perl.org/perl' + % 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 'ssh://perl5.git.perl.org/perl' As a matter of policy we do B 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 "fast-forward's", where all history is +allowed on these branches are "fast-forwards", where all history is preserved. 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 +a local tag to perl.git before doing so. (Pushing simple tags is not allowed.) =head2 Grafts @@ -560,7 +575,7 @@ this is now impossible to fix in the public repository. You can remove this mis-merge locally by adding the following line to your C<.git/info/grafts> file: - 296f12bbbbaa06de9be9d09d3dcf8f4528898a49 434946e0cb7a32589ed92d18008aaa1d88515930 + 296f12bbbbaa06de9be9d09d3dcf8f4528898a49 434946e0cb7a32589ed92d18008aaa1d88515930 It is particularly important to have this graft line if any bisecting is done in the area of the "merge" in question. @@ -579,7 +594,7 @@ this once globally in their F<~/.gitconfig> by doing something like: % git config --global user.name "Ævar Arnfjörð Bjarmason" % git config --global user.email avarab@gmail.com -However, if you'd like to override that just for perl, +However, if you'd like to override that just for perl, execute something like the following in F: % git config user.email avar@cpan.org @@ -607,42 +622,49 @@ you should try out the patch. First we need to create a temporary new branch for these changes and switch into it: - % git checkout -b experimental + % git checkout -b experimental Patches that were formatted by C are applied with C: - % git am 0001-Rename-Leon-Brocard-to-Orange-Brocard.patch - Applying Rename Leon Brocard to Orange Brocard + % git am 0001-Rename-Leon-Brocard-to-Orange-Brocard.patch + Applying Rename Leon Brocard to Orange Brocard + +Note that some UNIX mail systems can mess with text attachments containing +'From '. This will fix them up: + + % perl -pi -e's/^>From /From /' \ + 0001-Rename-Leon-Brocard-to-Orange-Brocard.patch If just a raw diff is provided, it is also possible use this two-step process: - % git apply bugfix.diff - % git commit -a -m "Some fixing" --author="That Guy " + % git apply bugfix.diff + % git commit -a -m "Some fixing" \ + --author="That Guy " Now we can inspect the change: - % git show HEAD - commit b1b3dab48344cff6de4087efca3dbd63548ab5e2 - Author: Leon Brocard - 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 - Laszlo Molnar - Leif Huhn - Len Johnson - -Leon Brocard - +Orange Brocard - Les Peters - Lesley Binks - Lincoln D. Stein + % git show HEAD + commit b1b3dab48344cff6de4087efca3dbd63548ab5e2 + Author: Leon Brocard + 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 + Laszlo Molnar + Leif Huhn + Len Johnson + -Leon Brocard + +Orange Brocard + Les Peters + Lesley Binks + Lincoln D. Stein 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: @@ -653,12 +675,13 @@ then merge it into blead then push it out to the main repository: If you want to delete your temporary branch, you may do so with: - % git checkout blead - % git branch -d experimental - error: The branch 'experimental' is not an ancestor of your current HEAD. - If you are sure you want to delete it, run 'git branch -D experimental'. - % git branch -D experimental - Deleted branch experimental. + % git checkout blead + % git branch -d experimental + error: The branch 'experimental' is not an ancestor of your current + HEAD. If you are sure you want to delete it, run 'git branch -D + experimental'. + % git branch -D experimental + Deleted branch experimental. =head2 Committing to blead @@ -680,8 +703,8 @@ message> for details. 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 +tests to an existing F<.t>. It couldn't possibly affect anything else, so +no need to test beyond the single affected F<.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. @@ -712,19 +735,20 @@ 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: - To ssh://perl5.git.perl.org/perl.git - ! [rejected] blead -> blead (non-fast-forward) - error: failed to push some refs to 'ssh://perl5.git.perl.org/perl.git' - To prevent you from losing history, non-fast-forward updates were rejected - Merge the remote changes (e.g. 'git pull') before pushing again. See the - 'Note about fast-forwards' section of 'git push --help' for details. + To ssh://perl5.git.perl.org/perl.git + ! [rejected] blead -> blead (non-fast-forward) + error: failed to push some refs to 'ssh://perl5.git.perl.org/perl.git' + To prevent you from losing history, non-fast-forward updates were + rejected Merge the remote changes (e.g. 'git pull') before pushing + again. See the 'Note about fast-forwards' section of 'git push --help' + for details. When this happens, you can just I your work against the new position of blead, like this (assuming your remote for the master repository is "p5p"): - $ git fetch p5p - $ git rebase p5p/blead + % git fetch p5p + % git rebase p5p/blead 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 @@ -742,14 +766,14 @@ again, making it easier for future maintainers to see what has happened. Rebase as follows (assuming your work was on the branch C<< committer/somework >>): - $ git checkout committer/somework - $ git rebase blead + % git checkout committer/somework + % git rebase blead Then you can merge it into master like this: - $ git checkout blead - $ git merge --no-ff --no-commit committer/somework - $ git commit -a + % git checkout blead + % git merge --no-ff --no-commit committer/somework + % git commit -a The switches above deserve explanation. C<--no-ff> indicates that even if all your work can be applied linearly against blead, a merge commit @@ -828,6 +852,9 @@ on other OSes test the change before you commit it to blead. Fortunately, there is a way to get your change smoke-tested on various OSes: push it to a "smoke-me" branch and wait for certain automated smoke-testers to report the results from their OSes. +A "smoke-me" branch is identified by the branch name: specifically, as +seen on perl5.git.perl.org it must be a local branch whose first name +component is precisely C. The procedure for doing this is roughly as follows (using the example of of tonyc's smoke-me branch called win32stat): @@ -882,9 +909,10 @@ Finally, you should then delete the remote smoke-me branch: (which is likely to produce a warning like this, which can be ignored: - remote: fatal: ambiguous argument 'refs/heads/smoke-me/tonyc/win32stat': - unknown revision or path not in the working tree. - remote: Use '--' to separate paths from revisions + remote: fatal: ambiguous argument + 'refs/heads/smoke-me/tonyc/win32stat': + unknown revision or path not in the working tree. + remote: Use '--' to separate paths from revisions ) and then delete your local branch: @@ -898,17 +926,17 @@ which is the 'master' repository. The second one is C (I), 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 CPAN mirror in /srv/CPAN, please use this. To share files -with the general public, dromedary serves your ~/public_html/ as -C +have a full CPAN mirror in F, please use this. To share files +with the general public, dromedary serves your F<~/public_html/> as +C> 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 +L as proxy. Incoming, the firewall tries to detect attacks and blocks IP 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. 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 -C. +L.