]> git.wh0rd.org Git - home.git/commitdiff
vcs-url: improve origin lookup
authorMike Frysinger <vapier@gentoo.org>
Sat, 25 Jan 2020 09:01:03 +0000 (04:01 -0500)
committerMike Frysinger <vapier@gentoo.org>
Sat, 25 Jan 2020 09:01:03 +0000 (04:01 -0500)
.bin/vcs-url

index 94ff2a03d7245cadb1042d7df40c87b2c099e738..8b05986768b33db107af0abf1bdf8d106d588e74 100755 (executable)
@@ -64,6 +64,16 @@ git_url() {
 
        local repo url
        local remote=$(git config remote.origin.url)
+
+       if [[ -z ${remote} ]] ; then
+               # Maybe the repo doesn't use "origin".  Try harder.
+               local branch=$(git rev-parse --abbrev-ref HEAD)
+               remote=$(git config "branch.${branch}.remote")
+               if [[ -n ${remote} ]] ; then
+                       remote=$(git config "remote.${remote}.url")
+               fi
+       fi
+
        case ${remote} in
        *://uclibc.org/*|*://git.uclibc.org/*|\
        *://busybox.net/*|*://git.busybox.net/*|\