From: Karl Hasselström Date: Mon, 15 May 2006 09:53:24 GMT Subject: [PATCH 1/3] Don't die when there are no branches Message-ID: <20060515095324.GA11386@backpacker.hemma.treskal.com> In-Reply-To: <20060510060040.GA3034@diana.vm.bytemark.co.uk> Signed-off-by: Karl Hasselström --- stgit/commands/branch.py | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-) c32f6b7bfd81bdbdb136ff72a4ad073e162ab97c diff --git a/stgit/commands/branch.py b/stgit/commands/branch.py index c7561a8..2218bbb 100644 --- a/stgit/commands/branch.py +++ b/stgit/commands/branch.py @@ -174,11 +174,14 @@ def func(parser, options, args): branches = os.listdir(os.path.join(basedir.get(), 'refs', 'heads')) branches.sort() - max_len = max([len(i) for i in branches]) - print 'Available branches:' - for i in branches: - __print_branch(i, max_len) + if branches: + print 'Available branches:' + max_len = max([len(i) for i in branches]) + for i in branches: + __print_branch(i, max_len) + else: + print 'No branches' return elif options.protect: -- 1.3.2.g639c -- Karl Hasselström, kha@treskal.com www.treskal.com/kalle