From 03a1b83c50c7d056e21a0217b9086593b3a5a717 Mon Sep 17 00:00:00 2001 Message-Id: <03a1b83c50c7d056e21a0217b9086593b3a5a717.1715253432.git.mdw@distorted.org.uk> From: Mark Wooding Date: Mon, 24 Mar 2008 18:53:13 +0000 Subject: [PATCH] Fix "stg branch --delete" on a nonexistent branch MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Organization: Straylight/Edgeware From: Toby Allsopp Before this patch, I get the following: $ stg branch --delete tmp Deleting branch "tmp" ... Traceback (most recent call last): File "/usr/bin/stg", line 43, in ? main() File "/var/lib/python-support/python2.4/stgit/main.py", line 281, in main command.func(parser, options, args) File "/var/lib/python-support/python2.4/stgit/commands/branch.py", line 190, in func __delete_branch(args[0], options.force) File "/var/lib/python-support/python2.4/stgit/commands/branch.py", line 100, in __delete_branch doomed.delete(force) File "/var/lib/python-support/python2.4/stgit/stack.py", line 758, in delete except GitException: NameError: global name 'GitException' is not defined After it, I get: Deleting branch "tmp" ... Warning: Could not delete branch "tmp" done Signed-off-by: Toby Allsopp Signed-off-by: Karl Hasselström --- stgit/stack.py | 2 +- t/t1005-branch-delete.sh | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/stgit/stack.py b/stgit/stack.py index c2eb2de..802a382 100644 --- a/stgit/stack.py +++ b/stgit/stack.py @@ -755,7 +755,7 @@ class Series(PatchSet): try: git.delete_branch(self.get_name()) - except GitException: + except git.GitException: out.warn('Could not delete branch "%s"' % self.get_name()) config.remove_section('branch.%s' % self.get_name()) diff --git a/t/t1005-branch-delete.sh b/t/t1005-branch-delete.sh index 00fc9eb..e061baf 100755 --- a/t/t1005-branch-delete.sh +++ b/t/t1005-branch-delete.sh @@ -19,6 +19,10 @@ test_expect_success 'Create a non-StGIT branch and delete it' ' stg branch --delete bar ' +test_expect_success 'Delete a nonexistent branch' ' + stg branch --delete bar + ' + test_expect_success 'Make sure the branch ref was deleted' ' [ -z "$(git show-ref | grep master | tee /dev/stderr)" ] ' -- [mdw]