1 : To be included in git-pull and git-fetch scripts.
3 # A remote repository can be specified on the command line
4 # in one of the following formats:
10 # where <repo> could be one of:
12 # a URL (including absolute or local pathname)
14 # a short-hand followed by a trailing path
16 # A short-hand <name> has a corresponding file $GIT_DIR/branches/<name>,
17 # whose contents is a URL, possibly followed by a URL fragment #<head>
18 # to name the default branch on the remote side to fetch from.
20 _remote_repo= _remote_store= _remote_head= _remote_name=
23 *:* | /* | ../* | ./* )
27 # otherwise, it is a short hand.
30 # a short-hand followed by a trailing path
31 _token=$(expr "$1" : '\([^/]*\)/')
32 _rest=$(expr "$1" : '[^/]*\(/.*\)$')
37 _remote_store="refs/heads/$_token"
40 test -f "$GIT_DIR/branches/$_token" ||
41 die "No such remote branch: $_token"
43 _remote_repo=$(cat "$GIT_DIR/branches/$_token")"$_rest"
47 case "$_remote_repo" in
49 _remote_head=`expr "$_remote_repo" : '.*#\(.*\)$'`
50 _remote_repo=`expr "$_remote_repo" : '\(.*\)#'`
54 _remote_name=$(echo "$_remote_repo" | sed 's|\.git/*$||')
58 _remote_name="tag '$3' of $_remote_name"
59 _remote_head="refs/tags/$3"
60 _remote_store="$_remote_head"
63 # command line specified a head explicitly; do not
64 # store the fetched head as a branch head.
65 _remote_name="head '$2' of $_remote_name"
66 _remote_head="refs/heads/$2"
70 case "$_remote_head" in
74 _remote_name="head '$_remote_head' of $_remote_name"
75 _remote_head="refs/heads/$_remote_head"