gitui
gitui copied to clipboard
gitui doesn't honor pushInsteadOf settings
Describe the bug Pushing to a remote that has a https url ignores an associated pushInsteadOf ssh url and prompts for a username.
To Reproduce Steps to reproduce the behavior:
- Clone a repository via https, e.g.
git clone https://github.com/extrawurst/gitui.git - Add a pushInsteadOf ssh url, e.e.g by adding this to your git config:
[url "[email protected]:extrawurst/"] pushInsteadOf = "https://github.com/extrawurst/" - Commit anything
- See gitui prompt for a username
Expected behavior gitui uses the configured ssh url and pushes successfully instead of prompting for credentials
Context (please complete the following information):
- OS/Distro + Version: Fedora 34
- GitUI Version:
gitui 0.16.2(installed with dnf) - Rust version:
rustc 1.55.0 (Fedora 1.55.0-1.fc34)
Additional context Documentation for pushInsteadOf
Hm weird this should actually be working correctly since https://github.com/libgit2/libgit2/pull/3048
Huh, agreed, that looks like it should prevent this. Is there a way to get debug output about what gitui is pushing to, or what configuration it read?
FWIW my configuration is in ~/.config/git/config which has occasionally caused problems but I'd expect libgit2 handles that case.
maybe we can learn anything from delta here: https://github.com/dandavison/delta/pull/694/files
i believe this is a bug in libgit2, or at least the version currently used in git2-rs.
this line is where the pushInsteadOf setting is applied, but is seems that code is only reached when the remote has an explicit pushurl setting.
the correct behavior would be to apply pushinsteadof to the url instead if there is no pushurl.
this also seems consistent with what i found in gitui, that the used remote has a url but not a pushurl
a related problem is that need_username_password should check the pushurl if there is one, because only that would have the replacement applied
i believe this is a bug in libgit2, or at least the version currently used in git2-rs. this line is where the
pushInsteadOfsetting is applied, but is seems that code is only reached when the remote has an explicitpushurlsetting. the correct behavior would be to applypushinsteadofto theurlinstead if there is nopushurl.
libgit2/libgit2#6099
libgit2/libgit2#6101 would fix this
https://github.com/libgit2/libgit2/pull/6101 Is merged, now we need to get it into git2-rs upstream
libgit2 release 1.4.0 released this now: https://github.com/libgit2/libgit2/releases/tag/v1.4.0
This issue has been automatically marked as stale because it has not had any activity half a year. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.
this is fixed in v0.21.0 :tada: