[PATCH 6/7] warn on "git pull" without a given branch.<name>.remote value
- From
Paolo Bonzini <bonzini@gnu.org>
- Date
- Apr 28, 2008, 15:32 UTC
- Message-ID
- <22f5914b1ffff814fa2387ff5cb762e0099aaa6b.1209391615.git.bonzini@gnu.org>
- In-Reply-To
- <b5b9b866e5f942d024831d528ae599e3e6ce31da.1209391615.git.bonzini@gnu.org>
This patch deprecates the behavior of "git pull" without a branch.<name>.remote value in the configuration. The value "origin" will be used, but a warning will be printed too.
Signed-off-by: Paolo Bonzini <bonzini@gnu.org> --- Documentation/git-pull.txt | 9 +++++---- git-parse-remote.sh | 8 ++++++++ 2 files changed, 13 insertions(+), 4 deletions(-)
In this case, I think we can warn because branch.*.remote lines are created by checkouts made with 1.5 or later.
diff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt index 3405ca0..18898f6 100644 --- a/Documentation/git-pull.txt +++ b/Documentation/git-pull.txt @@ -58,10 +58,11 @@ DEFAULT BEHAVIOUR ----------------- Often people use `git pull` without giving any parameter. -Traditionally, this has been equivalent to saying `git pull -origin`. However, when configuration `branch.<name>.remote` is -present while on branch `<name>`, that value is used instead of -`origin`. +While on branch `<name>`, this will use the value of configuration +`branch.<name>.remote` as the branch to pull from. If the +value is not present, it will be implicitly considered to be +`origin`; however, this is deprecated and you consider +writing the value explicitly in the configuration file. In order to determine what URL to use to fetch from, the value of the configuration `remote.<origin>.url` is consulted diff --git a/git-parse-remote.sh b/git-parse-remote.sh index 695a409..eddb593 100755 --- a/git-parse-remote.sh +++ b/git-parse-remote.sh @@ -54,9 +54,17 @@ get_remote_url () { esac } +warned_about_default_remote=no get_default_remote () { curr_branch=$(git symbolic-ref -q HEAD | sed -e 's|^refs/heads/||') origin=$(git config --get "branch.$curr_branch.remote") + if test -z "$origin" && test "$warned_about_default_remote" = no; then + echo "warning: you asked me to pull without telling me which repository" + echo "warning: you want to pull from, and 'branch.${curr_branch}.remote'" + echo "warning: in your configuration file does not tell me either." + echo "warning: proceeding with 'origin'." + warned_about_default_remote=yes + fi echo ${origin:-origin} }
-- 1.5.5