Skip to content

Commit cb1dafd

Browse files
larsxschneidergitster
authored andcommitted
git-p4: add gitConfigInt reader
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 692e179 commit cb1dafd

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

git-p4.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,17 @@ def gitConfigBool(key):
623623
_gitConfig[key] = gitConfig(key, '--bool') == "true"
624624
return _gitConfig[key]
625625

626+
def gitConfigInt(key):
627+
if not _gitConfig.has_key(key):
628+
cmd = [ "git", "config", "--int", key ]
629+
s = read_pipe(cmd, ignore_error=True)
630+
v = s.strip()
631+
try:
632+
_gitConfig[key] = int(gitConfig(key, '--int'))
633+
except ValueError:
634+
_gitConfig[key] = None
635+
return _gitConfig[key]
636+
626637
def gitConfigList(key):
627638
if not _gitConfig.has_key(key):
628639
s = read_pipe(["git", "config", "--get-all", key], ignore_error=True)

0 commit comments

Comments
 (0)