fast-import: use mem_pool_calloc()
[git.git] / t / t6022-rev-list-missing.sh
blob40265a4f66f996501207e6a6e950f45551453cf6
1 #!/bin/sh
3 test_description='handling of missing objects in rev-list'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 # We setup the repository with two commits, this way HEAD is always
9 # available and we can hide commit 1.
10 test_expect_success 'create repository and alternate directory' '
11 test_commit 1 &&
12 test_commit 2 &&
13 test_commit 3
16 for obj in "HEAD~1" "HEAD~1^{tree}" "HEAD:1.t"
18 test_expect_success "rev-list --missing=error fails with missing object $obj" '
19 oid="$(git rev-parse $obj)" &&
20 path=".git/objects/$(test_oid_to_path $oid)" &&
22 mv "$path" "$path.hidden" &&
23 test_when_finished "mv $path.hidden $path" &&
25 test_must_fail git rev-list --missing=error --objects \
26 --no-object-names HEAD
28 done
30 for obj in "HEAD~1" "HEAD~1^{tree}" "HEAD:1.t"
32 for action in "allow-any" "print"
34 test_expect_success "rev-list --missing=$action with missing $obj" '
35 oid="$(git rev-parse $obj)" &&
36 path=".git/objects/$(test_oid_to_path $oid)" &&
38 # Before the object is made missing, we use rev-list to
39 # get the expected oids.
40 git rev-list --objects --no-object-names \
41 HEAD ^$obj >expect.raw &&
43 # Blobs are shared by all commits, so evethough a commit/tree
44 # might be skipped, its blob must be accounted for.
45 if [ $obj != "HEAD:1.t" ]; then
46 echo $(git rev-parse HEAD:1.t) >>expect.raw &&
47 echo $(git rev-parse HEAD:2.t) >>expect.raw
48 fi &&
50 mv "$path" "$path.hidden" &&
51 test_when_finished "mv $path.hidden $path" &&
53 git rev-list --missing=$action --objects --no-object-names \
54 HEAD >actual.raw &&
56 # When the action is to print, we should also add the missing
57 # oid to the expect list.
58 case $action in
59 allow-any)
61 print)
62 grep ?$oid actual.raw &&
63 echo ?$oid >>expect.raw
65 esac &&
67 sort actual.raw >actual &&
68 sort expect.raw >expect &&
69 test_cmp expect actual
71 done
72 done
74 test_done