From 6f48e5f8db212cc241511aa03ed47534580357b2 Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Thu, 6 Oct 2005 11:18:18 +0100 Subject: [PATCH] Add the ability to delete a branch to git.py "git branch -D" checks first to see whether all the commits in the doomed branch are already in the branch pointed to by HEAD. I don't think we need that level of checking here. We just delete "refs/heads/branchname." Signed-off-by: Chuck Lever --- stgit/git.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/stgit/git.py b/stgit/git.py index cc3b55b..7bb41c5 100644 --- a/stgit/git.py +++ b/stgit/git.py @@ -307,6 +307,14 @@ def switch_branch(name): if os.path.isfile(os.path.join(base_dir, 'MERGE_HEAD')): os.remove(os.path.join(base_dir, 'MERGE_HEAD')) +def delete_branch(name): + """Delete a git branch + """ + branch_head = os.path.join('refs', 'heads', name) + if not branch_exists(branch_head): + raise GitException, 'Branch "%s" does not exist' % name + os.remove(os.path.join(base_dir, branch_head)) + def add(names): """Add the files or recursively add the directory contents """ -- 2.11.0