mirror of
https://github.com/git/git.git
synced 2024-12-01 05:54:16 +08:00
e6cc51046f
Since "git fetch" learned "--all" and "--multiple" options, it has become tempting for users to say "git pull --all". Even though it may fetch from remotes that do not need to be fetched from for merging with the current branch, it is handy. "git fetch" however clears the list of fetched branches every time it contacts a different remote. Unless the current branch is configured to merge with a branch from a remote that happens to be the last in the list of remotes that are contacted, "git pull" that fetches from multiple remotes will not be able to find the branch it should be merging with. Make "fetch" clear FETCH_HEAD (unless --append is given) and then append the list of branches fetched to it (even when --append is not given). That way, "pull" will be able to find the data for the branch being merged in FETCH_HEAD no matter where the remote appears in the list of remotes to be contacted by "git fetch". Reported-by: Michael Lukashov Signed-off-by: Junio C Hamano <gitster@pobox.com>
94 lines
1.8 KiB
Bash
Executable File
94 lines
1.8 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
test_description='pull options'
|
|
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success 'setup' '
|
|
mkdir parent &&
|
|
(cd parent && git init &&
|
|
echo one >file && git add file &&
|
|
git commit -m one)
|
|
'
|
|
|
|
test_expect_success 'git pull -q' '
|
|
mkdir clonedq &&
|
|
(cd clonedq && git init &&
|
|
git pull -q "../parent" >out 2>err &&
|
|
test ! -s err &&
|
|
test ! -s out)
|
|
'
|
|
|
|
test_expect_success 'git pull' '
|
|
mkdir cloned &&
|
|
(cd cloned && git init &&
|
|
git pull "../parent" >out 2>err &&
|
|
test -s err &&
|
|
test ! -s out)
|
|
'
|
|
|
|
test_expect_success 'git pull -v' '
|
|
mkdir clonedv &&
|
|
(cd clonedv && git init &&
|
|
git pull -v "../parent" >out 2>err &&
|
|
test -s err &&
|
|
test ! -s out)
|
|
'
|
|
|
|
test_expect_success 'git pull -v -q' '
|
|
mkdir clonedvq &&
|
|
(cd clonedvq && git init &&
|
|
git pull -v -q "../parent" >out 2>err &&
|
|
test ! -s out &&
|
|
test ! -s err)
|
|
'
|
|
|
|
test_expect_success 'git pull -q -v' '
|
|
mkdir clonedqv &&
|
|
(cd clonedqv && git init &&
|
|
git pull -q -v "../parent" >out 2>err &&
|
|
test ! -s out &&
|
|
test -s err)
|
|
'
|
|
|
|
test_expect_success 'git pull --force' '
|
|
mkdir clonedoldstyle &&
|
|
(cd clonedoldstyle && git init &&
|
|
cat >>.git/config <<-\EOF &&
|
|
[remote "one"]
|
|
url = ../parent
|
|
fetch = refs/heads/master:refs/heads/mirror
|
|
[remote "two"]
|
|
url = ../parent
|
|
fetch = refs/heads/master:refs/heads/origin
|
|
[branch "master"]
|
|
remote = two
|
|
merge = refs/heads/master
|
|
EOF
|
|
git pull two &&
|
|
test_commit A &&
|
|
git branch -f origin &&
|
|
git pull --all --force
|
|
)
|
|
'
|
|
|
|
test_expect_success 'git pull --all' '
|
|
mkdir clonedmulti &&
|
|
(cd clonedmulti && git init &&
|
|
cat >>.git/config <<-\EOF &&
|
|
[remote "one"]
|
|
url = ../parent
|
|
fetch = refs/heads/*:refs/remotes/one/*
|
|
[remote "two"]
|
|
url = ../parent
|
|
fetch = refs/heads/*:refs/remotes/two/*
|
|
[branch "master"]
|
|
remote = one
|
|
merge = refs/heads/master
|
|
EOF
|
|
git pull --all
|
|
)
|
|
'
|
|
|
|
test_done
|