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 int msg_type
, const char *message
)
91 /* TRANSLATORS: e.g. warning in tree 01bfda: <more explanation> */
92 fprintf_ln(stderr
, _("warning in %s %s: %s"),
93 printable_type(oid
, object_type
),
94 describe_object(oid
), message
);
97 /* TRANSLATORS: e.g. error in tree 01bfda: <more explanation> */
98 fprintf_ln(stderr
, _("error in %s %s: %s"),
99 printable_type(oid
, object_type
),
100 describe_object(oid
), message
);
103 BUG("%d (FSCK_IGNORE?) should never trigger this callback",
108 static struct object_array pending
;
110 static int mark_object(struct object
*obj
, int type
, void *data
, struct fsck_options
*options
)
112 struct object
*parent
= data
;
115 * The only case data is NULL or type is OBJ_ANY is when
116 * mark_object_reachable() calls us. All the callers of
117 * that function has non-NULL obj hence ...
120 /* ... these references to parent->fld are safe here */
121 printf_ln(_("broken link from %7s %s"),
122 printable_type(&parent
->oid
, parent
->type
),
123 describe_object(&parent
->oid
));
124 printf_ln(_("broken link from %7s %s"),
125 (type
== OBJ_ANY
? _("unknown") : type_name(type
)),
127 errors_found
|= ERROR_REACHABLE
;
131 if (type
!= OBJ_ANY
&& obj
->type
!= type
)
132 /* ... and the reference to parent is safe here */
133 objerror(parent
, _("wrong object type in link"));
135 if (obj
->flags
& REACHABLE
)
137 obj
->flags
|= REACHABLE
;
139 if (is_promisor_object(&obj
->oid
))
141 * Further recursion does not need to be performed on this
142 * object since it is a promisor object (so it does not need to
143 * be added to "pending").
147 if (!(obj
->flags
& HAS_OBJ
)) {
148 if (parent
&& !has_object(the_repository
, &obj
->oid
, 1)) {
149 printf_ln(_("broken link from %7s %s\n"
151 printable_type(&parent
->oid
, parent
->type
),
152 describe_object(&parent
->oid
),
153 printable_type(&obj
->oid
, obj
->type
),
154 describe_object(&obj
->oid
));
155 errors_found
|= ERROR_REACHABLE
;
160 add_object_array(obj
, NULL
, &pending
);
164 static void mark_object_reachable(struct object
*obj
)
166 mark_object(obj
, OBJ_ANY
, NULL
, NULL
);
169 static int traverse_one_object(struct object
*obj
)
171 int result
= fsck_walk(obj
, obj
, &fsck_walk_options
);
173 if (obj
->type
== OBJ_TREE
) {
174 struct tree
*tree
= (struct tree
*)obj
;
175 free_tree_buffer(tree
);
180 static int traverse_reachable(void)
182 struct progress
*progress
= NULL
;
186 progress
= start_delayed_progress(_("Checking connectivity"), 0);
188 result
|= traverse_one_object(object_array_pop(&pending
));
189 display_progress(progress
, ++nr
);
191 stop_progress(&progress
);
195 static int mark_used(struct object
*obj
, enum object_type object_type
,
196 void *data
, struct fsck_options
*options
)
204 static void mark_unreachable_referents(const struct object_id
*oid
)
206 struct fsck_options options
= FSCK_OPTIONS_DEFAULT
;
207 struct object
*obj
= lookup_object(the_repository
, oid
);
209 if (!obj
|| !(obj
->flags
& HAS_OBJ
))
210 return; /* not part of our original set */
211 if (obj
->flags
& REACHABLE
)
212 return; /* reachable objects already traversed */
215 * Avoid passing OBJ_NONE to fsck_walk, which will parse the object
216 * (and we want to avoid parsing blobs).
218 if (obj
->type
== OBJ_NONE
) {
219 enum object_type type
= oid_object_info(the_repository
,
222 object_as_type(obj
, type
, 0);
225 options
.walk
= mark_used
;
226 fsck_walk(obj
, NULL
, &options
);
229 static int mark_loose_unreachable_referents(const struct object_id
*oid
,
233 mark_unreachable_referents(oid
);
237 static int mark_packed_unreachable_referents(const struct object_id
*oid
,
238 struct packed_git
*pack
,
242 mark_unreachable_referents(oid
);
247 * Check a single reachable object
249 static void check_reachable_object(struct object
*obj
)
252 * We obviously want the object to be parsed,
253 * except if it was in a pack-file and we didn't
256 if (!(obj
->flags
& HAS_OBJ
)) {
257 if (is_promisor_object(&obj
->oid
))
259 if (has_object_pack(&obj
->oid
))
260 return; /* it is in pack - forget about it */
261 printf_ln(_("missing %s %s"),
262 printable_type(&obj
->oid
, obj
->type
),
263 describe_object(&obj
->oid
));
264 errors_found
|= ERROR_REACHABLE
;
270 * Check a single unreachable object
272 static void check_unreachable_object(struct object
*obj
)
275 * Missing unreachable object? Ignore it. It's not like
276 * we miss it (since it can't be reached), nor do we want
277 * to complain about it being unreachable (since it does
280 if (!(obj
->flags
& HAS_OBJ
))
284 * Unreachable object that exists? Show it if asked to,
285 * since this is something that is prunable.
287 if (show_unreachable
) {
288 printf_ln(_("unreachable %s %s"),
289 printable_type(&obj
->oid
, obj
->type
),
290 describe_object(&obj
->oid
));
295 * "!USED" means that nothing at all points to it, including
296 * other unreachable objects. In other words, it's the "tip"
297 * of some set of unreachable objects, usually a commit that
300 * Such starting points are more interesting than some random
301 * set of unreachable objects, so we show them even if the user
302 * hasn't asked for _all_ unreachable objects. If you have
303 * deleted a branch by mistake, this is a prime candidate to
304 * start looking at, for example.
306 if (!(obj
->flags
& USED
)) {
308 printf_ln(_("dangling %s %s"),
309 printable_type(&obj
->oid
, obj
->type
),
310 describe_object(&obj
->oid
));
311 if (write_lost_and_found
) {
312 char *filename
= git_pathdup("lost-found/%s/%s",
313 obj
->type
== OBJ_COMMIT
? "commit" : "other",
314 describe_object(&obj
->oid
));
317 if (safe_create_leading_directories_const(filename
)) {
318 error(_("could not create lost-found"));
322 f
= xfopen(filename
, "w");
323 if (obj
->type
== OBJ_BLOB
) {
324 if (stream_blob_to_fd(fileno(f
), &obj
->oid
, NULL
, 1))
325 die_errno(_("could not write '%s'"), filename
);
327 fprintf(f
, "%s\n", describe_object(&obj
->oid
));
329 die_errno(_("could not finish '%s'"),
337 * Otherwise? It's there, it's unreachable, and some other unreachable
338 * object points to it. Ignore it - it's not interesting, and we showed
339 * all the interesting cases above.
343 static void check_object(struct object
*obj
)
346 fprintf_ln(stderr
, _("Checking %s"), describe_object(&obj
->oid
));
348 if (obj
->flags
& REACHABLE
)
349 check_reachable_object(obj
);
351 check_unreachable_object(obj
);
354 static void check_connectivity(void)
358 /* Traverse the pending reachable objects */
359 traverse_reachable();
362 * With --connectivity-only, we won't have actually opened and marked
363 * unreachable objects with USED. Do that now to make --dangling, etc
366 if (connectivity_only
&& (show_dangling
|| write_lost_and_found
)) {
368 * Even though we already have a "struct object" for each of
369 * these in memory, we must not iterate over the internal
370 * object hash as we do below. Our loop would potentially
371 * resize the hash, making our iteration invalid.
373 * Instead, we'll just go back to the source list of objects,
374 * and ignore any that weren't present in our earlier
377 for_each_loose_object(mark_loose_unreachable_referents
, NULL
, 0);
378 for_each_packed_object(mark_packed_unreachable_referents
, NULL
, 0);
381 /* Look up all the requirements, warn about missing objects.. */
382 max
= get_max_object_index();
384 fprintf_ln(stderr
, _("Checking connectivity (%d objects)"), max
);
386 for (i
= 0; i
< max
; i
++) {
387 struct object
*obj
= get_indexed_object(i
);
394 static int fsck_obj(struct object
*obj
, void *buffer
, unsigned long size
)
398 if (obj
->flags
& SEEN
)
403 fprintf_ln(stderr
, _("Checking %s %s"),
404 printable_type(&obj
->oid
, obj
->type
),
405 describe_object(&obj
->oid
));
407 if (fsck_walk(obj
, NULL
, &fsck_obj_options
))
408 objerror(obj
, _("broken links"));
409 err
= fsck_object(obj
, buffer
, size
, &fsck_obj_options
);
413 if (obj
->type
== OBJ_COMMIT
) {
414 struct commit
*commit
= (struct commit
*) obj
;
416 if (!commit
->parents
&& show_root
)
417 printf_ln(_("root %s"),
418 describe_object(&commit
->object
.oid
));
421 if (obj
->type
== OBJ_TAG
) {
422 struct tag
*tag
= (struct tag
*) obj
;
424 if (show_tags
&& tag
->tagged
) {
425 printf_ln(_("tagged %s %s (%s) in %s"),
426 printable_type(&tag
->tagged
->oid
, tag
->tagged
->type
),
427 describe_object(&tag
->tagged
->oid
),
429 describe_object(&tag
->object
.oid
));
434 if (obj
->type
== OBJ_TREE
)
435 free_tree_buffer((struct tree
*)obj
);
436 if (obj
->type
== OBJ_COMMIT
)
437 free_commit_buffer(the_repository
->parsed_objects
,
438 (struct commit
*)obj
);
442 static int fsck_obj_buffer(const struct object_id
*oid
, enum object_type type
,
443 unsigned long size
, void *buffer
, int *eaten
)
446 * Note, buffer may be NULL if type is OBJ_BLOB. See
447 * verify_packfile(), data_valid variable for details.
450 obj
= parse_object_buffer(the_repository
, oid
, type
, size
, buffer
,
453 errors_found
|= ERROR_OBJECT
;
454 return error(_("%s: object corrupt or missing"),
457 obj
->flags
&= ~(REACHABLE
| SEEN
);
458 obj
->flags
|= HAS_OBJ
;
459 return fsck_obj(obj
, buffer
, size
);
462 static int default_refs
;
464 static void fsck_handle_reflog_oid(const char *refname
, struct object_id
*oid
,
465 timestamp_t timestamp
)
469 if (!is_null_oid(oid
)) {
470 obj
= lookup_object(the_repository
, oid
);
471 if (obj
&& (obj
->flags
& HAS_OBJ
)) {
473 fsck_put_object_name(&fsck_walk_options
, oid
,
477 mark_object_reachable(obj
);
478 } else if (!is_promisor_object(oid
)) {
479 error(_("%s: invalid reflog entry %s"),
480 refname
, oid_to_hex(oid
));
481 errors_found
|= ERROR_REACHABLE
;
486 static int fsck_handle_reflog_ent(struct object_id
*ooid
, struct object_id
*noid
,
487 const char *email
, timestamp_t timestamp
, int tz
,
488 const char *message
, void *cb_data
)
490 const char *refname
= cb_data
;
493 fprintf_ln(stderr
, _("Checking reflog %s->%s"),
494 oid_to_hex(ooid
), oid_to_hex(noid
));
496 fsck_handle_reflog_oid(refname
, ooid
, 0);
497 fsck_handle_reflog_oid(refname
, noid
, timestamp
);
501 static int fsck_handle_reflog(const char *logname
, const struct object_id
*oid
,
502 int flag
, void *cb_data
)
504 struct strbuf refname
= STRBUF_INIT
;
506 strbuf_worktree_ref(cb_data
, &refname
, logname
);
507 for_each_reflog_ent(refname
.buf
, fsck_handle_reflog_ent
, refname
.buf
);
508 strbuf_release(&refname
);
512 static int fsck_handle_ref(const char *refname
, const struct object_id
*oid
,
513 int flag
, void *cb_data
)
517 obj
= parse_object(the_repository
, oid
);
519 if (is_promisor_object(oid
)) {
521 * Increment default_refs anyway, because this is a
527 error(_("%s: invalid sha1 pointer %s"),
528 refname
, oid_to_hex(oid
));
529 errors_found
|= ERROR_REACHABLE
;
530 /* We'll continue with the rest despite the error.. */
533 if (obj
->type
!= OBJ_COMMIT
&& is_branch(refname
)) {
534 error(_("%s: not a commit"), refname
);
535 errors_found
|= ERROR_REFS
;
539 fsck_put_object_name(&fsck_walk_options
,
541 mark_object_reachable(obj
);
546 static int fsck_head_link(const char *head_ref_name
,
547 const char **head_points_at
,
548 struct object_id
*head_oid
);
550 static void get_default_heads(void)
552 struct worktree
**worktrees
, **p
;
553 const char *head_points_at
;
554 struct object_id head_oid
;
556 for_each_rawref(fsck_handle_ref
, NULL
);
558 worktrees
= get_worktrees();
559 for (p
= worktrees
; *p
; p
++) {
560 struct worktree
*wt
= *p
;
561 struct strbuf ref
= STRBUF_INIT
;
563 strbuf_worktree_ref(wt
, &ref
, "HEAD");
564 fsck_head_link(ref
.buf
, &head_points_at
, &head_oid
);
565 if (head_points_at
&& !is_null_oid(&head_oid
))
566 fsck_handle_ref(ref
.buf
, &head_oid
, 0, NULL
);
567 strbuf_release(&ref
);
570 refs_for_each_reflog(get_worktree_ref_store(wt
),
571 fsck_handle_reflog
, wt
);
573 free_worktrees(worktrees
);
576 * Not having any default heads isn't really fatal, but
577 * it does mean that "--unreachable" no longer makes any
578 * sense (since in this case everything will obviously
579 * be unreachable by definition.
581 * Showing dangling objects is valid, though (as those
582 * dangling objects are likely lost heads).
584 * So we just print a warning about it, and clear the
585 * "show_unreachable" flag.
588 fprintf_ln(stderr
, _("notice: No default references"));
589 show_unreachable
= 0;
593 static int fsck_loose(const struct object_id
*oid
, const char *path
, void *data
)
596 enum object_type type
;
601 if (read_loose_object(path
, oid
, &type
, &size
, &contents
) < 0) {
602 errors_found
|= ERROR_OBJECT
;
603 error(_("%s: object corrupt or missing: %s"),
604 oid_to_hex(oid
), path
);
605 return 0; /* keep checking other objects */
608 if (!contents
&& type
!= OBJ_BLOB
)
609 BUG("read_loose_object streamed a non-blob");
611 obj
= parse_object_buffer(the_repository
, oid
, type
, size
,
615 errors_found
|= ERROR_OBJECT
;
616 error(_("%s: object could not be parsed: %s"),
617 oid_to_hex(oid
), path
);
620 return 0; /* keep checking other objects */
623 obj
->flags
&= ~(REACHABLE
| SEEN
);
624 obj
->flags
|= HAS_OBJ
;
625 if (fsck_obj(obj
, contents
, size
))
626 errors_found
|= ERROR_OBJECT
;
630 return 0; /* keep checking other objects, even if we saw an error */
633 static int fsck_cruft(const char *basename
, const char *path
, void *data
)
635 if (!starts_with(basename
, "tmp_obj_"))
636 fprintf_ln(stderr
, _("bad sha1 file: %s"), path
);
640 static int fsck_subdir(unsigned int nr
, const char *path
, void *progress
)
642 display_progress(progress
, nr
+ 1);
646 static void fsck_object_dir(const char *path
)
648 struct progress
*progress
= NULL
;
651 fprintf_ln(stderr
, _("Checking object directory"));
654 progress
= start_progress(_("Checking object directories"), 256);
656 for_each_loose_file_in_objdir(path
, fsck_loose
, fsck_cruft
, fsck_subdir
,
658 display_progress(progress
, 256);
659 stop_progress(&progress
);
662 static int fsck_head_link(const char *head_ref_name
,
663 const char **head_points_at
,
664 struct object_id
*head_oid
)
666 int null_is_error
= 0;
669 fprintf_ln(stderr
, _("Checking %s link"), head_ref_name
);
671 *head_points_at
= resolve_ref_unsafe(head_ref_name
, 0, head_oid
, NULL
);
672 if (!*head_points_at
) {
673 errors_found
|= ERROR_REFS
;
674 return error(_("invalid %s"), head_ref_name
);
676 if (!strcmp(*head_points_at
, head_ref_name
))
679 else if (!starts_with(*head_points_at
, "refs/heads/")) {
680 errors_found
|= ERROR_REFS
;
681 return error(_("%s points to something strange (%s)"),
682 head_ref_name
, *head_points_at
);
684 if (is_null_oid(head_oid
)) {
686 errors_found
|= ERROR_REFS
;
687 return error(_("%s: detached HEAD points at nothing"),
691 _("notice: %s points to an unborn branch (%s)"),
692 head_ref_name
, *head_points_at
+ 11);
697 static int fsck_cache_tree(struct cache_tree
*it
)
703 fprintf_ln(stderr
, _("Checking cache tree"));
705 if (0 <= it
->entry_count
) {
706 struct object
*obj
= parse_object(the_repository
, &it
->oid
);
708 error(_("%s: invalid sha1 pointer in cache-tree"),
709 oid_to_hex(&it
->oid
));
710 errors_found
|= ERROR_REFS
;
714 fsck_put_object_name(&fsck_walk_options
, &it
->oid
, ":");
715 mark_object_reachable(obj
);
716 if (obj
->type
!= OBJ_TREE
)
717 err
|= objerror(obj
, _("non-tree in cache-tree"));
719 for (i
= 0; i
< it
->subtree_nr
; i
++)
720 err
|= fsck_cache_tree(it
->down
[i
]->cache_tree
);
724 static void mark_object_for_connectivity(const struct object_id
*oid
)
726 struct object
*obj
= lookup_unknown_object(oid
);
727 obj
->flags
|= HAS_OBJ
;
730 static int mark_loose_for_connectivity(const struct object_id
*oid
,
734 mark_object_for_connectivity(oid
);
738 static int mark_packed_for_connectivity(const struct object_id
*oid
,
739 struct packed_git
*pack
,
743 mark_object_for_connectivity(oid
);
747 static char const * const fsck_usage
[] = {
748 N_("git fsck [<options>] [<object>...]"),
752 static struct option fsck_opts
[] = {
753 OPT__VERBOSE(&verbose
, N_("be verbose")),
754 OPT_BOOL(0, "unreachable", &show_unreachable
, N_("show unreachable objects")),
755 OPT_BOOL(0, "dangling", &show_dangling
, N_("show dangling objects")),
756 OPT_BOOL(0, "tags", &show_tags
, N_("report tags")),
757 OPT_BOOL(0, "root", &show_root
, N_("report root nodes")),
758 OPT_BOOL(0, "cache", &keep_cache_objects
, N_("make index objects head nodes")),
759 OPT_BOOL(0, "reflogs", &include_reflogs
, N_("make reflogs head nodes (default)")),
760 OPT_BOOL(0, "full", &check_full
, N_("also consider packs and alternate objects")),
761 OPT_BOOL(0, "connectivity-only", &connectivity_only
, N_("check only connectivity")),
762 OPT_BOOL(0, "strict", &check_strict
, N_("enable more strict checking")),
763 OPT_BOOL(0, "lost-found", &write_lost_and_found
,
764 N_("write dangling objects in .git/lost-found")),
765 OPT_BOOL(0, "progress", &show_progress
, N_("show progress")),
766 OPT_BOOL(0, "name-objects", &name_objects
, N_("show verbose names for reachable objects")),
770 int cmd_fsck(int argc
, const char **argv
, const char *prefix
)
773 struct object_directory
*odb
;
775 /* fsck knows how to handle missing promisor objects */
776 fetch_if_missing
= 0;
779 read_replace_refs
= 0;
781 argc
= parse_options(argc
, argv
, prefix
, fsck_opts
, fsck_usage
, 0);
783 fsck_walk_options
.walk
= mark_object
;
784 fsck_obj_options
.walk
= mark_used
;
785 fsck_obj_options
.error_func
= fsck_error_func
;
787 fsck_obj_options
.strict
= 1;
789 if (show_progress
== -1)
790 show_progress
= isatty(2);
794 if (write_lost_and_found
) {
800 fsck_enable_object_names(&fsck_walk_options
);
802 git_config(git_fsck_config
, &fsck_obj_options
);
804 if (connectivity_only
) {
805 for_each_loose_object(mark_loose_for_connectivity
, NULL
, 0);
806 for_each_packed_object(mark_packed_for_connectivity
, NULL
, 0);
808 prepare_alt_odb(the_repository
);
809 for (odb
= the_repository
->objects
->odb
; odb
; odb
= odb
->next
)
810 fsck_object_dir(odb
->path
);
813 struct packed_git
*p
;
814 uint32_t total
= 0, count
= 0;
815 struct progress
*progress
= NULL
;
818 for (p
= get_all_packs(the_repository
); p
;
820 if (open_pack_index(p
))
822 total
+= p
->num_objects
;
825 progress
= start_progress(_("Checking objects"), total
);
827 for (p
= get_all_packs(the_repository
); p
;
829 /* verify gives error messages itself */
830 if (verify_pack(the_repository
,
833 errors_found
|= ERROR_PACK
;
834 count
+= p
->num_objects
;
836 stop_progress(&progress
);
839 if (fsck_finish(&fsck_obj_options
))
840 errors_found
|= ERROR_OBJECT
;
843 for (i
= 0; i
< argc
; i
++) {
844 const char *arg
= argv
[i
];
845 struct object_id oid
;
846 if (!get_oid(arg
, &oid
)) {
847 struct object
*obj
= lookup_object(the_repository
,
850 if (!obj
|| !(obj
->flags
& HAS_OBJ
)) {
851 if (is_promisor_object(&oid
))
853 error(_("%s: object missing"), oid_to_hex(&oid
));
854 errors_found
|= ERROR_OBJECT
;
859 fsck_put_object_name(&fsck_walk_options
, &oid
,
861 mark_object_reachable(obj
);
864 error(_("invalid parameter: expected sha1, got '%s'"), arg
);
865 errors_found
|= ERROR_OBJECT
;
869 * If we've not been given any explicit head information, do the
870 * default ones from .git/refs. We also consider the index file
871 * in this case (ie this implies --cache).
875 keep_cache_objects
= 1;
878 if (keep_cache_objects
) {
879 verify_index_checksum
= 1;
882 for (i
= 0; i
< active_nr
; i
++) {
887 mode
= active_cache
[i
]->ce_mode
;
888 if (S_ISGITLINK(mode
))
890 blob
= lookup_blob(the_repository
,
891 &active_cache
[i
]->oid
);
896 fsck_put_object_name(&fsck_walk_options
, &obj
->oid
,
897 ":%s", active_cache
[i
]->name
);
898 mark_object_reachable(obj
);
900 if (active_cache_tree
)
901 fsck_cache_tree(active_cache_tree
);
904 check_connectivity();
906 if (!git_config_get_bool("core.commitgraph", &i
) && i
) {
907 struct child_process commit_graph_verify
= CHILD_PROCESS_INIT
;
908 const char *verify_argv
[] = { "commit-graph", "verify", NULL
, NULL
, NULL
};
910 prepare_alt_odb(the_repository
);
911 for (odb
= the_repository
->objects
->odb
; odb
; odb
= odb
->next
) {
912 child_process_init(&commit_graph_verify
);
913 commit_graph_verify
.argv
= verify_argv
;
914 commit_graph_verify
.git_cmd
= 1;
915 verify_argv
[2] = "--object-dir";
916 verify_argv
[3] = odb
->path
;
917 if (run_command(&commit_graph_verify
))
918 errors_found
|= ERROR_COMMIT_GRAPH
;
922 if (!git_config_get_bool("core.multipackindex", &i
) && i
) {
923 struct child_process midx_verify
= CHILD_PROCESS_INIT
;
924 const char *midx_argv
[] = { "multi-pack-index", "verify", NULL
, NULL
, NULL
};
926 prepare_alt_odb(the_repository
);
927 for (odb
= the_repository
->objects
->odb
; odb
; odb
= odb
->next
) {
928 child_process_init(&midx_verify
);
929 midx_verify
.argv
= midx_argv
;
930 midx_verify
.git_cmd
= 1;
931 midx_argv
[2] = "--object-dir";
932 midx_argv
[3] = odb
->path
;
933 if (run_command(&midx_verify
))
934 errors_found
|= ERROR_MULTI_PACK_INDEX
;