def _fix_repo_url(repo_url):
    """Add empty credentials to a repo URL if not set, but only for HTTP/HTTPS.

       This is to make git not hang while trying to read the username and
       password from standard input."""
    parsed = urlparse.urlparse(repo_url)
    
    if parsed.scheme not in ('http', 'https'):
        # Fix only for http and https.
        return repo_url

    username = parsed.username or ""
    password = parsed.password or ""
    port = ":" + parsed.port if parsed.port else ""
    netloc = "".join((username, ":", password, "@", parsed.hostname, port))
    part_list = list(parsed)
    part_list[1] = netloc
    return urlparse.urlunparse(part_list)
Add empty credentials to a repo URL if not set, but only for HTTP/HTTPS.

       This is to make git not hang while trying to read the username and
       password from standard input.