2 つのブランチが交差マージされた回数ではなく、リポジトリ内の任意のブランチ間の交差マージの数を取得したいと考えています。その場合、Git に対して次のシェル スクリプトを実行する必要があります。
#!/bin/sh
# Get the list of branches and convert it to an array.
branches=$(git for-each-ref --format='%(refname:short)' refs/heads/)
branches=( $branches )
N=${#branches[*]}
cc_merges=0
# Loop over all combinations of two branches.
for ((i=0; i<N-1; ++i)); do
for ((k=i+1; k<N; ++k)); do
a=${branches[$i]}
b=${branches[$k]}
bases=$(git merge-base --all $a $b | wc -l)
if [ $bases -gt 1 ]; then
let "cc_merges += 1"
fi
done
done
echo "Number of criss-cross merges in repository: $cc_merges"
Mercurial の場合、残念ながら、ancestor()
revset とdebugancestor
コマンドの両方が、すべての祖先のリストではなく、最大の共通の祖先のみをリストしているため、ここで解決策を提案することはできません。