]> git.ipfire.org Git - thirdparty/git.git/blame - t/t6114-keep-packs.sh
Sync with Git 2.45.1
[thirdparty/git.git] / t / t6114-keep-packs.sh
CommitLineData
c9fff000
TB
1#!/bin/sh
2
3test_description='rev-list with .keep packs'
e75d2f7f
ÆAB
4
5TEST_PASSES_SANITIZE_LEAK=true
c9fff000
TB
6. ./test-lib.sh
7
8test_expect_success 'setup' '
9 test_commit loose &&
10 test_commit packed &&
11 test_commit kept &&
12
13 KEPT_PACK=$(git pack-objects --revs .git/objects/pack/pack <<-EOF
14 refs/tags/kept
15 ^refs/tags/packed
16 EOF
17 ) &&
18 MISC_PACK=$(git pack-objects --revs .git/objects/pack/pack <<-EOF
19 refs/tags/packed
20 ^refs/tags/loose
21 EOF
22 ) &&
23
24 touch .git/objects/pack/pack-$KEPT_PACK.keep
25'
26
27rev_list_objects () {
28 git rev-list "$@" >out &&
29 sort out
30}
31
32idx_objects () {
33 git show-index <$1 >expect-idx &&
34 cut -d" " -f2 <expect-idx | sort
35}
36
37test_expect_success '--no-kept-objects excludes trees and blobs in .keep packs' '
38 rev_list_objects --objects --all --no-object-names >kept &&
39 rev_list_objects --objects --all --no-object-names --no-kept-objects >no-kept &&
40
41 idx_objects .git/objects/pack/pack-$KEPT_PACK.idx >expect &&
42 comm -3 kept no-kept >actual &&
43
44 test_cmp expect actual
45'
46
47test_expect_success '--no-kept-objects excludes kept non-MIDX object' '
48 test_config core.multiPackIndex true &&
49
50 # Create a pack with just the commit object in pack, and do not mark it
51 # as kept (even though it appears in $KEPT_PACK, which does have a .keep
52 # file).
53 MIDX_PACK=$(git pack-objects .git/objects/pack/pack <<-EOF
54 $(git rev-parse kept)
55 EOF
56 ) &&
57
58 # Write a MIDX containing all packs, but use the version of the commit
59 # at "kept" in a non-kept pack by touching $MIDX_PACK.
60 touch .git/objects/pack/pack-$MIDX_PACK.pack &&
61 git multi-pack-index write &&
62
63 rev_list_objects --objects --no-object-names --no-kept-objects HEAD >actual &&
64 (
65 idx_objects .git/objects/pack/pack-$MISC_PACK.idx &&
66 git rev-list --objects --no-object-names refs/tags/loose
67 ) | sort >expect &&
68 test_cmp expect actual
69'
70
71test_done