summaryrefslogtreecommitdiff
path: root/contrib/subtree/git-subtree.sh
diff options
context:
space:
mode:
authorDave Ware <davidw@realtimegenomics.com>2016-01-15 00:41:43 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-01-20 22:53:18 (GMT)
commit933cfeb90b5d03b4096db6d60494a6eedea25d03 (patch)
treea916e337fe8deb41761d87c2219f240914239997 /contrib/subtree/git-subtree.sh
parent30fe9b2f9aece7f8f24bc069b9d7470b8291535e (diff)
downloadgit-933cfeb90b5d03b4096db6d60494a6eedea25d03.zip
git-933cfeb90b5d03b4096db6d60494a6eedea25d03.tar.gz
git-933cfeb90b5d03b4096db6d60494a6eedea25d03.tar.bz2
contrib/subtree: fix "subtree split" skipped-merge bug
'git subtree split' can incorrectly skip a merge even when both parents act on the subtree, provided the merge results in a tree identical to one of the parents. Fix by copying the merge if at least one parent is non-identical, and the non-identical parent is not an ancestor of the identical parent. Also, add a test case which checks that a descendant remains a descendent on the subtree in this case. Signed-off-by: Dave Ware <davidw@realtimegenomics.com> Reviewed-by: David A. Greene <greened@obbligato.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib/subtree/git-subtree.sh')
-rwxr-xr-xcontrib/subtree/git-subtree.sh12
1 files changed, 10 insertions, 2 deletions
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index edf36f8..5c83727 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -479,8 +479,16 @@ copy_or_skip()
p="$p -p $parent"
fi
done
-
- if [ -n "$identical" ]; then
+
+ copycommit=
+ if [ -n "$identical" ] && [ -n "$nonidentical" ]; then
+ extras=$(git rev-list --count $identical..$nonidentical)
+ if [ "$extras" -ne 0 ]; then
+ # we need to preserve history along the other branch
+ copycommit=1
+ fi
+ fi
+ if [ -n "$identical" ] && [ -z "$copycommit" ]; then
echo $identical
else
copy_commit $rev $tree "$p" || exit $?