Skip to content

Commit cf96b39

Browse files
committed
Merge branch 'jk/fsck-on-diet' into maint-2.38
"git fsck" failed to release contents of tree objects already used from the memory, which has been fixed. * jk/fsck-on-diet: parse_object_buffer(): respect save_commit_buffer fsck: turn off save_commit_buffer fsck: free tree buffers after walking unreachable objects
2 parents 1655ac8 + 51b2774 commit cf96b39

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

builtin/fsck.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ static void mark_unreachable_referents(const struct object_id *oid)
228228

229229
options.walk = mark_used;
230230
fsck_walk(obj, NULL, &options);
231+
if (obj->type == OBJ_TREE)
232+
free_tree_buffer((struct tree *)obj);
231233
}
232234

233235
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)
437439
out:
438440
if (obj->type == OBJ_TREE)
439441
free_tree_buffer((struct tree *)obj);
440-
if (obj->type == OBJ_COMMIT)
441-
free_commit_buffer(the_repository->parsed_objects,
442-
(struct commit *)obj);
443442
return err;
444443
}
445444

@@ -853,6 +852,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
853852

854853
errors_found = 0;
855854
read_replace_refs = 0;
855+
save_commit_buffer = 0;
856856

857857
argc = parse_options(argc, argv, prefix, fsck_opts, fsck_usage, 0);
858858

object.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ struct object *parse_object_buffer(struct repository *r, const struct object_id
233233
if (commit) {
234234
if (parse_commit_buffer(r, commit, buffer, size, 1))
235235
return NULL;
236-
if (!get_cached_commit_buffer(r, commit, NULL)) {
236+
if (save_commit_buffer &&
237+
!get_cached_commit_buffer(r, commit, NULL)) {
237238
set_commit_buffer(r, commit, buffer, size);
238239
*eaten_p = 1;
239240
}

0 commit comments

Comments
 (0)