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>
66 lines
2.4 KiB
Bash
Executable File
66 lines
2.4 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
test_description='git maintenance builtin'
|
|
|
|
. ./test-lib.sh
|
|
|
|
GIT_TEST_COMMIT_GRAPH=0
|
|
|
|
test_expect_success 'help text' '
|
|
test_expect_code 129 git maintenance -h 2>err &&
|
|
test_i18ngrep "usage: git maintenance run" err &&
|
|
test_expect_code 128 git maintenance barf 2>err &&
|
|
test_i18ngrep "invalid subcommand: barf" err &&
|
|
test_expect_code 129 git maintenance 2>err &&
|
|
test_i18ngrep "usage: git maintenance" err
|
|
'
|
|
|
|
test_expect_success 'run [--auto|--quiet]' '
|
|
GIT_TRACE2_EVENT="$(pwd)/run-no-auto.txt" \
|
|
git maintenance run 2>/dev/null &&
|
|
GIT_TRACE2_EVENT="$(pwd)/run-auto.txt" \
|
|
git maintenance run --auto 2>/dev/null &&
|
|
GIT_TRACE2_EVENT="$(pwd)/run-no-quiet.txt" \
|
|
git maintenance run --no-quiet 2>/dev/null &&
|
|
test_subcommand git gc --quiet <run-no-auto.txt &&
|
|
test_subcommand ! git gc --auto --quiet <run-auto.txt &&
|
|
test_subcommand git gc --no-quiet <run-no-quiet.txt
|
|
'
|
|
|
|
test_expect_success 'maintenance.<task>.enabled' '
|
|
git config maintenance.gc.enabled false &&
|
|
git config maintenance.commit-graph.enabled true &&
|
|
GIT_TRACE2_EVENT="$(pwd)/run-config.txt" git maintenance run 2>err &&
|
|
test_subcommand ! git gc --quiet <run-config.txt &&
|
|
test_subcommand git commit-graph write --split --reachable --no-progress <run-config.txt
|
|
'
|
|
|
|
test_expect_success 'run --task=<task>' '
|
|
GIT_TRACE2_EVENT="$(pwd)/run-commit-graph.txt" \
|
|
git maintenance run --task=commit-graph 2>/dev/null &&
|
|
GIT_TRACE2_EVENT="$(pwd)/run-gc.txt" \
|
|
git maintenance run --task=gc 2>/dev/null &&
|
|
GIT_TRACE2_EVENT="$(pwd)/run-commit-graph.txt" \
|
|
git maintenance run --task=commit-graph 2>/dev/null &&
|
|
GIT_TRACE2_EVENT="$(pwd)/run-both.txt" \
|
|
git maintenance run --task=commit-graph --task=gc 2>/dev/null &&
|
|
test_subcommand ! git gc --quiet <run-commit-graph.txt &&
|
|
test_subcommand git gc --quiet <run-gc.txt &&
|
|
test_subcommand git gc --quiet <run-both.txt &&
|
|
test_subcommand git commit-graph write --split --reachable --no-progress <run-commit-graph.txt &&
|
|
test_subcommand ! git commit-graph write --split --reachable --no-progress <run-gc.txt &&
|
|
test_subcommand git commit-graph write --split --reachable --no-progress <run-both.txt
|
|
'
|
|
|
|
test_expect_success 'run --task=bogus' '
|
|
test_must_fail git maintenance run --task=bogus 2>err &&
|
|
test_i18ngrep "is not a valid task" err
|
|
'
|
|
|
|
test_expect_success 'run --task duplicate' '
|
|
test_must_fail git maintenance run --task=gc --task=gc 2>err &&
|
|
test_i18ngrep "cannot be selected multiple times" err
|
|
'
|
|
|
|
test_done
|