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 fsck_config(const char *var
, const char *value
, void *cb
)
76 if (strcmp(var
, "fsck.skiplist") == 0) {
78 struct strbuf sb
= STRBUF_INIT
;
80 if (git_config_pathname(&path
, var
, value
))
82 strbuf_addf(&sb
, "skiplist=%s", path
);
84 fsck_set_msg_types(&fsck_obj_options
, sb
.buf
);
89 if (skip_prefix(var
, "fsck.", &var
)) {
90 fsck_set_msg_type(&fsck_obj_options
, var
, value
);
94 return git_default_config(var
, value
, cb
);
97 static int objerror(struct object
*obj
, const char *err
)
99 errors_found
|= ERROR_OBJECT
;
100 /* TRANSLATORS: e.g. error in tree 01bfda: <more explanation> */
101 fprintf_ln(stderr
, _("error in %s %s: %s"),
102 printable_type(&obj
->oid
, obj
->type
),
103 describe_object(&obj
->oid
), err
);
107 static int fsck_error_func(struct fsck_options
*o
,
108 const struct object_id
*oid
,
109 enum object_type object_type
,
110 int msg_type
, const char *message
)
114 /* TRANSLATORS: e.g. warning in tree 01bfda: <more explanation> */
115 fprintf_ln(stderr
, _("warning in %s %s: %s"),
116 printable_type(oid
, object_type
),
117 describe_object(oid
), message
);
120 /* TRANSLATORS: e.g. error in tree 01bfda: <more explanation> */
121 fprintf_ln(stderr
, _("error in %s %s: %s"),
122 printable_type(oid
, object_type
),
123 describe_object(oid
), message
);
126 BUG("%d (FSCK_IGNORE?) should never trigger this callback",
131 static struct object_array pending
;
133 static int mark_object(struct object
*obj
, int type
, void *data
, struct fsck_options
*options
)
135 struct object
*parent
= data
;
138 * The only case data is NULL or type is OBJ_ANY is when
139 * mark_object_reachable() calls us. All the callers of
140 * that function has non-NULL obj hence ...
143 /* ... these references to parent->fld are safe here */
144 printf_ln(_("broken link from %7s %s"),
145 printable_type(&parent
->oid
, parent
->type
),
146 describe_object(&parent
->oid
));
147 printf_ln(_("broken link from %7s %s"),
148 (type
== OBJ_ANY
? _("unknown") : type_name(type
)),
150 errors_found
|= ERROR_REACHABLE
;
154 if (type
!= OBJ_ANY
&& obj
->type
!= type
)
155 /* ... and the reference to parent is safe here */
156 objerror(parent
, _("wrong object type in link"));
158 if (obj
->flags
& REACHABLE
)
160 obj
->flags
|= REACHABLE
;
162 if (is_promisor_object(&obj
->oid
))
164 * Further recursion does not need to be performed on this
165 * object since it is a promisor object (so it does not need to
166 * be added to "pending").
170 if (!(obj
->flags
& HAS_OBJ
)) {
171 if (parent
&& !has_object(the_repository
, &obj
->oid
, 1)) {
172 printf_ln(_("broken link from %7s %s\n"
174 printable_type(&parent
->oid
, parent
->type
),
175 describe_object(&parent
->oid
),
176 printable_type(&obj
->oid
, obj
->type
),
177 describe_object(&obj
->oid
));
178 errors_found
|= ERROR_REACHABLE
;
183 add_object_array(obj
, NULL
, &pending
);
187 static void mark_object_reachable(struct object
*obj
)
189 mark_object(obj
, OBJ_ANY
, NULL
, NULL
);
192 static int traverse_one_object(struct object
*obj
)
194 int result
= fsck_walk(obj
, obj
, &fsck_walk_options
);
196 if (obj
->type
== OBJ_TREE
) {
197 struct tree
*tree
= (struct tree
*)obj
;
198 free_tree_buffer(tree
);
203 static int traverse_reachable(void)
205 struct progress
*progress
= NULL
;
209 progress
= start_delayed_progress(_("Checking connectivity"), 0);
211 result
|= traverse_one_object(object_array_pop(&pending
));
212 display_progress(progress
, ++nr
);
214 stop_progress(&progress
);
218 static int mark_used(struct object
*obj
, int type
, void *data
, struct fsck_options
*options
)
226 static void mark_unreachable_referents(const struct object_id
*oid
)
228 struct fsck_options options
= FSCK_OPTIONS_DEFAULT
;
229 struct object
*obj
= lookup_object(the_repository
, oid
);
231 if (!obj
|| !(obj
->flags
& HAS_OBJ
))
232 return; /* not part of our original set */
233 if (obj
->flags
& REACHABLE
)
234 return; /* reachable objects already traversed */
237 * Avoid passing OBJ_NONE to fsck_walk, which will parse the object
238 * (and we want to avoid parsing blobs).
240 if (obj
->type
== OBJ_NONE
) {
241 enum object_type type
= oid_object_info(the_repository
,
244 object_as_type(obj
, type
, 0);
247 options
.walk
= mark_used
;
248 fsck_walk(obj
, NULL
, &options
);
251 static int mark_loose_unreachable_referents(const struct object_id
*oid
,
255 mark_unreachable_referents(oid
);
259 static int mark_packed_unreachable_referents(const struct object_id
*oid
,
260 struct packed_git
*pack
,
264 mark_unreachable_referents(oid
);
269 * Check a single reachable object
271 static void check_reachable_object(struct object
*obj
)
274 * We obviously want the object to be parsed,
275 * except if it was in a pack-file and we didn't
278 if (!(obj
->flags
& HAS_OBJ
)) {
279 if (is_promisor_object(&obj
->oid
))
281 if (has_object_pack(&obj
->oid
))
282 return; /* it is in pack - forget about it */
283 printf_ln(_("missing %s %s"),
284 printable_type(&obj
->oid
, obj
->type
),
285 describe_object(&obj
->oid
));
286 errors_found
|= ERROR_REACHABLE
;
292 * Check a single unreachable object
294 static void check_unreachable_object(struct object
*obj
)
297 * Missing unreachable object? Ignore it. It's not like
298 * we miss it (since it can't be reached), nor do we want
299 * to complain about it being unreachable (since it does
302 if (!(obj
->flags
& HAS_OBJ
))
306 * Unreachable object that exists? Show it if asked to,
307 * since this is something that is prunable.
309 if (show_unreachable
) {
310 printf_ln(_("unreachable %s %s"),
311 printable_type(&obj
->oid
, obj
->type
),
312 describe_object(&obj
->oid
));
317 * "!USED" means that nothing at all points to it, including
318 * other unreachable objects. In other words, it's the "tip"
319 * of some set of unreachable objects, usually a commit that
322 * Such starting points are more interesting than some random
323 * set of unreachable objects, so we show them even if the user
324 * hasn't asked for _all_ unreachable objects. If you have
325 * deleted a branch by mistake, this is a prime candidate to
326 * start looking at, for example.
328 if (!(obj
->flags
& USED
)) {
330 printf_ln(_("dangling %s %s"),
331 printable_type(&obj
->oid
, obj
->type
),
332 describe_object(&obj
->oid
));
333 if (write_lost_and_found
) {
334 char *filename
= git_pathdup("lost-found/%s/%s",
335 obj
->type
== OBJ_COMMIT
? "commit" : "other",
336 describe_object(&obj
->oid
));
339 if (safe_create_leading_directories_const(filename
)) {
340 error(_("could not create lost-found"));
344 f
= xfopen(filename
, "w");
345 if (obj
->type
== OBJ_BLOB
) {
346 if (stream_blob_to_fd(fileno(f
), &obj
->oid
, NULL
, 1))
347 die_errno(_("could not write '%s'"), filename
);
349 fprintf(f
, "%s\n", describe_object(&obj
->oid
));
351 die_errno(_("could not finish '%s'"),
359 * Otherwise? It's there, it's unreachable, and some other unreachable
360 * object points to it. Ignore it - it's not interesting, and we showed
361 * all the interesting cases above.
365 static void check_object(struct object
*obj
)
368 fprintf_ln(stderr
, _("Checking %s"), describe_object(&obj
->oid
));
370 if (obj
->flags
& REACHABLE
)
371 check_reachable_object(obj
);
373 check_unreachable_object(obj
);
376 static void check_connectivity(void)
380 /* Traverse the pending reachable objects */
381 traverse_reachable();
384 * With --connectivity-only, we won't have actually opened and marked
385 * unreachable objects with USED. Do that now to make --dangling, etc
388 if (connectivity_only
&& (show_dangling
|| write_lost_and_found
)) {
390 * Even though we already have a "struct object" for each of
391 * these in memory, we must not iterate over the internal
392 * object hash as we do below. Our loop would potentially
393 * resize the hash, making our iteration invalid.
395 * Instead, we'll just go back to the source list of objects,
396 * and ignore any that weren't present in our earlier
399 for_each_loose_object(mark_loose_unreachable_referents
, NULL
, 0);
400 for_each_packed_object(mark_packed_unreachable_referents
, NULL
, 0);
403 /* Look up all the requirements, warn about missing objects.. */
404 max
= get_max_object_index();
406 fprintf_ln(stderr
, _("Checking connectivity (%d objects)"), max
);
408 for (i
= 0; i
< max
; i
++) {
409 struct object
*obj
= get_indexed_object(i
);
416 static int fsck_obj(struct object
*obj
, void *buffer
, unsigned long size
)
420 if (obj
->flags
& SEEN
)
425 fprintf_ln(stderr
, _("Checking %s %s"),
426 printable_type(&obj
->oid
, obj
->type
),
427 describe_object(&obj
->oid
));
429 if (fsck_walk(obj
, NULL
, &fsck_obj_options
))
430 objerror(obj
, _("broken links"));
431 err
= fsck_object(obj
, buffer
, size
, &fsck_obj_options
);
435 if (obj
->type
== OBJ_COMMIT
) {
436 struct commit
*commit
= (struct commit
*) obj
;
438 if (!commit
->parents
&& show_root
)
439 printf_ln(_("root %s"),
440 describe_object(&commit
->object
.oid
));
443 if (obj
->type
== OBJ_TAG
) {
444 struct tag
*tag
= (struct tag
*) obj
;
446 if (show_tags
&& tag
->tagged
) {
447 printf_ln(_("tagged %s %s (%s) in %s"),
448 printable_type(&tag
->tagged
->oid
, tag
->tagged
->type
),
449 describe_object(&tag
->tagged
->oid
),
451 describe_object(&tag
->object
.oid
));
456 if (obj
->type
== OBJ_TREE
)
457 free_tree_buffer((struct tree
*)obj
);
458 if (obj
->type
== OBJ_COMMIT
)
459 free_commit_buffer(the_repository
->parsed_objects
,
460 (struct commit
*)obj
);
464 static int fsck_obj_buffer(const struct object_id
*oid
, enum object_type type
,
465 unsigned long size
, void *buffer
, int *eaten
)
468 * Note, buffer may be NULL if type is OBJ_BLOB. See
469 * verify_packfile(), data_valid variable for details.
472 obj
= parse_object_buffer(the_repository
, oid
, type
, size
, buffer
,
475 errors_found
|= ERROR_OBJECT
;
476 return error(_("%s: object corrupt or missing"),
479 obj
->flags
&= ~(REACHABLE
| SEEN
);
480 obj
->flags
|= HAS_OBJ
;
481 return fsck_obj(obj
, buffer
, size
);
484 static int default_refs
;
486 static void fsck_handle_reflog_oid(const char *refname
, struct object_id
*oid
,
487 timestamp_t timestamp
)
491 if (!is_null_oid(oid
)) {
492 obj
= lookup_object(the_repository
, oid
);
493 if (obj
&& (obj
->flags
& HAS_OBJ
)) {
495 fsck_put_object_name(&fsck_walk_options
, oid
,
499 mark_object_reachable(obj
);
500 } else if (!is_promisor_object(oid
)) {
501 error(_("%s: invalid reflog entry %s"),
502 refname
, oid_to_hex(oid
));
503 errors_found
|= ERROR_REACHABLE
;
508 static int fsck_handle_reflog_ent(struct object_id
*ooid
, struct object_id
*noid
,
509 const char *email
, timestamp_t timestamp
, int tz
,
510 const char *message
, void *cb_data
)
512 const char *refname
= cb_data
;
515 fprintf_ln(stderr
, _("Checking reflog %s->%s"),
516 oid_to_hex(ooid
), oid_to_hex(noid
));
518 fsck_handle_reflog_oid(refname
, ooid
, 0);
519 fsck_handle_reflog_oid(refname
, noid
, timestamp
);
523 static int fsck_handle_reflog(const char *logname
, const struct object_id
*oid
,
524 int flag
, void *cb_data
)
526 struct strbuf refname
= STRBUF_INIT
;
528 strbuf_worktree_ref(cb_data
, &refname
, logname
);
529 for_each_reflog_ent(refname
.buf
, fsck_handle_reflog_ent
, refname
.buf
);
530 strbuf_release(&refname
);
534 static int fsck_handle_ref(const char *refname
, const struct object_id
*oid
,
535 int flag
, void *cb_data
)
539 obj
= parse_object(the_repository
, oid
);
541 if (is_promisor_object(oid
)) {
543 * Increment default_refs anyway, because this is a
549 error(_("%s: invalid sha1 pointer %s"),
550 refname
, oid_to_hex(oid
));
551 errors_found
|= ERROR_REACHABLE
;
552 /* We'll continue with the rest despite the error.. */
555 if (obj
->type
!= OBJ_COMMIT
&& is_branch(refname
)) {
556 error(_("%s: not a commit"), refname
);
557 errors_found
|= ERROR_REFS
;
561 fsck_put_object_name(&fsck_walk_options
,
563 mark_object_reachable(obj
);
568 static int fsck_head_link(const char *head_ref_name
,
569 const char **head_points_at
,
570 struct object_id
*head_oid
);
572 static void get_default_heads(void)
574 struct worktree
**worktrees
, **p
;
575 const char *head_points_at
;
576 struct object_id head_oid
;
578 for_each_rawref(fsck_handle_ref
, NULL
);
580 worktrees
= get_worktrees();
581 for (p
= worktrees
; *p
; p
++) {
582 struct worktree
*wt
= *p
;
583 struct strbuf ref
= STRBUF_INIT
;
585 strbuf_worktree_ref(wt
, &ref
, "HEAD");
586 fsck_head_link(ref
.buf
, &head_points_at
, &head_oid
);
587 if (head_points_at
&& !is_null_oid(&head_oid
))
588 fsck_handle_ref(ref
.buf
, &head_oid
, 0, NULL
);
589 strbuf_release(&ref
);
592 refs_for_each_reflog(get_worktree_ref_store(wt
),
593 fsck_handle_reflog
, wt
);
595 free_worktrees(worktrees
);
598 * Not having any default heads isn't really fatal, but
599 * it does mean that "--unreachable" no longer makes any
600 * sense (since in this case everything will obviously
601 * be unreachable by definition.
603 * Showing dangling objects is valid, though (as those
604 * dangling objects are likely lost heads).
606 * So we just print a warning about it, and clear the
607 * "show_unreachable" flag.
610 fprintf_ln(stderr
, _("notice: No default references"));
611 show_unreachable
= 0;
615 static int fsck_loose(const struct object_id
*oid
, const char *path
, void *data
)
618 enum object_type type
;
623 if (read_loose_object(path
, oid
, &type
, &size
, &contents
) < 0) {
624 errors_found
|= ERROR_OBJECT
;
625 error(_("%s: object corrupt or missing: %s"),
626 oid_to_hex(oid
), path
);
627 return 0; /* keep checking other objects */
630 if (!contents
&& type
!= OBJ_BLOB
)
631 BUG("read_loose_object streamed a non-blob");
633 obj
= parse_object_buffer(the_repository
, oid
, type
, size
,
637 errors_found
|= ERROR_OBJECT
;
638 error(_("%s: object could not be parsed: %s"),
639 oid_to_hex(oid
), path
);
642 return 0; /* keep checking other objects */
645 obj
->flags
&= ~(REACHABLE
| SEEN
);
646 obj
->flags
|= HAS_OBJ
;
647 if (fsck_obj(obj
, contents
, size
))
648 errors_found
|= ERROR_OBJECT
;
652 return 0; /* keep checking other objects, even if we saw an error */
655 static int fsck_cruft(const char *basename
, const char *path
, void *data
)
657 if (!starts_with(basename
, "tmp_obj_"))
658 fprintf_ln(stderr
, _("bad sha1 file: %s"), path
);
662 static int fsck_subdir(unsigned int nr
, const char *path
, void *progress
)
664 display_progress(progress
, nr
+ 1);
668 static void fsck_object_dir(const char *path
)
670 struct progress
*progress
= NULL
;
673 fprintf_ln(stderr
, _("Checking object directory"));
676 progress
= start_progress(_("Checking object directories"), 256);
678 for_each_loose_file_in_objdir(path
, fsck_loose
, fsck_cruft
, fsck_subdir
,
680 display_progress(progress
, 256);
681 stop_progress(&progress
);
684 static int fsck_head_link(const char *head_ref_name
,
685 const char **head_points_at
,
686 struct object_id
*head_oid
)
688 int null_is_error
= 0;
691 fprintf_ln(stderr
, _("Checking %s link"), head_ref_name
);
693 *head_points_at
= resolve_ref_unsafe(head_ref_name
, 0, head_oid
, NULL
);
694 if (!*head_points_at
) {
695 errors_found
|= ERROR_REFS
;
696 return error(_("invalid %s"), head_ref_name
);
698 if (!strcmp(*head_points_at
, head_ref_name
))
701 else if (!starts_with(*head_points_at
, "refs/heads/")) {
702 errors_found
|= ERROR_REFS
;
703 return error(_("%s points to something strange (%s)"),
704 head_ref_name
, *head_points_at
);
706 if (is_null_oid(head_oid
)) {
708 errors_found
|= ERROR_REFS
;
709 return error(_("%s: detached HEAD points at nothing"),
713 _("notice: %s points to an unborn branch (%s)"),
714 head_ref_name
, *head_points_at
+ 11);
719 static int fsck_cache_tree(struct cache_tree
*it
)
725 fprintf_ln(stderr
, _("Checking cache tree"));
727 if (0 <= it
->entry_count
) {
728 struct object
*obj
= parse_object(the_repository
, &it
->oid
);
730 error(_("%s: invalid sha1 pointer in cache-tree"),
731 oid_to_hex(&it
->oid
));
732 errors_found
|= ERROR_REFS
;
736 fsck_put_object_name(&fsck_walk_options
, &it
->oid
, ":");
737 mark_object_reachable(obj
);
738 if (obj
->type
!= OBJ_TREE
)
739 err
|= objerror(obj
, _("non-tree in cache-tree"));
741 for (i
= 0; i
< it
->subtree_nr
; i
++)
742 err
|= fsck_cache_tree(it
->down
[i
]->cache_tree
);
746 static void mark_object_for_connectivity(const struct object_id
*oid
)
748 struct object
*obj
= lookup_unknown_object(oid
);
749 obj
->flags
|= HAS_OBJ
;
752 static int mark_loose_for_connectivity(const struct object_id
*oid
,
756 mark_object_for_connectivity(oid
);
760 static int mark_packed_for_connectivity(const struct object_id
*oid
,
761 struct packed_git
*pack
,
765 mark_object_for_connectivity(oid
);
769 static char const * const fsck_usage
[] = {
770 N_("git fsck [<options>] [<object>...]"),
774 static struct option fsck_opts
[] = {
775 OPT__VERBOSE(&verbose
, N_("be verbose")),
776 OPT_BOOL(0, "unreachable", &show_unreachable
, N_("show unreachable objects")),
777 OPT_BOOL(0, "dangling", &show_dangling
, N_("show dangling objects")),
778 OPT_BOOL(0, "tags", &show_tags
, N_("report tags")),
779 OPT_BOOL(0, "root", &show_root
, N_("report root nodes")),
780 OPT_BOOL(0, "cache", &keep_cache_objects
, N_("make index objects head nodes")),
781 OPT_BOOL(0, "reflogs", &include_reflogs
, N_("make reflogs head nodes (default)")),
782 OPT_BOOL(0, "full", &check_full
, N_("also consider packs and alternate objects")),
783 OPT_BOOL(0, "connectivity-only", &connectivity_only
, N_("check only connectivity")),
784 OPT_BOOL(0, "strict", &check_strict
, N_("enable more strict checking")),
785 OPT_BOOL(0, "lost-found", &write_lost_and_found
,
786 N_("write dangling objects in .git/lost-found")),
787 OPT_BOOL(0, "progress", &show_progress
, N_("show progress")),
788 OPT_BOOL(0, "name-objects", &name_objects
, N_("show verbose names for reachable objects")),
792 int cmd_fsck(int argc
, const char **argv
, const char *prefix
)
795 struct object_directory
*odb
;
797 /* fsck knows how to handle missing promisor objects */
798 fetch_if_missing
= 0;
801 read_replace_refs
= 0;
803 argc
= parse_options(argc
, argv
, prefix
, fsck_opts
, fsck_usage
, 0);
805 fsck_walk_options
.walk
= mark_object
;
806 fsck_obj_options
.walk
= mark_used
;
807 fsck_obj_options
.error_func
= fsck_error_func
;
809 fsck_obj_options
.strict
= 1;
811 if (show_progress
== -1)
812 show_progress
= isatty(2);
816 if (write_lost_and_found
) {
822 fsck_enable_object_names(&fsck_walk_options
);
824 git_config(fsck_config
, NULL
);
826 if (connectivity_only
) {
827 for_each_loose_object(mark_loose_for_connectivity
, NULL
, 0);
828 for_each_packed_object(mark_packed_for_connectivity
, NULL
, 0);
830 prepare_alt_odb(the_repository
);
831 for (odb
= the_repository
->objects
->odb
; odb
; odb
= odb
->next
)
832 fsck_object_dir(odb
->path
);
835 struct packed_git
*p
;
836 uint32_t total
= 0, count
= 0;
837 struct progress
*progress
= NULL
;
840 for (p
= get_all_packs(the_repository
); p
;
842 if (open_pack_index(p
))
844 total
+= p
->num_objects
;
847 progress
= start_progress(_("Checking objects"), total
);
849 for (p
= get_all_packs(the_repository
); p
;
851 /* verify gives error messages itself */
852 if (verify_pack(the_repository
,
855 errors_found
|= ERROR_PACK
;
856 count
+= p
->num_objects
;
858 stop_progress(&progress
);
861 if (fsck_finish(&fsck_obj_options
))
862 errors_found
|= ERROR_OBJECT
;
865 for (i
= 0; i
< argc
; i
++) {
866 const char *arg
= argv
[i
];
867 struct object_id oid
;
868 if (!get_oid(arg
, &oid
)) {
869 struct object
*obj
= lookup_object(the_repository
,
872 if (!obj
|| !(obj
->flags
& HAS_OBJ
)) {
873 if (is_promisor_object(&oid
))
875 error(_("%s: object missing"), oid_to_hex(&oid
));
876 errors_found
|= ERROR_OBJECT
;
881 fsck_put_object_name(&fsck_walk_options
, &oid
,
883 mark_object_reachable(obj
);
886 error(_("invalid parameter: expected sha1, got '%s'"), arg
);
887 errors_found
|= ERROR_OBJECT
;
891 * If we've not been given any explicit head information, do the
892 * default ones from .git/refs. We also consider the index file
893 * in this case (ie this implies --cache).
897 keep_cache_objects
= 1;
900 if (keep_cache_objects
) {
901 verify_index_checksum
= 1;
904 for (i
= 0; i
< active_nr
; i
++) {
909 mode
= active_cache
[i
]->ce_mode
;
910 if (S_ISGITLINK(mode
))
912 blob
= lookup_blob(the_repository
,
913 &active_cache
[i
]->oid
);
918 fsck_put_object_name(&fsck_walk_options
, &obj
->oid
,
919 ":%s", active_cache
[i
]->name
);
920 mark_object_reachable(obj
);
922 if (active_cache_tree
)
923 fsck_cache_tree(active_cache_tree
);
926 check_connectivity();
928 if (!git_config_get_bool("core.commitgraph", &i
) && i
) {
929 struct child_process commit_graph_verify
= CHILD_PROCESS_INIT
;
930 const char *verify_argv
[] = { "commit-graph", "verify", NULL
, NULL
, NULL
};
932 prepare_alt_odb(the_repository
);
933 for (odb
= the_repository
->objects
->odb
; odb
; odb
= odb
->next
) {
934 child_process_init(&commit_graph_verify
);
935 commit_graph_verify
.argv
= verify_argv
;
936 commit_graph_verify
.git_cmd
= 1;
937 verify_argv
[2] = "--object-dir";
938 verify_argv
[3] = odb
->path
;
939 if (run_command(&commit_graph_verify
))
940 errors_found
|= ERROR_COMMIT_GRAPH
;
944 if (!git_config_get_bool("core.multipackindex", &i
) && i
) {
945 struct child_process midx_verify
= CHILD_PROCESS_INIT
;
946 const char *midx_argv
[] = { "multi-pack-index", "verify", NULL
, NULL
, NULL
};
948 prepare_alt_odb(the_repository
);
949 for (odb
= the_repository
->objects
->odb
; odb
; odb
= odb
->next
) {
950 child_process_init(&midx_verify
);
951 midx_verify
.argv
= midx_argv
;
952 midx_verify
.git_cmd
= 1;
953 midx_argv
[2] = "--object-dir";
954 midx_argv
[3] = odb
->path
;
955 if (run_command(&midx_verify
))
956 errors_found
|= ERROR_MULTI_PACK_INDEX
;