aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/git-deli53
1 files changed, 52 insertions, 1 deletions
diff --git a/bin/git-deli b/bin/git-deli
index 6a00b40..60b5ff0 100755
--- a/bin/git-deli
+++ b/bin/git-deli
@@ -5,6 +5,10 @@
# Copytight (C) 2025 Mirek Kratochvil <exa.exa@gmail.com>
#
+#
+# ARGUMENT PARSING AND MAIN ENTRYPOINT
+#
+
OPTS_SPEC="\
git deli head [-b=<branch>] [-m=<msg>] [<commit>]
git deli commit ...
@@ -22,7 +26,6 @@ d,delete delete the boundary commit instead of adding it
'push' options:
f,force internally do a true force-push instead of the safe force-with-lease
"
-
main() {
if test $# -eq 0
then set -- -h
@@ -93,6 +96,10 @@ main() {
esac
}
+#
+# COMMANDS
+#
+
cmd_head () {
msg="$1"
branch="$2"
@@ -137,4 +144,48 @@ cmd_pull () {
# TODO like a normal git fetch followed by git deli merge
}
+#
+# PRUNING ANCESTORS
+#
+
+add_to_merge_points () {
+ shas="$1"
+ new="$2"
+ for sha in $shas ; do
+ [ "$sha" = "$new" ] && continue
+ 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
+ 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"
+}
+
+prune_merge_points () {
+ mps=
+ while read sha trailing_garbage
+ do mps=$( add_to_merge_points "$mps" "$sha" )
+ done
+ for sha in $mps
+ do echo "$sha"
+ done
+}
+
+# finally, run the main
main "$@"