Skip to content

Commit

Permalink
git-p4: Teach gitConfig method about arguments.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Tor Arvid Lund authored and Junio C Hamano committed Mar 15, 2011
1 parent a35138a commit 99f790f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions contrib/fast-import/git-p4
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,13 @@ def gitBranchExists(branch):
return proc.wait() == 0;

_gitConfig = {}
def gitConfig(key):
def gitConfig(key, args = None): # set args to "--bool", for instance
if not _gitConfig.has_key(key):
_gitConfig[key] = read_pipe("git config %s" % key, ignore_error=True).strip()
argsFilter = ""
if args != None:
argsFilter = "%s " % args
cmd = "git config %s%s" % (argsFilter, key)
_gitConfig[key] = read_pipe(cmd, ignore_error=True).strip()
return _gitConfig[key]

def p4BranchesInGit(branchesAreInRemotes = True):
Expand Down

0 comments on commit 99f790f

Please sign in to comment.