aboutsummaryrefslogtreecommitdiff
path: root/git-parse-remote.sh
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-11-22 23:15:00 -0800
committerJunio C Hamano <junkio@cox.net>2006-11-23 16:54:54 -0800
commit5677882be721be5e2706a546d90804da8d8d0bd5 (patch)
tree19fa83a977829fe18666af55b9d46091d8952f95 /git-parse-remote.sh
parent2986c02217f98809d8990e7679edf0f5d99f904d (diff)
downloadgit-5677882be721be5e2706a546d90804da8d8d0bd5.tar.gz
git-5677882be721be5e2706a546d90804da8d8d0bd5.tar.xz
git-fetch: allow glob pattern in refspec
This adds Andy's refspec glob. You can have a single line: Pull: refs/heads/*:refs/remotes/origin/* in your ".git/remotes/origin" and say "git fetch" to retrieve all refs under heads/ at the remote side to remotes/origin/ in the local repository. Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'git-parse-remote.sh')
-rwxr-xr-xgit-parse-remote.sh35
1 files changed, 35 insertions, 0 deletions
diff --git a/git-parse-remote.sh b/git-parse-remote.sh
index c325ef761..e281b7c6e 100755
--- a/git-parse-remote.sh
+++ b/git-parse-remote.sh
@@ -90,6 +90,39 @@ 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
+ # a non glob pattern is given back as-is.
+ expr "z$ref" : 'zrefs/.*/\*:refs/.*/\*$' >/dev/null || {
+ echo "$ref"
+ continue
+ }
+ from=`expr "z$ref" : 'z\(refs/.*/\)\*:refs/.*/\*$'`
+ to=`expr "z$ref" : 'zrefs/.*/\*:\(refs/.*/\)\*$'`
+ 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 "${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 +140,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