Merge branch 'maint'
[gitweb.git] / contrib / subtree / git-subtree.sh
index efbdb720e6946dae85316ec98644187e4159ece4..7a39b30ad09483ef9796d98ca78e52f652046582 100755 (executable)
@@ -485,8 +485,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 $?