@matheusbsbs / matheus-bagliano / commits / f9d72413bc
Fork 0

Handle really trivial case inside git-merge.

Using Linus' --trivial option, this handles really trivial case inside git-merge itself, without using any strategy modules. A 'really trivial case' is: - we are merging one branch into the current branch; - there is only one merge base between the branches; - there is no file-level merge required. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Oct 2, 2005 at 11:13 UTC f9d72413bcbf33ced45f12e17ef156abd73963f6
1 file changed +21 -1
git-merge.sh
+21 -1
@@ -123,10 +123,30 @@ case "$#,$common" in
123 dropsave
124 exit 0
125 ;;
126 -1,*)
126 +1,?*"$LF"?*)
127 # We are not doing octopus and not fast forward. Need a
128 # real merge.
129 ;;
130 +1,*)
131 + # We are not doing octopus, not fast forward, and have only
132 + # one common. See if it is really trivial.
133 + echo "Trying really trivial in-index merge..."
134 + git-update-index --refresh 2>/dev/null
135 + if git-read-tree --trivial -m -u $common $head "$1" &&
136 + result_tree=$(git-write-tree)
137 + then
138 + echo "Wonderful."
139 + result_commit=$(
140 + echo "$merge_msg" |
141 + git-commit-tree $result_tree -p HEAD -p "$1"
142 + ) || exit
143 + git-update-ref HEAD $result_commit $head
144 + summary $result_commit
145 + dropsave
146 + exit 0
147 + fi
148 + echo "Nope."
149 + ;;
150 *)
151 # An octopus. If we can reach all the remote we are up to date.
152 up_to_date=t