]>
Commit | Line | Data |
---|---|---|
2057d750 DS |
1 | #!/bin/sh |
2 | ||
3 | test_description='git maintenance builtin' | |
4 | ||
5 | . ./test-lib.sh | |
6 | ||
663b2b1b DS |
7 | GIT_TEST_COMMIT_GRAPH=0 |
8 | ||
2057d750 DS |
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 | |
16 | ' | |
17 | ||
3ddaad0e DS |
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 && | |
916d0626 | 26 | test_subcommand ! git gc --auto --quiet <run-auto.txt && |
3ddaad0e | 27 | test_subcommand git gc --no-quiet <run-no-quiet.txt |
2057d750 DS |
28 | ' |
29 | ||
65d655b5 DS |
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 | |
36 | ' | |
37 | ||
090511bc DS |
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 | |
53 | ' | |
54 | ||
55 | test_expect_success 'run --task=bogus' ' | |
56 | test_must_fail git maintenance run --task=bogus 2>err && | |
57 | test_i18ngrep "is not a valid task" err | |
58 | ' | |
59 | ||
60 | test_expect_success 'run --task duplicate' ' | |
61 | test_must_fail git maintenance run --task=gc --task=gc 2>err && | |
62 | test_i18ngrep "cannot be selected multiple times" err | |
63 | ' | |
64 | ||
28cb5e66 DS |
65 | test_expect_success 'run --task=prefetch with no remotes' ' |
66 | git maintenance run --task=prefetch 2>err && | |
67 | test_must_be_empty err | |
68 | ' | |
69 | ||
70 | test_expect_success 'prefetch multiple remotes' ' | |
71 | git clone . clone1 && | |
72 | git clone . clone2 && | |
73 | git remote add remote1 "file://$(pwd)/clone1" && | |
74 | git remote add remote2 "file://$(pwd)/clone2" && | |
75 | git -C clone1 switch -c one && | |
76 | git -C clone2 switch -c two && | |
77 | test_commit -C clone1 one && | |
78 | test_commit -C clone2 two && | |
79 | GIT_TRACE2_EVENT="$(pwd)/run-prefetch.txt" git maintenance run --task=prefetch 2>/dev/null && | |
80 | fetchargs="--prune --no-tags --no-write-fetch-head --recurse-submodules=no --refmap= --quiet" && | |
81 | test_subcommand git fetch remote1 $fetchargs +refs/heads/\\*:refs/prefetch/remote1/\\* <run-prefetch.txt && | |
82 | test_subcommand git fetch remote2 $fetchargs +refs/heads/\\*:refs/prefetch/remote2/\\* <run-prefetch.txt && | |
83 | test_path_is_missing .git/refs/remotes && | |
84 | git log prefetch/remote1/one && | |
85 | git log prefetch/remote2/two && | |
86 | git fetch --all && | |
87 | test_cmp_rev refs/remotes/remote1/one refs/prefetch/remote1/one && | |
88 | test_cmp_rev refs/remotes/remote2/two refs/prefetch/remote2/two | |
89 | ' | |
90 | ||
2057d750 | 91 | test_done |