From: Oleg Broytman Date: Wed, 29 Nov 2023 15:18:03 +0000 (+0300) Subject: Add a script to resolve rewritten URL X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=eb47be630a96af035defbd47484627d4597e55c2;p=git-scripts.git Add a script to resolve rewritten URL --- diff --git a/git-resolve-remote b/git-resolve-remote new file mode 100755 index 0000000..4c76cf6 --- /dev/null +++ b/git-resolve-remote @@ -0,0 +1,24 @@ +#! /bin/sh +# See https://stackoverflow.com/q/77560684/7976758 + +# Uses a transient repository so it's not effective to resolve many URLs. +# For many URLs create one repository, add remotes, +# get rewritten URLs and then remove the repository. + +set -e + +if [ $# -ne 1 ]; then + echo "Usage $0 URL" >&2 + exit 1 +fi + +cd /tmp +rm -rf _git_resolve_remote.tmp +git init --quiet _git_resolve_remote.tmp +cd _git_resolve_remote.tmp + +git remote add origin "$1" +git remote get-url origin + +cd .. +exec rm -rf _git_resolve_remote.tmp