git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Karl Hasselström <kha@treskal.com>
Date
May 15, 2006, 09:53 UTC
Message-ID
<20060515095324.GA11386@backpacker.hemma.treskal.com>
In-Reply-To
<20060510060040.GA3034@diana.vm.bytemark.co.uk>
Signed-off-by: Karl Hasselström <kha@treskal.com>
---
 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
Next: Karl Hasselström
Message 1 of 15 in “Don't die when there are no branches”
  1. 1/3 Don't die when there are no branchesKarl Hasselström, May 15, 2006
  2. 2/3 Handle branch names with slashesKarl Hasselström, May 15, 2006
  3. Catalin MarinasMay 15, 2006
  4. Karl HasselströmMay 15, 2006
  5. 1/2 Handle branch names with slashesKarl Hasselström, May 16, 2006
  6. Junio C HamanoMay 16, 2006
  7. Karl HasselströmMay 16, 2006
  8. Catalin MarinasMay 17, 2006
  9. 1/2 Handle branch names with slashesKarl Hasselström, May 18, 2006
  10. Handle branch names with slashesKarl Hasselström, May 18, 2006
  11. Catalin MarinasMay 18, 2006
  12. Karl HasselströmMay 18, 2006
  13. 2/2 Tests for branch names with slashesKarl Hasselström, May 18, 2006
  14. 2/2 Tests for branch names with slashesKarl Hasselström, May 16, 2006
  15. 3/3 Tests for branch names with slashesKarl Hasselström, May 15, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.