1

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 .git/config.

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

  1. tell the host and repo for a git URL
  2. fetch the antialiased URL based on the git URL which might contain SSH aliases

For (1) I can think of splitting on the first : or / 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.