[PATCH 1/3] Don't die when there are no branches

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Karl Hasselström <kha@xxxxxxxxxxx>


---

 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@xxxxxxxxxxx
      www.treskal.com/kalle
-
: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]