Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

headless-git maintenance locks repository forever when askPass is triggered #4706

Open
1 task done
JustusGreiberORGADATA opened this issue Nov 24, 2023 · 2 comments
Open
1 task done

Comments

@JustusGreiberORGADATA
Copy link

  • I was not able to find an open or closed issue matching what I'm seeing

Setup

  • Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
$ git --version --build-options

git version 2.42.0.windows.2
cpu: x86_64
built from commit: 2f819d1670fff9a1818f63b6722e9959405378e3
sizeof-long: 4
sizeof-size_t: 8
shell-path: /bin/sh
feature: fsmonitor--daemon
  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
$ cmd.exe /c ver

Microsoft Windows [Version 10.0.22621.2715]
  • What options did you set as part of the installation? Or did you choose the
    defaults?
# 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: VIM
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: FFOnly
Use Credential Manager: Enabled
Performance Tweaks FSCache: Enabled
Enable Symlinks: Disabled
Enable Pseudo Console Support: Disabled
Enable FSMonitor: Disabled
  • Any other interesting things about your environment that might be related
    to the issue you're seeing?

When our git server restarts the git client will fail to authenticate and use askPass to ask for a username and password. The restarts coincide with the times set in the task scheduler by git maintenance start. IMHO the issue is a general one though and not really special to this environment.

Details

  • Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other

Git Bash in Windows Terminal. But in the real world this issue likely happens outside the terminal in the Windows Task Scheduler.

The actual problem occurs when git maintenance tasks are running in the Windows Task Scheduler. The minimal example below just reproduces the issue in a terminal.

# you need a git server which will trigger askPass. I reproduced this, by deleting the credentials I had
# (The blank line below protocol signals the input is complete.)
$ git credential-manager erase
host=github.com
protocol=https

# If credential manager is installed the next command might open a window or two.
# After the user closes those windows git will fallback to askPass. The user can't type in the password though,
# because headless-git is used.
# SIGINT also does not work so you need to kill the task some other way.
$ "C:/Program Files/Git/mingw64/libexec/git-core/headless-git.exe" maintenance run --task=prefetch

# When the previous command started, it locked the repo with .git/objects/maintenance.lock
# All maintenance commands after that will fail:
$ git maintenance run --task=prefetch
warning: lock file '.git/objects/maintenance' exists, skipping maintenance
  • What did you expect to occur after running these commands?

I expected headless-git to not start any terminal interaction, because there is no way for the user to interact with the terminal.
If headless-git is just a helper to facilitate git maintenance start I could live with the fact that it is not truly "headless" as long as the task that are registered in the Windows Task Scheduler set git config values to prevent the terminal interactions, e. g.

git -c "core.askPass=true" -c "credential.interactive=false" for-each-repo --config=maintenance.repo maintenance run --schedule=daily

(This is not a good solution if the graphical user interfaces triggered by askPass and Credential Manager are desired though and only the terminal interaction should be suppressed. I sadly haven't found a config value to only deactivate terminal interaction.)

  • What actually happened instead?

It did start a terminal interaction and locked all maintenance commands.

@dscho
Copy link
Member

dscho commented Nov 24, 2023

I guess we need to upstream microsoft#598 (patches 2-4, that is).

@dscho
Copy link
Member

dscho commented Nov 24, 2023

git -c "core.askPass=true" -c "credential.interactive=false" for-each-repo --config=maintenance.repo maintenance run --schedule=daily

FWIW the reason why this does not work as intended is that credential.interactive is only supported in the Microsoft fork of Git so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants