From dc3f34978376ff066892e369ccb287851581042c Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Sun, 28 Dec 2025 10:13:54 +0100 Subject: intern base finding --- bin/git-deli | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) (limited to 'bin') 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 # +# +# ARGUMENT PARSING AND MAIN ENTRYPOINT +# + OPTS_SPEC="\ git deli head [-b=] [-m=] [] 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 "$@" -- cgit v1.2.3