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(struct object
*obj
)
55 return fsck_describe_object(&fsck_walk_options
, obj
);
58 static const char *printable_type(struct object
*obj
)
62 if (obj
->type
== OBJ_NONE
) {
63 enum object_type type
= oid_object_info(the_repository
,
66 object_as_type(the_repository
, obj
, type
, 0);
69 ret
= type_name(obj
->type
);
76 static int fsck_config(const char *var
, const char *value
, void *cb
)
78 if (strcmp(var
, "fsck.skiplist") == 0) {
80 struct strbuf sb
= STRBUF_INIT
;
82 if (git_config_pathname(&path
, var
, value
))
84 strbuf_addf(&sb
, "skiplist=%s", path
);
86 fsck_set_msg_types(&fsck_obj_options
, sb
.buf
);
91 if (skip_prefix(var
, "fsck.", &var
)) {
92 fsck_set_msg_type(&fsck_obj_options
, var
, value
);
96 return git_default_config(var
, value
, cb
);
99 static int objerror(struct object
*obj
, const char *err
)
101 errors_found
|= ERROR_OBJECT
;
102 /* TRANSLATORS: e.g. error in tree 01bfda: <more explanation> */
103 fprintf_ln(stderr
, _("error in %s %s: %s"),
104 printable_type(obj
), describe_object(obj
), err
);
108 static int fsck_error_func(struct fsck_options
*o
,
109 struct object
*obj
, int 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(obj
), describe_object(obj
), message
);
118 /* TRANSLATORS: e.g. error in tree 01bfda: <more explanation> */
119 fprintf_ln(stderr
, _("error in %s %s: %s"),
120 printable_type(obj
), describe_object(obj
), message
);
123 BUG("%d (FSCK_IGNORE?) should never trigger this callback", type
);
127 static struct object_array pending
;
129 static int mark_object(struct object
*obj
, int type
, void *data
, struct fsck_options
*options
)
131 struct object
*parent
= data
;
134 * The only case data is NULL or type is OBJ_ANY is when
135 * mark_object_reachable() calls us. All the callers of
136 * that function has non-NULL obj hence ...
139 /* ... these references to parent->fld are safe here */
140 printf_ln(_("broken link from %7s %s"),
141 printable_type(parent
), describe_object(parent
));
142 printf_ln(_("broken link from %7s %s"),
143 (type
== OBJ_ANY
? _("unknown") : type_name(type
)),
145 errors_found
|= ERROR_REACHABLE
;
149 if (type
!= OBJ_ANY
&& obj
->type
!= type
)
150 /* ... and the reference to parent is safe here */
151 objerror(parent
, _("wrong object type in link"));
153 if (obj
->flags
& REACHABLE
)
155 obj
->flags
|= REACHABLE
;
157 if (is_promisor_object(&obj
->oid
))
159 * Further recursion does not need to be performed on this
160 * object since it is a promisor object (so it does not need to
161 * be added to "pending").
165 if (!(obj
->flags
& HAS_OBJ
)) {
166 if (parent
&& !has_object_file(&obj
->oid
)) {
167 printf_ln(_("broken link from %7s %s\n"
169 printable_type(parent
),
170 describe_object(parent
),
172 describe_object(obj
));
173 errors_found
|= ERROR_REACHABLE
;
178 add_object_array(obj
, NULL
, &pending
);
182 static void mark_object_reachable(struct object
*obj
)
184 mark_object(obj
, OBJ_ANY
, NULL
, NULL
);
187 static int traverse_one_object(struct object
*obj
)
189 int result
= fsck_walk(obj
, obj
, &fsck_walk_options
);
191 if (obj
->type
== OBJ_TREE
) {
192 struct tree
*tree
= (struct tree
*)obj
;
193 free_tree_buffer(tree
);
198 static int traverse_reachable(void)
200 struct progress
*progress
= NULL
;
204 progress
= start_delayed_progress(_("Checking connectivity"), 0);
206 result
|= traverse_one_object(object_array_pop(&pending
));
207 display_progress(progress
, ++nr
);
209 stop_progress(&progress
);
213 static int mark_used(struct object
*obj
, int type
, void *data
, struct fsck_options
*options
)
221 static void mark_unreachable_referents(const struct object_id
*oid
)
223 struct fsck_options options
= FSCK_OPTIONS_DEFAULT
;
224 struct object
*obj
= lookup_object(the_repository
, oid
);
226 if (!obj
|| !(obj
->flags
& HAS_OBJ
))
227 return; /* not part of our original set */
228 if (obj
->flags
& REACHABLE
)
229 return; /* reachable objects already traversed */
232 * Avoid passing OBJ_NONE to fsck_walk, which will parse the object
233 * (and we want to avoid parsing blobs).
235 if (obj
->type
== OBJ_NONE
) {
236 enum object_type type
= oid_object_info(the_repository
,
239 object_as_type(the_repository
, obj
, type
, 0);
242 options
.walk
= mark_used
;
243 fsck_walk(obj
, NULL
, &options
);
246 static int mark_loose_unreachable_referents(const struct object_id
*oid
,
250 mark_unreachable_referents(oid
);
254 static int mark_packed_unreachable_referents(const struct object_id
*oid
,
255 struct packed_git
*pack
,
259 mark_unreachable_referents(oid
);
264 * Check a single reachable object
266 static void check_reachable_object(struct object
*obj
)
269 * We obviously want the object to be parsed,
270 * except if it was in a pack-file and we didn't
273 if (!(obj
->flags
& HAS_OBJ
)) {
274 if (is_promisor_object(&obj
->oid
))
276 if (has_object_pack(&obj
->oid
))
277 return; /* it is in pack - forget about it */
278 printf_ln(_("missing %s %s"), printable_type(obj
),
279 describe_object(obj
));
280 errors_found
|= ERROR_REACHABLE
;
286 * Check a single unreachable object
288 static void check_unreachable_object(struct object
*obj
)
291 * Missing unreachable object? Ignore it. It's not like
292 * we miss it (since it can't be reached), nor do we want
293 * to complain about it being unreachable (since it does
296 if (!(obj
->flags
& HAS_OBJ
))
300 * Unreachable object that exists? Show it if asked to,
301 * since this is something that is prunable.
303 if (show_unreachable
) {
304 printf_ln(_("unreachable %s %s"), printable_type(obj
),
305 describe_object(obj
));
310 * "!USED" means that nothing at all points to it, including
311 * other unreachable objects. In other words, it's the "tip"
312 * of some set of unreachable objects, usually a commit that
315 * Such starting points are more interesting than some random
316 * set of unreachable objects, so we show them even if the user
317 * hasn't asked for _all_ unreachable objects. If you have
318 * deleted a branch by mistake, this is a prime candidate to
319 * start looking at, for example.
321 if (!(obj
->flags
& USED
)) {
323 printf_ln(_("dangling %s %s"), printable_type(obj
),
324 describe_object(obj
));
325 if (write_lost_and_found
) {
326 char *filename
= git_pathdup("lost-found/%s/%s",
327 obj
->type
== OBJ_COMMIT
? "commit" : "other",
328 describe_object(obj
));
331 if (safe_create_leading_directories_const(filename
)) {
332 error(_("could not create lost-found"));
336 f
= xfopen(filename
, "w");
337 if (obj
->type
== OBJ_BLOB
) {
338 if (stream_blob_to_fd(fileno(f
), &obj
->oid
, NULL
, 1))
339 die_errno(_("could not write '%s'"), filename
);
341 fprintf(f
, "%s\n", describe_object(obj
));
343 die_errno(_("could not finish '%s'"),
351 * Otherwise? It's there, it's unreachable, and some other unreachable
352 * object points to it. Ignore it - it's not interesting, and we showed
353 * all the interesting cases above.
357 static void check_object(struct object
*obj
)
360 fprintf_ln(stderr
, _("Checking %s"), describe_object(obj
));
362 if (obj
->flags
& REACHABLE
)
363 check_reachable_object(obj
);
365 check_unreachable_object(obj
);
368 static void check_connectivity(void)
372 /* Traverse the pending reachable objects */
373 traverse_reachable();
376 * With --connectivity-only, we won't have actually opened and marked
377 * unreachable objects with USED. Do that now to make --dangling, etc
380 if (connectivity_only
&& (show_dangling
|| write_lost_and_found
)) {
382 * Even though we already have a "struct object" for each of
383 * these in memory, we must not iterate over the internal
384 * object hash as we do below. Our loop would potentially
385 * resize the hash, making our iteration invalid.
387 * Instead, we'll just go back to the source list of objects,
388 * and ignore any that weren't present in our earlier
391 for_each_loose_object(mark_loose_unreachable_referents
, NULL
, 0);
392 for_each_packed_object(mark_packed_unreachable_referents
, NULL
, 0);
395 /* Look up all the requirements, warn about missing objects.. */
396 max
= get_max_object_index();
398 fprintf_ln(stderr
, _("Checking connectivity (%d objects)"), max
);
400 for (i
= 0; i
< max
; i
++) {
401 struct object
*obj
= get_indexed_object(i
);
408 static int fsck_obj(struct object
*obj
, void *buffer
, unsigned long size
)
412 if (obj
->flags
& SEEN
)
417 fprintf_ln(stderr
, _("Checking %s %s"),
418 printable_type(obj
), describe_object(obj
));
420 if (fsck_walk(obj
, NULL
, &fsck_obj_options
))
421 objerror(obj
, _("broken links"));
422 err
= fsck_object(obj
, buffer
, size
, &fsck_obj_options
);
426 if (obj
->type
== OBJ_COMMIT
) {
427 struct commit
*commit
= (struct commit
*) obj
;
429 if (!commit
->parents
&& show_root
)
430 printf_ln(_("root %s"),
431 describe_object(&commit
->object
));
434 if (obj
->type
== OBJ_TAG
) {
435 struct tag
*tag
= (struct tag
*) obj
;
437 if (show_tags
&& tag
->tagged
) {
438 printf_ln(_("tagged %s %s (%s) in %s"),
439 printable_type(tag
->tagged
),
440 describe_object(tag
->tagged
),
442 describe_object(&tag
->object
));
447 if (obj
->type
== OBJ_TREE
)
448 free_tree_buffer((struct tree
*)obj
);
449 if (obj
->type
== OBJ_COMMIT
)
450 free_commit_buffer(the_repository
->parsed_objects
,
451 (struct commit
*)obj
);
455 static int fsck_obj_buffer(const struct object_id
*oid
, enum object_type type
,
456 unsigned long size
, void *buffer
, int *eaten
)
459 * Note, buffer may be NULL if type is OBJ_BLOB. See
460 * verify_packfile(), data_valid variable for details.
463 obj
= parse_object_buffer(the_repository
, oid
, type
, size
, buffer
,
466 errors_found
|= ERROR_OBJECT
;
467 return error(_("%s: object corrupt or missing"),
470 obj
->flags
&= ~(REACHABLE
| SEEN
);
471 obj
->flags
|= HAS_OBJ
;
472 return fsck_obj(obj
, buffer
, size
);
475 static int default_refs
;
477 static void fsck_handle_reflog_oid(const char *refname
, struct object_id
*oid
,
478 timestamp_t timestamp
)
482 if (!is_null_oid(oid
)) {
483 obj
= lookup_object(the_repository
, oid
);
484 if (obj
&& (obj
->flags
& HAS_OBJ
)) {
486 fsck_put_object_name(&fsck_walk_options
, obj
,
490 mark_object_reachable(obj
);
491 } else if (!is_promisor_object(oid
)) {
492 error(_("%s: invalid reflog entry %s"),
493 refname
, oid_to_hex(oid
));
494 errors_found
|= ERROR_REACHABLE
;
499 static int fsck_handle_reflog_ent(struct object_id
*ooid
, struct object_id
*noid
,
500 const char *email
, timestamp_t timestamp
, int tz
,
501 const char *message
, void *cb_data
)
503 const char *refname
= cb_data
;
506 fprintf_ln(stderr
, _("Checking reflog %s->%s"),
507 oid_to_hex(ooid
), oid_to_hex(noid
));
509 fsck_handle_reflog_oid(refname
, ooid
, 0);
510 fsck_handle_reflog_oid(refname
, noid
, timestamp
);
514 static int fsck_handle_reflog(const char *logname
, const struct object_id
*oid
,
515 int flag
, void *cb_data
)
517 struct strbuf refname
= STRBUF_INIT
;
519 strbuf_worktree_ref(cb_data
, &refname
, logname
);
520 for_each_reflog_ent(refname
.buf
, fsck_handle_reflog_ent
, refname
.buf
);
521 strbuf_release(&refname
);
525 static int fsck_handle_ref(const char *refname
, const struct object_id
*oid
,
526 int flag
, void *cb_data
)
530 obj
= parse_object(the_repository
, oid
);
532 if (is_promisor_object(oid
)) {
534 * Increment default_refs anyway, because this is a
540 error(_("%s: invalid sha1 pointer %s"),
541 refname
, oid_to_hex(oid
));
542 errors_found
|= ERROR_REACHABLE
;
543 /* We'll continue with the rest despite the error.. */
546 if (obj
->type
!= OBJ_COMMIT
&& is_branch(refname
)) {
547 error(_("%s: not a commit"), refname
);
548 errors_found
|= ERROR_REFS
;
552 fsck_put_object_name(&fsck_walk_options
,
554 mark_object_reachable(obj
);
559 static int fsck_head_link(const char *head_ref_name
,
560 const char **head_points_at
,
561 struct object_id
*head_oid
);
563 static void get_default_heads(void)
565 struct worktree
**worktrees
, **p
;
566 const char *head_points_at
;
567 struct object_id head_oid
;
569 for_each_rawref(fsck_handle_ref
, NULL
);
571 worktrees
= get_worktrees(0);
572 for (p
= worktrees
; *p
; p
++) {
573 struct worktree
*wt
= *p
;
574 struct strbuf ref
= STRBUF_INIT
;
576 strbuf_worktree_ref(wt
, &ref
, "HEAD");
577 fsck_head_link(ref
.buf
, &head_points_at
, &head_oid
);
578 if (head_points_at
&& !is_null_oid(&head_oid
))
579 fsck_handle_ref(ref
.buf
, &head_oid
, 0, NULL
);
580 strbuf_release(&ref
);
583 refs_for_each_reflog(get_worktree_ref_store(wt
),
584 fsck_handle_reflog
, wt
);
586 free_worktrees(worktrees
);
589 * Not having any default heads isn't really fatal, but
590 * it does mean that "--unreachable" no longer makes any
591 * sense (since in this case everything will obviously
592 * be unreachable by definition.
594 * Showing dangling objects is valid, though (as those
595 * dangling objects are likely lost heads).
597 * So we just print a warning about it, and clear the
598 * "show_unreachable" flag.
601 fprintf_ln(stderr
, _("notice: No default references"));
602 show_unreachable
= 0;
606 static int fsck_loose(const struct object_id
*oid
, const char *path
, void *data
)
609 enum object_type type
;
614 if (read_loose_object(path
, oid
, &type
, &size
, &contents
) < 0) {
615 errors_found
|= ERROR_OBJECT
;
616 error(_("%s: object corrupt or missing: %s"),
617 oid_to_hex(oid
), path
);
618 return 0; /* keep checking other objects */
621 if (!contents
&& type
!= OBJ_BLOB
)
622 BUG("read_loose_object streamed a non-blob");
624 obj
= parse_object_buffer(the_repository
, oid
, type
, size
,
628 errors_found
|= ERROR_OBJECT
;
629 error(_("%s: object could not be parsed: %s"),
630 oid_to_hex(oid
), path
);
633 return 0; /* keep checking other objects */
636 obj
->flags
&= ~(REACHABLE
| SEEN
);
637 obj
->flags
|= HAS_OBJ
;
638 if (fsck_obj(obj
, contents
, size
))
639 errors_found
|= ERROR_OBJECT
;
643 return 0; /* keep checking other objects, even if we saw an error */
646 static int fsck_cruft(const char *basename
, const char *path
, void *data
)
648 if (!starts_with(basename
, "tmp_obj_"))
649 fprintf_ln(stderr
, _("bad sha1 file: %s"), path
);
653 static int fsck_subdir(unsigned int nr
, const char *path
, void *progress
)
655 display_progress(progress
, nr
+ 1);
659 static void fsck_object_dir(const char *path
)
661 struct progress
*progress
= NULL
;
664 fprintf_ln(stderr
, _("Checking object directory"));
667 progress
= start_progress(_("Checking object directories"), 256);
669 for_each_loose_file_in_objdir(path
, fsck_loose
, fsck_cruft
, fsck_subdir
,
671 display_progress(progress
, 256);
672 stop_progress(&progress
);
675 static int fsck_head_link(const char *head_ref_name
,
676 const char **head_points_at
,
677 struct object_id
*head_oid
)
679 int null_is_error
= 0;
682 fprintf_ln(stderr
, _("Checking %s link"), head_ref_name
);
684 *head_points_at
= resolve_ref_unsafe(head_ref_name
, 0, head_oid
, NULL
);
685 if (!*head_points_at
) {
686 errors_found
|= ERROR_REFS
;
687 return error(_("invalid %s"), head_ref_name
);
689 if (!strcmp(*head_points_at
, head_ref_name
))
692 else if (!starts_with(*head_points_at
, "refs/heads/")) {
693 errors_found
|= ERROR_REFS
;
694 return error(_("%s points to something strange (%s)"),
695 head_ref_name
, *head_points_at
);
697 if (is_null_oid(head_oid
)) {
699 errors_found
|= ERROR_REFS
;
700 return error(_("%s: detached HEAD points at nothing"),
704 _("notice: %s points to an unborn branch (%s)"),
705 head_ref_name
, *head_points_at
+ 11);
710 static int fsck_cache_tree(struct cache_tree
*it
)
716 fprintf_ln(stderr
, _("Checking cache tree"));
718 if (0 <= it
->entry_count
) {
719 struct object
*obj
= parse_object(the_repository
, &it
->oid
);
721 error(_("%s: invalid sha1 pointer in cache-tree"),
722 oid_to_hex(&it
->oid
));
723 errors_found
|= ERROR_REFS
;
727 fsck_put_object_name(&fsck_walk_options
, obj
, ":");
728 mark_object_reachable(obj
);
729 if (obj
->type
!= OBJ_TREE
)
730 err
|= objerror(obj
, _("non-tree in cache-tree"));
732 for (i
= 0; i
< it
->subtree_nr
; i
++)
733 err
|= fsck_cache_tree(it
->down
[i
]->cache_tree
);
737 static void mark_object_for_connectivity(const struct object_id
*oid
)
739 struct object
*obj
= lookup_unknown_object(oid
);
740 obj
->flags
|= HAS_OBJ
;
743 static int mark_loose_for_connectivity(const struct object_id
*oid
,
747 mark_object_for_connectivity(oid
);
751 static int mark_packed_for_connectivity(const struct object_id
*oid
,
752 struct packed_git
*pack
,
756 mark_object_for_connectivity(oid
);
760 static char const * const fsck_usage
[] = {
761 N_("git fsck [<options>] [<object>...]"),
765 static struct option fsck_opts
[] = {
766 OPT__VERBOSE(&verbose
, N_("be verbose")),
767 OPT_BOOL(0, "unreachable", &show_unreachable
, N_("show unreachable objects")),
768 OPT_BOOL(0, "dangling", &show_dangling
, N_("show dangling objects")),
769 OPT_BOOL(0, "tags", &show_tags
, N_("report tags")),
770 OPT_BOOL(0, "root", &show_root
, N_("report root nodes")),
771 OPT_BOOL(0, "cache", &keep_cache_objects
, N_("make index objects head nodes")),
772 OPT_BOOL(0, "reflogs", &include_reflogs
, N_("make reflogs head nodes (default)")),
773 OPT_BOOL(0, "full", &check_full
, N_("also consider packs and alternate objects")),
774 OPT_BOOL(0, "connectivity-only", &connectivity_only
, N_("check only connectivity")),
775 OPT_BOOL(0, "strict", &check_strict
, N_("enable more strict checking")),
776 OPT_BOOL(0, "lost-found", &write_lost_and_found
,
777 N_("write dangling objects in .git/lost-found")),
778 OPT_BOOL(0, "progress", &show_progress
, N_("show progress")),
779 OPT_BOOL(0, "name-objects", &name_objects
, N_("show verbose names for reachable objects")),
783 int cmd_fsck(int argc
, const char **argv
, const char *prefix
)
786 struct object_directory
*odb
;
788 /* fsck knows how to handle missing promisor objects */
789 fetch_if_missing
= 0;
792 read_replace_refs
= 0;
794 argc
= parse_options(argc
, argv
, prefix
, fsck_opts
, fsck_usage
, 0);
796 fsck_walk_options
.walk
= mark_object
;
797 fsck_obj_options
.walk
= mark_used
;
798 fsck_obj_options
.error_func
= fsck_error_func
;
800 fsck_obj_options
.strict
= 1;
802 if (show_progress
== -1)
803 show_progress
= isatty(2);
807 if (write_lost_and_found
) {
813 fsck_enable_object_names(&fsck_walk_options
);
815 git_config(fsck_config
, NULL
);
817 if (connectivity_only
) {
818 for_each_loose_object(mark_loose_for_connectivity
, NULL
, 0);
819 for_each_packed_object(mark_packed_for_connectivity
, NULL
, 0);
821 prepare_alt_odb(the_repository
);
822 for (odb
= the_repository
->objects
->odb
; odb
; odb
= odb
->next
)
823 fsck_object_dir(odb
->path
);
826 struct packed_git
*p
;
827 uint32_t total
= 0, count
= 0;
828 struct progress
*progress
= NULL
;
831 for (p
= get_all_packs(the_repository
); p
;
833 if (open_pack_index(p
))
835 total
+= p
->num_objects
;
838 progress
= start_progress(_("Checking objects"), total
);
840 for (p
= get_all_packs(the_repository
); p
;
842 /* verify gives error messages itself */
843 if (verify_pack(the_repository
,
846 errors_found
|= ERROR_PACK
;
847 count
+= p
->num_objects
;
849 stop_progress(&progress
);
852 if (fsck_finish(&fsck_obj_options
))
853 errors_found
|= ERROR_OBJECT
;
856 for (i
= 0; i
< argc
; i
++) {
857 const char *arg
= argv
[i
];
858 struct object_id oid
;
859 if (!get_oid(arg
, &oid
)) {
860 struct object
*obj
= lookup_object(the_repository
,
863 if (!obj
|| !(obj
->flags
& HAS_OBJ
)) {
864 if (is_promisor_object(&oid
))
866 error(_("%s: object missing"), oid_to_hex(&oid
));
867 errors_found
|= ERROR_OBJECT
;
872 fsck_put_object_name(&fsck_walk_options
, obj
,
874 mark_object_reachable(obj
);
877 error(_("invalid parameter: expected sha1, got '%s'"), arg
);
878 errors_found
|= ERROR_OBJECT
;
882 * If we've not been given any explicit head information, do the
883 * default ones from .git/refs. We also consider the index file
884 * in this case (ie this implies --cache).
888 keep_cache_objects
= 1;
891 if (keep_cache_objects
) {
892 verify_index_checksum
= 1;
895 for (i
= 0; i
< active_nr
; i
++) {
900 mode
= active_cache
[i
]->ce_mode
;
901 if (S_ISGITLINK(mode
))
903 blob
= lookup_blob(the_repository
,
904 &active_cache
[i
]->oid
);
909 fsck_put_object_name(&fsck_walk_options
, obj
,
910 ":%s", active_cache
[i
]->name
);
911 mark_object_reachable(obj
);
913 if (active_cache_tree
)
914 fsck_cache_tree(active_cache_tree
);
917 check_connectivity();
919 if (!git_config_get_bool("core.commitgraph", &i
) && i
) {
920 struct child_process commit_graph_verify
= CHILD_PROCESS_INIT
;
921 const char *verify_argv
[] = { "commit-graph", "verify", NULL
, NULL
, NULL
};
923 prepare_alt_odb(the_repository
);
924 for (odb
= the_repository
->objects
->odb
; odb
; odb
= odb
->next
) {
925 child_process_init(&commit_graph_verify
);
926 commit_graph_verify
.argv
= verify_argv
;
927 commit_graph_verify
.git_cmd
= 1;
928 verify_argv
[2] = "--object-dir";
929 verify_argv
[3] = odb
->path
;
930 if (run_command(&commit_graph_verify
))
931 errors_found
|= ERROR_COMMIT_GRAPH
;
935 if (!git_config_get_bool("core.multipackindex", &i
) && i
) {
936 struct child_process midx_verify
= CHILD_PROCESS_INIT
;
937 const char *midx_argv
[] = { "multi-pack-index", "verify", NULL
, NULL
, NULL
};
939 prepare_alt_odb(the_repository
);
940 for (odb
= the_repository
->objects
->odb
; odb
; odb
= odb
->next
) {
941 child_process_init(&midx_verify
);
942 midx_verify
.argv
= midx_argv
;
943 midx_verify
.git_cmd
= 1;
944 midx_argv
[2] = "--object-dir";
945 midx_argv
[3] = odb
->path
;
946 if (run_command(&midx_verify
))
947 errors_found
|= ERROR_COMMIT_GRAPH
;