# [PATCH] stgit namelength is an integer

2 messages from 2009-01-05 to 2009-01-12. Participants: Pete Wyckoff, Karl Hasselström.
Thread: https://gitlist.dev/t/16997

## Pete Wyckoff, 2009-01-05 19:03

Subject: [PATCH] stgit namelength is an integer
Message-ID: <20090105190354.GA8295@osc.edu>
URL: https://gitlist.dev/e/20090105190354.GA8295%40osc.edu

```
Interpret stgit namelength as an integer, else the use of
name_len will fail with

  File "/usr/lib/python2.5/site-packages/stgit/utils.py", line 206, in patch_name_from_msg
    return re.sub('[\W]+', '-', subject_line).strip('-')[:name_len]
TypeError: slice indices must be integers or None or have an __index__ method

Signed-off-by: Pete Wyckoff <pw@padd.com>
---
 stgit/utils.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/stgit/utils.py b/stgit/utils.py
index 81035a5..1fa96c2 100644
--- a/stgit/utils.py
+++ b/stgit/utils.py
@@ -215,7 +215,7 @@ def patch_name_from_msg(msg):
     if not msg:
         return None
 
-    name_len = config.get('stgit.namelength')
+    name_len = config.getint('stgit.namelength')
     if not name_len:
         name_len = 30
 
-- 
1.6.0.6

```

## Karl Hasselström, 2009-01-12 20:13

Subject: Re: [PATCH] stgit namelength is an integer
Message-ID: <20090112201309.GA32588@diana.vm.bytemark.co.uk>
URL: https://gitlist.dev/e/20090112201309.GA32588%40diana.vm.bytemark.co.uk
In-Reply-To: <20090105190354.GA8295@osc.edu>

```
Thanks, but the test suite fails unless I apply this first:

    Return None instead of crashing on undefined integer config items

    Signed-off-by: Karl Hasselström <kha@treskal.com>

diff --git a/stgit/config.py b/stgit/config.py
index 8934445..5b47580 100644
--- a/stgit/config.py
+++ b/stgit/config.py
@@ -65,7 +65,9 @@ class GitConfig:
 
     def getint(self, name):
         value = self.get(name)
-        if value.isdigit():
+        if value == None:
+            return None
+        elif value.isdigit():
             return int(value)
         else:
             raise GitConfigException, 'Value for "%s" is not an integer: "%s"' % (name, value)

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle

```
