@matheusbsbs / matheus-bagliano / commits / d41cb273d3
Fork 0

parse-remote: mark all refs not for merge only when fetching more than one

An earlier commit a71fb0a1 implemented much requested safety valve to refuse "git pull" or "git pull origin" without explicit refspecs from using the first set of remote refs obtained by reading .git/remotes/origin file or branch.*.fetch configuration variables to create a merge. The argument was that while on a branch different from the default branch, it is often wrong to merge the default remote ref suitable for merging into the master. That is fine as a theory. But many repositories already in use by people in the real world do not have any of the per branch configuration crap. They did not need it, and they do not need it now. Merging with the first remote ref listed was just fine, because they had only one ref (e.g. 'master' from linux-2.6.git) anyway. So this changes the safety valve to be a lot looser. When "git fetch" gets only one remote branch, the irritating warning would not trigger anymore. I think we could also make the warning trigger when branch.*.merge is not specified for the current branch, but is for some other branch. That is for another commit. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Dec 21, 2006 at 22:39 UTC d41cb273d313a21979b05dba57d0c6b565b28ba6
1 file changed +9 -2
git-parse-remote.sh
+9 -2
@@ -136,6 +136,8 @@ canon_refs_list_for_fetch () {
136 if test "$1" = "-d"
137 then
138 shift ; remote="$1" ; shift
139 + set x $(expand_refs_wildcard "$@")
140 + shift
141 if test "$remote" = "$(get_default_remote)"
142 then
143 curr_branch=$(git-symbolic-ref HEAD | \
@@ -143,8 +145,13 @@ canon_refs_list_for_fetch () {
145 merge_branches=$(git-repo-config \
146 --get-all "branch.${curr_branch}.merge")
147 fi
146 - set x $(expand_refs_wildcard "$@")
147 - shift
148 + # If we are fetching only one branch, then first branch
149 + # is the only thing that makes sense to merge anyway,
150 + # so there is no point refusing that traditional rule.
151 + if test $# != 1 && test "z$merge_branches" = z
152 + then
153 + merge_branches=..this..would..never..match..
154 + fi
155 fi
156 for ref
157 do