Fetch: default remote repository from branch properties
If in branch "foo" and this in config: [branch "foo"] remote=bar "git fetch" = "git fetch bar" "git pull" = "git pull bar" Signed-off-by: Santi Béjar <sbejar@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
Santi Béjar committed
Sep 23, 2006 at 12:05 UTC
648ad18f5077295c4317f0784b29e09d2c0bac93
3 files changed
+13
-5
Documentation/config.txt
+3
@@ -119,6 +119,9 @@ apply.whitespace::
119
Tells `git-apply` how to handle whitespaces, in the same way
120
as the '--whitespace' option. See gitlink:git-apply[1].
121
122
+branch.<name>.remote::
123
+ When in branch <name>, it tells `git fetch` which remote to fetch.
124
+
125
pager.color::
126
A boolean to enable/disable colored output when the pager is in
127
use (default is true).
git-fetch.sh
+4
-5
@@ -68,11 +68,10 @@ done
68
69
case "$#" in
70
0)
71
- test -f "$GIT_DIR/branches/origin" ||
72
- test -f "$GIT_DIR/remotes/origin" ||
73
- git-repo-config --get remote.origin.url >/dev/null ||
74
- die "Where do you want to fetch from today?"
75
- set origin ;;
71
+ origin=$(get_default_remote)
72
+ test -n "$(get_remote_url ${origin})" ||
73
+ die "Where do you want to fetch from today?"
74
+ set x $origin ; shift ;;
75
esac
76
77
remote_nick="$1"
git-parse-remote.sh
+6
@@ -68,6 +68,12 @@ get_remote_url () {
68
esac
69
}
70
71
+get_default_remote () {
72
+ curr_branch=$(git-symbolic-ref HEAD | sed -e 's|^refs/heads/||')
73
+ origin=$(git-repo-config --get "branch.$curr_branch.remote")
74
+ echo ${origin:-origin}
75
+}
76
+
77
get_remote_default_refs_for_push () {
78
data_source=$(get_data_source "$1")
79
case "$data_source" in