From 648ad18f5077295c4317f0784b29e09d2c0bac93 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Santi=20B=C3=A9jar?= Date: Sat, 23 Sep 2006 12:05:43 +0200 Subject: [PATCH] Fetch: default remote repository from branch properties MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Junio C Hamano --- Documentation/config.txt | 3 +++ git-fetch.sh | 9 ++++----- git-parse-remote.sh | 6 ++++++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Documentation/config.txt b/Documentation/config.txt index bb2fbc324..04c5094fd 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -119,6 +119,9 @@ apply.whitespace:: Tells `git-apply` how to handle whitespaces, in the same way as the '--whitespace' option. See gitlink:git-apply[1]. +branch..remote:: + When in branch , it tells `git fetch` which remote to fetch. + pager.color:: A boolean to enable/disable colored output when the pager is in use (default is true). diff --git a/git-fetch.sh b/git-fetch.sh index 09a5d6cea..50ad101e8 100755 --- a/git-fetch.sh +++ b/git-fetch.sh @@ -68,11 +68,10 @@ done case "$#" in 0) - test -f "$GIT_DIR/branches/origin" || - test -f "$GIT_DIR/remotes/origin" || - git-repo-config --get remote.origin.url >/dev/null || - die "Where do you want to fetch from today?" - set origin ;; + origin=$(get_default_remote) + test -n "$(get_remote_url ${origin})" || + die "Where do you want to fetch from today?" + set x $origin ; shift ;; esac remote_nick="$1" diff --git a/git-parse-remote.sh b/git-parse-remote.sh index 187f0883c..69998169b 100755 --- a/git-parse-remote.sh +++ b/git-parse-remote.sh @@ -68,6 +68,12 @@ get_remote_url () { esac } +get_default_remote () { + curr_branch=$(git-symbolic-ref HEAD | sed -e 's|^refs/heads/||') + origin=$(git-repo-config --get "branch.$curr_branch.remote") + echo ${origin:-origin} +} + get_remote_default_refs_for_push () { data_source=$(get_data_source "$1") case "$data_source" in -- 2.26.2