3 test_description
='handling of missing objects in rev-list'
5 TEST_PASSES_SANITIZE_LEAK
=true
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' '
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
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
50 mv "$path" "$path.hidden" &&
51 test_when_finished "mv $path.hidden $path" &&
53 git rev-list --missing=$action --objects --no-object-names \
56 # When the action is to print, we should also add the missing
57 # oid to the expect list.
62 grep ?$oid actual.raw &&
63 echo ?$oid >>expect.raw
67 sort actual.raw >actual &&
68 sort expect.raw >expect &&
69 test_cmp expect actual