Fix the bash completion when there is no patch applied
[stgit] / stgit / commands / series.py
index e66f1bd..58c706c 100644 (file)
@@ -33,6 +33,9 @@ prefixed with a '>'. Empty patches are prefixed with a '0'."""
 
 options = [make_option('-b', '--branch',
                        help = 'use BRANCH instead of the default one'),
+           make_option('-c', '--count',
+                       help = 'print the number of patches in the series',
+                       action = 'store_true'),
            make_option('-d', '--description',
                        help = 'show a short description for each patch',
                        action = 'store_true'),
@@ -52,7 +55,7 @@ def __get_description(patch):
     """Extract and return a patch's short description
     """
     p = crt_series.get_patch(patch)
-    descr = p.get_description().strip()
+    descr = (p.get_description() or '').strip()
     descr_lines = descr.split('\n')
     return descr_lines[0].rstrip()
 
@@ -73,6 +76,10 @@ def func(parser, options, args):
     applied = crt_series.get_applied()
     unapplied = crt_series.get_unapplied()
 
+    if options.count:
+        print len(applied) + len(unapplied)
+        return
+
     if options.short:
         if len(applied) > 5:
             applied = applied[-6:]