@matheusbsbs / matheus-bagliano / commits / 17cf939724
Fork 0

octopus: do not do AND'ed merge base.

When doing an octopus, we incorrectly used the previous merge base as the reference to compute next merge base. This was unnecessary, because that can never be better than using the original HEAD. And that is far simpler as well ;-). Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Nov 9, 2005 at 22:37 UTC 17cf939724a244a56e687559fae062a3e6207145
1 file changed +20 -5
git-merge-octopus.sh
+20 -5
@@ -5,6 +5,9 @@
5 # Resolve two or more trees.
6 #
7
8 +LF='
9 +'
10 +
11 # The first parameters up to -- are merge bases; the rest are heads.
12 bases= head= remotes= sep_seen=
13 for arg
@@ -42,14 +45,18 @@ CNT=1 ;# counting our head
45 NON_FF_MERGE=0
46 for SHA1 in $remotes
47 do
45 - common=$(git-merge-base $MRC $SHA1) ||
48 + common=$(git-merge-base --all $MRC $SHA1) ||
49 die "Unable to find common commit with $SHA1"
50
48 - if test "$common" = $SHA1
49 - then
51 + case "$common" in
52 + ?*"$LF"?*)
53 + die "Not trivially mergeable."
54 + ;;
55 + $SHA1)
56 echo "Already up-to-date with $SHA1"
57 continue
52 - fi
58 + ;;
59 + esac
60
61 CNT=`expr $CNT + 1`
62 PARENT="$PARENT -p $SHA1"
@@ -79,7 +86,15 @@ do
86 exit 2 ; # Automatic merge failed; should not be doing Octopus
87 next=$(git-write-tree 2>/dev/null)
88 fi
82 - MRC=$common
89 +
90 + # We have merged the other branch successfully. Ideally
91 + # we could implement OR'ed heads in merge-base, and keep
92 + # a list of commits we have merged so far in MRC to feed
93 + # them to merge-base, but we approximate it by keep using
94 + # the current MRC. We used to update it to $common, which
95 + # was incorrectly doing AND'ed merge-base here, which was
96 + # unneeded.
97 +
98 MRT=$next
99 done
100