Which git commands perform integrity checks?

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
Initialized empty Git repository in /tmp/repo/.git/
$ cd repo
$ echo 'very important info' >critical
$ git add critical
$ git commit -m critical
[master (root-commit) c4d6d90] critical
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 critical
$ git ls-tree HEAD
100644 blob 82d423c32c4bb2c52938088e0234db041bf4eaaf    critical
$ git show 82d423c32c4bb2c52938088e0234db041bf4eaaf
very important info
$ echo 'Very important info' | git hash-object --stdin -w
81a3797afe76d339db25c0f9c705a6caa47279c2
$ mv .git/objects/81/a3797afe76d339db25c0f9c705a6caa47279c2 \
     .git/objects/82/d423c32c4bb2c52938088e0234db041bf4eaaf

Of course, git-fsck notices

$ git fsck
error: sha1 mismatch 82d423c32c4bb2c52938088e0234db041bf4eaaf

error: 82d423c32c4bb2c52938088e0234db041bf4eaaf: object corrupt or missing
missing blob 82d423c32c4bb2c52938088e0234db041bf4eaaf

but git-log is happy with the change

$ git log -p
commit c4d6d90467af9ffa94772795d5c5d191228933c1
Author: Greg Bacon <gbacon@dbresearch.net>
Date:   Thu Apr 7 12:20:53 2011 -0500

    critical

diff --git a/critical b/critical
new file mode 100644
index 0000000..82d423c
--- /dev/null
+++ b/critical
@@ -0,0 +1 @@
+Very important info

as is git-checkout.

$ rm critical 
$ git checkout .
$ cat critical 
Very important info

A specific invocation of git-show reveals the corruption

$ git show 82d423c32c4bb2c52938088e0234db041bf4eaaf
error: sha1 mismatch 82d423c32c4bb2c52938088e0234db041bf4eaaf

fatal: bad object 82d423c32c4bb2c52938088e0234db041bf4eaaf

but not a broader one.

$ git show
commit c4d6d90467af9ffa94772795d5c5d191228933c1
Author: Greg Bacon <gbacon@dbresearch.net>
Date:   Thu Apr 7 12:20:53 2011 -0500

    critical

diff --git a/critical b/critical
new file mode 100644
index 0000000..82d423c
--- /dev/null
+++ b/critical
@@ -0,0 +1 @@
+Very important info

Even git-clone doesn't notice!

$ cd ..
$ git clone repo clone
Cloning into clone...
done.
$ cat clone/critical 
Very important info

What is the full list of specific git command modes (e.g., git show $sha1 should be present but not git show or git show HEAD) that perform integrity checks?

20
задан Greg Bacon 7 April 2011 в 17:52
поделиться