The patches we carry in debian/patches apply to the gcc-4.9 source extracted
from the gcc-4.9-source package. Note that this differs from the usual setup
where the source being patched by debian/patches lives in the same repository as
the patches themselves. The usual patch-management tools (most notably gbp-pq)
make this assumption, so as it stands we cannot use them. What we do instead is
described below.

We have a separate git repository that contains sources for the released gcc-4.9
packages and our patches, as git commits. This repository is at

 ssh://git.debian.org/git/crosstoolchain/gcc-4.9.git

There are 3 branches here:

- "upstream" is the source as released by the gcc project
- "master" is "upstream" + a few commits. This is the debianization of this
  source by the Debian gcc maintainer
- "patches" is "master" + a few commits. This is the debianization with patches
  needed for building a cross compiler. Each patch lives in a separate git
  commit

When a new Debian gcc release is made, the workflow to update the patches:

1. 'apt-get update' to make the new sources available

2. gcc-4.9 repository: Clean out the repository. "git status" should say that
the "working directory" is clean: no changes and no untracked files are present

3. gcc-4.9 repository: run

 gbp import-dsc --download gcc-4.9-source

This should import the new sources, updating the "upstream" and "master"
branches

4. gcc-4.9 repository: at this point, the "master" branch and the "patches"
branch have diverged, since the "patches" branch is a descendant of the old
"master", not the one we just updated. We thus rebase the "patches": Run

 git checkout patches; git rebase master

The patches may or may not apply cleanly to the new sources. If not, do the
usual git thing to resolve conflicts until we have our patches in a form we
like, descending from the "master" branch.

5. We can now export the patches as files that quilt can consume later.

cross-gcc repository: Remove old patches; run

 git rm debian/patches/*; mkdir debian/patches

gcc-4.9 repository: with the "patches" branch checked out, run

 git format-patch -o path_to_cross_gcc_repo/debian/patches master

cross-gcc repository: Commit new patches; run

 cd debian/patches; ls *.patch > series; git add *; git commit -m 'patch update'

6. gcc-4.9 repository: push the changes

 git push --all

works to push the "master" and "upstream". The "patches" branch doesn't follow a
linear history, however (more on this in a bit), so it needs to be pushed
explicitly:

 git push origin +patches:patches



This workflow allows us to use git to manage the patches as much as is possible.

An annoying property of this workflow is that in our gcc-4.9 tree it would be
normal to rewrite the history in the "patches" branch. The exported patches are
versioned normally in the cross-gcc tree, but in the gcc-4.9 tree, the "patches"
branch is more ephemeral. This is important to recognize. Thus the golden copy
of the current patch sent is in the exported files, NOT in the "patches" tree.
The exported patches can be imported back to git with the 'git am' command.

This can be wrapped into nicer scripts at some point, but let's test it out
first.
