]> git.ipfire.org Git - thirdparty/git.git/blame - t/t0081-find-pack.sh
The third batch
[thirdparty/git.git] / t / t0081-find-pack.sh
CommitLineData
66589f89
CC
1#!/bin/sh
2
3test_description='test `test-tool find-pack`'
4
5TEST_PASSES_SANITIZE_LEAK=true
6. ./test-lib.sh
7
8test_expect_success 'setup' '
9 test_commit one &&
10 test_commit two &&
11 test_commit three &&
12 test_commit four &&
13 test_commit five
14'
15
16test_expect_success 'repack everything into a single packfile' '
17 git repack -a -d --no-write-bitmap-index &&
18
19 head_commit_pack=$(test-tool find-pack HEAD) &&
20 head_tree_pack=$(test-tool find-pack HEAD^{tree}) &&
21 one_pack=$(test-tool find-pack HEAD:one.t) &&
22 three_pack=$(test-tool find-pack HEAD:three.t) &&
23 old_commit_pack=$(test-tool find-pack HEAD~4) &&
24
25 test-tool find-pack --check-count 1 HEAD &&
26 test-tool find-pack --check-count=1 HEAD^{tree} &&
27 ! test-tool find-pack --check-count=0 HEAD:one.t &&
28 ! test-tool find-pack -c 2 HEAD:one.t &&
29 test-tool find-pack -c 1 HEAD:three.t &&
30
31 # Packfile exists at the right path
32 case "$head_commit_pack" in
33 ".git/objects/pack/pack-"*".pack") true ;;
34 *) false ;;
35 esac &&
36 test -f "$head_commit_pack" &&
37
38 # Everything is in the same pack
39 test "$head_commit_pack" = "$head_tree_pack" &&
40 test "$head_commit_pack" = "$one_pack" &&
41 test "$head_commit_pack" = "$three_pack" &&
42 test "$head_commit_pack" = "$old_commit_pack"
43'
44
45test_expect_success 'add more packfiles' '
46 git rev-parse HEAD^{tree} HEAD:two.t HEAD:four.t >objects &&
47 git pack-objects .git/objects/pack/mypackname1 >packhash1 <objects &&
48
49 git rev-parse HEAD~ HEAD~^{tree} HEAD:five.t >objects &&
50 git pack-objects .git/objects/pack/mypackname2 >packhash2 <objects &&
51
52 head_commit_pack=$(test-tool find-pack HEAD) &&
53
54 # HEAD^{tree} is in 2 packfiles
55 test-tool find-pack HEAD^{tree} >head_tree_packs &&
56 grep "$head_commit_pack" head_tree_packs &&
57 grep mypackname1 head_tree_packs &&
58 ! grep mypackname2 head_tree_packs &&
59 test-tool find-pack --check-count 2 HEAD^{tree} &&
60 ! test-tool find-pack --check-count 1 HEAD^{tree} &&
61
62 # HEAD:five.t is also in 2 packfiles
63 test-tool find-pack HEAD:five.t >five_packs &&
64 grep "$head_commit_pack" five_packs &&
65 ! grep mypackname1 five_packs &&
66 grep mypackname2 five_packs &&
67 test-tool find-pack -c 2 HEAD:five.t &&
68 ! test-tool find-pack --check-count=0 HEAD:five.t
69'
70
71test_expect_success 'add more commits (as loose objects)' '
72 test_commit six &&
73 test_commit seven &&
74
75 test -z "$(test-tool find-pack HEAD)" &&
76 test -z "$(test-tool find-pack HEAD:six.t)" &&
77 test-tool find-pack --check-count 0 HEAD &&
78 test-tool find-pack -c 0 HEAD:six.t &&
79 ! test-tool find-pack -c 1 HEAD:seven.t
80'
81
82test_done