About lib.rs' git redirecting and git's mechanism for handling redirects

lib.rs supports redirecting to repository url of a crate when git cloning. But today I suddenly discovered that the origin of repositorys cloned this way is still the original address of lib.rs entered when cloning, not the actual address of the git repository. I don't know if this will lead to trouble.

Also, what worse, the folder name of the cloned repository will also be the entered name when cloning (name of crate or lib), not the repository itself name. This is obviously a problem for repositories with multiple crates.
For example:
clone https://lib.rs/hex-literal (crate name) or https://lib.rs/hex_literal (lib name)
actually cloned repository: https://github.com/rustcrypto/utils
folder name: hex-literal or hex_literal
origin: https://lib.rs/hex-literal or https://lib.rs/hex_literal

redirection is an operation of the transport layer, (e.g. http/https have the concept of redirect, but ssh does not), git itself is agnostic about the underlying transport, it just use the info you give it as command line argument.

for the most part, this should not make a difference, as the local path or remote config is local to your clone.

This is based on git's HTTPS transport (not git or ssh protocols), and sends redirect with Location to the actual repo URL when git asks lib.rs for /info/refs (which is an initial git-specific request of the git-HTTPS protocol).

Unfortunately I can't control the directory name, since git client picks that up based on the URL you provide. I can't control settings of the cloned repo either, that's between the git client and GitHub or other git server that takes over after the redirect.

So don't use lib.rs's git URLs for anything serious. It's there if you want to have a quick peek at the repo without going to the website, but if you're going to be working with the clone, clone it properly via its real URL.


This is actually my practice now.
And if I need to "work with" some crate, basically means that I need to send a PR or make a modified version of my own, then I definitely need to fork first and then clone the version I forked.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.