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

gitui doesn't honor pushInsteadOf settings #953

Closed
mkhl opened this issue Oct 20, 2021 · 11 comments · Fixed by #967
Closed

gitui doesn't honor pushInsteadOf settings #953

mkhl opened this issue Oct 20, 2021 · 11 comments · Fixed by #967
Labels
bug Something isn't working dormant Marked by stale bot on close
Milestone

Comments

@mkhl
Copy link
Contributor

mkhl commented Oct 20, 2021

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:

  1. Clone a repository via https, e.g. git clone https://github.com/extrawurst/gitui.git
  2. Add a pushInsteadOf ssh url, e.e.g by adding this to your git config:
    [url "[email protected]:extrawurst/"]
        pushInsteadOf = "https://github.com/extrawurst/"
    
  3. Commit anything
  4. 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

@extrawurst
Copy link
Collaborator

Hm weird this should actually be working correctly since libgit2/libgit2#3048

@extrawurst extrawurst added the bug Something isn't working label Oct 20, 2021
@mkhl
Copy link
Contributor Author

mkhl commented Oct 20, 2021

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.

@extrawurst
Copy link
Collaborator

maybe we can learn anything from delta here: https://github.com/dandavison/delta/pull/694/files

@mkhl
Copy link
Contributor Author

mkhl commented Oct 27, 2021

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

@mkhl
Copy link
Contributor Author

mkhl commented Oct 27, 2021

a related problem is that need_username_password should check the pushurl if there is one, because only that would have the replacement applied

@mkhl
Copy link
Contributor Author

mkhl commented Oct 27, 2021

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.

libgit2/libgit2#6099

@mkhl
Copy link
Contributor Author

mkhl commented Oct 28, 2021

libgit2/libgit2#6101 would fix this

@extrawurst
Copy link
Collaborator

extrawurst commented Jan 1, 2022

libgit2/libgit2#6101 Is merged, now we need to get it into git2-rs upstream

@extrawurst
Copy link
Collaborator

libgit2 release 1.4.0 released this now: https://github.com/libgit2/libgit2/releases/tag/v1.4.0

@stale
Copy link

stale bot commented Aug 13, 2022

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.

@stale stale bot added the dormant Marked by stale bot on close label Aug 13, 2022
@mkhl
Copy link
Contributor Author

mkhl commented Aug 22, 2022

this is fixed in v0.21.0 🎉

@mkhl mkhl closed this as completed Aug 22, 2022
@extrawurst extrawurst added this to the v0.21 milestone Aug 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dormant Marked by stale bot on close
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants