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