diff --git a/builtin/fsck.c b/builtin/fsck.c index f7916f06ed..41acbc229e 100644 --- a/builtin/fsck.c +++ b/builtin/fsck.c @@ -228,6 +228,8 @@ static void mark_unreachable_referents(const struct object_id *oid) options.walk = mark_used; fsck_walk(obj, NULL, &options); + if (obj->type == OBJ_TREE) + free_tree_buffer((struct tree *)obj); } static int mark_loose_unreachable_referents(const struct object_id *oid, @@ -437,9 +439,6 @@ static int fsck_obj(struct object *obj, void *buffer, unsigned long size) out: if (obj->type == OBJ_TREE) free_tree_buffer((struct tree *)obj); - if (obj->type == OBJ_COMMIT) - free_commit_buffer(the_repository->parsed_objects, - (struct commit *)obj); return err; } @@ -853,6 +852,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix) errors_found = 0; read_replace_refs = 0; + save_commit_buffer = 0; argc = parse_options(argc, argv, prefix, fsck_opts, fsck_usage, 0); diff --git a/object.c b/object.c index 2e4589bae5..8a74eb85e9 100644 --- a/object.c +++ b/object.c @@ -233,7 +233,8 @@ struct object *parse_object_buffer(struct repository *r, const struct object_id if (commit) { if (parse_commit_buffer(r, commit, buffer, size, 1)) return NULL; - if (!get_cached_commit_buffer(r, commit, NULL)) { + if (save_commit_buffer && + !get_cached_commit_buffer(r, commit, NULL)) { set_commit_buffer(r, commit, buffer, size); *eaten_p = 1; }