rev-list --verify-object

Often we want to verify everything reachable from a given set of commits are present in our repository and connected without a gap to the tips of our refs. We used to do this for this purpose: $ rev-list --objects $commits_to_be_tested --not --all Even though this is good enough for catching missing commits and trees, we show the object name but do not verify their existence, let alone their well-formedness, for the blob objects at the leaf level. Add a new "--verify-object" option so that we can catch missing and broken blobs as well. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Sep 1, 2011 at 15:43 UTC 5a48d24012fa39cdd02c1cb614db2e62d445e2ce
3 files changed +10
builtin/rev-list.c
+4
@@ -180,7 +180,11 @@ static void show_object(struct object *obj,
180 const struct name_path *path, const char *component,
181 void *cb_data)
182 {
183 + struct rev_info *info = cb_data;
184 +
185 finish_object(obj, path, component, cb_data);
186 + if (info->verify_objects && !obj->parsed && obj->type != OBJ_COMMIT)
187 + parse_object(obj->sha1);
188 show_object_with_name(stdout, obj, path, component);
189 }
190
revision.c
+5
@@ -1383,6 +1383,11 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
1383 revs->tree_objects = 1;
1384 revs->blob_objects = 1;
1385 revs->edge_hint = 1;
1386 + } else if (!strcmp(arg, "--verify-objects")) {
1387 + revs->tag_objects = 1;
1388 + revs->tree_objects = 1;
1389 + revs->blob_objects = 1;
1390 + revs->verify_objects = 1;
1391 } else if (!strcmp(arg, "--unpacked")) {
1392 revs->unpacked = 1;
1393 } else if (!prefixcmp(arg, "--unpacked=")) {
revision.h
+1
@@ -53,6 +53,7 @@ struct rev_info {
53 tag_objects:1,
54 tree_objects:1,
55 blob_objects:1,
56 + verify_objects:1,
57 edge_hint:1,
58 limited:1,
59 unpacked:1,