[PATCH v8 2/7] git-p4: add gitConfigInt reader
- From
larsxschneider@gmail.com <larsxschneider@gmail.com>
- Date
- Sep 26, 2015, 07:54 UTC
- Message-ID
- <1443254104-14966-3-git-send-email-larsxschneider@gmail.com>
- In-Reply-To
- <1443254104-14966-1-git-send-email-larsxschneider@gmail.com>
From: Lars Schneider <larsxschneider@gmail.com>
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> --- git-p4.py | 11 +++++++++++ 1 file changed, 11 insertions(+)
diff --git a/git-p4.py b/git-p4.py index c139cab..40ad4ae 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 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)
-- 2.5.1