Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Cai <johncai86@gmail.com>2023-05-13 00:34:42 +0300
committerJunio C Hamano <gitster@pobox.com>2023-05-13 00:54:14 +0300
commit4fe42f326e10a547dc65dfe9e5ceaeeee02b98db (patch)
tree47c2e26fc240e0bf6d8dad6a6d8c2f3f6ab0bcce /t/t3210-pack-refs.sh
parent826ae79fca263bc2b70c54fddacb1603c5ebb9c6 (diff)
pack-refs: teach pack-refs --include option
Allow users to be more selective over which refs to pack by adding an --include option to git-pack-refs. The existing options allow some measure of selectivity. By default git-pack-refs packs all tags. --all can be used to include all refs, and the previous commit added the ability to exclude certain refs with --exclude. While these knobs give the user some selection over which refs to pack, it could be useful to give more control. For instance, a repository may have a set of branches that are rarely updated and would benefit from being packed. --include would allow the user to easily include a set of branches to be packed while leaving everything else unpacked. Signed-off-by: John Cai <johncai86@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t3210-pack-refs.sh')
-rwxr-xr-xt/t3210-pack-refs.sh21
1 files changed, 21 insertions, 0 deletions
diff --git a/t/t3210-pack-refs.sh b/t/t3210-pack-refs.sh
index 925b90cd3b..9f399d2f75 100755
--- a/t/t3210-pack-refs.sh
+++ b/t/t3210-pack-refs.sh
@@ -124,6 +124,27 @@ test_expect_success 'test --no-exclude refs clears excluded refs' '
! test -f .git/refs/heads/dont_pack3 &&
! test -f .git/refs/heads/dont_pack4'
+test_expect_success 'test only included refs are packed' '
+ git branch pack_this1 &&
+ git branch pack_this2 &&
+ git tag dont_pack5 &&
+ git pack-refs --include "refs/heads/pack_this*" &&
+ test -f .git/refs/tags/dont_pack5 &&
+ ! test -f .git/refs/heads/pack_this1 &&
+ ! test -f .git/refs/heads/pack_this2'
+
+test_expect_success 'test --no-include refs clears included refs' '
+ git branch pack1 &&
+ git branch pack2 &&
+ git pack-refs --include "refs/heads/pack*" --no-include &&
+ test -f .git/refs/heads/pack1 &&
+ test -f .git/refs/heads/pack2'
+
+test_expect_success 'test --exclude takes precedence over --include' '
+ git branch dont_pack5 &&
+ git pack-refs --include "refs/heads/pack*" --exclude "refs/heads/pack*" &&
+ test -f .git/refs/heads/dont_pack5'
+
test_expect_success \
'see if up-to-date packed refs are preserved' \
'git branch q &&