'Check if the given path is a git submodule.  If so, attempt to initialize
and/or update the submodule if needed.
This function makes calls to the ``git`` command in subprocesses.  The
``_check_submodule_no_git`` option uses pure Python to check if the given
path looks like a git submodule, but it cannot perform updates.'

def _check_submodule_using_git(self):

    cmd = ['git', 'submodule', 'status', '--', self.path]
    try:
        log.info('Running    `{0}`;    use    the    --no-git    option    to    disable    git    commands'.format('    '.join(cmd)))
        (returncode, stdout, stderr) = run_cmd(cmd)
    except _CommandNotFound:
        return False
    stderr = stderr.strip()
    if ((returncode != 0) and stderr):
        perl_warning = 'perl:    warning:    Falling    back    to    the    standard    locale    ("C").'
        if (not stderr.strip().endswith(perl_warning)):
            log.warn('git    submodule    command    failed    unexpectedly:\n{0}'.format(stderr))
            return False
    _git_submodule_status_re = re.compile('^(?P<status>[+-U    ])(?P<commit>[0-9a-f]{40})    (?P<submodule>\\S+)(    .*)?$')
    m = _git_submodule_status_re.match(stdout)
    if m:
        self._update_submodule(m.group('submodule'), m.group('status'))
        return True
    else:
        log.warn('Unexpected    output    from    `git    submodule    status`:\n{0}\nWill    attempt    import    from    {1!r}    regardless.'.format(stdout, self.path))
        return False
