So that I don't forget, and in the hopes of picking up tips from more experienced users, I'm going to write down my notes on using git to work on OpenLayers without any commit access. OpenLayers is a big project, and enhancing it in a significant way takes time and care. It's worth doing this work within a revision control system. The project has SVN sandboxes, but you can't use them offline (which I've been quite a bit this summer), you have to apply for them (I'm impatient), and my OpenLayers guru is annoyed by them. For these reasons, I've gone with a DVCS, and chose git on account of its nice bridge for Subversion:
To begin, clone the OpenLayers trunk. As of today, there have been 9623 revisions. Don't fetch all of them! In this example, I'm going to fetch a small revision range just short of the SVN head so that I can illustrate rebasing later.
$ git svn clone -r 9621:9622 http://svn.openlayers.org/trunk/openlayers ... r9621 = 4f62382011af58e8dd8be3b81a817fff80b4f4c4 (git-svn) Checked out HEAD: http://svn.openlayers.org/trunk/openlayers r9621
Now I have cloned OpenLayers and begin by default in a branch named "master". I'll do my work around http://trac.openlayers.org/ticket/1366 in a new branch named "atom".
I've already produced a patch using the methods I'm noting here, and will apply it to the new branch for the sake of this demo.
$ patch -p1 < atom-format-2.patch patching file lib/OpenLayers.js patching file lib/OpenLayers/Format/Atom.js patching file tests/Format/Atom.html patching file tests/list-tests.html $ git commit -a [atom 315def2] Apply patch from http://trac.openlayers.org/attachment/ticket/1366/atom-format-2.patch. 4 files changed, 1171 insertions(+), 0 deletions(-) create mode 100644 lib/OpenLayers/Format/Atom.js create mode 100644 tests/Format/Atom.html
If I were to run "git diff master" I'd recover that same patch. Now, there's a new attachment on my favorite OpenLayers ticket. A patch would have been nice, but a file is better than nothing. I'll create a new branch named "atom-pwr" based on "atom", copy the attached file and overwrite Format/Atom.js in the new branch.
Running "git diff atom" shows me the difference between atom-pwr and atom branches. I'll commit the changes to atom-pwr.
$ git commit -a [atom-pwr 29ae464] Incorporate pwr's work from http://trac.openlayers.org/attachment/ticket/1366/atom.js. 1 files changed, 48 insertions(+), 7 deletions(-)
A patch to the OpenLayers trunk incorporating all these changes is generated with:
Now, lib/OpenLayers/Control/GetFeature.js was added in r9623. To keep up with these changes, use
git-svn rebase. First on the master branch:
$ git checkout master $ git svn rebase M lib/OpenLayers/Control/GetFeature.js r9623 = 3e4282ccb05e9421d8f078893c5c495c55085621 (git-svn) First, rewinding head to replay your work on top of it... Fast-forwarded master to refs/remotes/git-svn.
And then on the development branch:
$ git checkout atom $ git svn rebase First, rewinding head to replay your work on top of it... Applying: Apply patch from http://trac.openlayers.org/attachment/ticket/1366/atom-format-2.patch.
Now a patch against the current head is generated by:
As nothing was changed in the files I'm working on between r9621 and r9623, this patch is identical to the one I started with. Up the new patch goes to the OpenLayers issue tracker to make things as easy as possible for an actual committer.