Skip to content

Commit b345d6c

Browse files
Pete Wyckoffgitster
authored andcommitted
git p4: avoid shell when calling git config
Signed-off-by: Pete Wyckoff <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2abba30 commit b345d6c

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

git-p4.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -560,13 +560,16 @@ def gitBranchExists(branch):
560560
return proc.wait() == 0;
561561

562562
_gitConfig = {}
563-
def gitConfig(key, args = None): # set args to "--bool", for instance
563+
564+
def gitConfig(key, args=None): # set args to "--bool", for instance
564565
if not _gitConfig.has_key(key):
565-
argsFilter = ""
566-
if args != None:
567-
argsFilter = "%s " % args
568-
cmd = "git config %s%s" % (argsFilter, key)
569-
_gitConfig[key] = read_pipe(cmd, ignore_error=True).strip()
566+
cmd = [ "git", "config" ]
567+
if args:
568+
assert(args == "--bool")
569+
cmd.append(args)
570+
cmd.append(key)
571+
s = read_pipe(cmd, ignore_error=True)
572+
_gitConfig[key] = s.strip()
570573
return _gitConfig[key]
571574

572575
def gitConfigList(key):

0 commit comments

Comments
 (0)