git-gui: Allow users to delete remote branches
commitaa252f194b6a32240117ef339631f42842b6d5b4
authorShawn O. Pearce <spearce@spearce.org>
Mon, 28 May 2007 19:23:32 +0000 (28 15:23 -0400)
committerShawn O. Pearce <spearce@spearce.org>
Mon, 28 May 2007 21:50:42 +0000 (28 17:50 -0400)
tree3401bb6feeecfe8e4f64416c70f74c01f287d24c
parent61f82ce79abe965c466bb7d3d1d89ae631fbbd24
git-gui: Allow users to delete remote branches

Git has supported remote branch deletion for quite some time, but
I've just never gotten around to supporting it in git-gui.  Some
workflows have users push short-term branches to some remote Git
repository, then delete them a few days/weeks later when that topic
has been fully merged into the main trunk.  Typically in that style
of workflow the user will want to remove the branches they created.

We now offer a "Delete..." option in the Push menu, right below the
generic "Push..." option.  When the user opens our generic delete
dialog they can select a preconfigured remote, or enter a random
URL.  We run `git ls-remote $url` to obtain the list of branches and
tags known there, and offer this list in a listbox for the user to
select one or more from.

Like our local branch delete dialog we offer the user a way to filter
their selected branch list down to only those branches that have been
merged into another branch.  This is a very common operation as the
user will likely want to select a range of topic branches, but only
delete them if they have been merged into some sort of common trunk.

Unfortunately our remote merge base detection is not nearly as strict
as the local branch version.  We only offer remote heads as the test
commit (not any local ones) and we require that all necessary commits
to successfully run git-merge-base are available locally.  If one or
more is missing we suggest that the user run a fetch first.

Since the Git remote protocol doesn't let us specify what the tested
commit was when we evaluated our decision to execute the remote delete
there is a race condition here.  The user could do a merge test against
the trunk, determine a topic branch was fully merged, but before they
can start pushing the delete request another user could fast-forward
the remote topic branch to a new commit that is not merged into the
trunk.  The delete will arrive after, and remove the topic, even though
it was not fully merged.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
git-gui.sh
lib/remote_branch_delete.tcl [new file with mode: 0644]