git-for-windows / git

A fork of Git containing Windows-specific patches.
http://gitforwindows.org/
Other
8.28k stars 2.51k forks source link

Git commands inside vscode fail when using basic authentication #5115

Closed isaacag closed 2 days ago

isaacag commented 2 weeks ago

Setup

$ git --version --build-options

git version 2.46.0.windows.1
cpu: x86_64
built from commit: 2e6a859ffc0471f60f79c1256f766042b0d5d17d
sizeof-long: 4
sizeof-size_t: 8
shell-path: D:/git-sdk-64-build-installers/usr/bin/sh
feature: fsmonitor--daemon
libcurl: 8.9.0
OpenSSL: OpenSSL 3.2.2 4 Jun 2024
zlib: 1.3.1
$ cmd.exe /c ver

Microsoft Windows [Version 10.0.19045.4651]
# One of the following:
> type "C:\Program Files\Git\etc\install-options.txt"
> type "C:\Program Files (x86)\Git\etc\install-options.txt"
> type "%USERPROFILE%\AppData\Local\Programs\Git\etc\install-options.txt"
> type "$env:USERPROFILE\AppData\Local\Programs\Git\etc\install-options.txt"
$ cat /etc/install-options.txt

Editor Option: Nano
Custom Editor Path: 
Default Branch Option:
Path Option: Cmd
SSH Option: OpenSSH
Tortoise Option: false
CURL Option: OpenSSL
CRLF Option: CRLFAlways
Bash Terminal Option: MinTTY
Git Pull Behavior Option: Merge
Use Credential Manager: Enabled
Performance Tweaks FSCache: Enabled
Enable Symlinks: Disabled
Enable Pseudo Console Support: Disabled
Enable FSMonitor: Disabled

No

Details

Powershell (but also tested in CMD and Git Bash)

git config --system --unset credential.helper
git pull
  1. Open a terminal inside Visual Studio Code
  2. Run git commands above

At 2 after two vscode popups for user and password git command is executed.

At 2 after two vscode popups for user and password, terminal shows: fatal: read error: Invalid argument fatal: expected flush after ref listing

Problem is happening in all repositories.

Downgrading to Git 2.45 fixes the problem. Error is not reproducible on terminals outside vscode (powershell, cmd, git bash). Error is not reproducible when windows credential manager integration is active.

dscho commented 2 weeks ago

I can reproduce this problem. A less invasive reproducer is:

$ git -c credential.helper= -c credential.helper= ls-remote https://github.com/<private-repository>

Unfortunately, due to the way VS Code inserts itself via GIT_ASKPASS, the private repository must exist and the current user needs to be authorized to access it, therefore it is not such a straight-forward reproducer.

dscho commented 2 weeks ago

I've bisected this to https://github.com/git-for-windows/msys2-runtime/commit/a4d92d60dc618a2c1207dab20dcd04b4fb7cb541.

@tyan0 this is one of your patches (backported from your upstream commit https://github.com/cygwin/cygwin/commit/55431b408e7a6cb29d52ec619c38cdb6c40e2120), do you have any idea what is going wrong here?

tyan0 commented 2 weeks ago

I could reproduce the problem. I'll look into this problem, so please wait a while.

dscho commented 2 weeks ago

I could reproduce the problem. I'll look into this problem, so please wait a while.

Thank you.

tyan0 commented 2 weeks ago

@dscho I have submitted a patch for this issue: https://cygwin.com/pipermail/cygwin-patches/2024q3/012747.html. For cygwin-3_5-branch, please try cygwin-3_5-branch.patch

dscho commented 2 days ago

/add relnote When using an askpass helper (e.g. implicitly when running inside VS Code's internal terminal), Git v2.46.0 would error out with "read error: Invalid argument"; This bug has been fixed.

dscho commented 2 days ago

/add relnote bug When using an askpass helper (e.g. implicitly when running inside VS Code's internal terminal), Git v2.46.0 would error out with "read error: Invalid argument"; This bug has been fixed.

The workflow run was started