]> git.ipfire.org Git - thirdparty/git.git/commitdiff
onemerge: quick check and exit when the numbers match
authorJunio C Hamano <gitster@pobox.com>
Mon, 13 Jul 2026 18:07:10 +0000 (11:07 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 13 Jul 2026 18:07:10 +0000 (11:07 -0700)
Before diving into inspecting each merge commit to see if it merges
more than two topics at the same time, we can count the number of
branches that are merged and the number of merge commits.  If they
match, we can skip the more expensive check.

This will break if we merge a topic in multiple steps, but we do not
do that these days, so it would be a reasonable optimization.

onemerge.sh

index d0bed02db5dae34576805383b4487559fbd87591..43f07f9d61abf88a5e12994123eb722678334145 100755 (executable)
@@ -4,6 +4,14 @@
 
 endpoint=${1-seen}
 
+cnt1=$(git lgf --grep="Merge branch '" master..$endpoint | wc -l)
+cnt2=$(git branch --no-merged master --merged seen '??/*' | wc -l)
+
+if test $cnt1 -eq $cnt2
+then
+       exit 0
+fi
+
 tmp=/var/tmp/e.$$
 rm -f "$tmp.1" "$tmp.2" &&
 prev= &&