aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMirek Kratochvil <exa.exa@gmail.com>2025-12-27 15:13:59 +0100
committerMirek Kratochvil <exa.exa@gmail.com>2025-12-27 15:13:59 +0100
commit7683acc382b5499d718487ccfef6050436c17d4e (patch)
tree6821c55616ab960a3d51d3c51daa2d3b85c90030
downloadgit-deli-7683acc382b5499d718487ccfef6050436c17d4e.tar.gz
git-deli-7683acc382b5499d718487ccfef6050436c17d4e.tar.bz2
initial toolification
-rw-r--r--README.md2
-rw-r--r--blames.awk21
-rwxr-xr-xfind-base-commits.sh40
3 files changed, 63 insertions, 0 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..7932770
--- /dev/null
+++ b/README.md
@@ -0,0 +1,2 @@
+# `git deli` the git delinearizer
+
diff --git a/blames.awk b/blames.awk
new file mode 100644
index 0000000..ff817f1
--- /dev/null
+++ b/blames.awk
@@ -0,0 +1,21 @@
+#!/usr/bin/env gawk
+
+BEGIN {
+ file="";
+ ranges="";
+}
+
+match($0, /^\+\+\+ b\/(.+)$/, matched) {
+ if(ranges!="") print(ranges, "--", file);
+ file=matched[1];
+ ranges="";
+}
+
+match($0, /^@@ -([0-9]+),([0-9]+) /, matched) && file!="" {
+ if(matched[2]!="0")
+ ranges = ranges " -L " matched[1] ",+" matched[2];
+}
+
+END {
+ if(ranges!="") print(ranges, "--", file);
+}
diff --git a/find-base-commits.sh b/find-base-commits.sh
new file mode 100755
index 0000000..3e16227
--- /dev/null
+++ b/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