prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Poetry inheriting issue for git-client on github.com
  - [X] I am on the [latest](https://github.com/python-poetry/poetry/releases/latest) Poetry version. 
  - [X] I have searched the [issues](https://github.com/python-poetry/poetry/issues) of this repo and believe that this is not a duplicate.
  - [X] If an exception occurs when executing a command, I executed it again in debug mode (`-vvv` option).
  
  - **OS version and name**: Linux Mint 20, Py3.8.2 virtualenv
  - **Poetry version**: 1.1.2
  - **Link of a [Gist](https://gist.github.com/) with the contents of your pyproject.toml file**: 
  
  ## Issue
  While `installing` or `locking`, if the github git repo is wrong (e.g. returns a 404 in a browser), then poetry (sometimes) shows an authentication error and ask for the username for that url. 
  
  ```Updating dependencies
  Resolving dependencies...
     1: fact: actions-gateway is 0.7.0
     1: derived: actions-gateway
  Username for 'https://github.com':
  ```
  The pyproject.toml has a git dependency like
  ```
  Flask-Pika = { git = "https://github.com/rienafairefr/flask_pika.git", rev= "b2b4d68186c52ae034b39f4fb56fe86786b3a055"}
  ```
  The typo is hard to see, it should be `flask-pika` instead of `flask_pika`
  
  If the command is run without verbose output, then the "Username for 'https://github.com':" is sometimes shown only for a fraction of a second, so the command may never terminate and it's hard to know why.
  
  Not sure poetry can or should mitigate the problem that comes from a lower level.
  
  The problem comes (pretty sure) from github.com returning a 401 when it should return a 404:
  ```
  GET /inexistent-user/inexistent-repo/info/refs?service=git-upload-pack
  Host github.com
  User-Agent: git/inexistent-version
  ```
  gives us
  ```
  HTTP/1.1 401 Authorization Required
  Server: GitHub Babel 2.0
  ```
  This makes the git client (which is called in a subprocess by poetry) to ask for authentication. 
  
  setting the GIT_ASKPASS variable to false while caling `git` is an option, the credentials to use for a git dependency should be provided by poetry, not leaving `git` to figure it out by itself
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `src/poetry/vcs/git/system.py`
  Content:
  ```
  1 from __future__ import annotations
  2 
  3 import subprocess
  4 
  5 from typing import TYPE_CHECKING
  6 
  7 from dulwich.client import find_git_command
  8 
  9 
  10 if TYPE_CHECKING:
  11     from pathlib import Path
  12     from typing import Any
  13 
  14 
  15 class SystemGit:
  16     @classmethod
  17     def clone(cls, repository: str, dest: Path) -> str:
  18         cls._check_parameter(repository)
  19 
  20         return cls.run("clone", "--recurse-submodules", "--", repository, str(dest))
  21 
  22     @classmethod
  23     def checkout(cls, rev: str, target: Path | None = None) -> str:
  24         args = []
  25 
  26         if target:
  27             args += [
  28                 "--git-dir",
  29                 (target / ".git").as_posix(),
  30                 "--work-tree",
  31                 target.as_posix(),
  32             ]
  33 
  34         cls._check_parameter(rev)
  35 
  36         args += ["checkout", rev]
  37 
  38         return cls.run(*args)
  39 
  40     @staticmethod
  41     def run(*args: Any, **kwargs: Any) -> str:
  42         folder = kwargs.pop("folder", None)
  43         if folder:
  44             args = (
  45                 "--git-dir",
  46                 (folder / ".git").as_posix(),
  47                 "--work-tree",
  48                 folder.as_posix(),
  49             ) + args
  50 
  51         git_command = find_git_command()
  52         return (
  53             subprocess.check_output(git_command + list(args), stderr=subprocess.STDOUT)
  54             .decode()
  55             .strip()
  56         )
  57 
  58     @staticmethod
  59     def _check_parameter(parameter: str) -> None:
  60         """
  61         Checks a git parameter to avoid unwanted code execution.
  62         """
  63         if parameter.strip().startswith("-"):
  64             raise RuntimeError(f"Invalid Git parameter: {parameter}")
  65
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/src/poetry/vcs/git/system.py b/src/poetry/vcs/git/system.py
  --- a/src/poetry/vcs/git/system.py
  +++ b/src/poetry/vcs/git/system.py
  @@ -1,5 +1,6 @@
   from __future__ import annotations
   
  +import os
   import subprocess
   
   from typing import TYPE_CHECKING
  @@ -49,8 +50,14 @@
               ) + args
   
           git_command = find_git_command()
  +        env = os.environ.copy()
  +        env["GIT_TERMINAL_PROMPT"] = "0"
           return (
  -            subprocess.check_output(git_command + list(args), stderr=subprocess.STDOUT)
  +            subprocess.check_output(
  +                git_command + list(args),
  +                stderr=subprocess.STDOUT,
  +                env=env,
  +            )
               .decode()
               .strip()
           )
  
verification_info: {"golden_diff": "diff --git a/src/poetry/vcs/git/system.py b/src/poetry/vcs/git/system.py\n--- a/src/poetry/vcs/git/system.py\n+++ b/src/poetry/vcs/git/system.py\n@@ -1,5 +1,6 @@\n from __future__ import annotations\n \n+import os\n import subprocess\n \n from typing import TYPE_CHECKING\n@@ -49,8 +50,14 @@\n             ) + args\n \n         git_command = find_git_command()\n+        env = os.environ.copy()\n+        env[\"GIT_TERMINAL_PROMPT\"] = \"0\"\n         return (\n-            subprocess.check_output(git_command + list(args), stderr=subprocess.STDOUT)\n+            subprocess.check_output(\n+                git_command + list(args),\n+                stderr=subprocess.STDOUT,\n+                env=env,\n+            )\n             .decode()\n             .strip()\n         )\n", "issue": "Poetry inheriting issue for git-client on github.com\n- [X] I am on the [latest](https://github.com/python-poetry/poetry/releases/latest) Poetry version. \r\n- [X] I have searched the [issues](https://github.com/python-poetry/poetry/issues) of this repo and believe that this is not a duplicate.\r\n- [X] If an exception occurs when executing a command, I executed it again in debug mode (`-vvv` option).\r\n\r\n- **OS version and name**: Linux Mint 20, Py3.8.2 virtualenv\r\n- **Poetry version**: 1.1.2\r\n- **Link of a [Gist](https://gist.github.com/) with the contents of your pyproject.toml file**: \r\n\r\n## Issue\r\nWhile `installing` or `locking`, if the github git repo is wrong (e.g. returns a 404 in a browser), then poetry (sometimes) shows an authentication error and ask for the username for that url. \r\n\r\n```Updating dependencies\r\nResolving dependencies...\r\n   1: fact: actions-gateway is 0.7.0\r\n   1: derived: actions-gateway\r\nUsername for 'https://github.com':\r\n```\r\nThe pyproject.toml has a git dependency like\r\n```\r\nFlask-Pika = { git = \"https://github.com/rienafairefr/flask_pika.git\", rev= \"b2b4d68186c52ae034b39f4fb56fe86786b3a055\"}\r\n```\r\nThe typo is hard to see, it should be `flask-pika` instead of `flask_pika`\r\n\r\nIf the command is run without verbose output, then the \"Username for 'https://github.com':\" is sometimes shown only for a fraction of a second, so the command may never terminate and it's hard to know why.\r\n\r\nNot sure poetry can or should mitigate the problem that comes from a lower level.\r\n\r\nThe problem comes (pretty sure) from github.com returning a 401 when it should return a 404:\r\n```\r\nGET /inexistent-user/inexistent-repo/info/refs?service=git-upload-pack\r\nHost github.com\r\nUser-Agent: git/inexistent-version\r\n```\r\ngives us\r\n```\r\nHTTP/1.1 401 Authorization Required\r\nServer: GitHub Babel 2.0\r\n```\r\nThis makes the git client (which is called in a subprocess by poetry) to ask for authentication. \r\n\r\nsetting the GIT_ASKPASS variable to false while caling `git` is an option, the credentials to use for a git dependency should be provided by poetry, not leaving `git` to figure it out by itself\r\n\n", "before_files": [{"content": "from __future__ import annotations\n\nimport subprocess\n\nfrom typing import TYPE_CHECKING\n\nfrom dulwich.client import find_git_command\n\n\nif TYPE_CHECKING:\n    from pathlib import Path\n    from typing import Any\n\n\nclass SystemGit:\n    @classmethod\n    def clone(cls, repository: str, dest: Path) -> str:\n        cls._check_parameter(repository)\n\n        return cls.run(\"clone\", \"--recurse-submodules\", \"--\", repository, str(dest))\n\n    @classmethod\n    def checkout(cls, rev: str, target: Path | None = None) -> str:\n        args = []\n\n        if target:\n            args += [\n                \"--git-dir\",\n                (target / \".git\").as_posix(),\n                \"--work-tree\",\n                target.as_posix(),\n            ]\n\n        cls._check_parameter(rev)\n\n        args += [\"checkout\", rev]\n\n        return cls.run(*args)\n\n    @staticmethod\n    def run(*args: Any, **kwargs: Any) -> str:\n        folder = kwargs.pop(\"folder\", None)\n        if folder:\n            args = (\n                \"--git-dir\",\n                (folder / \".git\").as_posix(),\n                \"--work-tree\",\n                folder.as_posix(),\n            ) + args\n\n        git_command = find_git_command()\n        return (\n            subprocess.check_output(git_command + list(args), stderr=subprocess.STDOUT)\n            .decode()\n            .strip()\n        )\n\n    @staticmethod\n    def _check_parameter(parameter: str) -> None:\n        \"\"\"\n        Checks a git parameter to avoid unwanted code execution.\n        \"\"\"\n        if parameter.strip().startswith(\"-\"):\n            raise RuntimeError(f\"Invalid Git parameter: {parameter}\")\n", "path": "src/poetry/vcs/git/system.py"}], "after_files": [{"content": "from __future__ import annotations\n\nimport os\nimport subprocess\n\nfrom typing import TYPE_CHECKING\n\nfrom dulwich.client import find_git_command\n\n\nif TYPE_CHECKING:\n    from pathlib import Path\n    from typing import Any\n\n\nclass SystemGit:\n    @classmethod\n    def clone(cls, repository: str, dest: Path) -> str:\n        cls._check_parameter(repository)\n\n        return cls.run(\"clone\", \"--recurse-submodules\", \"--\", repository, str(dest))\n\n    @classmethod\n    def checkout(cls, rev: str, target: Path | None = None) -> str:\n        args = []\n\n        if target:\n            args += [\n                \"--git-dir\",\n                (target / \".git\").as_posix(),\n                \"--work-tree\",\n                target.as_posix(),\n            ]\n\n        cls._check_parameter(rev)\n\n        args += [\"checkout\", rev]\n\n        return cls.run(*args)\n\n    @staticmethod\n    def run(*args: Any, **kwargs: Any) -> str:\n        folder = kwargs.pop(\"folder\", None)\n        if folder:\n            args = (\n                \"--git-dir\",\n                (folder / \".git\").as_posix(),\n                \"--work-tree\",\n                folder.as_posix(),\n            ) + args\n\n        git_command = find_git_command()\n        env = os.environ.copy()\n        env[\"GIT_TERMINAL_PROMPT\"] = \"0\"\n        return (\n            subprocess.check_output(\n                git_command + list(args),\n                stderr=subprocess.STDOUT,\n                env=env,\n            )\n            .decode()\n            .strip()\n        )\n\n    @staticmethod\n    def _check_parameter(parameter: str) -> None:\n        \"\"\"\n        Checks a git parameter to avoid unwanted code execution.\n        \"\"\"\n        if parameter.strip().startswith(\"-\"):\n            raise RuntimeError(f\"Invalid Git parameter: {parameter}\")\n", "path": "src/poetry/vcs/git/system.py"}]}