The twelfth batch
[git/gitster.git] / t / t0081-find-pack.sh
blob67b11216a3e54185882d176bb59899411ae6666a
1 #!/bin/sh
3 test_description='test `test-tool find-pack`'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 test_expect_success 'setup' '
9 test_commit one &&
10 test_commit two &&
11 test_commit three &&
12 test_commit four &&
13 test_commit five
16 test_expect_success 'repack everything into a single packfile' '
17 git repack -a -d --no-write-bitmap-index &&
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) &&
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 &&
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" &&
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"
45 test_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 &&
49 git rev-parse HEAD~ HEAD~^{tree} HEAD:five.t >objects &&
50 git pack-objects .git/objects/pack/mypackname2 >packhash2 <objects &&
52 head_commit_pack=$(test-tool find-pack HEAD) &&
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} &&
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
71 test_expect_success 'add more commits (as loose objects)' '
72 test_commit six &&
73 test_commit seven &&
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
82 test_done