You are not using `$remote_name`, you probably want this:
```
    local ref=$(git symbolic-ref HEAD 2>/dev/null)
    local remote_name=$(cd $repos/$reponame; git config branch.$ref.name 2>/dev/null)
    local remote_url=$(cd $repos/$reponame; git config remote.$remote_name.url)
```