@ -23,6 +23,7 @@ static int show_tags;
static int show_unreachable;
static int show_unreachable;
static int include_reflogs = 1;
static int include_reflogs = 1;
static int check_full = 1;
static int check_full = 1;
static int connectivity_only;
static int check_strict;
static int check_strict;
static int keep_cache_objects;
static int keep_cache_objects;
static struct fsck_options fsck_walk_options = FSCK_OPTIONS_DEFAULT;
static struct fsck_options fsck_walk_options = FSCK_OPTIONS_DEFAULT;
@ -181,6 +182,8 @@ static void check_reachable_object(struct object *obj)
if (!(obj->flags & HAS_OBJ)) {
if (!(obj->flags & HAS_OBJ)) {
if (has_sha1_pack(obj->sha1))
if (has_sha1_pack(obj->sha1))
return; /* it is in pack - forget about it */
return; /* it is in pack - forget about it */
if (connectivity_only && has_sha1_file(obj->sha1))
return;
printf("missing %s %s\n", typename(obj->type), sha1_to_hex(obj->sha1));
printf("missing %s %s\n", typename(obj->type), sha1_to_hex(obj->sha1));
errors_found |= ERROR_REACHABLE;
errors_found |= ERROR_REACHABLE;
return;
return;
@ -617,6 +620,7 @@ static struct option fsck_opts[] = {
OPT_BOOL(0, "cache", &keep_cache_objects, N_("make index objects head nodes")),
OPT_BOOL(0, "cache", &keep_cache_objects, N_("make index objects head nodes")),
OPT_BOOL(0, "reflogs", &include_reflogs, N_("make reflogs head nodes (default)")),
OPT_BOOL(0, "reflogs", &include_reflogs, N_("make reflogs head nodes (default)")),
OPT_BOOL(0, "full", &check_full, N_("also consider packs and alternate objects")),
OPT_BOOL(0, "full", &check_full, N_("also consider packs and alternate objects")),
OPT_BOOL(0, "connectivity-only", &connectivity_only, N_("check only connectivity")),
OPT_BOOL(0, "strict", &check_strict, N_("enable more strict checking")),
OPT_BOOL(0, "strict", &check_strict, N_("enable more strict checking")),
OPT_BOOL(0, "lost-found", &write_lost_and_found,
OPT_BOOL(0, "lost-found", &write_lost_and_found,
N_("write dangling objects in .git/lost-found")),
N_("write dangling objects in .git/lost-found")),
@ -653,7 +657,8 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
git_config(fsck_config, NULL);
git_config(fsck_config, NULL);
fsck_head_link();
fsck_head_link();
fsck_object_dir(get_object_directory());
if (!connectivity_only)
fsck_object_dir(get_object_directory());
prepare_alt_odb();
prepare_alt_odb();
for (alt = alt_odb_list; alt; alt = alt->next) {
for (alt = alt_odb_list; alt; alt = alt->next) {