From: Pete Wyckoff Date: Fri, 28 Sep 2012 12:04:24 GMT Subject: [PATCH 20/21] git p4: avoid shell when calling git config Message-ID: <1348833865-6093-21-git-send-email-pw@padd.com> In-Reply-To: <1348833865-6093-1-git-send-email-pw@padd.com> Signed-off-by: Pete Wyckoff --- git-p4.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/git-p4.py b/git-p4.py index c0c738a..007ef6b 100755 --- a/git-p4.py +++ b/git-p4.py @@ -514,13 +514,16 @@ def gitBranchExists(branch): return proc.wait() == 0; _gitConfig = {} -def gitConfig(key, args = None): # set args to "--bool", for instance + +def gitConfig(key, args=None): # set args to "--bool", for instance if not _gitConfig.has_key(key): - argsFilter = "" - if args != None: - argsFilter = "%s " % args - cmd = "git config %s%s" % (argsFilter, key) - _gitConfig[key] = read_pipe(cmd, ignore_error=True).strip() + cmd = [ "git", "config" ] + if args: + assert(args == "--bool") + cmd.append(args) + cmd.append(key) + s = read_pipe(cmd, ignore_error=True) + _gitConfig[key] = s.strip() return _gitConfig[key] def gitConfigList(key): -- 1.7.12.1.403.g28165e1