Trying to determine how quickly a user would be warned of corruption in the object database with git-1.7.4.1, I pulled a one-bit switcheroo:
$ git init repo Initia
In response to Mark Longair's answer, I fired up cscope and found:
(note how cscope has a curses interface and integrates nicely into Vim in case your interest was piqued)
Functions calling this function: parse_object
File Function Line
0 bundle.c verify_bundle 110 struct object *o = parse_object(e->sha1);
1 bundle.c create_bundle 242 struct object *object = parse_object(sha1);
2 bundle.c create_bundle 247 struct object *object = parse_object(sha1);
3 bundle.c create_bundle 323 obj = parse_object(sha1);
4 commit.c lookup_commit_reference_gently 30 struct object *obj = deref_tag(parse_object(sha1), NULL, 0);
5 http-backend.c show_text_ref 372 struct object *o = parse_object(sha1);
6 http-push.c one_remote_object 742 obj = parse_object(sha1);
7 http-push.c add_remote_info_ref 1530 o = parse_object(ref->old_sha1);
8 log-tree.c add_ref_decoration 93 struct object *obj = parse_object(sha1);
9 merge-recursive.c get_ref 1664 object = deref_tag(parse_object(sha1), name, strlen(name));
a pack-refs.c handle_one_ref 43 struct object *o = parse_object(sha1);
b pretty.c format_commit_one 835 parse_object(commit->object.sha1);
c reachable.c add_one_reflog_ent 122 object = parse_object(osha1);
d reachable.c add_one_reflog_ent 125 object = parse_object(nsha1);
e reachable.c add_one_ref 133 struct object *object = parse_object(sha1);
f reflog-walk.c fake_reflog_parent 234 commit_info->commit = (struct commit *)parse_object(reflog->osha1);
g refs.c peel_ref 647 o = parse_object(base);
h refs.c write_ref_sha1 1452 o = parse_object(sha1);
i remote.c ref_newer 1482 o = deref_tag(parse_object(old_sha1), NULL, 0);
j remote.c ref_newer 1487 o = deref_tag(parse_object(new_sha1), NULL, 0);
k revision.c add_head_to_pending 166 obj = parse_object(sha1);
l revision.c get_reference 176 object = parse_object(sha1);
m revision.c handle_commit 196 object = parse_object(tag->tagged->sha1);
n revision.c handle_one_reflog_commit 855 struct object *o = parse_object(sha1);
o server-info.c add_info_ref 12 struct object *o = parse_object(sha1);
p sha1_name.c peel_to_type 508 o = parse_object(sha1);
q sha1_name.c peel_to_type 511 if (!o || (!o->parsed && !parse_object(o->sha1)))
r sha1_name.c peel_onion 573 o = parse_object(outer);
s sha1_name.c peel_onion 578 if (!o || (!o->parsed && !parse_object(o->sha1)))
t sha1_name.c handle_one_ref 698 struct object *object = parse_object(sha1);
u sha1_name.c get_sha1_oneline 740 if (!parse_object(commit->object.sha1))
v tag.c deref_tag 16 o = parse_object(((struct tag *)o)->tagged->sha1);
w tree.c parse_tree_indirect 271 struct object *obj = parse_object(sha1);
x tree.c parse_tree_indirect 284 parse_object(obj->sha1);
y upload-pack.c got_sha1 342 o = parse_object(sha1);
z upload-pack.c reachable 382 parse_object(commit->object.sha1);
A upload-pack.c receive_needs 526 object = parse_object(sha1);
B upload-pack.c send_ref 644 struct object *o = parse_object(sha1);
C upload-pack.c mark_our_ref 670 struct object *o = parse_object(sha1);
D walker.c loop 182 parse_object(obj->sha1);
Here's how I would go about finding this out, although I'm not going to go through each source file to work out the conditions under which the check is performed. :)
Clone git's source code:
git clone git://git.kernel.org/pub/scm/git/git.git
Check out the version you care about:
cd git
git checkout v1.7.1
Look for that error message:
git grep 'sha1 mismatch'
That leads you to object.c
and the parse_object
function. Now look for that function:
git grep parse_object
... and go through the 38 files checking the conditions under which that function will be called.