Skip to content

Commit d945d4b

Browse files
author
Junio C Hamano
committed
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 <[email protected]>
1 parent cadd8a7 commit d945d4b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

git-parse-remote.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,17 @@ get_remote_default_refs_for_push () {
9999
expand_refs_wildcard () {
100100
for ref
101101
do
102+
lref=${ref#'+'}
102103
# 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 || {
104105
echo "$ref"
105106
continue
106107
}
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='+'
109113
echo "$ls_remote_result" |
110114
(
111115
IFS=' '
@@ -117,7 +121,7 @@ expand_refs_wildcard () {
117121
then
118122
continue
119123
fi
120-
echo "${name}:${to}${mapped}"
124+
echo "${local_force}${name}:${to}${mapped}"
121125
done
122126
)
123127
done

0 commit comments

Comments
 (0)