You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
merge() of an already merged branch creates an empty merge commit #6
Merging a branch that is already contained in HEAD creates a new merge commit every time. git answers "Already up to date." and leaves HEAD alone.
Repro
# main contains feature after a first merge
pitmaster merge feature # "Merge successful.", creates "Merge branch 'feature'"
pitmaster merge feature # "Merge successful." again, creates a second merge commit with the same tree
git log --oneline -3
# 643f58d Merge branch 'feature'# d5382c8 Merge branch 'feature'
Cause
merge() checks isAncestor($oursId, $theirsId) for the fast-forward case (
if ($mergeBaseFinder->isAncestor($oursId, $theirsId)) {
) but has no check for the reverse case ($theirsId already an ancestor of HEAD), so it falls through to the three-way path and createCommitFromTree() (L2321-L2322).
Expected
When the merged commit is an ancestor of (or equal to) HEAD, return a clean result without creating a commit or touching the working tree.
Activity