mirror of
https://github.com/newren/git-filter-repo.git
synced 2024-07-06 18:32:14 +02:00
filter-repo: handle tags pointing at commits pruned along with their history
If a tag points at a commit whose changes are all filtered out and thus becomes empty and gets pruned, and all of its ancestors are likewise pruned, then there is no need for the tag; just nuke it. Signed-off-by: Elijah Newren <newren@gmail.com>
This commit is contained in:
parent
77d5e93135
commit
37c92d9352
@ -1154,8 +1154,6 @@ class FastExportFilter(object):
|
||||
# Parse the Tag
|
||||
tag = self._parse_ref_line('tag')
|
||||
from_ref = self._parse_optional_parent_ref('from')
|
||||
if from_ref is None:
|
||||
raise SystemExit("Expected 'from' line while parsing tag %s" % tag)
|
||||
|
||||
original_id = None
|
||||
if self._currentline.startswith('original-oid'):
|
||||
@ -1177,8 +1175,17 @@ class FastExportFilter(object):
|
||||
if self._everything_callback:
|
||||
self._everything_callback('tag', tag)
|
||||
|
||||
# Now print the resulting reset
|
||||
if not tag.dumped:
|
||||
# The tag might not point at anything that still exists ( self.from_ref
|
||||
# will be None if the commit it pointed to and all its ancestors were
|
||||
# pruned due to being empty)
|
||||
if not tag.from_ref:
|
||||
# If everything in the history of this tag was pruned, we need to delete
|
||||
# the fact that it was seen so that refs_to_nuke will include it and
|
||||
# wipe out the original version of that tag.
|
||||
full_ref = 'refs/tags/{}'.format(tag.ref)
|
||||
if full_ref in self._seen_refs:
|
||||
del self._seen_refs[full_ref]
|
||||
elif not tag.dumped:
|
||||
tag.dump(self._output)
|
||||
|
||||
def _parse_progress(self):
|
||||
|
Loading…
Reference in New Issue
Block a user