[OpenStack-Infra] Announcing a simple new tool: git-restack

James E. Blair corvus at inaugust.com
Tue Feb 2 17:53:53 UTC 2016


Hi,

I'm pleased to announce a new and very simple tool to help with managing
large patch series with our Gerrit workflow.

In our workflow we often find it necessary to create a series of
dependent changes in order to make a larger change in manageable chunks,
or because we have a series of related changes.  Because these are part
of larger efforts, it often seems like they are even more likely to have
to go through many revisions before they are finally merged.  Each step
along the way reviewers look at the patches in Gerrit and leave
comments.  As a reviewer, I rely heavily on looking at the difference
between patchsets to see how the series evolves over time.

Occasionally we also find it necessary to re-order the patch series, or
to include or exclude a particular patch from the series.  Of course the
interactive git rebase command makes this easy -- but in order to use
it, you need to supply a base upon which to "rebase".  A simple choice
would be to rebase the series on master, however, that creates
difficulties for reviewers if master has moved on since the series was
begun.  It is very difficult to see any actual intended changes between
different patch sets when they have different bases which include
unrelated changes.

The best thing to do to make it easy for reviewers (and yourself as you
try to follow your own changes) is to keep the same "base" for the
entire patch series even as you "rebase" it.  If you know how long your
patch series is, you can simply run "git rebase -i HEAD~N" where N is
the patch series depth.  But if you're like me and have trouble with
numbers other than 0 and 1, then you'll like this new command.

The git-restack command is very simple -- it looks for the most recent
commit that is both in your current branch history and in the branch it
was based on.  It uses that as the base for an interactive rebase
command.  This means that any time you are editing a patch series, you
can simply run:

  git restack

and you will be placed in an interactive rebase session with all of the
commits in that patch series staged.  Git-restack is somewhat
branch-aware as well -- it will read a .gitreview file to find the
remote branch to compare against.  If your stack was based on a
different branch, simply run:

  git restack <branchname>

and it will use that branch for comparison instead.

Git-restack is on pypi so you can install it with:

  pip install git-restack

The source code is based heavily on git-review and is in Gerrit under
openstack-infra/git-restack.

https://pypi.python.org/pypi/git-restack/1.0.0
https://git.openstack.org/cgit/openstack-infra/git-restack

I hope you find this useful,

Jim



More information about the OpenStack-Infra mailing list