3 test_description='git maintenance builtin'
7 GIT_TEST_COMMIT_GRAPH=0
9 test_expect_success 'help text' '
10 test_expect_code 129 git maintenance -h 2>err &&
11 test_i18ngrep "usage: git maintenance run" err &&
12 test_expect_code 128 git maintenance barf 2>err &&
13 test_i18ngrep "invalid subcommand: barf" err &&
14 test_expect_code 129 git maintenance 2>err &&
15 test_i18ngrep "usage: git maintenance" err
18 test_expect_success 'run [--auto|--quiet]' '
19 GIT_TRACE2_EVENT="$(pwd)/run-no-auto.txt" \
20 git maintenance run 2>/dev/null &&
21 GIT_TRACE2_EVENT="$(pwd)/run-auto.txt" \
22 git maintenance run --auto 2>/dev/null &&
23 GIT_TRACE2_EVENT="$(pwd)/run-no-quiet.txt" \
24 git maintenance run --no-quiet 2>/dev/null &&
25 test_subcommand git gc --quiet <run-no-auto.txt &&
26 test_subcommand ! git gc --auto --quiet <run-auto.txt &&
27 test_subcommand git gc --no-quiet <run-no-quiet.txt
30 test_expect_success 'maintenance.<task>.enabled' '
31 git config maintenance.gc.enabled false &&
32 git config maintenance.commit-graph.enabled true &&
33 GIT_TRACE2_EVENT="$(pwd)/run-config.txt" git maintenance run 2>err &&
34 test_subcommand ! git gc --quiet <run-config.txt &&
35 test_subcommand git commit-graph write --split --reachable --no-progress <run-config.txt
38 test_expect_success 'run --task=<task>' '
39 GIT_TRACE2_EVENT="$(pwd)/run-commit-graph.txt" \
40 git maintenance run --task=commit-graph 2>/dev/null &&
41 GIT_TRACE2_EVENT="$(pwd)/run-gc.txt" \
42 git maintenance run --task=gc 2>/dev/null &&
43 GIT_TRACE2_EVENT="$(pwd)/run-commit-graph.txt" \
44 git maintenance run --task=commit-graph 2>/dev/null &&
45 GIT_TRACE2_EVENT="$(pwd)/run-both.txt" \
46 git maintenance run --task=commit-graph --task=gc 2>/dev/null &&
47 test_subcommand ! git gc --quiet <run-commit-graph.txt &&
48 test_subcommand git gc --quiet <run-gc.txt &&
49 test_subcommand git gc --quiet <run-both.txt &&
50 test_subcommand git commit-graph write --split --reachable --no-progress <run-commit-graph.txt &&
51 test_subcommand ! git commit-graph write --split --reachable --no-progress <run-gc.txt &&
52 test_subcommand git commit-graph write --split --reachable --no-progress <run-both.txt
55 test_expect_success 'commit-graph auto condition' '
56 COMMAND="maintenance run --task=commit-graph --auto --quiet" &&
58 GIT_TRACE2_EVENT="$(pwd)/cg-no.txt" \
59 git -c maintenance.commit-graph.auto=1 $COMMAND &&
60 GIT_TRACE2_EVENT="$(pwd)/cg-negative-means-yes.txt" \
61 git -c maintenance.commit-graph.auto="-1" $COMMAND &&
65 GIT_TRACE2_EVENT="$(pwd)/cg-zero-means-no.txt" \
66 git -c maintenance.commit-graph.auto=0 $COMMAND &&
67 GIT_TRACE2_EVENT="$(pwd)/cg-one-satisfied.txt" \
68 git -c maintenance.commit-graph.auto=1 $COMMAND &&
70 git commit --allow-empty -m "second" &&
71 git commit --allow-empty -m "third" &&
73 GIT_TRACE2_EVENT="$(pwd)/cg-two-satisfied.txt" \
74 git -c maintenance.commit-graph.auto=2 $COMMAND &&
76 COMMIT_GRAPH_WRITE="git commit-graph write --split --reachable --no-progress" &&
77 test_subcommand ! $COMMIT_GRAPH_WRITE <cg-no.txt &&
78 test_subcommand $COMMIT_GRAPH_WRITE <cg-negative-means-yes.txt &&
79 test_subcommand ! $COMMIT_GRAPH_WRITE <cg-zero-means-no.txt &&
80 test_subcommand $COMMIT_GRAPH_WRITE <cg-one-satisfied.txt &&
81 test_subcommand $COMMIT_GRAPH_WRITE <cg-two-satisfied.txt
84 test_expect_success 'run --task=bogus' '
85 test_must_fail git maintenance run --task=bogus 2>err &&
86 test_i18ngrep "is not a valid task" err
89 test_expect_success 'run --task duplicate' '
90 test_must_fail git maintenance run --task=gc --task=gc 2>err &&
91 test_i18ngrep "cannot be selected multiple times" err