aboutsummaryrefslogtreecommitdiff
path: root/libexec/git-deli-find-base-commits.sh
diff options
context:
space:
mode:
authorMirek Kratochvil <exa.exa@gmail.com>2025-12-27 15:34:33 +0100
committerMirek Kratochvil <exa.exa@gmail.com>2025-12-27 15:34:33 +0100
commit4e9ee8c61695df19b14db5fc053172f6494b598d (patch)
treeb1c22d82b83431b6c02786178f7ca99786f94985 /libexec/git-deli-find-base-commits.sh
parent346895a69bb6b3d724b9b7dcbf4dfb4098c4c587 (diff)
downloadgit-deli-4e9ee8c61695df19b14db5fc053172f6494b598d.tar.gz
git-deli-4e9ee8c61695df19b14db5fc053172f6494b598d.tar.bz2
rename further
Diffstat (limited to 'libexec/git-deli-find-base-commits.sh')
-rwxr-xr-xlibexec/git-deli-find-base-commits.sh40
1 files changed, 40 insertions, 0 deletions
diff --git a/libexec/git-deli-find-base-commits.sh b/libexec/git-deli-find-base-commits.sh
new file mode 100755
index 0000000..3e16227
--- /dev/null
+++ b/libexec/git-deli-find-base-commits.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+extend_bases () {
+ shas="$1"
+ new="$2"
+ for sha in $shas ; do
+ [ "$sha" = "$new" ] && continue
+ ${DELI_GIT_IS_ANCESTOR_CMD:-git merge-base --is-ancestor} "$sha" "$new"
+ res=$?
+ case $res in
+ 0) ;;
+ 1) echo "$sha" ;;
+ *) echo "$0: ancestor finding failed" >&2
+ exit 1 ;;
+ esac
+ done
+ old=no
+ for sha in $shas ; do
+ [ "$sha" = "$new" ] && continue
+ ${DELI_GIT_IS_ANCESTOR_CMD:-git merge-base --is-ancestor} "$new" "$sha"
+ res=$?
+ case $res in
+ 0) old=yes ; break ;;
+ 1) ;;
+ *) echo "$0: ancestor finding failed" >&2
+ exit 1 ;;
+ esac
+ done
+ [ $old = no ] && echo "$new"
+}
+
+bases=""
+
+while read sha ; do
+ bases=$( extend_bases "$bases" "$sha" )
+done
+
+for sha in $bases ; do
+ echo "$sha"
+done