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
53 static const char *describe_object(const struct object_id
*oid
)
55 return fsck_describe_object(&fsck_walk_options
, oid
);
58 static const char *printable_type(const struct object_id
*oid
,
59 enum object_type type
)
64 type
= oid_object_info(the_repository
, oid
, NULL
);
66 ret
= type_name(type
);
73 static int fsck_config(const char *var
, const char *value
, void *cb
)
75 if (strcmp(var
, "fsck.skiplist") == 0) {
77 struct strbuf sb
= STRBUF_INIT
;
79 if (git_config_pathname(&path
, var
, value
))
81 strbuf_addf(&sb
, "skiplist=%s", path
);
83 fsck_set_msg_types(&fsck_obj_options
, sb
.buf
);
88 if (skip_prefix(var
, "fsck.", &var
)) {
89 fsck_set_msg_type(&fsck_obj_options
, var
, value
);
93 return git_default_config(var
, value
, cb
);
96 static int objerror(struct object
*obj
, const char *err
)
98 errors_found
|= ERROR_OBJECT
;
99 /* TRANSLATORS: e.g. error in tree 01bfda: <more explanation> */
100 fprintf_ln(stderr
, _("error in %s %s: %s"),
101 printable_type(&obj
->oid
, obj
->type
),
102 describe_object(&obj
->oid
), err
);
106 static int fsck_error_func(struct fsck_options
*o
,
107 const struct object_id
*oid
,
108 enum object_type object_type
,
109 int msg_type
, const char *message
)
113 /* TRANSLATORS: e.g. warning in tree 01bfda: <more explanation> */
114 fprintf_ln(stderr
, _("warning in %s %s: %s"),
115 printable_type(oid
, object_type
),
116 describe_object(oid
), message
);
119 /* TRANSLATORS: e.g. error in tree 01bfda: <more explanation> */
120 fprintf_ln(stderr
, _("error in %s %s: %s"),
121 printable_type(oid
, object_type
),
122 describe_object(oid
), message
);
125 BUG("%d (FSCK_IGNORE?) should never trigger this callback",
130 static struct object_array pending
;
132 static int mark_object(struct object
*obj
, int type
, void *data
, struct fsck_options
*options
)
134 struct object
*parent
= data
;
137 * The only case data is NULL or type is OBJ_ANY is when
138 * mark_object_reachable() calls us. All the callers of
139 * that function has non-NULL obj hence ...
142 /* ... these references to parent->fld are safe here */
143 printf_ln(_("broken link from %7s %s"),
144 printable_type(&parent
->oid
, parent
->type
),
145 describe_object(&parent
->oid
));
146 printf_ln(_("broken link from %7s %s"),
147 (type
== OBJ_ANY
? _("unknown") : type_name(type
)),
149 errors_found
|= ERROR_REACHABLE
;
153 if (type
!= OBJ_ANY
&& obj
->type
!= type
)
154 /* ... and the reference to parent is safe here */
155 objerror(parent
, _("wrong object type in link"));
157 if (obj
->flags
& REACHABLE
)
159 obj
->flags
|= REACHABLE
;
161 if (is_promisor_object(&obj
->oid
))
163 * Further recursion does not need to be performed on this
164 * object since it is a promisor object (so it does not need to
165 * be added to "pending").
169 if (!(obj
->flags
& HAS_OBJ
)) {
170 if (parent
&& !has_object_file(&obj
->oid
)) {
171 printf_ln(_("broken link from %7s %s\n"
173 printable_type(&parent
->oid
, parent
->type
),
174 describe_object(&parent
->oid
),
175 printable_type(&obj
->oid
, obj
->type
),
176 describe_object(&obj
->oid
));
177 errors_found
|= ERROR_REACHABLE
;
182 add_object_array(obj
, NULL
, &pending
);
186 static void mark_object_reachable(struct object
*obj
)
188 mark_object(obj
, OBJ_ANY
, NULL
, NULL
);
191 static int traverse_one_object(struct object
*obj
)
193 int result
= fsck_walk(obj
, obj
, &fsck_walk_options
);
195 if (obj
->type
== OBJ_TREE
) {
196 struct tree
*tree
= (struct tree
*)obj
;
197 free_tree_buffer(tree
);
202 static int traverse_reachable(void)
204 struct progress
*progress
= NULL
;
208 progress
= start_delayed_progress(_("Checking connectivity"), 0);
210 result
|= traverse_one_object(object_array_pop(&pending
));
211 display_progress(progress
, ++nr
);
213 stop_progress(&progress
);
217 static int mark_used(struct object
*obj
, int type
, void *data
, struct fsck_options
*options
)
225 static void mark_unreachable_referents(const struct object_id
*oid
)
227 struct fsck_options options
= FSCK_OPTIONS_DEFAULT
;
228 struct object
*obj
= lookup_object(the_repository
, oid
);
230 if (!obj
|| !(obj
->flags
& HAS_OBJ
))
231 return; /* not part of our original set */
232 if (obj
->flags
& REACHABLE
)
233 return; /* reachable objects already traversed */
236 * Avoid passing OBJ_NONE to fsck_walk, which will parse the object
237 * (and we want to avoid parsing blobs).
239 if (obj
->type
== OBJ_NONE
) {
240 enum object_type type
= oid_object_info(the_repository
,
243 object_as_type(the_repository
, obj
, type
, 0);
246 options
.walk
= mark_used
;
247 fsck_walk(obj
, NULL
, &options
);
250 static int mark_loose_unreachable_referents(const struct object_id
*oid
,
254 mark_unreachable_referents(oid
);
258 static int mark_packed_unreachable_referents(const struct object_id
*oid
,
259 struct packed_git
*pack
,
263 mark_unreachable_referents(oid
);
268 * Check a single reachable object
270 static void check_reachable_object(struct object
*obj
)
273 * We obviously want the object to be parsed,
274 * except if it was in a pack-file and we didn't
277 if (!(obj
->flags
& HAS_OBJ
)) {
278 if (is_promisor_object(&obj
->oid
))
280 if (has_object_pack(&obj
->oid
))
281 return; /* it is in pack - forget about it */
282 printf_ln(_("missing %s %s"),
283 printable_type(&obj
->oid
, obj
->type
),
284 describe_object(&obj
->oid
));
285 errors_found
|= ERROR_REACHABLE
;
291 * Check a single unreachable object
293 static void check_unreachable_object(struct object
*obj
)
296 * Missing unreachable object? Ignore it. It's not like
297 * we miss it (since it can't be reached), nor do we want
298 * to complain about it being unreachable (since it does
301 if (!(obj
->flags
& HAS_OBJ
))
305 * Unreachable object that exists? Show it if asked to,
306 * since this is something that is prunable.
308 if (show_unreachable
) {
309 printf_ln(_("unreachable %s %s"),
310 printable_type(&obj
->oid
, obj
->type
),
311 describe_object(&obj
->oid
));
316 * "!USED" means that nothing at all points to it, including
317 * other unreachable objects. In other words, it's the "tip"
318 * of some set of unreachable objects, usually a commit that
321 * Such starting points are more interesting than some random
322 * set of unreachable objects, so we show them even if the user
323 * hasn't asked for _all_ unreachable objects. If you have
324 * deleted a branch by mistake, this is a prime candidate to
325 * start looking at, for example.
327 if (!(obj
->flags
& USED
)) {
329 printf_ln(_("dangling %s %s"),
330 printable_type(&obj
->oid
, obj
->type
),
331 describe_object(&obj
->oid
));
332 if (write_lost_and_found
) {
333 char *filename
= git_pathdup("lost-found/%s/%s",
334 obj
->type
== OBJ_COMMIT
? "commit" : "other",
335 describe_object(&obj
->oid
));
338 if (safe_create_leading_directories_const(filename
)) {
339 error(_("could not create lost-found"));
343 f
= xfopen(filename
, "w");
344 if (obj
->type
== OBJ_BLOB
) {
345 if (stream_blob_to_fd(fileno(f
), &obj
->oid
, NULL
, 1))
346 die_errno(_("could not write '%s'"), filename
);
348 fprintf(f
, "%s\n", describe_object(&obj
->oid
));
350 die_errno(_("could not finish '%s'"),
358 * Otherwise? It's there, it's unreachable, and some other unreachable
359 * object points to it. Ignore it - it's not interesting, and we showed
360 * all the interesting cases above.
364 static void check_object(struct object
*obj
)
367 fprintf_ln(stderr
, _("Checking %s"), describe_object(&obj
->oid
));
369 if (obj
->flags
& REACHABLE
)
370 check_reachable_object(obj
);
372 check_unreachable_object(obj
);
375 static void check_connectivity(void)
379 /* Traverse the pending reachable objects */
380 traverse_reachable();
383 * With --connectivity-only, we won't have actually opened and marked
384 * unreachable objects with USED. Do that now to make --dangling, etc
387 if (connectivity_only
&& (show_dangling
|| write_lost_and_found
)) {
389 * Even though we already have a "struct object" for each of
390 * these in memory, we must not iterate over the internal
391 * object hash as we do below. Our loop would potentially
392 * resize the hash, making our iteration invalid.
394 * Instead, we'll just go back to the source list of objects,
395 * and ignore any that weren't present in our earlier
398 for_each_loose_object(mark_loose_unreachable_referents
, NULL
, 0);
399 for_each_packed_object(mark_packed_unreachable_referents
, NULL
, 0);
402 /* Look up all the requirements, warn about missing objects.. */
403 max
= get_max_object_index();
405 fprintf_ln(stderr
, _("Checking connectivity (%d objects)"), max
);
407 for (i
= 0; i
< max
; i
++) {
408 struct object
*obj
= get_indexed_object(i
);
415 static int fsck_obj(struct object
*obj
, void *buffer
, unsigned long size
)
419 if (obj
->flags
& SEEN
)
424 fprintf_ln(stderr
, _("Checking %s %s"),
425 printable_type(&obj
->oid
, obj
->type
),
426 describe_object(&obj
->oid
));
428 if (fsck_walk(obj
, NULL
, &fsck_obj_options
))
429 objerror(obj
, _("broken links"));
430 err
= fsck_object(obj
, buffer
, size
, &fsck_obj_options
);
434 if (obj
->type
== OBJ_COMMIT
) {
435 struct commit
*commit
= (struct commit
*) obj
;
437 if (!commit
->parents
&& show_root
)
438 printf_ln(_("root %s"),
439 describe_object(&commit
->object
.oid
));
442 if (obj
->type
== OBJ_TAG
) {
443 struct tag
*tag
= (struct tag
*) obj
;
445 if (show_tags
&& tag
->tagged
) {
446 printf_ln(_("tagged %s %s (%s) in %s"),
447 printable_type(&tag
->tagged
->oid
, tag
->tagged
->type
),
448 describe_object(&tag
->tagged
->oid
),
450 describe_object(&tag
->object
.oid
));
455 if (obj
->type
== OBJ_TREE
)
456 free_tree_buffer((struct tree
*)obj
);
457 if (obj
->type
== OBJ_COMMIT
)
458 free_commit_buffer(the_repository
->parsed_objects
,
459 (struct commit
*)obj
);
463 static int fsck_obj_buffer(const struct object_id
*oid
, enum object_type type
,
464 unsigned long size
, void *buffer
, int *eaten
)
467 * Note, buffer may be NULL if type is OBJ_BLOB. See
468 * verify_packfile(), data_valid variable for details.
471 obj
= parse_object_buffer(the_repository
, oid
, type
, size
, buffer
,
474 errors_found
|= ERROR_OBJECT
;
475 return error(_("%s: object corrupt or missing"),
478 obj
->flags
&= ~(REACHABLE
| SEEN
);
479 obj
->flags
|= HAS_OBJ
;
480 return fsck_obj(obj
, buffer
, size
);
483 static int default_refs
;
485 static void fsck_handle_reflog_oid(const char *refname
, struct object_id
*oid
,
486 timestamp_t timestamp
)
490 if (!is_null_oid(oid
)) {
491 obj
= lookup_object(the_repository
, oid
);
492 if (obj
&& (obj
->flags
& HAS_OBJ
)) {
494 fsck_put_object_name(&fsck_walk_options
, oid
,
498 mark_object_reachable(obj
);
499 } else if (!is_promisor_object(oid
)) {
500 error(_("%s: invalid reflog entry %s"),
501 refname
, oid_to_hex(oid
));
502 errors_found
|= ERROR_REACHABLE
;
507 static int fsck_handle_reflog_ent(struct object_id
*ooid
, struct object_id
*noid
,
508 const char *email
, timestamp_t timestamp
, int tz
,
509 const char *message
, void *cb_data
)
511 const char *refname
= cb_data
;
514 fprintf_ln(stderr
, _("Checking reflog %s->%s"),
515 oid_to_hex(ooid
), oid_to_hex(noid
));
517 fsck_handle_reflog_oid(refname
, ooid
, 0);
518 fsck_handle_reflog_oid(refname
, noid
, timestamp
);
522 static int fsck_handle_reflog(const char *logname
, const struct object_id
*oid
,
523 int flag
, void *cb_data
)
525 struct strbuf refname
= STRBUF_INIT
;
527 strbuf_worktree_ref(cb_data
, &refname
, logname
);
528 for_each_reflog_ent(refname
.buf
, fsck_handle_reflog_ent
, refname
.buf
);
529 strbuf_release(&refname
);
533 static int fsck_handle_ref(const char *refname
, const struct object_id
*oid
,
534 int flag
, void *cb_data
)
538 obj
= parse_object(the_repository
, oid
);
540 if (is_promisor_object(oid
)) {
542 * Increment default_refs anyway, because this is a
548 error(_("%s: invalid sha1 pointer %s"),
549 refname
, oid_to_hex(oid
));
550 errors_found
|= ERROR_REACHABLE
;
551 /* We'll continue with the rest despite the error.. */
554 if (obj
->type
!= OBJ_COMMIT
&& is_branch(refname
)) {
555 error(_("%s: not a commit"), refname
);
556 errors_found
|= ERROR_REFS
;
560 fsck_put_object_name(&fsck_walk_options
,
562 mark_object_reachable(obj
);
567 static int fsck_head_link(const char *head_ref_name
,
568 const char **head_points_at
,
569 struct object_id
*head_oid
);
571 static void get_default_heads(void)
573 struct worktree
**worktrees
, **p
;
574 const char *head_points_at
;
575 struct object_id head_oid
;
577 for_each_rawref(fsck_handle_ref
, NULL
);
579 worktrees
= get_worktrees(0);
580 for (p
= worktrees
; *p
; p
++) {
581 struct worktree
*wt
= *p
;
582 struct strbuf ref
= STRBUF_INIT
;
584 strbuf_worktree_ref(wt
, &ref
, "HEAD");
585 fsck_head_link(ref
.buf
, &head_points_at
, &head_oid
);
586 if (head_points_at
&& !is_null_oid(&head_oid
))
587 fsck_handle_ref(ref
.buf
, &head_oid
, 0, NULL
);
588 strbuf_release(&ref
);
591 refs_for_each_reflog(get_worktree_ref_store(wt
),
592 fsck_handle_reflog
, wt
);
594 free_worktrees(worktrees
);
597 * Not having any default heads isn't really fatal, but
598 * it does mean that "--unreachable" no longer makes any
599 * sense (since in this case everything will obviously
600 * be unreachable by definition.
602 * Showing dangling objects is valid, though (as those
603 * dangling objects are likely lost heads).
605 * So we just print a warning about it, and clear the
606 * "show_unreachable" flag.
609 fprintf_ln(stderr
, _("notice: No default references"));
610 show_unreachable
= 0;
614 static int fsck_loose(const struct object_id
*oid
, const char *path
, void *data
)
617 enum object_type type
;
622 if (read_loose_object(path
, oid
, &type
, &size
, &contents
) < 0) {
623 errors_found
|= ERROR_OBJECT
;
624 error(_("%s: object corrupt or missing: %s"),
625 oid_to_hex(oid
), path
);
626 return 0; /* keep checking other objects */
629 if (!contents
&& type
!= OBJ_BLOB
)
630 BUG("read_loose_object streamed a non-blob");
632 obj
= parse_object_buffer(the_repository
, oid
, type
, size
,
636 errors_found
|= ERROR_OBJECT
;
637 error(_("%s: object could not be parsed: %s"),
638 oid_to_hex(oid
), path
);
641 return 0; /* keep checking other objects */
644 obj
->flags
&= ~(REACHABLE
| SEEN
);
645 obj
->flags
|= HAS_OBJ
;
646 if (fsck_obj(obj
, contents
, size
))
647 errors_found
|= ERROR_OBJECT
;
651 return 0; /* keep checking other objects, even if we saw an error */
654 static int fsck_cruft(const char *basename
, const char *path
, void *data
)
656 if (!starts_with(basename
, "tmp_obj_"))
657 fprintf_ln(stderr
, _("bad sha1 file: %s"), path
);
661 static int fsck_subdir(unsigned int nr
, const char *path
, void *progress
)
663 display_progress(progress
, nr
+ 1);
667 static void fsck_object_dir(const char *path
)
669 struct progress
*progress
= NULL
;
672 fprintf_ln(stderr
, _("Checking object directory"));
675 progress
= start_progress(_("Checking object directories"), 256);
677 for_each_loose_file_in_objdir(path
, fsck_loose
, fsck_cruft
, fsck_subdir
,
679 display_progress(progress
, 256);
680 stop_progress(&progress
);
683 static int fsck_head_link(const char *head_ref_name
,
684 const char **head_points_at
,
685 struct object_id
*head_oid
)
687 int null_is_error
= 0;
690 fprintf_ln(stderr
, _("Checking %s link"), head_ref_name
);
692 *head_points_at
= resolve_ref_unsafe(head_ref_name
, 0, head_oid
, NULL
);
693 if (!*head_points_at
) {
694 errors_found
|= ERROR_REFS
;
695 return error(_("invalid %s"), head_ref_name
);
697 if (!strcmp(*head_points_at
, head_ref_name
))
700 else if (!starts_with(*head_points_at
, "refs/heads/")) {
701 errors_found
|= ERROR_REFS
;
702 return error(_("%s points to something strange (%s)"),
703 head_ref_name
, *head_points_at
);
705 if (is_null_oid(head_oid
)) {
707 errors_found
|= ERROR_REFS
;
708 return error(_("%s: detached HEAD points at nothing"),
712 _("notice: %s points to an unborn branch (%s)"),
713 head_ref_name
, *head_points_at
+ 11);
718 static int fsck_cache_tree(struct cache_tree
*it
)
724 fprintf_ln(stderr
, _("Checking cache tree"));
726 if (0 <= it
->entry_count
) {
727 struct object
*obj
= parse_object(the_repository
, &it
->oid
);
729 error(_("%s: invalid sha1 pointer in cache-tree"),
730 oid_to_hex(&it
->oid
));
731 errors_found
|= ERROR_REFS
;
735 fsck_put_object_name(&fsck_walk_options
, &it
->oid
, ":");
736 mark_object_reachable(obj
);
737 if (obj
->type
!= OBJ_TREE
)
738 err
|= objerror(obj
, _("non-tree in cache-tree"));
740 for (i
= 0; i
< it
->subtree_nr
; i
++)
741 err
|= fsck_cache_tree(it
->down
[i
]->cache_tree
);
745 static void mark_object_for_connectivity(const struct object_id
*oid
)
747 struct object
*obj
= lookup_unknown_object(oid
);
748 obj
->flags
|= HAS_OBJ
;
751 static int mark_loose_for_connectivity(const struct object_id
*oid
,
755 mark_object_for_connectivity(oid
);
759 static int mark_packed_for_connectivity(const struct object_id
*oid
,
760 struct packed_git
*pack
,
764 mark_object_for_connectivity(oid
);
768 static char const * const fsck_usage
[] = {
769 N_("git fsck [<options>] [<object>...]"),
773 static struct option fsck_opts
[] = {
774 OPT__VERBOSE(&verbose
, N_("be verbose")),
775 OPT_BOOL(0, "unreachable", &show_unreachable
, N_("show unreachable objects")),
776 OPT_BOOL(0, "dangling", &show_dangling
, N_("show dangling objects")),
777 OPT_BOOL(0, "tags", &show_tags
, N_("report tags")),
778 OPT_BOOL(0, "root", &show_root
, N_("report root nodes")),
779 OPT_BOOL(0, "cache", &keep_cache_objects
, N_("make index objects head nodes")),
780 OPT_BOOL(0, "reflogs", &include_reflogs
, N_("make reflogs head nodes (default)")),
781 OPT_BOOL(0, "full", &check_full
, N_("also consider packs and alternate objects")),
782 OPT_BOOL(0, "connectivity-only", &connectivity_only
, N_("check only connectivity")),
783 OPT_BOOL(0, "strict", &check_strict
, N_("enable more strict checking")),
784 OPT_BOOL(0, "lost-found", &write_lost_and_found
,
785 N_("write dangling objects in .git/lost-found")),
786 OPT_BOOL(0, "progress", &show_progress
, N_("show progress")),
787 OPT_BOOL(0, "name-objects", &name_objects
, N_("show verbose names for reachable objects")),
791 int cmd_fsck(int argc
, const char **argv
, const char *prefix
)
794 struct object_directory
*odb
;
796 /* fsck knows how to handle missing promisor objects */
797 fetch_if_missing
= 0;
800 read_replace_refs
= 0;
802 argc
= parse_options(argc
, argv
, prefix
, fsck_opts
, fsck_usage
, 0);
804 fsck_walk_options
.walk
= mark_object
;
805 fsck_obj_options
.walk
= mark_used
;
806 fsck_obj_options
.error_func
= fsck_error_func
;
808 fsck_obj_options
.strict
= 1;
810 if (show_progress
== -1)
811 show_progress
= isatty(2);
815 if (write_lost_and_found
) {
821 fsck_enable_object_names(&fsck_walk_options
);
823 git_config(fsck_config
, NULL
);
825 if (connectivity_only
) {
826 for_each_loose_object(mark_loose_for_connectivity
, NULL
, 0);
827 for_each_packed_object(mark_packed_for_connectivity
, NULL
, 0);
829 prepare_alt_odb(the_repository
);
830 for (odb
= the_repository
->objects
->odb
; odb
; odb
= odb
->next
)
831 fsck_object_dir(odb
->path
);
834 struct packed_git
*p
;
835 uint32_t total
= 0, count
= 0;
836 struct progress
*progress
= NULL
;
839 for (p
= get_all_packs(the_repository
); p
;
841 if (open_pack_index(p
))
843 total
+= p
->num_objects
;
846 progress
= start_progress(_("Checking objects"), total
);
848 for (p
= get_all_packs(the_repository
); p
;
850 /* verify gives error messages itself */
851 if (verify_pack(the_repository
,
854 errors_found
|= ERROR_PACK
;
855 count
+= p
->num_objects
;
857 stop_progress(&progress
);
860 if (fsck_finish(&fsck_obj_options
))
861 errors_found
|= ERROR_OBJECT
;
864 for (i
= 0; i
< argc
; i
++) {
865 const char *arg
= argv
[i
];
866 struct object_id oid
;
867 if (!get_oid(arg
, &oid
)) {
868 struct object
*obj
= lookup_object(the_repository
,
871 if (!obj
|| !(obj
->flags
& HAS_OBJ
)) {
872 if (is_promisor_object(&oid
))
874 error(_("%s: object missing"), oid_to_hex(&oid
));
875 errors_found
|= ERROR_OBJECT
;
880 fsck_put_object_name(&fsck_walk_options
, &oid
,
882 mark_object_reachable(obj
);
885 error(_("invalid parameter: expected sha1, got '%s'"), arg
);
886 errors_found
|= ERROR_OBJECT
;
890 * If we've not been given any explicit head information, do the
891 * default ones from .git/refs. We also consider the index file
892 * in this case (ie this implies --cache).
896 keep_cache_objects
= 1;
899 if (keep_cache_objects
) {
900 verify_index_checksum
= 1;
903 for (i
= 0; i
< active_nr
; i
++) {
908 mode
= active_cache
[i
]->ce_mode
;
909 if (S_ISGITLINK(mode
))
911 blob
= lookup_blob(the_repository
,
912 &active_cache
[i
]->oid
);
917 fsck_put_object_name(&fsck_walk_options
, &obj
->oid
,
918 ":%s", active_cache
[i
]->name
);
919 mark_object_reachable(obj
);
921 if (active_cache_tree
)
922 fsck_cache_tree(active_cache_tree
);
925 check_connectivity();
927 if (!git_config_get_bool("core.commitgraph", &i
) && i
) {
928 struct child_process commit_graph_verify
= CHILD_PROCESS_INIT
;
929 const char *verify_argv
[] = { "commit-graph", "verify", NULL
, NULL
, NULL
};
931 prepare_alt_odb(the_repository
);
932 for (odb
= the_repository
->objects
->odb
; odb
; odb
= odb
->next
) {
933 child_process_init(&commit_graph_verify
);
934 commit_graph_verify
.argv
= verify_argv
;
935 commit_graph_verify
.git_cmd
= 1;
936 verify_argv
[2] = "--object-dir";
937 verify_argv
[3] = odb
->path
;
938 if (run_command(&commit_graph_verify
))
939 errors_found
|= ERROR_COMMIT_GRAPH
;
943 if (!git_config_get_bool("core.multipackindex", &i
) && i
) {
944 struct child_process midx_verify
= CHILD_PROCESS_INIT
;
945 const char *midx_argv
[] = { "multi-pack-index", "verify", NULL
, NULL
, NULL
};
947 prepare_alt_odb(the_repository
);
948 for (odb
= the_repository
->objects
->odb
; odb
; odb
= odb
->next
) {
949 child_process_init(&midx_verify
);
950 midx_verify
.argv
= midx_argv
;
951 midx_verify
.git_cmd
= 1;
952 midx_argv
[2] = "--object-dir";
953 midx_argv
[3] = odb
->path
;
954 if (run_command(&midx_verify
))
955 errors_found
|= ERROR_COMMIT_GRAPH
;