log: clean unneeded objects during log --remerge-diff

The --remerge-diff option will need to create new blobs and trees
representing the "automatic merge" state.  If one is traversing a
long project history, one can easily get hundreds of thousands of
loose objects generated during `log --remerge-diff`.  However, none of
those loose objects are needed after we have completed our diff
operation; they can be summarily deleted.

Add a new helper function to tmp_objdir to discard all the contained
objects, and call it after each merge is handled.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Elijah Newren
2022-02-02 02:37:29 +00:00
committed by Junio C Hamano
parent db757e8b8d
commit 7b90ab467a
5 changed files with 28 additions and 7 deletions

View File

@ -79,6 +79,11 @@ static void remove_tmp_objdir_on_signal(int signo)
raise(signo);
}
void tmp_objdir_discard_objects(struct tmp_objdir *t)
{
remove_dir_recursively(&t->path, REMOVE_DIR_KEEP_TOPLEVEL);
}
/*
* These env_* functions are for setting up the child environment; the
* "replace" variant overrides the value of any existing variable with that