chiark / gitweb /
Fix "stg branch --delete" on a nonexistent branch
authorToby Allsopp <Toby.Allsopp@navman.co.nz>
Mon, 24 Mar 2008 18:53:13 +0000 (18:53 +0000)
committerCatalin Marinas <catalin.marinas@gmail.com>
Mon, 24 Mar 2008 18:53:13 +0000 (18:53 +0000)
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 <toby.allsopp@navman.co.nz>
Signed-off-by: Karl Hasselström <kha@treskal.com>
stgit/stack.py
t/t1005-branch-delete.sh

index c2eb2de9e7292521a38fe1cbc4aaa17db3fe66ba..802a382ad0f7609c136d660daee6c05e28c68c1a 100644 (file)
@@ -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())
index 00fc9ebd758eb0fa80d57d4288803445448a1d74..e061bafe4dcbe8101336328679fbd596a0da0e51 100755 (executable)
@@ -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)" ]
     '