Moving a git layout from debian-only to debian+upstream
... and live happily with git-buildpackage
Let's say you have a
git
repository you have used thus far to maintain only the Debian part
of some package (i.e. no upstream sources on sight).
OK, you're right, that would be quite an uncommon
scenario for a git repository. In fact the truth is that you are in
such a situation because the git repo was obtained converting from
a subversion repo which was using the mergeWithUpstream
stuff of svn-buildpackage.
Now that you have git's space efficiency you want to change
this, import upstream sources, and possibly adhere to a branch
layout which is compatible with
git-buildpackage
(which is very simple in its minimal requirements: an
upstream
branch containing just upstream sources and a
master
branch containing a debianized source tree).
Out of the box
git-import-orig won't work since don't
have the upstream branch. Creating it branching from master (or
somewhere else) won't work either unfortunately. Indeed after
branching you will need to remove the
debian/ dir from
upstream and when you will merge upstream with master you will be
merging the removal as well, bad idea.
By myself I've found some horrifying solutions involving
using git-filter-branch on the upstream branch merged
from master and then squashing all the history of that branch with
git-rebase, but they are so horrible that I won't
mention them here more than this.
The nice solution came from a hint by madduck on the
creation of branches without ancestry. Here is the complete
recipe (assumed to be run from the master branch of the repo,
before creating any upstream branch):
$ git-symbolic-ref HEAD refs/heads/upstream
$ git rm --cached -r .
$ git commit --allow-empty -m 'initial upstream branch'
$ git checkout -f master
$ git merge upstream
$ git-import-orig --no-dch ../foo_1.2.3.orig.tar.gz
In short: you should create an
upstream branch without any ancestry, in it you should create
an empty commit, then merge it (vacuously) in master, and now
you're ready to call
git-import-orig to the rescue.
Feature request on
git-buildpackage
to support this out of the box is on the go:
bug #471560.