[PATCH 6/7] warn on "git pull" without a given branch.<name>.remote value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux