interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / t / t6114-keep-packs.sh

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