maintenance: create basic maintenance runner
The 'gc' builtin is our current entrypoint for automatically maintaining
a repository. This one tool does many operations, such as repacking the
repository, packing refs, and rewriting the commit-graph file. The name
implies it performs "garbage collection" which means several different
things, and some users may not want to use this operation that rewrites
the entire object database.
Create a new 'maintenance' builtin that will become a more general-
purpose command. To start, it will only support the 'run' subcommand,
but will later expand to add subcommands for scheduling maintenance in
the background.
For now, the 'maintenance' builtin is a thin shim over the 'gc' builtin.
In fact, the only option is the '--auto' toggle, which is handed
directly to the 'gc' builtin. The current change is isolated to this
simple operation to prevent more interesting logic from being lost in
all of the boilerplate of adding a new builtin.
Use existing builtin/gc.c file because we want to share code between the
two builtins. It is possible that we will have 'maintenance' replace the
'gc' builtin entirely at some point, leaving 'git gc' as an alias for
some specific arguments to 'git maintenance run'.
Create a new test_subcommand helper that allows us to test if a certain
subcommand was run. It requires storing the GIT_TRACE2_EVENT logs in a
file. A negation mode is available that will be used in later tests.
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-09-18 02:11:42 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='git maintenance builtin'
|
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
2020-09-18 02:11:46 +08:00
|
|
|
GIT_TEST_COMMIT_GRAPH=0
|
|
|
|
|
maintenance: create basic maintenance runner
The 'gc' builtin is our current entrypoint for automatically maintaining
a repository. This one tool does many operations, such as repacking the
repository, packing refs, and rewriting the commit-graph file. The name
implies it performs "garbage collection" which means several different
things, and some users may not want to use this operation that rewrites
the entire object database.
Create a new 'maintenance' builtin that will become a more general-
purpose command. To start, it will only support the 'run' subcommand,
but will later expand to add subcommands for scheduling maintenance in
the background.
For now, the 'maintenance' builtin is a thin shim over the 'gc' builtin.
In fact, the only option is the '--auto' toggle, which is handed
directly to the 'gc' builtin. The current change is isolated to this
simple operation to prevent more interesting logic from being lost in
all of the boilerplate of adding a new builtin.
Use existing builtin/gc.c file because we want to share code between the
two builtins. It is possible that we will have 'maintenance' replace the
'gc' builtin entirely at some point, leaving 'git gc' as an alias for
some specific arguments to 'git maintenance run'.
Create a new test_subcommand helper that allows us to test if a certain
subcommand was run. It requires storing the GIT_TRACE2_EVENT logs in a
file. A negation mode is available that will be used in later tests.
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-09-18 02:11:42 +08:00
|
|
|
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
|
|
|
|
'
|
|
|
|
|
2020-09-18 02:11:43 +08:00
|
|
|
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 &&
|
2020-09-18 02:11:50 +08:00
|
|
|
test_subcommand ! git gc --auto --quiet <run-auto.txt &&
|
2020-09-18 02:11:43 +08:00
|
|
|
test_subcommand git gc --no-quiet <run-no-quiet.txt
|
maintenance: create basic maintenance runner
The 'gc' builtin is our current entrypoint for automatically maintaining
a repository. This one tool does many operations, such as repacking the
repository, packing refs, and rewriting the commit-graph file. The name
implies it performs "garbage collection" which means several different
things, and some users may not want to use this operation that rewrites
the entire object database.
Create a new 'maintenance' builtin that will become a more general-
purpose command. To start, it will only support the 'run' subcommand,
but will later expand to add subcommands for scheduling maintenance in
the background.
For now, the 'maintenance' builtin is a thin shim over the 'gc' builtin.
In fact, the only option is the '--auto' toggle, which is handed
directly to the 'gc' builtin. The current change is isolated to this
simple operation to prevent more interesting logic from being lost in
all of the boilerplate of adding a new builtin.
Use existing builtin/gc.c file because we want to share code between the
two builtins. It is possible that we will have 'maintenance' replace the
'gc' builtin entirely at some point, leaving 'git gc' as an alias for
some specific arguments to 'git maintenance run'.
Create a new test_subcommand helper that allows us to test if a certain
subcommand was run. It requires storing the GIT_TRACE2_EVENT logs in a
file. A negation mode is available that will be used in later tests.
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-09-18 02:11:42 +08:00
|
|
|
'
|
|
|
|
|
2020-09-18 02:11:49 +08:00
|
|
|
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
|
|
|
|
'
|
|
|
|
|
2020-09-18 02:11:47 +08:00
|
|
|
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
|
|
|
|
'
|
|
|
|
|
maintenance: create basic maintenance runner
The 'gc' builtin is our current entrypoint for automatically maintaining
a repository. This one tool does many operations, such as repacking the
repository, packing refs, and rewriting the commit-graph file. The name
implies it performs "garbage collection" which means several different
things, and some users may not want to use this operation that rewrites
the entire object database.
Create a new 'maintenance' builtin that will become a more general-
purpose command. To start, it will only support the 'run' subcommand,
but will later expand to add subcommands for scheduling maintenance in
the background.
For now, the 'maintenance' builtin is a thin shim over the 'gc' builtin.
In fact, the only option is the '--auto' toggle, which is handed
directly to the 'gc' builtin. The current change is isolated to this
simple operation to prevent more interesting logic from being lost in
all of the boilerplate of adding a new builtin.
Use existing builtin/gc.c file because we want to share code between the
two builtins. It is possible that we will have 'maintenance' replace the
'gc' builtin entirely at some point, leaving 'git gc' as an alias for
some specific arguments to 'git maintenance run'.
Create a new test_subcommand helper that allows us to test if a certain
subcommand was run. It requires storing the GIT_TRACE2_EVENT logs in a
file. A negation mode is available that will be used in later tests.
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-09-18 02:11:42 +08:00
|
|
|
test_done
|