@matheusbsbs / matheus-bagliano / commits / 73136b2e8a
Fork 0

fetch, pull: ask config for remote information

Now you can say [remote.junio] url = git://git.kernel.org/pub/scm/git/git.git fetch = next:next in your .git/config. [jc: fixed up the log message that still said "pull" ] Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>

Johannes Schindelin committed May 3, 2006 at 15:20 UTC 73136b2e8a8ee024320c5ac6a0f14f912432bf03
1 file changed +24 -4
git-parse-remote.sh
+24 -4
@@ -10,7 +10,10 @@ get_data_source () {
10 # Not so fast. This could be the partial URL shorthand...
11 token=$(expr "z$1" : 'z\([^/]*\)/')
12 remainder=$(expr "z$1" : 'z[^/]*/\(.*\)')
13 - if test -f "$GIT_DIR/branches/$token"
13 + if test "$(git-repo-config --get "remote.$token.url")"
14 + then
15 + echo config-partial
16 + elif test -f "$GIT_DIR/branches/$token"
17 then
18 echo branches-partial
19 else
@@ -18,7 +21,10 @@ get_data_source () {
21 fi
22 ;;
23 *)
21 - if test -f "$GIT_DIR/remotes/$1"
24 + if test "$(git-repo-config --get "remote.$1.url")"
25 + then
26 + echo config
27 + elif test -f "$GIT_DIR/remotes/$1"
28 then
29 echo remotes
30 elif test -f "$GIT_DIR/branches/$1"
@@ -35,6 +41,15 @@ get_remote_url () {
41 case "$data_source" in
42 '')
43 echo "$1" ;;
44 + config-partial)
45 + token=$(expr "z$1" : 'z\([^/]*\)/')
46 + remainder=$(expr "z$1" : 'z[^/]*/\(.*\)')
47 + url=$(git-repo-config --get "remote.$token.url")
48 + echo "$url/$remainder"
49 + ;;
50 + config)
51 + git-repo-config --get "remote.$1.url"
52 + ;;
53 remotes)
54 sed -ne '/^URL: */{
55 s///p
@@ -56,8 +71,10 @@ get_remote_url () {
71 get_remote_default_refs_for_push () {
72 data_source=$(get_data_source "$1")
73 case "$data_source" in
59 - '' | branches | branches-partial)
74 + '' | config-partial | branches | branches-partial)
75 ;; # no default push mapping, just send matching refs.
76 + config)
77 + git-repo-config --get-all "remote.$1.push" ;;
78 remotes)
79 sed -ne '/^Push: */{
80 s///p
@@ -111,8 +128,11 @@ canon_refs_list_for_fetch () {
128 get_remote_default_refs_for_fetch () {
129 data_source=$(get_data_source "$1")
130 case "$data_source" in
114 - '' | branches-partial)
131 + '' | config-partial | branches-partial)
132 echo "HEAD:" ;;
133 + config)
134 + canon_refs_list_for_fetch \
135 + $(git-repo-config --get-all "remote.$1.fetch") ;;
136 branches)
137 remote_branch=$(sed -ne '/#/s/.*#//p' "$GIT_DIR/branches/$1")
138 case "$remote_branch" in '') remote_branch=master ;; esac