summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGianni Ceccarelli <gianni.ceccarelli@broadbean.com>2021-04-26 11:37:01 +0100
committerGianni Ceccarelli <gianni.ceccarelli@broadbean.com>2021-04-26 11:40:10 +0100
commit1c0fa15c88ab473b23b531a87671313ec0e9dbc6 (patch)
treedfdd213ead980ea17c557639424eb00723661ebe
parentfix dmount completion (diff)
downloadmisc-scripts-1c0fa15c88ab473b23b531a87671313ec0e9dbc6.tar.gz
misc-scripts-1c0fa15c88ab473b23b531a87671313ec0e9dbc6.tar.bz2
misc-scripts-1c0fa15c88ab473b23b531a87671313ec0e9dbc6.zip
`git landed` command
-rwxr-xr-xbin/git-landed22
1 files changed, 22 insertions, 0 deletions
diff --git a/bin/git-landed b/bin/git-landed
new file mode 100755
index 0000000..78c0e8d
--- /dev/null
+++ b/bin/git-landed
@@ -0,0 +1,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 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