summaryrefslogtreecommitdiff
path: root/bin/git-landed
diff options
context:
space:
mode:
Diffstat (limited to 'bin/git-landed')
-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..420d6ac
--- /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