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 <larsxschneider@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Lars Schneider committed
Sep 26, 2015 at 09:54 UTC
cb1dafdfdadca4d1bbe4147d2f9c72b5ef0f4ab7
1 file changed
+11
git-p4.py
+11
@@ -623,6 +623,17 @@ def gitConfigBool(key):
623
_gitConfig[key] = gitConfig(key, '--bool') == "true"
624
return _gitConfig[key]
625
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
+
637
def gitConfigList(key):
638
if not _gitConfig.has_key(key):
639
s = read_pipe(["git", "config", "--get-all", key], ignore_error=True)