Skip to content

Commit

Permalink
git-p4: add gitConfigInt reader
Browse files Browse the repository at this point in the history
Add a git config reader for integer variables. Please note that the
git config implementation automatically supports k, m, and g suffixes.

Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Lars Schneider authored and Junio C Hamano committed Oct 3, 2015
1 parent 692e179 commit cb1dafd
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions git-p4.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 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)
Expand Down

0 comments on commit cb1dafd

Please sign in to comment.