Re: [PATCH v2 2/4] git-p4: add gitConfigInt reader

2015-09-03 Thread Luke Diamand

On 03/09/15 21:17, Lars Schneider wrote:


On 03 Sep 2015, at 21:57, Luke Diamand  wrote:


On 03/09/15 17:35, larsxschnei...@gmail.com wrote:

From: Lars Schneider 



Explanation?

Add a git config reader for integer variables. Please note that the git config 
implementation automatically supports k, m, and g suffixes.


Sorry, I should have been clearer. The commit needs a comment to say 
both what it's doing ("adding a git config int reader") and why.


c.f. Documentation/SubmittingChanges.

Luke

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 2/4] git-p4: add gitConfigInt reader

2015-09-03 Thread Lars Schneider

On 03 Sep 2015, at 21:57, Luke Diamand  wrote:

> On 03/09/15 17:35, larsxschnei...@gmail.com wrote:
>> From: Lars Schneider 
>> 
> 
> Explanation?
Add a git config reader for integer variables. Please note that the git config 
implementation automatically supports k, m, and g suffixes.

OK?
 
> 
>> Signed-off-by: Lars Schneider 
>> ---
>>  git-p4.py | 11 +++
>>  1 file changed, 11 insertions(+)
>> 
>> diff --git a/git-p4.py b/git-p4.py
>> index c139cab..ae1a4d3 100755
>> --- a/git-p4.py
>> +++ b/git-p4.py
>> @@ -623,6 +623,17 @@ def gitConfigBool(key):
>>  _gitConfig[key] = gitConfig(key, '--bool') == "true"
>>  return _gitConfig[key]
>> 
>> +def gitConfigInt(key):
>> +if not _gitConfig.has_key(key):
>> +cmd = [ "git", "config", "--int", key ]
>> +s = read_pipe(cmd, ignore_error=True)
>> +v = s.strip()
>> +try:
>> +_gitConfig[key] = int(gitConfig(key, '--int'))
>> +except Exception, e:
> 
> Could do with specifying the actual type of the exception here (ValueError).
Will do!

Thanks!--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 2/4] git-p4: add gitConfigInt reader

2015-09-03 Thread Luke Diamand

On 03/09/15 17:35, larsxschnei...@gmail.com wrote:

From: Lars Schneider 



Explanation?


Signed-off-by: Lars Schneider 
---
  git-p4.py | 11 +++
  1 file changed, 11 insertions(+)

diff --git a/git-p4.py b/git-p4.py
index c139cab..ae1a4d3 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -623,6 +623,17 @@ def gitConfigBool(key):
  _gitConfig[key] = gitConfig(key, '--bool') == "true"
  return _gitConfig[key]

+def gitConfigInt(key):
+if not _gitConfig.has_key(key):
+cmd = [ "git", "config", "--int", key ]
+s = read_pipe(cmd, ignore_error=True)
+v = s.strip()
+try:
+_gitConfig[key] = int(gitConfig(key, '--int'))
+except Exception, e:


Could do with specifying the actual type of the exception here (ValueError).




+_gitConfig[key] = None
+return _gitConfig[key]
+
  def gitConfigList(key):
  if not _gitConfig.has_key(key):
  s = read_pipe(["git", "config", "--get-all", key], ignore_error=True)



--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 2/4] git-p4: add gitConfigInt reader

2015-09-03 Thread larsxschneider
From: Lars Schneider 

Signed-off-by: Lars Schneider 
---
 git-p4.py | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/git-p4.py b/git-p4.py
index c139cab..ae1a4d3 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -623,6 +623,17 @@ def gitConfigBool(key):
 _gitConfig[key] = gitConfig(key, '--bool') == "true"
 return _gitConfig[key]
 
+def gitConfigInt(key):
+if not _gitConfig.has_key(key):
+cmd = [ "git", "config", "--int", key ]
+s = read_pipe(cmd, ignore_error=True)
+v = s.strip()
+try:
+_gitConfig[key] = int(gitConfig(key, '--int'))
+except Exception, e:
+_gitConfig[key] = None
+return _gitConfig[key]
+
 def gitConfigList(key):
 if not _gitConfig.has_key(key):
 s = read_pipe(["git", "config", "--get-all", key], ignore_error=True)
-- 
1.9.5 (Apple Git-50.3)

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html