Skip to content

Commit d41cb27

Browse files
author
Junio C Hamano
committed
parse-remote: mark all refs not for merge only when fetching more than one
An earlier commit a71fb0a 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>
1 parent 27e4dd8 commit d41cb27

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

git-parse-remote.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,22 @@ canon_refs_list_for_fetch () {
136136
if test "$1" = "-d"
137137
then
138138
shift ; remote="$1" ; shift
139+
set x $(expand_refs_wildcard "$@")
140+
shift
139141
if test "$remote" = "$(get_default_remote)"
140142
then
141143
curr_branch=$(git-symbolic-ref HEAD | \
142144
sed -e 's|^refs/heads/||')
143145
merge_branches=$(git-repo-config \
144146
--get-all "branch.${curr_branch}.merge")
145147
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
148155
fi
149156
for ref
150157
do

0 commit comments

Comments
 (0)