git-fetch: allow forcing glob pattern in refspec
Building on top of the earlier refspec glob pattern enhancement, this allows a glob pattern to say the updates should be forced by prefixing it with '+' as usual, like this: Pull: +refs/heads/*:refs/remotes/origin/* Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Nov 25, 2006 at 01:10 UTC
d945d4be20d577868646f1b676b605cd9fdadf86
1 file changed
+8
-4
git-parse-remote.sh
+8
-4
@@ -99,13 +99,17 @@ get_remote_default_refs_for_push () {
99
expand_refs_wildcard () {
100
for ref
101
do
102
+ lref=${ref#'+'}
103
# a non glob pattern is given back as-is.
103
- expr "z$ref" : 'zrefs/.*/\*:refs/.*/\*$' >/dev/null || {
104
+ expr "z$lref" : 'zrefs/.*/\*:refs/.*/\*$' >/dev/null || {
105
echo "$ref"
106
continue
107
}
107
- from=`expr "z$ref" : 'z\(refs/.*/\)\*:refs/.*/\*$'`
108
- to=`expr "z$ref" : 'zrefs/.*/\*:\(refs/.*/\)\*$'`
108
+
109
+ from=`expr "z$lref" : 'z\(refs/.*/\)\*:refs/.*/\*$'`
110
+ to=`expr "z$lref" : 'zrefs/.*/\*:\(refs/.*/\)\*$'`
111
+ local_force=
112
+ test "z$lref" = "z$ref" || local_force='+'
113
echo "$ls_remote_result" |
114
(
115
IFS=' '
@@ -117,7 +121,7 @@ expand_refs_wildcard () {
121
then
122
continue
123
fi
120
- echo "${name}:${to}${mapped}"
124
+ echo "${local_force}${name}:${to}${mapped}"
125
done
126
)
127
done