ref: 9a7efce5f114ba90987f12b441225b340d554ea6
parent: 3163e5253240db5a98d05b8392704dd8c99fc196
author: Jacob Moody <[email protected]>
date: Sat Feb 20 08:40:54 EST 2021
Add git-remote-hjgit and update README
--- a/README
+++ b/README
@@ -1,13 +1,20 @@
tlsclient: tlsclient(1) for unix
-tlsclient comes with two programs, tlsclient itself and 9cpu which uses tlsclient
-to connect to a 9front cpu server and acts as rcpu(1).
+This repo contains three programs, tlsclient itself, 9cpu and git-remote-hjgit.
+9cpu acts as rcpu(1).
+Git-remote-hjgit is a git remote helper for unix git that allows use of hjgit repos.
-Most of this code is pillaged from jsdrawterm: https://github.com/aiju/jsdrawterm
+Most of the tlsclient code is pillaged from jsdrawterm: https://github.com/aiju/jsdrawterm
Usage:
tlsclient [ -u user] [ -h host ] [ -a auth ] -p port cmd...
9cpu [ -u user ] [ -h host ] [ -a auth ] cmd...
+Example:
+ 9cpu -u moody -h shithub.us -a p9auth.shithub.us newrepo tlsclient
+
+ # with git-remote-hjgit in your $PATH
+ git clone hjgit://shithub.us/user/repo
+
Bugs:
- Currently 9cpu uses gnutls, a better alternative is welcome.
+ Currently tlsclient uses gnutls, a better alternative is welcome.
--- /dev/null
+++ b/git-remote-hjgit
@@ -1,0 +1,53 @@
+#!/bin/sh
+
+alias=$1
+url=$2
+
+host=`echo $url | awk 'BEGIN{ FS = "/" } { print $3 }'`
+path=`echo $url | awk "BEGIN{ FS = \"/\" } { gsub(/.*$host/, \"\"); printf(\"%s\", "'$0'") }"`
+
+dir="$GIT_DIR/hjgit/$alias"
+prefix="refs/hjgit/$alias"
+
+default_refspec="refs/heads/*:${prefix}/heads/*"
+
+refspec="${GIT_REMOTE_HJGIT_REFSPEC-$default_refspec}"
+
+test -z "$refspec" && prefix="refs"
+
+force=
+
+mkdir -p "$dir"
+
+if test -z "$GIT_REMOTE_HJGIT_NO_MARKS"
+then
+ gitmarks="$dir/git.marks"
+ hjgitmarks="$dir/hjgit.marks"
+ test -e "$gitmarks" || >"$gitmarks"
+ test -e "$hjgitmarks" || >"$hjgitmarks"
+fi
+
+packinitfmt(){
+ printf "%s %s\0host=%s" $1 $2 $3 | awk '{ printf("%04x%s\0", length($0)+1+4, $0) }'
+}
+
+while read line
+do
+ case $line in
+ capabilities)
+ # connect tells git that we're speaking the git protocol with extra steps
+ echo 'connect'
+ echo
+ ;;
+ connect*)
+ # lie that the connection works
+ echo
+ {
+ packinitfmt $(echo $line | awk '{ print $2 }') $path $host
+ cat
+ } | CPU=$host AUTH='p9auth.'$host tlsclient -p 17021
+ exit
+ ;;
+ esac
+
+done