git/t/t5514-fetch-multiple.sh
Björn Gustavsson 16679e373f Teach the --multiple option to 'git fetch'
Add the --multiple option to specify that all arguments are either
groups or remotes. The primary reason for adding this option is
to allow us to re-implement 'git remote update' using fetch.

It would have been nice if this option was not needed, but since
the colon in a refspec is optional, it is in general not possible
to know whether a single, colon-less argument is a remote or a
refspec.

Signed-off-by: Björn Gustavsson <bgustavsson@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-11-10 01:01:07 -08:00

121 lines
2.3 KiB
Bash
Executable file

#!/bin/sh
test_description='fetch --all works correctly'
. ./test-lib.sh
setup_repository () {
mkdir "$1" && (
cd "$1" &&
git init &&
>file &&
git add file &&
test_tick &&
git commit -m "Initial" &&
git checkout -b side &&
>elif &&
git add elif &&
test_tick &&
git commit -m "Second" &&
git checkout master
)
}
test_expect_success setup '
setup_repository one &&
setup_repository two &&
(
cd two && git branch another
) &&
git clone --mirror two three
git clone one test
'
cat > test/expect << EOF
one/master
one/side
origin/HEAD -> origin/master
origin/master
origin/side
three/another
three/master
three/side
two/another
two/master
two/side
EOF
test_expect_success 'git fetch --all' '
(cd test &&
git remote add one ../one &&
git remote add two ../two &&
git remote add three ../three &&
git fetch --all &&
git branch -r > output &&
test_cmp expect output)
'
test_expect_success 'git fetch --all should continue if a remote has errors' '
(git clone one test2 &&
cd test2 &&
git remote add bad ../non-existing &&
git remote add one ../one &&
git remote add two ../two &&
git remote add three ../three &&
test_must_fail git fetch --all &&
git branch -r > output &&
test_cmp ../test/expect output)
'
test_expect_success 'git fetch --all does not allow non-option arguments' '
(cd test &&
test_must_fail git fetch --all origin &&
test_must_fail git fetch --all origin master)
'
cat > expect << EOF
origin/HEAD -> origin/master
origin/master
origin/side
three/another
three/master
three/side
EOF
test_expect_success 'git fetch --multiple (but only one remote)' '
(git clone one test3 &&
cd test3 &&
git remote add three ../three &&
git fetch --multiple three &&
git branch -r > output &&
test_cmp ../expect output)
'
cat > expect << EOF
one/master
one/side
origin/HEAD -> origin/master
origin/master
origin/side
two/another
two/master
two/side
EOF
test_expect_success 'git fetch --multiple (two remotes)' '
(git clone one test4 &&
cd test4 &&
git remote add one ../one &&
git remote add two ../two &&
git fetch --multiple one two &&
git branch -r > output &&
test_cmp ../expect output)
'
test_expect_success 'git fetch --multiple (bad remote names)' '
(cd test4 &&
test_must_fail git fetch --multiple four)
'
test_done