Skip to content
  • CB Bailey's avatar
    filter-branch: eliminate duplicate mapped parents · 79bc4ef3
    CB Bailey authored and Junio C Hamano's avatar Junio C Hamano committed
    
    
    When multiple parents of a merge commit get mapped to the same
    commit, filter-branch used to pass all instances of the parent
    commit to the parent and commit filters and to "git commit-tree" or
    "git_commit_non_empty_tree".
    
    This can often happen when extracting a small project from a large
    repository; merges can join history with no commits on any branch
    which affect the paths being retained.  Once the intermediate
    commits have been filtered out, all the immediate parents of the
    merge commit can end up being mapped to the same commit - either the
    original merge-base or an ancestor of it.
    
    "git commit-tree" would display an error but write the commit with
    the normalized parents in any case.  "git_commit_non_empty_tree"
    would fail to notice that the commit being made was in fact a
    non-merge commit and would retain it even if a further pass with
    "--prune-empty" would discard the commit as empty.
    
    Ensure that duplicate parents are pruned before the parent filter to
    make "--prune-empty" idempotent, removing all empty non-merge
    commits in a singe pass.
    
    Signed-off-by: default avatarCharles Bailey <cbailey32@bloomberg.net>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    79bc4ef3