Skip to content

Commit 5a48d24

Browse files
committed
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 <[email protected]>
1 parent 4947367 commit 5a48d24

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

builtin/rev-list.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,11 @@ static void show_object(struct object *obj,
180180
const struct name_path *path, const char *component,
181181
void *cb_data)
182182
{
183+
struct rev_info *info = cb_data;
184+
183185
finish_object(obj, path, component, cb_data);
186+
if (info->verify_objects && !obj->parsed && obj->type != OBJ_COMMIT)
187+
parse_object(obj->sha1);
184188
show_object_with_name(stdout, obj, path, component);
185189
}
186190

revision.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,6 +1383,11 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
13831383
revs->tree_objects = 1;
13841384
revs->blob_objects = 1;
13851385
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;
13861391
} else if (!strcmp(arg, "--unpacked")) {
13871392
revs->unpacked = 1;
13881393
} else if (!prefixcmp(arg, "--unpacked=")) {

revision.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ struct rev_info {
5353
tag_objects:1,
5454
tree_objects:1,
5555
blob_objects:1,
56+
verify_objects:1,
5657
edge_hint:1,
5758
limited:1,
5859
unpacked:1,

0 commit comments

Comments
 (0)