aboutsummaryrefslogtreecommitdiff
path: root/git-parse-remote.sh
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-11-28 23:07:20 -0800
committerJunio C Hamano <junkio@cox.net>2006-11-28 23:07:20 -0800
commitdf6b7bfb719622af05f62656ea25435538c82e19 (patch)
tree316193a74e1c1e4aa9410747c21938bf8fee763d /git-parse-remote.sh
parent2570458fdaeb577eb60e470bee0f7065dd2058b8 (diff)
parent310b86d48091ebb6a71782678769b2cb8fe2ecd5 (diff)
downloadgit-df6b7bfb719622af05f62656ea25435538c82e19.tar.xz
Merge branch 'jc/globfetch'
* jc/globfetch: fetch-pack: do not barf when duplicate re patterns are given git-fetch: allow forcing glob pattern in refspec git-fetch: allow glob pattern in refspec git-fetch: fix dumb protocol transport to fetch from pack-pruned ref git-fetch: reuse ls-remote result.
Diffstat (limited to 'git-parse-remote.sh')
-rwxr-xr-xgit-parse-remote.sh39
1 files changed, 39 insertions, 0 deletions
diff --git a/git-parse-remote.sh b/git-parse-remote.sh
index c325ef761e..19bc3857d1 100755
--- a/git-parse-remote.sh
+++ b/git-parse-remote.sh
@@ -90,6 +90,43 @@ get_remote_default_refs_for_push () {
esac
}
+# Called from canon_refs_list_for_fetch -d "$remote", which
+# is called from get_remote_default_refs_for_fetch to grok
+# refspecs that are retrieved from the configuration, but not
+# from get_remote_refs_for_fetch when it deals with refspecs
+# supplied on the command line. $ls_remote_result has the list
+# of refs available at remote.
+expand_refs_wildcard () {
+ for ref
+ do
+ lref=${ref#'+'}
+ # a non glob pattern is given back as-is.
+ expr "z$lref" : 'zrefs/.*/\*:refs/.*/\*$' >/dev/null || {
+ echo "$ref"
+ continue
+ }
+
+ 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#'^{}'}" ||
+ test "z$name" = "z$mapped"
+ then
+ continue
+ fi
+ echo "${local_force}${name}:${to}${mapped}"
+ done
+ )
+ done
+}
+
# Subroutine to canonicalize remote:local notation.
canon_refs_list_for_fetch () {
# If called from get_remote_default_refs_for_fetch
@@ -107,6 +144,8 @@ canon_refs_list_for_fetch () {
merge_branches=$(git-repo-config \
--get-all "branch.${curr_branch}.merge")
fi
+ set x $(expand_refs_wildcard "$@")
+ shift
fi
for ref
do