fix(git): convert SCP-like submodule URLs to ssh:// format#16727
fix(git): convert SCP-like submodule URLs to ssh:// format#16727weihanglo merged 2 commits intorust-lang:masterfrom
Conversation
|
r? @weihanglo rustbot has assigned @weihanglo. Use Why was this reviewer chosen?The reviewer was selected based on:
|
There was a problem hiding this comment.
Thanks for taking a stab. This is indeed a regression.
Since Cargo doesn't support SCP-like git dependency URL in Cargo.toml, this case was overlooked. However, libgit2 supports SCP-like URL, so we should follow if it is in .gitmodules not in Cargo.toml. I think it is fine we scope this for supporting submodule only. For general SCP-like URL support, we track in #1851.
55580eb to
22c81c7
Compare
|
@weihanglo One task failed because the CI runner was unable to verify the SSH host key. I could disable host key checking inside the test case using the |
Sure, we could try it. The best case is that we don't need to diverge our snapshot based on different platforms. The other alternative here would be we only run this test on certain platform that is guaranteed to pass. |
22c81c7 to
8afd44e
Compare
Signed-off-by: Cibil Pankiras <cibil.pankiras@egym.com>
PR rust-lang#16246 introduced a regression where submodules using SCP-like URLs fail because `child_remote_url.into_url()` requires WHATWG-parsable URLs. This commit fixes the issue by detecting SCP-like URLs in `absolute_submodule_url()` and converting them to the equivalent `ssh://` format. Signed-off-by: Cibil Pankiras <cibil.pankiras@egym.com>
8afd44e to
dbb2b56
Compare
I updated the commit, and the test case now passes on all platforms |
There was a problem hiding this comment.
Thanks for working with us!
One thing to note that the path semantic is a bit different between the two forms
- In SCP-like
git@host:path/repo.git, path is relative to the user's home directory (~git/path/repo.git) - In SSH
ssh:// ssh://git@host/path/repo.git, path is absolute from root (/path/repo.git)
For like GitHub and GitLab, this doesn't really matter as they intercept the path and resolve it. But for a self-hosted git server this might be an issue after the conversion.
That said, this conversion is as same as the suggestion in IntoUrl::into_url, and also this is a regression already a hard error, so this change is still better than nothing.
We may probably want a way to track the original Git submodule URL and use that during fetching, if possible.
## What does this PR try to resolve? This is a follow-up of #16727 to fix more edge cases. This decouples the fetch URL from the `SourceId` URL for submodules: * The conversion only happens in `update_submodule` for creating a `SourceId`, which requires a WHATWG URL. * The original URL is preserved in `GitRemote` and used for the actual git fetch and user-facing messages. Fixes #16740 ## How to test and review this PR? Commit by commit. However, there is still a limitation about cache collision. See <#16740 (comment)>
Update cargo submodule 21 commits in 90ed291a50efc459e0c380d7b455777ed41c6799..cbb9bb8bd0fb272b1be0d63a010701ecb3d1d6d3 2026-03-05 15:11:25 +0000 to 2026-03-13 14:34:16 +0000 - fix(git): preserve SCP-like submodule URLs for fetch (rust-lang/cargo#16744) - Fix 16732 (rust-lang/cargo#16746) - fix(rustdoc): switch to new `--emit` options (rust-lang/cargo#16739) - fix(git): convert SCP-like submodule URLs to ssh:// format (rust-lang/cargo#16727) - fix(core): typo (rust-lang/cargo#16738) - CARGO_TARGET_DIR doesn't have to be relative (rust-lang/cargo#16735) - chore(ci): Detect user changes to src/etc/man (rust-lang/cargo#16736) - util: Exclude from iCloud Drive sync on macOS (rust-lang/cargo#16728) - fix(compile): Stop on denying warnings without --keep-going (rust-lang/cargo#16725) - feat(shell): Support OSC 9;4 progress on ptyxis (rust-lang/cargo#16730) - Let git decide when to run gc (rust-lang/cargo#16459) - chore(deps): update cargo-semver-checks to v0.47.0 (rust-lang/cargo#16723) - fix(compile): Turn warning summaries into errors also (rust-lang/cargo#16721) - fix(fix): Switch from ad-hoc to structured warnings (rust-lang/cargo#16711) - fix: ignore implicit std dependencies in `unused-crate-dependencies` lint (rust-lang/cargo#16677) - chore(deps): update msrv (3 versions) to v1.92 (rust-lang/cargo#16716) - chore(deps): update msrv (1 version) to v1.94 (rust-lang/cargo#16710) - fix(script): surpress `unused_features` lint for embedded (rust-lang/cargo#16714) - Split `build-dir` lock into dedicated lock (rust-lang/cargo#16708) - Add missing truncate when writing .crate files (rust-lang/cargo#16688) - refactor(fix): Prep for annotate-snippets (rust-lang/cargo#16702)
What does this PR try to resolve?
PR #16246 introduced a regression where submodules using SCP-like URLs fail because
child_remote_url.into_url()requires WHATWG-parsable URLs.This commit fixes the issue by detecting SCP-like URLs in
absolute_submodule_url()and converting them to the equivalentssh://format.How to test and review this PR?
Cargo.tomland configure the dependency repository to pull its submodules using the following.gitmodulesentry:cargo fetchshould succeed