зеркало из https://github.com/microsoft/git.git
subtree: improve decision on merges kept in split
When multiple identical parents are detected for a commit being considered for copying, explicitly check whether one is the common merge base between the commits. If so, the other commit can be used as the identical parent; if not, a merge must be performed to maintain history. In some situations two parents of a merge commit may appear to both have identical subtree content with each other and the current commit. However, those parents can potentially come from different commit graphs. Previous behavior would simply select one of the identical parents to serve as the replacement for this commit, based on the order in which they were processed. New behavior compares the merge base between the commits to determine if a new merge commit is necessary to maintain history despite the identical content. Signed-off-by: Strain, Roger L <roger.strain@swri.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
315a84f9aa
Коммит
68f8ff8151
|
@ -541,6 +541,7 @@ copy_or_skip () {
|
|||
nonidentical=
|
||||
p=
|
||||
gotparents=
|
||||
copycommit=
|
||||
for parent in $newparents
|
||||
do
|
||||
ptree=$(toptree_for_commit $parent) || exit $?
|
||||
|
@ -548,7 +549,24 @@ copy_or_skip () {
|
|||
if test "$ptree" = "$tree"
|
||||
then
|
||||
# an identical parent could be used in place of this rev.
|
||||
identical="$parent"
|
||||
if test -n "$identical"
|
||||
then
|
||||
# if a previous identical parent was found, check whether
|
||||
# one is already an ancestor of the other
|
||||
mergebase=$(git merge-base $identical $parent)
|
||||
if test "$identical" = "$mergebase"
|
||||
then
|
||||
# current identical commit is an ancestor of parent
|
||||
identical="$parent"
|
||||
elif test "$parent" != "$mergebase"
|
||||
then
|
||||
# no common history; commit must be copied
|
||||
copycommit=1
|
||||
fi
|
||||
else
|
||||
# first identical parent detected
|
||||
identical="$parent"
|
||||
fi
|
||||
else
|
||||
nonidentical="$parent"
|
||||
fi
|
||||
|
@ -571,7 +589,6 @@ copy_or_skip () {
|
|||
fi
|
||||
done
|
||||
|
||||
copycommit=
|
||||
if test -n "$identical" && test -n "$nonidentical"
|
||||
then
|
||||
extras=$(git rev-list --count $identical..$nonidentical)
|
||||
|
|
Загрузка…
Ссылка в новой задаче