Skip to content

Commit

Permalink
git p4: avoid shell when calling git config
Browse files Browse the repository at this point in the history
Signed-off-by: Pete Wyckoff <pw@padd.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Pete Wyckoff authored and Junio C Hamano committed Jan 27, 2013
1 parent 2abba30 commit b345d6c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions git-p4.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,13 +560,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):
Expand Down

0 comments on commit b345d6c

Please sign in to comment.