1 #define USE_THE_INDEX_COMPATIBILITY_MACROS
4 #include "repository.h"
12 #include "cache-tree.h"
13 #include "tree-walk.h"
15 #include "parse-options.h"
18 #include "streaming.h"
21 #include "object-store.h"
22 #include "run-command.h"
25 #define REACHABLE 0x0001
27 #define HAS_OBJ 0x0004
28 /* This flag is set if something points to this object. */
33 static int show_unreachable
;
34 static int include_reflogs
= 1;
35 static int check_full
= 1;
36 static int connectivity_only
;
37 static int check_strict
;
38 static int keep_cache_objects
;
39 static struct fsck_options fsck_walk_options
= FSCK_OPTIONS_DEFAULT
;
40 static struct fsck_options fsck_obj_options
= FSCK_OPTIONS_DEFAULT
;
41 static int errors_found
;
42 static int write_lost_and_found
;
44 static int show_progress
= -1;
45 static int show_dangling
= 1;
46 static int name_objects
;
47 #define ERROR_OBJECT 01
48 #define ERROR_REACHABLE 02
50 #define ERROR_REFS 010
51 #define ERROR_COMMIT_GRAPH 020
52 #define ERROR_MULTI_PACK_INDEX 040
54 static const char *describe_object(const struct object_id
*oid
)
56 return fsck_describe_object(&fsck_walk_options
, oid
);
59 static const char *printable_type(const struct object_id
*oid
,
60 enum object_type type
)
65 type
= oid_object_info(the_repository
, oid
, NULL
);
67 ret
= type_name(type
);
74 static int objerror(struct object
*obj
, const char *err
)
76 errors_found
|= ERROR_OBJECT
;
77 /* TRANSLATORS: e.g. error in tree 01bfda: <more explanation> */
78 fprintf_ln(stderr
, _("error in %s %s: %s"),
79 printable_type(&obj
->oid
, obj
->type
),
80 describe_object(&obj
->oid
), err
);
84 static int fsck_error_func(struct fsck_options
*o
,
85 const struct object_id
*oid
,
86 enum object_type object_type
,
87 enum fsck_msg_type msg_type
,
88 enum fsck_msg_id msg_id
,
93 /* TRANSLATORS: e.g. warning in tree 01bfda: <more explanation> */
94 fprintf_ln(stderr
, _("warning in %s %s: %s"),
95 printable_type(oid
, object_type
),
96 describe_object(oid
), message
);
99 /* TRANSLATORS: e.g. error in tree 01bfda: <more explanation> */
100 fprintf_ln(stderr
, _("error in %s %s: %s"),
101 printable_type(oid
, object_type
),
102 describe_object(oid
), message
);
105 BUG("%d (FSCK_IGNORE?) should never trigger this callback",
110 static struct object_array pending
;
112 static int mark_object(struct object
*obj
, int type
, void *data
, struct fsck_options
*options
)
114 struct object
*parent
= data
;
117 * The only case data is NULL or type is OBJ_ANY is when
118 * mark_object_reachable() calls us. All the callers of
119 * that function has non-NULL obj hence ...
122 /* ... these references to parent->fld are safe here */
123 printf_ln(_("broken link from %7s %s"),
124 printable_type(&parent
->oid
, parent
->type
),
125 describe_object(&parent
->oid
));
126 printf_ln(_("broken link from %7s %s"),
127 (type
== OBJ_ANY
? _("unknown") : type_name(type
)),
129 errors_found
|= ERROR_REACHABLE
;
133 if (type
!= OBJ_ANY
&& obj
->type
!= type
)
134 /* ... and the reference to parent is safe here */
135 objerror(parent
, _("wrong object type in link"));
137 if (obj
->flags
& REACHABLE
)
139 obj
->flags
|= REACHABLE
;
141 if (is_promisor_object(&obj
->oid
))
143 * Further recursion does not need to be performed on this
144 * object since it is a promisor object (so it does not need to
145 * be added to "pending").
149 if (!(obj
->flags
& HAS_OBJ
)) {
150 if (parent
&& !has_object(the_repository
, &obj
->oid
, 1)) {
151 printf_ln(_("broken link from %7s %s\n"
153 printable_type(&parent
->oid
, parent
->type
),
154 describe_object(&parent
->oid
),
155 printable_type(&obj
->oid
, obj
->type
),
156 describe_object(&obj
->oid
));
157 errors_found
|= ERROR_REACHABLE
;
162 add_object_array(obj
, NULL
, &pending
);
166 static void mark_object_reachable(struct object
*obj
)
168 mark_object(obj
, OBJ_ANY
, NULL
, NULL
);
171 static int traverse_one_object(struct object
*obj
)
173 int result
= fsck_walk(obj
, obj
, &fsck_walk_options
);
175 if (obj
->type
== OBJ_TREE
) {
176 struct tree
*tree
= (struct tree
*)obj
;
177 free_tree_buffer(tree
);
182 static int traverse_reachable(void)
184 struct progress
*progress
= NULL
;
188 progress
= start_delayed_progress(_("Checking connectivity"), 0);
190 result
|= traverse_one_object(object_array_pop(&pending
));
191 display_progress(progress
, ++nr
);
193 stop_progress(&progress
);
197 static int mark_used(struct object
*obj
, enum object_type object_type
,
198 void *data
, struct fsck_options
*options
)
206 static void mark_unreachable_referents(const struct object_id
*oid
)
208 struct fsck_options options
= FSCK_OPTIONS_DEFAULT
;
209 struct object
*obj
= lookup_object(the_repository
, oid
);
211 if (!obj
|| !(obj
->flags
& HAS_OBJ
))
212 return; /* not part of our original set */
213 if (obj
->flags
& REACHABLE
)
214 return; /* reachable objects already traversed */
217 * Avoid passing OBJ_NONE to fsck_walk, which will parse the object
218 * (and we want to avoid parsing blobs).
220 if (obj
->type
== OBJ_NONE
) {
221 enum object_type type
= oid_object_info(the_repository
,
224 object_as_type(obj
, type
, 0);
227 options
.walk
= mark_used
;
228 fsck_walk(obj
, NULL
, &options
);
231 static int mark_loose_unreachable_referents(const struct object_id
*oid
,
235 mark_unreachable_referents(oid
);
239 static int mark_packed_unreachable_referents(const struct object_id
*oid
,
240 struct packed_git
*pack
,
244 mark_unreachable_referents(oid
);
249 * Check a single reachable object
251 static void check_reachable_object(struct object
*obj
)
254 * We obviously want the object to be parsed,
255 * except if it was in a pack-file and we didn't
258 if (!(obj
->flags
& HAS_OBJ
)) {
259 if (is_promisor_object(&obj
->oid
))
261 if (has_object_pack(&obj
->oid
))
262 return; /* it is in pack - forget about it */
263 printf_ln(_("missing %s %s"),
264 printable_type(&obj
->oid
, obj
->type
),
265 describe_object(&obj
->oid
));
266 errors_found
|= ERROR_REACHABLE
;
272 * Check a single unreachable object
274 static void check_unreachable_object(struct object
*obj
)
277 * Missing unreachable object? Ignore it. It's not like
278 * we miss it (since it can't be reached), nor do we want
279 * to complain about it being unreachable (since it does
282 if (!(obj
->flags
& HAS_OBJ
))
286 * Unreachable object that exists? Show it if asked to,
287 * since this is something that is prunable.
289 if (show_unreachable
) {
290 printf_ln(_("unreachable %s %s"),
291 printable_type(&obj
->oid
, obj
->type
),
292 describe_object(&obj
->oid
));
297 * "!USED" means that nothing at all points to it, including
298 * other unreachable objects. In other words, it's the "tip"
299 * of some set of unreachable objects, usually a commit that
302 * Such starting points are more interesting than some random
303 * set of unreachable objects, so we show them even if the user
304 * hasn't asked for _all_ unreachable objects. If you have
305 * deleted a branch by mistake, this is a prime candidate to
306 * start looking at, for example.
308 if (!(obj
->flags
& USED
)) {
310 printf_ln(_("dangling %s %s"),
311 printable_type(&obj
->oid
, obj
->type
),
312 describe_object(&obj
->oid
));
313 if (write_lost_and_found
) {
314 char *filename
= git_pathdup("lost-found/%s/%s",
315 obj
->type
== OBJ_COMMIT
? "commit" : "other",
316 describe_object(&obj
->oid
));
319 if (safe_create_leading_directories_const(filename
)) {
320 error(_("could not create lost-found"));
324 f
= xfopen(filename
, "w");
325 if (obj
->type
== OBJ_BLOB
) {
326 if (stream_blob_to_fd(fileno(f
), &obj
->oid
, NULL
, 1))
327 die_errno(_("could not write '%s'"), filename
);
329 fprintf(f
, "%s\n", describe_object(&obj
->oid
));
331 die_errno(_("could not finish '%s'"),
339 * Otherwise? It's there, it's unreachable, and some other unreachable
340 * object points to it. Ignore it - it's not interesting, and we showed
341 * all the interesting cases above.
345 static void check_object(struct object
*obj
)
348 fprintf_ln(stderr
, _("Checking %s"), describe_object(&obj
->oid
));
350 if (obj
->flags
& REACHABLE
)
351 check_reachable_object(obj
);
353 check_unreachable_object(obj
);
356 static void check_connectivity(void)
360 /* Traverse the pending reachable objects */
361 traverse_reachable();
364 * With --connectivity-only, we won't have actually opened and marked
365 * unreachable objects with USED. Do that now to make --dangling, etc
368 if (connectivity_only
&& (show_dangling
|| write_lost_and_found
)) {
370 * Even though we already have a "struct object" for each of
371 * these in memory, we must not iterate over the internal
372 * object hash as we do below. Our loop would potentially
373 * resize the hash, making our iteration invalid.
375 * Instead, we'll just go back to the source list of objects,
376 * and ignore any that weren't present in our earlier
379 for_each_loose_object(mark_loose_unreachable_referents
, NULL
, 0);
380 for_each_packed_object(mark_packed_unreachable_referents
, NULL
, 0);
383 /* Look up all the requirements, warn about missing objects.. */
384 max
= get_max_object_index();
386 fprintf_ln(stderr
, _("Checking connectivity (%d objects)"), max
);
388 for (i
= 0; i
< max
; i
++) {
389 struct object
*obj
= get_indexed_object(i
);
396 static int fsck_obj(struct object
*obj
, void *buffer
, unsigned long size
)
400 if (obj
->flags
& SEEN
)
405 fprintf_ln(stderr
, _("Checking %s %s"),
406 printable_type(&obj
->oid
, obj
->type
),
407 describe_object(&obj
->oid
));
409 if (fsck_walk(obj
, NULL
, &fsck_obj_options
))
410 objerror(obj
, _("broken links"));
411 err
= fsck_object(obj
, buffer
, size
, &fsck_obj_options
);
415 if (obj
->type
== OBJ_COMMIT
) {
416 struct commit
*commit
= (struct commit
*) obj
;
418 if (!commit
->parents
&& show_root
)
419 printf_ln(_("root %s"),
420 describe_object(&commit
->object
.oid
));
423 if (obj
->type
== OBJ_TAG
) {
424 struct tag
*tag
= (struct tag
*) obj
;
426 if (show_tags
&& tag
->tagged
) {
427 printf_ln(_("tagged %s %s (%s) in %s"),
428 printable_type(&tag
->tagged
->oid
, tag
->tagged
->type
),
429 describe_object(&tag
->tagged
->oid
),
431 describe_object(&tag
->object
.oid
));
436 if (obj
->type
== OBJ_TREE
)
437 free_tree_buffer((struct tree
*)obj
);
438 if (obj
->type
== OBJ_COMMIT
)
439 free_commit_buffer(the_repository
->parsed_objects
,
440 (struct commit
*)obj
);
444 static int fsck_obj_buffer(const struct object_id
*oid
, enum object_type type
,
445 unsigned long size
, void *buffer
, int *eaten
)
448 * Note, buffer may be NULL if type is OBJ_BLOB. See
449 * verify_packfile(), data_valid variable for details.
452 obj
= parse_object_buffer(the_repository
, oid
, type
, size
, buffer
,
455 errors_found
|= ERROR_OBJECT
;
456 return error(_("%s: object corrupt or missing"),
459 obj
->flags
&= ~(REACHABLE
| SEEN
);
460 obj
->flags
|= HAS_OBJ
;
461 return fsck_obj(obj
, buffer
, size
);
464 static int default_refs
;
466 static void fsck_handle_reflog_oid(const char *refname
, struct object_id
*oid
,
467 timestamp_t timestamp
)
471 if (!is_null_oid(oid
)) {
472 obj
= lookup_object(the_repository
, oid
);
473 if (obj
&& (obj
->flags
& HAS_OBJ
)) {
475 fsck_put_object_name(&fsck_walk_options
, oid
,
479 mark_object_reachable(obj
);
480 } else if (!is_promisor_object(oid
)) {
481 error(_("%s: invalid reflog entry %s"),
482 refname
, oid_to_hex(oid
));
483 errors_found
|= ERROR_REACHABLE
;
488 static int fsck_handle_reflog_ent(struct object_id
*ooid
, struct object_id
*noid
,
489 const char *email
, timestamp_t timestamp
, int tz
,
490 const char *message
, void *cb_data
)
492 const char *refname
= cb_data
;
495 fprintf_ln(stderr
, _("Checking reflog %s->%s"),
496 oid_to_hex(ooid
), oid_to_hex(noid
));
498 fsck_handle_reflog_oid(refname
, ooid
, 0);
499 fsck_handle_reflog_oid(refname
, noid
, timestamp
);
503 static int fsck_handle_reflog(const char *logname
, const struct object_id
*oid
,
504 int flag
, void *cb_data
)
506 struct strbuf refname
= STRBUF_INIT
;
508 strbuf_worktree_ref(cb_data
, &refname
, logname
);
509 for_each_reflog_ent(refname
.buf
, fsck_handle_reflog_ent
, refname
.buf
);
510 strbuf_release(&refname
);
514 static int fsck_handle_ref(const char *refname
, const struct object_id
*oid
,
515 int flag
, void *cb_data
)
519 obj
= parse_object(the_repository
, oid
);
521 if (is_promisor_object(oid
)) {
523 * Increment default_refs anyway, because this is a
529 error(_("%s: invalid sha1 pointer %s"),
530 refname
, oid_to_hex(oid
));
531 errors_found
|= ERROR_REACHABLE
;
532 /* We'll continue with the rest despite the error.. */
535 if (obj
->type
!= OBJ_COMMIT
&& is_branch(refname
)) {
536 error(_("%s: not a commit"), refname
);
537 errors_found
|= ERROR_REFS
;
541 fsck_put_object_name(&fsck_walk_options
,
543 mark_object_reachable(obj
);
548 static int fsck_head_link(const char *head_ref_name
,
549 const char **head_points_at
,
550 struct object_id
*head_oid
);
552 static void get_default_heads(void)
554 struct worktree
**worktrees
, **p
;
555 const char *head_points_at
;
556 struct object_id head_oid
;
558 for_each_rawref(fsck_handle_ref
, NULL
);
560 worktrees
= get_worktrees();
561 for (p
= worktrees
; *p
; p
++) {
562 struct worktree
*wt
= *p
;
563 struct strbuf ref
= STRBUF_INIT
;
565 strbuf_worktree_ref(wt
, &ref
, "HEAD");
566 fsck_head_link(ref
.buf
, &head_points_at
, &head_oid
);
567 if (head_points_at
&& !is_null_oid(&head_oid
))
568 fsck_handle_ref(ref
.buf
, &head_oid
, 0, NULL
);
569 strbuf_release(&ref
);
572 refs_for_each_reflog(get_worktree_ref_store(wt
),
573 fsck_handle_reflog
, wt
);
575 free_worktrees(worktrees
);
578 * Not having any default heads isn't really fatal, but
579 * it does mean that "--unreachable" no longer makes any
580 * sense (since in this case everything will obviously
581 * be unreachable by definition.
583 * Showing dangling objects is valid, though (as those
584 * dangling objects are likely lost heads).
586 * So we just print a warning about it, and clear the
587 * "show_unreachable" flag.
590 fprintf_ln(stderr
, _("notice: No default references"));
591 show_unreachable
= 0;
595 static int fsck_loose(const struct object_id
*oid
, const char *path
, void *data
)
598 enum object_type type
;
603 if (read_loose_object(path
, oid
, &type
, &size
, &contents
) < 0) {
604 errors_found
|= ERROR_OBJECT
;
605 error(_("%s: object corrupt or missing: %s"),
606 oid_to_hex(oid
), path
);
607 return 0; /* keep checking other objects */
610 if (!contents
&& type
!= OBJ_BLOB
)
611 BUG("read_loose_object streamed a non-blob");
613 obj
= parse_object_buffer(the_repository
, oid
, type
, size
,
617 errors_found
|= ERROR_OBJECT
;
618 error(_("%s: object could not be parsed: %s"),
619 oid_to_hex(oid
), path
);
622 return 0; /* keep checking other objects */
625 obj
->flags
&= ~(REACHABLE
| SEEN
);
626 obj
->flags
|= HAS_OBJ
;
627 if (fsck_obj(obj
, contents
, size
))
628 errors_found
|= ERROR_OBJECT
;
632 return 0; /* keep checking other objects, even if we saw an error */
635 static int fsck_cruft(const char *basename
, const char *path
, void *data
)
637 if (!starts_with(basename
, "tmp_obj_"))
638 fprintf_ln(stderr
, _("bad sha1 file: %s"), path
);
642 static int fsck_subdir(unsigned int nr
, const char *path
, void *progress
)
644 display_progress(progress
, nr
+ 1);
648 static void fsck_object_dir(const char *path
)
650 struct progress
*progress
= NULL
;
653 fprintf_ln(stderr
, _("Checking object directory"));
656 progress
= start_progress(_("Checking object directories"), 256);
658 for_each_loose_file_in_objdir(path
, fsck_loose
, fsck_cruft
, fsck_subdir
,
660 display_progress(progress
, 256);
661 stop_progress(&progress
);
664 static int fsck_head_link(const char *head_ref_name
,
665 const char **head_points_at
,
666 struct object_id
*head_oid
)
668 int null_is_error
= 0;
671 fprintf_ln(stderr
, _("Checking %s link"), head_ref_name
);
673 *head_points_at
= resolve_ref_unsafe(head_ref_name
, 0, head_oid
, NULL
);
674 if (!*head_points_at
) {
675 errors_found
|= ERROR_REFS
;
676 return error(_("invalid %s"), head_ref_name
);
678 if (!strcmp(*head_points_at
, head_ref_name
))
681 else if (!starts_with(*head_points_at
, "refs/heads/")) {
682 errors_found
|= ERROR_REFS
;
683 return error(_("%s points to something strange (%s)"),
684 head_ref_name
, *head_points_at
);
686 if (is_null_oid(head_oid
)) {
688 errors_found
|= ERROR_REFS
;
689 return error(_("%s: detached HEAD points at nothing"),
693 _("notice: %s points to an unborn branch (%s)"),
694 head_ref_name
, *head_points_at
+ 11);
699 static int fsck_cache_tree(struct cache_tree
*it
)
705 fprintf_ln(stderr
, _("Checking cache tree"));
707 if (0 <= it
->entry_count
) {
708 struct object
*obj
= parse_object(the_repository
, &it
->oid
);
710 error(_("%s: invalid sha1 pointer in cache-tree"),
711 oid_to_hex(&it
->oid
));
712 errors_found
|= ERROR_REFS
;
716 fsck_put_object_name(&fsck_walk_options
, &it
->oid
, ":");
717 mark_object_reachable(obj
);
718 if (obj
->type
!= OBJ_TREE
)
719 err
|= objerror(obj
, _("non-tree in cache-tree"));
721 for (i
= 0; i
< it
->subtree_nr
; i
++)
722 err
|= fsck_cache_tree(it
->down
[i
]->cache_tree
);
726 static void mark_object_for_connectivity(const struct object_id
*oid
)
728 struct object
*obj
= lookup_unknown_object(oid
);
729 obj
->flags
|= HAS_OBJ
;
732 static int mark_loose_for_connectivity(const struct object_id
*oid
,
736 mark_object_for_connectivity(oid
);
740 static int mark_packed_for_connectivity(const struct object_id
*oid
,
741 struct packed_git
*pack
,
745 mark_object_for_connectivity(oid
);
749 static char const * const fsck_usage
[] = {
750 N_("git fsck [<options>] [<object>...]"),
754 static struct option fsck_opts
[] = {
755 OPT__VERBOSE(&verbose
, N_("be verbose")),
756 OPT_BOOL(0, "unreachable", &show_unreachable
, N_("show unreachable objects")),
757 OPT_BOOL(0, "dangling", &show_dangling
, N_("show dangling objects")),
758 OPT_BOOL(0, "tags", &show_tags
, N_("report tags")),
759 OPT_BOOL(0, "root", &show_root
, N_("report root nodes")),
760 OPT_BOOL(0, "cache", &keep_cache_objects
, N_("make index objects head nodes")),
761 OPT_BOOL(0, "reflogs", &include_reflogs
, N_("make reflogs head nodes (default)")),
762 OPT_BOOL(0, "full", &check_full
, N_("also consider packs and alternate objects")),
763 OPT_BOOL(0, "connectivity-only", &connectivity_only
, N_("check only connectivity")),
764 OPT_BOOL(0, "strict", &check_strict
, N_("enable more strict checking")),
765 OPT_BOOL(0, "lost-found", &write_lost_and_found
,
766 N_("write dangling objects in .git/lost-found")),
767 OPT_BOOL(0, "progress", &show_progress
, N_("show progress")),
768 OPT_BOOL(0, "name-objects", &name_objects
, N_("show verbose names for reachable objects")),
772 int cmd_fsck(int argc
, const char **argv
, const char *prefix
)
775 struct object_directory
*odb
;
777 /* fsck knows how to handle missing promisor objects */
778 fetch_if_missing
= 0;
781 read_replace_refs
= 0;
783 argc
= parse_options(argc
, argv
, prefix
, fsck_opts
, fsck_usage
, 0);
785 fsck_walk_options
.walk
= mark_object
;
786 fsck_obj_options
.walk
= mark_used
;
787 fsck_obj_options
.error_func
= fsck_error_func
;
789 fsck_obj_options
.strict
= 1;
791 if (show_progress
== -1)
792 show_progress
= isatty(2);
796 if (write_lost_and_found
) {
802 fsck_enable_object_names(&fsck_walk_options
);
804 git_config(git_fsck_config
, &fsck_obj_options
);
806 if (connectivity_only
) {
807 for_each_loose_object(mark_loose_for_connectivity
, NULL
, 0);
808 for_each_packed_object(mark_packed_for_connectivity
, NULL
, 0);
810 prepare_alt_odb(the_repository
);
811 for (odb
= the_repository
->objects
->odb
; odb
; odb
= odb
->next
)
812 fsck_object_dir(odb
->path
);
815 struct packed_git
*p
;
816 uint32_t total
= 0, count
= 0;
817 struct progress
*progress
= NULL
;
820 for (p
= get_all_packs(the_repository
); p
;
822 if (open_pack_index(p
))
824 total
+= p
->num_objects
;
827 progress
= start_progress(_("Checking objects"), total
);
829 for (p
= get_all_packs(the_repository
); p
;
831 /* verify gives error messages itself */
832 if (verify_pack(the_repository
,
835 errors_found
|= ERROR_PACK
;
836 count
+= p
->num_objects
;
838 stop_progress(&progress
);
841 if (fsck_finish(&fsck_obj_options
))
842 errors_found
|= ERROR_OBJECT
;
845 for (i
= 0; i
< argc
; i
++) {
846 const char *arg
= argv
[i
];
847 struct object_id oid
;
848 if (!get_oid(arg
, &oid
)) {
849 struct object
*obj
= lookup_object(the_repository
,
852 if (!obj
|| !(obj
->flags
& HAS_OBJ
)) {
853 if (is_promisor_object(&oid
))
855 error(_("%s: object missing"), oid_to_hex(&oid
));
856 errors_found
|= ERROR_OBJECT
;
861 fsck_put_object_name(&fsck_walk_options
, &oid
,
863 mark_object_reachable(obj
);
866 error(_("invalid parameter: expected sha1, got '%s'"), arg
);
867 errors_found
|= ERROR_OBJECT
;
871 * If we've not been given any explicit head information, do the
872 * default ones from .git/refs. We also consider the index file
873 * in this case (ie this implies --cache).
877 keep_cache_objects
= 1;
880 if (keep_cache_objects
) {
881 verify_index_checksum
= 1;
884 for (i
= 0; i
< active_nr
; i
++) {
889 mode
= active_cache
[i
]->ce_mode
;
890 if (S_ISGITLINK(mode
))
892 blob
= lookup_blob(the_repository
,
893 &active_cache
[i
]->oid
);
898 fsck_put_object_name(&fsck_walk_options
, &obj
->oid
,
899 ":%s", active_cache
[i
]->name
);
900 mark_object_reachable(obj
);
902 if (active_cache_tree
)
903 fsck_cache_tree(active_cache_tree
);
906 check_connectivity();
908 if (!git_config_get_bool("core.commitgraph", &i
) && i
) {
909 struct child_process commit_graph_verify
= CHILD_PROCESS_INIT
;
910 const char *verify_argv
[] = { "commit-graph", "verify", NULL
, NULL
, NULL
};
912 prepare_alt_odb(the_repository
);
913 for (odb
= the_repository
->objects
->odb
; odb
; odb
= odb
->next
) {
914 child_process_init(&commit_graph_verify
);
915 commit_graph_verify
.argv
= verify_argv
;
916 commit_graph_verify
.git_cmd
= 1;
917 verify_argv
[2] = "--object-dir";
918 verify_argv
[3] = odb
->path
;
919 if (run_command(&commit_graph_verify
))
920 errors_found
|= ERROR_COMMIT_GRAPH
;
924 if (!git_config_get_bool("core.multipackindex", &i
) && i
) {
925 struct child_process midx_verify
= CHILD_PROCESS_INIT
;
926 const char *midx_argv
[] = { "multi-pack-index", "verify", NULL
, NULL
, NULL
};
928 prepare_alt_odb(the_repository
);
929 for (odb
= the_repository
->objects
->odb
; odb
; odb
= odb
->next
) {
930 child_process_init(&midx_verify
);
931 midx_verify
.argv
= midx_argv
;
932 midx_verify
.git_cmd
= 1;
933 midx_argv
[2] = "--object-dir";
934 midx_argv
[3] = odb
->path
;
935 if (run_command(&midx_verify
))
936 errors_found
|= ERROR_MULTI_PACK_INDEX
;