@matheusbsbs / matheus-bagliano / commits / fbc9012307
Fork 0

Do not merge random set of refs out of wildcarded refs

When your fetch configuration has only the wildcards, we would pick the lexicographically first ref from the remote side for merging, which was complete nonsense. Make sure nothing except the one that is specified with branch.*.merge is merged in this case. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Dec 31, 2006 at 17:44 UTC fbc9012307d3b2e1bcee84e4455b11e97f580e07
1 file changed +22 -1
git-parse-remote.sh
+22 -1
@@ -76,16 +76,32 @@ get_remote_default_refs_for_push () {
76 # from get_remote_refs_for_fetch when it deals with refspecs
77 # supplied on the command line. $ls_remote_result has the list
78 # of refs available at remote.
79 +#
80 +# The first token returned is either "explicit" or "glob"; this
81 +# is to help prevent randomly "globbed" ref from being chosen as
82 +# a merge candidate
83 expand_refs_wildcard () {
84 + first_one=yes
85 for ref
86 do
87 lref=${ref#'+'}
88 # a non glob pattern is given back as-is.
89 expr "z$lref" : 'zrefs/.*/\*:refs/.*/\*$' >/dev/null || {
90 + if test -n "$first_one"
91 + then
92 + echo "explicit"
93 + first_one=
94 + fi
95 echo "$ref"
96 continue
97 }
98
99 + # glob
100 + if test -n "$first_one"
101 + then
102 + echo "glob"
103 + first_one=
104 + fi
105 from=`expr "z$lref" : 'z\(refs/.*/\)\*:refs/.*/\*$'`
106 to=`expr "z$lref" : 'zrefs/.*/\*:\(refs/.*/\)\*$'`
107 local_force=
@@ -116,7 +132,8 @@ canon_refs_list_for_fetch () {
132 if test "$1" = "-d"
133 then
134 shift ; remote="$1" ; shift
119 - set x $(expand_refs_wildcard "$@")
135 + set $(expand_refs_wildcard "$@")
136 + is_explicit="$1"
137 shift
138 if test "$remote" = "$(get_default_remote)"
139 then
@@ -125,6 +142,10 @@ canon_refs_list_for_fetch () {
142 merge_branches=$(git-repo-config \
143 --get-all "branch.${curr_branch}.merge")
144 fi
145 + if test -z "$merge_branches" && test $is_explicit != explicit
146 + then
147 + merge_branches=..this.will.never.match.any.ref..
148 + fi
149 fi
150 for ref
151 do