summaryrefslogtreecommitdiff
path: root/t/t7900-maintenance.sh
diff options
context:
space:
mode:
authorDerrick Stolee <dstolee@microsoft.com>2021-02-09 13:42:28 +0000
committerJunio C Hamano <gitster@pobox.com>2021-02-09 23:09:24 -0800
commit41abfe15d95ede4c2a047180a6062eac23d8f7d6 (patch)
tree6195118eb4bf1c9484c495a9b979f2737af2fc6b /t/t7900-maintenance.sh
parentfb7fa4a1fd273f22efcafdd13c7f897814fd1eb9 (diff)
downloadgit-41abfe15d95ede4c2a047180a6062eac23d8f7d6.tar.gz
maintenance: add pack-refs task
It is valuable to collect loose refs into a more compressed form. This is typically the packed-refs file, although this could be the reftable in the future. Having packed refs can be extremely valuable in repos with many tags or remote branches that are not modified by the local user, but still are necessary for other queries. For instance, with many exploded refs, commands such as git describe --tags --exact-match HEAD can be very slow (multiple seconds). This command in particular is used by terminal prompts to show when a detatched HEAD is pointing to an existing tag, so having it be slow causes significant delays for users. Add a new 'pack-refs' maintenance task. It runs 'git pack-refs --all --prune' to move loose refs into a packed form. For now, that is the packed-refs file, but could adjust to other file formats in the future. This is the first of several sub-tasks of the 'gc' task that could be extracted to their own tasks. In this process, we should not change the behavior of the 'gc' task since that remains the default way to keep repositories maintained. Creating a new task for one of these sub-tasks only provides more customization options for those choosing to not use the 'gc' task. It is certainly possible to have both the 'gc' and 'pack-refs' tasks enabled and run regularly. While they may repeat effort, they do not conflict in a destructive way. The 'auto_condition' function pointer is left NULL for now. We could extend this in the future to have a condition check if pack-refs should be run during 'git maintenance run --auto'. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Reviewed-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t7900-maintenance.sh')
-rwxr-xr-xt/t7900-maintenance.sh12
1 files changed, 12 insertions, 0 deletions
diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh
index 78ccf4b33f..4a8a78769b 100755
--- a/t/t7900-maintenance.sh
+++ b/t/t7900-maintenance.sh
@@ -343,6 +343,18 @@ test_expect_success 'maintenance.incremental-repack.auto' '
test_subcommand git multi-pack-index write --no-progress <trace-B
'
+test_expect_success 'pack-refs task' '
+ for n in $(test_seq 1 5)
+ do
+ git branch -f to-pack/$n HEAD || return 1
+ done &&
+ GIT_TRACE2_EVENT="$(pwd)/pack-refs.txt" \
+ git maintenance run --task=pack-refs &&
+ ls .git/refs/heads/ >after &&
+ test_must_be_empty after &&
+ test_subcommand git pack-refs --all --prune <pack-refs.txt
+'
+
test_expect_success '--auto and --schedule incompatible' '
test_must_fail git maintenance run --auto --schedule=daily 2>err &&
test_i18ngrep "at most one" err