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 # We manually corrupt the repository, which means that the commit-graph may
17 # contain references to already-deleted objects. We thus need to enable
18 # commit-graph paranoia to not returned these deleted commits from the graph.
19 GIT_COMMIT_GRAPH_PARANOIA
=true
20 export GIT_COMMIT_GRAPH_PARANOIA
22 for obj
in "HEAD~1" "HEAD~1^{tree}" "HEAD:1.t"
24 test_expect_success
"rev-list --missing=error fails with missing object $obj" '
25 oid="$(git rev-parse $obj)" &&
26 path=".git/objects/$(test_oid_to_path $oid)" &&
28 mv "$path" "$path.hidden" &&
29 test_when_finished "mv $path.hidden $path" &&
31 test_must_fail git rev-list --missing=error --objects \
32 --no-object-names HEAD
36 for obj
in "HEAD~1" "HEAD~1^{tree}" "HEAD:1.t"
38 for action
in "allow-any" "print"
40 test_expect_success
"rev-list --missing=$action with missing $obj" '
41 oid="$(git rev-parse $obj)" &&
42 path=".git/objects/$(test_oid_to_path $oid)" &&
44 # Before the object is made missing, we use rev-list to
45 # get the expected oids.
46 git rev-list --objects --no-object-names \
47 HEAD ^$obj >expect.raw &&
49 # Blobs are shared by all commits, so evethough a commit/tree
50 # might be skipped, its blob must be accounted for.
51 if [ $obj != "HEAD:1.t" ]; then
52 echo $(git rev-parse HEAD:1.t) >>expect.raw &&
53 echo $(git rev-parse HEAD:2.t) >>expect.raw
56 mv "$path" "$path.hidden" &&
57 test_when_finished "mv $path.hidden $path" &&
59 git rev-list --missing=$action --objects --no-object-names \
62 # When the action is to print, we should also add the missing
63 # oid to the expect list.
68 grep ?$oid actual.raw &&
69 echo ?$oid >>expect.raw
73 sort actual.raw >actual &&
74 sort expect.raw >expect &&
75 test_cmp expect actual