Merge branch 'jc/clone'
[gitweb.git] / git-parse-remote.sh
index e281b7c6ebd5515d74201869574eed6077f37c9d..ea7511e8a0f18a3402146ce8acc1c051fc92475f 100755 (executable)
@@ -99,25 +99,27 @@ get_remote_default_refs_for_push () {
 expand_refs_wildcard () {
        for ref
        do
+               lref=${ref#'+'}
                # a non glob pattern is given back as-is.
-               expr "z$ref" : 'zrefs/.*/\*:refs/.*/\*$' >/dev/null || {
+               expr "z$lref" : 'zrefs/.*/\*:refs/.*/\*$' >/dev/null || {
                        echo "$ref"
                        continue
                }
-               from=`expr "z$ref" : 'z\(refs/.*/\)\*:refs/.*/\*$'`
-               to=`expr "z$ref" : 'zrefs/.*/\*:\(refs/.*/\)\*$'`
+
+               from=`expr "z$lref" : 'z\(refs/.*/\)\*:refs/.*/\*$'`
+               to=`expr "z$lref" : 'zrefs/.*/\*:\(refs/.*/\)\*$'`
+               local_force=
+               test "z$lref" = "z$ref" || local_force='+'
                echo "$ls_remote_result" |
+               sed -e '/\^{}$/d' |
                (
                        IFS='   '
                        while read sha1 name
                        do
+                               # ignore the ones that do not start with $from
                                mapped=${name#"$from"}
-                               if test "z$name" != "z${name#'^{}'}" ||
-                                       test "z$name" = "z$mapped"
-                               then
-                                       continue
-                               fi
-                               echo "${name}:${to}${mapped}"
+                               test "z$name" = "z$mapped" && continue
+                               echo "${local_force}${name}:${to}${mapped}"
                        done
                )
        done
@@ -130,6 +132,7 @@ canon_refs_list_for_fetch () {
        # or the first one otherwise; add prefix . to the rest
        # to prevent the secondary branches to be merged by default.
        merge_branches=
+       curr_branch=
        if test "$1" = "-d"
        then
                shift ; remote="$1" ; shift
@@ -138,7 +141,8 @@ canon_refs_list_for_fetch () {
                        curr_branch=$(git-symbolic-ref HEAD | \
                            sed -e 's|^refs/heads/||')
                        merge_branches=$(git-repo-config \
-                           --get-all "branch.${curr_branch}.merge")
+                           --get-all "branch.${curr_branch}.merge") ||
+                       merge_branches=.this.would.never.match.any.ref.
                fi
                set x $(expand_refs_wildcard "$@")
                shift