From dbdb18170bdfce57cf29c042986dbd3b30952353 Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Thu, 20 Dec 2018 11:27:29 -0800 Subject: [PATCH] filter-repo: perf hack -- avoid expensive empty pruning checks If a commit was a non-merge commit previously, then since we do not do any kind of blob modifications (or funny parent grafting), there is no way for a filemodify instruction to introduce the same version of the file that already existed in the parent, as such the only check we need to do to determine whether a commit becomes empty is whether file_changes is empty. Subsequent more expensive checks can be skipped. Signed-off-by: Elijah Newren --- git-filter-repo | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/git-filter-repo b/git-filter-repo index 1bf07ca..fd37caa 100755 --- a/git-filter-repo +++ b/git-filter-repo @@ -1130,6 +1130,12 @@ class FastExportFilter(object): if not fast_import_pipes: return False + # Perf hack: since we don't support blob rewriting yet, non-merge commits + # can only be empty if commit.file_changes is empty, which we checked + # above. So return early in such a case. + if len(orig_parents) < 2: + return False + # Finally, the hard case: due to either blob rewriting, or due to pruning # of empty commits wiping out the first parent history back to the merge # base, the list of file_changes we have may not actually differ from our