gitui
gitui copied to clipboard
Push/pull fail when remote contains square brackets (non-standard SSH port)
Describe the bug
When using a remote of the format [git@host:8080]:namespace/repo.git it's not currently possible to pull or push with gitui. With the same repo, CLI operations work OK. For context, this format seems to be what GitLab generates in its UI when configured to use a non-standard SSH port.
The error (for a fetch/pull) is:
fetch failed:
git error:Bad credentials.
Not sure if this is upstream or not (seems likely) but going to file this to at least help others with a workaround for now!
Workaround
Change your remote to the following format:
ssh://git@host:8080/namespace/repo.git
So for the example below (I know it looks a bit weird because GitHub SSH is just using the standard port):
git remote set-url origin ssh://[email protected]:22/extrawurst/gitui.git
To Reproduce Steps to reproduce the behavior:
git clone "[[email protected]:22]:extrawurst/gitui.git"cd gituigitui- Type
fto Pull (default binding)
Expected behavior Fetch (pull) operation succeeds (assuming you have a valid SSH key set up with GitHub)
Screenshots n/a
Context (please complete the following information):
- OS/Distro + Version: Pop!_OS 21.04 (Ubuntu-like)
- GitUI Version 0.17.0 (but reproduced on 0.17.1 as well on macOS)
- Rust version: (Probably not applicable)
Additional context
Log:
13:09:16 [TRACE] (1) gitui::app: [src/app.rs:352] update
13:09:16 [TRACE] (6) mio::poll: [/build/gitui-0.17-vendor.tar.gz/mio/src/poll.rs:478] registering event source with poller: token=Token(0), interests=READABLE
13:09:16 [TRACE] (6) mio::poll: [/build/gitui-0.17-vendor.tar.gz/mio/src/poll.rs:478] registering event source with poller: token=Token(1), interests=READABLE
13:09:16 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:95] request: [hash: 1915316720143881540] (type: WorkingDir)
13:09:16 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:95] request: [hash: 13667276242224620811] (type: Stage)
13:09:16 [TRACE] (3) asyncgit::status: [asyncgit/src/status.rs:151] status fetched: 13667276242224620811 (type: Stage)
13:09:16 [TRACE] (2) asyncgit::status: [asyncgit/src/status.rs:151] status fetched: 1915316720143881540 (type: WorkingDir)
13:09:16 [TRACE] (1) gitui::app: [src/app.rs:371] update_async: Git(Status)
13:09:16 [TRACE] (1) gitui::app: [src/app.rs:371] update_async: Git(Status)
13:09:18 [TRACE] (1) gitui::app: [src/app.rs:280] event: Input(Key(KeyEvent { code: Char('f'), modifiers: NONE }))
13:09:18 [TRACE] (1) asyncgit::fetch: [asyncgit/src/fetch.rs:70] request
13:09:18 [TRACE] (1) gitui::app: [src/app.rs:352] update
13:09:18 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:95] request: [hash: 10315854148163913168] (type: WorkingDir)
13:09:18 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:95] request: [hash: 10786361832688014167] (type: Stage)
13:09:18 [TRACE] (4) asyncgit::status: [asyncgit/src/status.rs:151] status fetched: 10786361832688014167 (type: Stage)
13:09:18 [TRACE] (2) asyncgit::status: [asyncgit/src/status.rs:151] status fetched: 10315854148163913168 (type: WorkingDir)
13:09:18 [TRACE] (1) gitui::app: [src/app.rs:371] update_async: Git(Status)
13:09:18 [TRACE] (1) gitui::app: [src/app.rs:371] update_async: Git(Status)
13:09:18 [DEBUG] (7) asyncgit::sync::remotes::callbacks: creds: '[[email protected]:22]:extrawurst/gitui.git' Some("[git") (SSH_KEY | SSH_MEMORY | SSH_CUSTOM)
13:09:18 [DEBUG] (7) asyncgit::sync::remotes::callbacks: creds: '[[email protected]:22]:extrawurst/gitui.git' Some("[git") (SSH_KEY | SSH_MEMORY | SSH_CUSTOM)
13:09:18 [TRACE] (1) gitui::app: [src/app.rs:371] update_async: Git(Fetch)
13:09:18 [ERROR] fetch error: git error:Bad credentials.
13:09:18 [TRACE] (1) gitui::app: [src/app.rs:352] update
13:09:18 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:95] request: [hash: 16497959313889857639] (type: WorkingDir)
13:09:18 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:95] request: [hash: 10760547439531155206] (type: Stage)
13:09:18 [TRACE] (3) asyncgit::status: [asyncgit/src/status.rs:151] status fetched: 10760547439531155206 (type: Stage)
13:09:18 [TRACE] (2) asyncgit::status: [asyncgit/src/status.rs:151] status fetched: 16497959313889857639 (type: WorkingDir)
13:09:18 [TRACE] (1) gitui::app: [src/app.rs:371] update_async: Git(Fetch)
13:09:18 [TRACE] (1) gitui::app: [src/app.rs:371] update_async: Git(Status)
13:09:18 [TRACE] (1) gitui::app: [src/app.rs:371] update_async: Git(Status)
13:09:19 [TRACE] (1) gitui::app: [src/app.rs:280] event: Input(Key(KeyEvent { code: Enter, modifiers: NONE }))
13:09:21 [TRACE] (1) gitui::app: [src/app.rs:352] update
13:09:21 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:95] request: [hash: 3058622914774764491] (type: WorkingDir)
13:09:21 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:95] request: [hash: 165825549770520795] (type: Stage)
13:09:21 [TRACE] (3) asyncgit::status: [asyncgit/src/status.rs:151] status fetched: 165825549770520795 (type: Stage)
13:09:21 [TRACE] (1) gitui::app: [src/app.rs:371] update_async: Git(Status)
13:09:21 [TRACE] (2) asyncgit::status: [asyncgit/src/status.rs:151] status fetched: 3058622914774764491 (type: WorkingDir)
13:09:21 [TRACE] (1) gitui::app: [src/app.rs:371] update_async: Git(Status)
13:09:22 [TRACE] (1) gitui::app: [src/app.rs:280] event: Input(Key(KeyEvent { code: Char('q'), modifiers: NONE }))
ok I tested that and our core library libgit2 does not support this bracket-style format. it is an upstream issue - please report it over at libgit2 that the git_remote_callbacks field credentials will pass a malformed url when using this bracket style-format. you can see this in the log in this line:
13:09:18 [DEBUG] (7) asyncgit::sync::remotes::callbacks: creds: '[[email protected]:22]:extrawurst/gitui.git' Some("[git") (SSH_KEY | SSH_MEMORY | SSH_CUSTOM)
where the Some("[git") is maleformed - but it is what libgit2 passes to us in this callback.
@extrawurst I took some time this morning to start writing up a bug report but I'm not really sure what to specify for reproduction steps. Should I look at https://github.com/rust-lang/git2-rs to provide the best context for upstream?
@extrawurst I took some time this morning to start writing up a bug report but I'm not really sure what to specify for reproduction steps. Should I look at https://github.com/rust-lang/git2-rs to provide the best context for upstream?
just startout writing it in prose, pointing here, my write-up above should be pretty clear without any git2-rs knowledge to the libgit2 guys
@Cottser you made libgit2 move! There is a PR to add that now 🥳
Hi there,
I am a bit confused. I am using SSH as remote url and I can not pull or push.
Git error: Bad credentials.
I tried with this 2 syntaxes for url.
[remote "origin"]
url = [[email protected]:22]:extrawurst/gitui.git
fetch = +refs/heads/*:refs/remotes/origin/*
[remote "origin"]
url = [email protected]:extrawurst/gitui.git
fetch = +refs/heads/*:refs/remotes/origin/*
Here is the log file.
00:26:25 [TRACE] (6) mio::poll: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/mio-0.7.14/src/poll.rs:478] registering event source with poller: token=Token(0), interests=READABLE
00:26:25 [TRACE] (1) gitui::app: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/gitui-0.20.1/src/app.rs:396] update
00:26:25 [TRACE] (6) mio::poll: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/mio-0.7.14/src/poll.rs:478] registering event source with poller: token=Token(1), interests=READABLE
00:26:25 [TRACE] (1) asyncgit::status: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/asyncgit-0.20.1/src/status.rs:102] request: [hash: 15287649054255557588] (type: WorkingDir)
00:26:25 [TRACE] (1) asyncgit::status: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/asyncgit-0.20.1/src/status.rs:102] request: [hash: 6905101481325427856] (type: Stage)
00:26:25 [TRACE] (3) asyncgit::status: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/asyncgit-0.20.1/src/status.rs:160] status fetched: 6905101481325427856 (type: Stage)
00:26:25 [TRACE] (2) asyncgit::status: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/asyncgit-0.20.1/src/status.rs:160] status fetched: 15287649054255557588 (type: WorkingDir)
00:26:25 [TRACE] (1) gitui::app: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/gitui-0.20.1/src/app.rs:415] update_async: Git(Status)
00:26:25 [TRACE] (1) gitui::app: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/gitui-0.20.1/src/app.rs:415] update_async: Git(Status)
00:26:30 [TRACE] (1) gitui::app: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/gitui-0.20.1/src/app.rs:396] update
00:26:30 [TRACE] (1) asyncgit::status: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/asyncgit-0.20.1/src/status.rs:102] request: [hash: 10812326724480443125] (type: WorkingDir)
00:26:30 [TRACE] (1) asyncgit::status: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/asyncgit-0.20.1/src/status.rs:102] request: [hash: 9276555521591255851] (type: Stage)
00:26:30 [TRACE] (4) asyncgit::status: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/asyncgit-0.20.1/src/status.rs:160] status fetched: 9276555521591255851 (type: Stage)
00:26:30 [TRACE] (2) asyncgit::status: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/asyncgit-0.20.1/src/status.rs:160] status fetched: 10812326724480443125 (type: WorkingDir)
00:26:30 [TRACE] (1) gitui::app: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/gitui-0.20.1/src/app.rs:415] update_async: Git(Status)
00:26:30 [TRACE] (1) gitui::app: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/gitui-0.20.1/src/app.rs:415] update_async: Git(Status)
00:26:30 [TRACE] (1) gitui::app: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/gitui-0.20.1/src/app.rs:320] event: Input(Key(KeyEvent { code: Char('p'), modifiers: NONE }))
00:26:30 [INFO] push: branch 'master' has no upstream - looking up default remote
00:26:30 [INFO] push: branch 'master' to remote 'origin'
00:26:30 [TRACE] (1) asyncgit::push: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/asyncgit-0.20.1/src/push.rs:82] request
00:26:30 [TRACE] (1) gitui::app: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/gitui-0.20.1/src/app.rs:396] update
00:26:30 [TRACE] (1) asyncgit::status: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/asyncgit-0.20.1/src/status.rs:102] request: [hash: 147088564693645521] (type: WorkingDir)
00:26:30 [TRACE] (1) asyncgit::status: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/asyncgit-0.20.1/src/status.rs:102] request: [hash: 1836712185120383020] (type: Stage)
00:26:30 [TRACE] (3) asyncgit::status: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/asyncgit-0.20.1/src/status.rs:160] status fetched: 1836712185120383020 (type: Stage)
00:26:30 [TRACE] (1) gitui::app: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/gitui-0.20.1/src/app.rs:415] update_async: Git(Status)
00:26:30 [TRACE] (2) asyncgit::status: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/asyncgit-0.20.1/src/status.rs:160] status fetched: 147088564693645521 (type: WorkingDir)
00:26:30 [TRACE] (1) gitui::app: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/gitui-0.20.1/src/app.rs:415] update_async: Git(Status)
00:26:31 [DEBUG] (7) asyncgit::sync::remotes::callbacks: creds: '[[email protected]:22]:Flo-Slv/Dotfiles.git' Some("[git") (SSH_KEY | SSH_MEMORY | SSH_CUSTOM)
00:26:31 [DEBUG] (7) asyncgit::sync::remotes::callbacks: creds: '[[email protected]:22]:Flo-Slv/Dotfiles.git' Some("[git") (SSH_KEY | SSH_MEMORY | SSH_CUSTOM)
00:26:31 [TRACE] (1) gitui::app: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/gitui-0.20.1/src/app.rs:415] update_async: Git(Push)
00:26:31 [ERROR] push error: git error:Bad credentials.
00:26:31 [TRACE] (1) gitui::app: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/gitui-0.20.1/src/app.rs:396] update
00:26:31 [TRACE] (1) asyncgit::status: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/asyncgit-0.20.1/src/status.rs:102] request: [hash: 1682125281187338286] (type: WorkingDir)
00:26:31 [TRACE] (1) asyncgit::status: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/asyncgit-0.20.1/src/status.rs:102] request: [hash: 8797176440792844900] (type: Stage)
00:26:31 [TRACE] (3) asyncgit::status: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/asyncgit-0.20.1/src/status.rs:160] status fetched: 8797176440792844900 (type: Stage)
00:26:31 [TRACE] (2) asyncgit::status: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/asyncgit-0.20.1/src/status.rs:160] status fetched: 1682125281187338286 (type: WorkingDir)
00:26:31 [TRACE] (1) gitui::app: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/gitui-0.20.1/src/app.rs:415] update_async: Git(Push)
00:26:31 [TRACE] (1) gitui::app: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/gitui-0.20.1/src/app.rs:415] update_async: Git(Status)
00:26:31 [TRACE] (1) gitui::app: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/gitui-0.20.1/src/app.rs:415] update_async: Git(Status)
00:26:33 [TRACE] (1) gitui::app: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/gitui-0.20.1/src/app.rs:320] event: Input(Key(KeyEvent { code: Enter, modifiers: NONE }))
00:26:34 [TRACE] (1) gitui::app: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/gitui-0.20.1/src/app.rs:320] event: Input(Key(KeyEvent { code: Esc, modifiers: NONE }))
00:26:35 [TRACE] (1) gitui::app: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/gitui-0.20.1/src/app.rs:396] update
00:26:35 [TRACE] (1) asyncgit::status: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/asyncgit-0.20.1/src/status.rs:102] request: [hash: 9049503835120470749] (type: WorkingDir)
00:26:35 [TRACE] (1) asyncgit::status: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/asyncgit-0.20.1/src/status.rs:102] request: [hash: 15008532056155636767] (type: Stage)
00:26:35 [TRACE] (2) asyncgit::status: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/asyncgit-0.20.1/src/status.rs:160] status fetched: 9049503835120470749 (type: WorkingDir)
00:26:35 [TRACE] (3) asyncgit::status: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/asyncgit-0.20.1/src/status.rs:160] status fetched: 15008532056155636767 (type: Stage)
00:26:35 [TRACE] (1) gitui::app: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/gitui-0.20.1/src/app.rs:415] update_async: Git(Status)
00:26:35 [TRACE] (1) gitui::app: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/gitui-0.20.1/src/app.rs:415] update_async: Git(Status)
00:26:35 [TRACE] (1) gitui::app: [/home/floslv/.cargo/registry/src/github.com-1ecc6299db9ec823/gitui-0.20.1/src/app.rs:320] event: Input(Key(KeyEvent { code: Char('q'), modifiers: NONE }))
Do I miss something ? Do we have to wait a PR ?
Edit: I also added my key to SSH agent and still not working.
Edit 2: I fixed the problem by adding this lines to my git config file
[branch "master"]
remote = origin
merge = refs/head/master
I can not explain why it's working now, but if it's can help someone :smile:
Thanks for help
Flo
Feel free to try to build from master, the fix in upstream is not in the last gitui release (the bracket url syntax)
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.
Just wanted to confirm that this is fixed in 0.21.0, thanks, closing!
Run eval "$(ssh-agent)" before ssh-add ~/.ssh/id_rsa resolve this issue for me.