filter-repo: prune commits that started empty if they now have no parents

If ancient history that pre-dated some subdirectory had a few empty
commits, we would rather those all got pruned as well.  Empty commits
from the original repository should only be retained if they have at
least one retained parent.

Signed-off-by: Elijah Newren <newren@gmail.com>
This commit is contained in:
Elijah Newren 2018-11-07 11:46:26 -08:00
parent e3fde7689c
commit 057947f6ff

View File

@ -987,9 +987,10 @@ class FastExportFilter(object):
# Now print the resulting commit, unless all its changes were dropped and
# it was a non-merge commit
merge_commit = len(commit.get_parents()) > 1
merge_commit = len(parents) > 1
if not commit.dumped:
if merge_commit or not had_file_changes or commit.file_changes:
if (commit.file_changes or merge_commit or
(not had_file_changes and len(parents) >= 1)):
commit.dump(self._output)
new_id = None
# Determine the mapping of old commit hash to new one