Skip to content

Commit 692e179

Browse files
larsxschneidergitster
authored andcommitted
git-p4: add optional type specifier to gitConfig reader
The functions "gitConfig" and "gitConfigBool" are almost identical. Make "gitConfig" more generic by adding an optional type specifier. Use the type specifier "--bool" with "gitConfig" to implement "gitConfigBool. This prepares the implementation of other type specifiers such as "--int". Signed-off-by: Lars Schneider <[email protected]> Acked-by: Luke Diamand <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 689efb7 commit 692e179

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

git-p4.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -604,9 +604,12 @@ def gitBranchExists(branch):
604604

605605
_gitConfig = {}
606606

607-
def gitConfig(key):
607+
def gitConfig(key, typeSpecifier=None):
608608
if not _gitConfig.has_key(key):
609-
cmd = [ "git", "config", key ]
609+
cmd = [ "git", "config" ]
610+
if typeSpecifier:
611+
cmd += [ typeSpecifier ]
612+
cmd += [ key ]
610613
s = read_pipe(cmd, ignore_error=True)
611614
_gitConfig[key] = s.strip()
612615
return _gitConfig[key]
@@ -617,10 +620,7 @@ def gitConfigBool(key):
617620
in the config."""
618621

619622
if not _gitConfig.has_key(key):
620-
cmd = [ "git", "config", "--bool", key ]
621-
s = read_pipe(cmd, ignore_error=True)
622-
v = s.strip()
623-
_gitConfig[key] = v == "true"
623+
_gitConfig[key] = gitConfig(key, '--bool') == "true"
624624
return _gitConfig[key]
625625

626626
def gitConfigList(key):

0 commit comments

Comments
 (0)