docs: fix filter-branch subdir example for exotic repo names
[gitweb.git] / git-parse-remote.sh
index 4da72aefbd226f6f42af381b5d5a5a3178414576..9b950be28d75b173ed81d5cf83271e9a8c4e6dff 100644 (file)
@@ -55,7 +55,8 @@ get_remote_url () {
 }
 
 get_default_remote () {
-       curr_branch=$(git symbolic-ref -q HEAD | sed -e 's|^refs/heads/||')
+       curr_branch=$(git symbolic-ref -q HEAD)
+       curr_branch="${curr_branch#refs/heads/}"
        origin=$(git config --get "branch.$curr_branch.remote")
        echo ${origin:-origin}
 }
@@ -89,7 +90,13 @@ get_remote_merge_branch () {
            refs/heads/*) remote=${remote#refs/heads/} ;;
            refs/* | tags/* | remotes/* ) remote=
            esac
-
-           [ -n "$remote" ] && echo "refs/remotes/$repo/$remote"
+           [ -n "$remote" ] && case "$repo" in
+               .)
+                   echo "refs/heads/$remote"
+                   ;;
+               *)
+                   echo "refs/remotes/$repo/$remote"
+                   ;;
+           esac
        esac
 }