Think of a utility like gerrit-sh which uses git config options to determine where the gerrit host is located. The context for my question is this function get_repo_remote_config(). So I want to retrieve the repository and more important the host name of the git URL configured in
The method assumes you have your username, host, port and repo all inside your git config. Which ignores that you can use ssh aliases.
What is a recommended way to either
- tell the host and repo for a git URL
- fetch the antialiased URL based on the git URL which might contain SSH aliases
For (1) I can think of splitting on the first
/ with some additional magic.
For (2) I could think of something like in this question: awk.
Both approaches would work, but isn't there a more convenient way to do that? Isn't there a utility for some SSH/URL calculation?
Thanks in advance.