mirror of
https://github.com/git/git.git
synced 2024-10-29 21:37:53 +01:00
916d0626c2
The 'git maintenance run' command has an '--auto' option. This is used by other Git commands such as 'git commit' or 'git fetch' to check if maintenance should be run after adding data to the repository. Previously, this --auto option was only used to add the argument to the 'git gc' command as part of the 'gc' task. We will be expanding the other tasks to perform a check to see if they should do work as part of the --auto flag, when they are enabled by config. First, update the 'gc' task to perform the auto check inside the maintenance process. This prevents running an extra 'git gc --auto' command when not needed. It also shows a model for other tasks. Second, use the 'auto_condition' function pointer as a signal for whether we enable the maintenance task under '--auto'. For instance, we do not want to enable the 'fetch' task in '--auto' mode, so that function pointer will remain NULL. Now that we are not automatically calling 'git gc', a test in t5514-fetch-multiple.sh must be changed to watch for 'git maintenance' instead. We continue to pass the '--auto' option to the 'git gc' command when necessary, because of the gc.autoDetach config option changes behavior. Likely, we will want to absorb the daemonizing behavior implied by gc.autoDetach as a maintenance.autoDetach config option. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
197 lines
3.9 KiB
Bash
Executable file
197 lines
3.9 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
|
|
two/another
|
|
two/master
|
|
two/side
|
|
EOF
|
|
|
|
test_expect_success 'git fetch --multiple (two remotes)' '
|
|
(git clone one test4 &&
|
|
cd test4 &&
|
|
git remote rm origin &&
|
|
git remote add one ../one &&
|
|
git remote add two ../two &&
|
|
GIT_TRACE=1 git fetch --multiple one two 2>trace &&
|
|
git branch -r > output &&
|
|
test_cmp ../expect output &&
|
|
grep "built-in: git maintenance" trace >gc &&
|
|
test_line_count = 1 gc
|
|
)
|
|
'
|
|
|
|
test_expect_success 'git fetch --multiple (bad remote names)' '
|
|
(cd test4 &&
|
|
test_must_fail git fetch --multiple four)
|
|
'
|
|
|
|
|
|
test_expect_success 'git fetch --all (skipFetchAll)' '
|
|
(cd test4 &&
|
|
for b in $(git branch -r)
|
|
do
|
|
git branch -r -d $b || exit 1
|
|
done &&
|
|
git remote add three ../three &&
|
|
git config remote.three.skipFetchAll true &&
|
|
git fetch --all &&
|
|
git branch -r > output &&
|
|
test_cmp ../expect output)
|
|
'
|
|
|
|
cat > expect << EOF
|
|
one/master
|
|
one/side
|
|
three/another
|
|
three/master
|
|
three/side
|
|
two/another
|
|
two/master
|
|
two/side
|
|
EOF
|
|
|
|
test_expect_success 'git fetch --multiple (ignoring skipFetchAll)' '
|
|
(cd test4 &&
|
|
for b in $(git branch -r)
|
|
do
|
|
git branch -r -d $b || exit 1
|
|
done &&
|
|
git fetch --multiple one two three &&
|
|
git branch -r > output &&
|
|
test_cmp ../expect output)
|
|
'
|
|
|
|
test_expect_success 'git fetch --all --no-tags' '
|
|
git clone one test5 &&
|
|
git clone test5 test6 &&
|
|
(cd test5 && git tag test-tag) &&
|
|
(
|
|
cd test6 &&
|
|
git fetch --all --no-tags &&
|
|
git tag >output
|
|
) &&
|
|
test_must_be_empty test6/output
|
|
'
|
|
|
|
test_expect_success 'git fetch --all --tags' '
|
|
echo test-tag >expect &&
|
|
git clone one test7 &&
|
|
git clone test7 test8 &&
|
|
(
|
|
cd test7 &&
|
|
test_commit test-tag &&
|
|
git reset --hard HEAD^
|
|
) &&
|
|
(
|
|
cd test8 &&
|
|
git fetch --all --tags &&
|
|
git tag >output
|
|
) &&
|
|
test_cmp expect test8/output
|
|
'
|
|
|
|
test_expect_success 'parallel' '
|
|
git remote add one ./bogus1 &&
|
|
git remote add two ./bogus2 &&
|
|
|
|
test_must_fail env GIT_TRACE="$PWD/trace" \
|
|
git fetch --jobs=2 --multiple one two 2>err &&
|
|
grep "preparing to run up to 2 tasks" trace &&
|
|
test_i18ngrep "could not fetch .one.*128" err &&
|
|
test_i18ngrep "could not fetch .two.*128" err
|
|
'
|
|
|
|
test_done
|