Skip to content

Commit f9d7241

Browse files
author
Junio C Hamano
committed
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 <[email protected]>
1 parent 23822a3 commit f9d7241

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

git-merge.sh

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,30 @@ case "$#,$common" in
123123
dropsave
124124
exit 0
125125
;;
126-
1,*)
126+
1,?*"$LF"?*)
127127
# We are not doing octopus and not fast forward. Need a
128128
# real merge.
129129
;;
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+
;;
130150
*)
131151
# An octopus. If we can reach all the remote we are up to date.
132152
up_to_date=t

0 commit comments

Comments
 (0)