From: Karl Hasselström Date: Thu, 18 May 2006 20:36:40 +0000 (+0100) Subject: Don't die when there are no branches X-Git-Tag: v0.14.3~494 X-Git-Url: https://git.distorted.org.uk/~mdw/stgit/commitdiff_plain/7217efbf26d7ec757ac72fdadf247a932e56244a Don't die when there are no branches Signed-off-by: Karl Hasselström --- 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: