Merge branch 'nd/git-common-dir-fix' into maint
[gitweb.git] / contrib / subtree / git-subtree.sh
index edf36f8c36091551d0a3e6cacb6c91446f0147eb..5c8372709b31b4ecd8caf0e05faedd0626f03021 100755 (executable)
@@ -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 $?