8 # Not so fast. This could be the partial URL shorthand...
9 token=$(expr "$1" : '\([^/]*\)/')
10 remainder=$(expr "$1" : '[^/]*/\(.*\)')
11 if test -f "$GIT_DIR/branches/$token"
19 if test -f "$GIT_DIR/remotes/$1"
22 elif test -f "$GIT_DIR/branches/$1"
32 data_source=$(get_data_source "$1")
33 case "$data_source" in
40 }' "$GIT_DIR/remotes/$1" ;;
42 sed -e 's/#.*//' "$GIT_DIR/branches/$1" ;;
44 token=$(expr "$1" : '\([^/]*\)/')
45 remainder=$(expr "$1" : '[^/]*/\(.*\)')
46 url=$(sed -e 's/#.*//' "$GIT_DIR/branches/$token")
47 echo "$url/$remainder"
50 die "internal error: get-remote-url $1" ;;
54 get_remote_default_refs_for_push () {
55 data_source=$(get_data_source "$1")
56 case "$data_source" in
57 '' | branches | branches-partial)
58 ;; # no default push mapping, just send matching refs.
62 }' "$GIT_DIR/remotes/$1" ;;
64 die "internal error: get-remote-default-ref-for-push $1" ;;
68 # Subroutine to canonicalize remote:local notation.
69 canon_refs_list_for_fetch () {
70 # Leave only the first one alone; add prefix . to the rest
71 # to prevent the secondary branches to be merged by default.
78 ref=$(expr "$ref" : '\+\(.*\)')
82 expr "$ref" : '.*:' >/dev/null || ref="${ref}:"
83 remote=$(expr "$ref" : '\([^:]*\):')
84 local=$(expr "$ref" : '[^:]*:\(.*\)')
87 refs/heads/* | refs/tags/*) ;;
88 heads/* | tags/* ) remote="refs/$remote" ;;
89 *) remote="refs/heads/$remote" ;;
93 refs/heads/* | refs/tags/*) ;;
94 heads/* | tags/* ) local="refs/$local" ;;
95 *) local="refs/heads/$local" ;;
97 echo "${dot_prefix}${force}${remote}:${local}"
102 # Returns list of src: (no store), or src:dst (store)
103 get_remote_default_refs_for_fetch () {
104 data_source=$(get_data_source "$1")
105 case "$data_source" in
106 '' | branches-partial)
109 remote_branch=$(sed -ne '/#/s/.*#//p' "$GIT_DIR/branches/$1")
110 case "$remote_branch" in '') remote_branch=master ;; esac
111 echo "refs/heads/${remote_branch}:refs/heads/$1"
114 # This prefixes the second and later default refspecs
115 # with a '.', to signal git-fetch to mark them
117 canon_refs_list_for_fetch $(sed -ne '/^Pull: */{
119 }' "$GIT_DIR/remotes/$1")
122 die "internal error: get-remote-default-ref-for-push $1" ;;
126 get_remote_refs_for_push () {
128 0) die "internal error: get-remote-refs-for-push." ;;
129 1) get_remote_default_refs_for_push "$@" ;;
130 *) shift; echo "$@" ;;
134 get_remote_refs_for_fetch () {
137 die "internal error: get-remote-refs-for-fetch." ;;
139 get_remote_default_refs_for_fetch "$@" ;;
145 if test "$tag_just_seen"
147 echo "refs/tags/${ref}:refs/tags/${ref}"
158 canon_refs_list_for_fetch "$ref"
164 resolve_alternates () {
165 # original URL (xxx.git)
166 top_=`expr "$1" : '\([^:]*:/*[^/]*\)/'`
173 echo "$top_$path/" ;;
175 # relative -- ugly but seems to work.
176 echo "$1/objects/$path/" ;;
178 # exit code may not be caught by the reader.
179 echo "bad alternate: $path"