@matheusbsbs / matheus-bagliano / commits / 99f790f22e
Fork 0

git-p4: Teach gitConfig method about arguments.

With this patch, it is possible to call the gitConfig method with an optional argument string, which will be passed to the "git config" executable. For instance: gitConfig("core.ignorecase", "--bool") will ensure that you get the value "true", and won't have to check the returned value for [1, true, on, yes]. Signed-off-by: Tor Arvid Lund <torarvid@gmail.com> Acked-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Tor Arvid Lund committed Mar 15, 2011 at 13:08 UTC 99f790f22e2b2dabf00cf386339e829fe2bac6bc
1 file changed +6 -2
contrib/fast-import/git-p4
+6 -2
@@ -333,9 +333,13 @@ def gitBranchExists(branch):
333 return proc.wait() == 0;
334
335 _gitConfig = {}
336 -def gitConfig(key):
336 +def gitConfig(key, args = None): # set args to "--bool", for instance
337 if not _gitConfig.has_key(key):
338 - _gitConfig[key] = read_pipe("git config %s" % key, ignore_error=True).strip()
338 + argsFilter = ""
339 + if args != None:
340 + argsFilter = "%s " % args
341 + cmd = "git config %s%s" % (argsFilter, key)
342 + _gitConfig[key] = read_pipe(cmd, ignore_error=True).strip()
343 return _gitConfig[key]
344
345 def p4BranchesInGit(branchesAreInRemotes = True):