summaryrefslogtreecommitdiffstats
path: root/repo-access.sh
diff options
context:
space:
mode:
Diffstat (limited to 'repo-access.sh')
-rw-r--r--repo-access.sh84
1 files changed, 84 insertions, 0 deletions
diff --git a/repo-access.sh b/repo-access.sh
index 6f6bf74..2b6a5cc 100644
--- a/repo-access.sh
+++ b/repo-access.sh
@@ -36,6 +36,90 @@ function systr_repo_resolve_reference
}
##
+# systr_repo_commit_dist <a> <b>
+#
+# Determine how many commits have occurred between <a> and <b>.
+# IE: How far behind <b> is <a>? If <a> and <b> are (or
+# reference) the same commit, the result it zero. Result
+# written to stdout.
+##
+function systr_repo_commit_dist
+{
+ if [ $# -lt 2 ]; then
+ echo "Fatal: too few args to repo_commit_dist" >&2
+ exit 1
+ fi
+
+ a=$(systr_repo_resolve_reference "$1")
+ b=$(systr_repo_resolve_reference "$2")
+ d=$((0))
+
+ while [[ "$b" != "NULL" ]]
+ do
+ if [[ "$b" == "$a" ]]; then
+ echo "$d"
+ exit
+ fi
+
+ d=$(($d+1))
+ read b <"$path/revs/$b/.commit.systr"
+ done
+
+ echo "Inf"
+}
+
+##
+# systrunk shortlog [<commit>=BASE]
+#
+# View commit history. Generate list of commit IDs only, each
+# one a newline. Written to stdout.
+##
+function systr_short_log
+{
+ if [ $# -lt 1 ]; then
+ commit="$BASE"
+ else
+ commit=$(systr_repo_resolve_reference "$1")
+ fi
+
+ while [[ "$commit" != "NULL" ]]
+ do
+ echo "$commit"
+ read commit <"$path/revs/$commit/.commit.systr"
+ done
+}
+
+##
+# systr_repo_merge_base <a> <b>
+#
+# Find the merge base between <a> and <b>. That is, determine
+# which other commit is the closest common ancestor of both
+# <a> and <b>. Result or "NULL" written to stdout.
+##
+function systr_repo_merge_base
+{
+ if [ $# -lt 2 ]; then
+ echo "Fatal: too few args to repo_merge_base" >&2
+ exit 1
+ fi
+
+ a=$(systr_repo_resolve_reference "$1")
+ b=$(systr_repo_resolve_reference "$2")
+
+ while [[ "$a" != "NULL" ]]
+ do
+ check=$(systr_short_log "$b" | grep "$a")
+
+ if [[ "$check" == "$a" ]]; then
+ echo "$a"
+ exit
+ fi
+
+ read a <"$path/revs/$a/.commit.systr"
+ done
+}
+
+##
# systrunk log [<commit>=BASE]
#
# View commit history. Generate a dump of all commits reachable