1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#!/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 revsdeclare -a flags for p in "$@"; do if [[ $p =~ ^- ]]; then flags+=( "$p" ) else revs+=( "$p" ) fidone there="${revs[0]:?need a commitish}"here="${revs[1]:-HEAD}" git log "$here" ^"$there" --ancestry-path --merges --reverse -z "$flags" \ | head -z -n 1