Merge branch 'dw/subtree-split-do-not-drop-merge'
authorJunio C Hamano <gitster@pobox.com>
Wed, 3 Feb 2016 22:16:03 +0000 (14:16 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 3 Feb 2016 22:16:03 +0000 (14:16 -0800)
The "split" subcommand of "git subtree" (in contrib/) incorrectly
skipped merges when it shouldn't, which was corrected.

* dw/subtree-split-do-not-drop-merge:
contrib/subtree: fix "subtree split" skipped-merge bug

1  2 
contrib/subtree/git-subtree.sh
index efbdb720e6946dae85316ec98644187e4159ece4,5c8372709b31b4ecd8caf0e05faedd0626f03021..7a39b30ad09483ef9796d98ca78e52f652046582
@@@ -245,10 -245,7 +245,10 @@@ find_latest_squash(
                case "$a" in
                        START) sq="$b" ;;
                        git-subtree-mainline:) main="$b" ;;
 -                      git-subtree-split:) sub="$b" ;;
 +                      git-subtree-split:)
 +                              sub="$(git rev-parse "$b^0")" ||
 +                                  die "could not rev-parse split hash $b from commit $sq"
 +                              ;;
                        END)
                                if [ -n "$sub" ]; then
                                        if [ -n "$main" ]; then
@@@ -281,10 -278,7 +281,10 @@@ find_existing_splits(
                case "$a" in
                        START) sq="$b" ;;
                        git-subtree-mainline:) main="$b" ;;
 -                      git-subtree-split:) sub="$b" ;;
 +                      git-subtree-split:)
 +                              sub="$(git rev-parse "$b^0")" ||
 +                                  die "could not rev-parse split hash $b from commit $sq"
 +                              ;;
                        END)
                                debug "  Main is: '$main'"
                                if [ -z "$main" -a -n "$sub" ]; then
@@@ -485,8 -479,16 +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 $?