diff options
authorJunio C Hamano <>2012-03-15 21:57:02 (GMT)
committerJunio C Hamano <>2012-03-15 22:23:17 (GMT)
commitd21c463d558a1450c2560869193f279fc7ddba4a (patch)
parente521850bfd4aa79632c99293a39dad56bcaa4143 (diff)
fetch/receive: remove over-pessimistic connectivity check
Git 1.7.8 introduced an object and history re-validation step after "fetch" or "push" causes new history to be added to a receiving repository. This is to protect a malicious server or pushing client from corrupting the repository by taking advantage of an existing corrupt object that is unconnected to existing history. But this check is way over-pessimistic. During "fetch" or "receive-pack" (the server side of "push"), unpack-objects and index-pack already validate individual objects that are received, and the only thing we would want to catch are corrupted objects that already happen to exist in our repository but are not referenced from our refs. Such objects must have been written by an earlier run of our codepaths that write out loose objects or packfiles, and they must have done the validation of individual objects when they did so. The only thing left to worry about is the connectivity integrity, which can be checked with "rev-list --objects", which is much cheaper. We have been paying the 5x to 8x runtime overhead the --verify-objects often adds for no real gain. Revert check_everything_connected() not to use this over-pessimistic check. Credit goes to Nguyễn Thái Ngọc Duy, who originally identified the performance regression and endured multiple rounds of reviews to fix it. Signed-off-by: Junio C Hamano <>
1 files changed, 4 insertions, 4 deletions
diff --git a/connected.c b/connected.c
index d762423..1e89c1c 100644
--- a/connected.c
+++ b/connected.c
@@ -6,18 +6,18 @@
* If we feed all the commits we want to verify to this command
- * $ git rev-list --verify-objects --stdin --not --all
+ * $ git rev-list --objects --stdin --not --all
* and if it does not error out, that means everything reachable from
- * these commits locally exists and is connected to some of our
- * existing refs.
+ * these commits locally exists and is connected to our existing refs.
+ * Note that this does _not_ validate the individual objects.
* Returns 0 if everything is connected, non-zero otherwise.
int check_everything_connected(sha1_iterate_fn fn, int quiet, void *cb_data)
struct child_process rev_list;
- const char *argv[] = {"rev-list", "--verify-objects",
+ const char *argv[] = {"rev-list", "--objects",
"--stdin", "--not", "--all", NULL, NULL};
char commit[41];
unsigned char sha1[20];