#!/bin/bash # shows the commit that "landed" a branch on HEAD # # git landed $commit-on-branch [ $head-to-land-on ] [ git-log options ] declare -a revs declare -a flags for p in "$@"; do if [[ $p =~ ^- ]]; then flags+=( "$p" ) else revs+=( "$p" ) fi done there="${revs[0]:?need a commitish}" here="${revs[1]:-HEAD}" git log "$here" ^"$there" --ancestry-path --merges --reverse -z "${flags[@]}" \ | head -z -n 1