]> git.ipfire.org Git - thirdparty/git.git/commitdiff
parse-remote: mark all refs not for merge only when fetching more than one
authorJunio C Hamano <junkio@cox.net>
Fri, 22 Dec 2006 06:39:09 +0000 (22:39 -0800)
committerJunio C Hamano <junkio@cox.net>
Fri, 22 Dec 2006 06:56:25 +0000 (22:56 -0800)
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>
git-parse-remote.sh

index 871c08f0973826f96490835dd029b47c64768a53..f163821d033cc0dc81dcd7ce0af13a7e75986db1 100755 (executable)
@@ -136,6 +136,8 @@ canon_refs_list_for_fetch () {
        if test "$1" = "-d"
        then
                shift ; remote="$1" ; shift
+               set x $(expand_refs_wildcard "$@")
+               shift
                if test "$remote" = "$(get_default_remote)"
                then
                        curr_branch=$(git-symbolic-ref HEAD | \
@@ -143,8 +145,13 @@ canon_refs_list_for_fetch () {
                        merge_branches=$(git-repo-config \
                            --get-all "branch.${curr_branch}.merge")
                fi
-               set x $(expand_refs_wildcard "$@")
-               shift
+               # If we are fetching only one branch, then first branch
+               # is the only thing that makes sense to merge anyway,
+               # so there is no point refusing that traditional rule.
+               if test $# != 1 && test "z$merge_branches" = z
+               then
+                       merge_branches=..this..would..never..match..
+               fi
        fi
        for ref
        do