Enable reflogs by default in any repository with a working directory.
[gitweb.git] / git-parse-remote.sh
index e281b7c6ebd5515d74201869574eed6077f37c9d..6ae534bf89a7a1fd0bfeee4248c37b4ea71290b9 100755 (executable)
@@ -99,25 +99,29 @@ 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" |
                (
                        IFS='   '
                        while read sha1 name
                        do
                                mapped=${name#"$from"}
-                               if test "z$name" != "z${name#'^{}'}" ||
+                               if test "z$name" != "z${name%'^{}'}" ||
                                        test "z$name" = "z$mapped"
                                then
                                        continue
                                fi
-                               echo "${name}:${to}${mapped}"
+                               echo "${local_force}${name}:${to}${mapped}"
                        done
                )
        done
@@ -130,6 +134,8 @@ 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=
+       found_mergeref=
+       curr_branch=
        if test "$1" = "-d"
        then
                shift ; remote="$1" ; shift
@@ -167,6 +173,10 @@ canon_refs_list_for_fetch () {
                            dot_prefix= && break
                        done
                fi
+               if test -z $dot_prefix
+               then
+                       found_mergeref=true
+               fi
                case "$remote" in
                '') remote=HEAD ;;
                refs/heads/* | refs/tags/* | refs/remotes/*) ;;
@@ -187,6 +197,11 @@ canon_refs_list_for_fetch () {
                fi
                echo "${dot_prefix}${force}${remote}:${local}"
        done
+       if test -z "$found_mergeref" -a "$curr_branch"
+       then
+               echo >&2 "Warning: No merge candidate found because value of config option
+         \"branch.${curr_branch}.merge\" does not match any remote branch fetched."
+       fi
 }
 
 # Returns list of src: (no store), or src:dst (store)