gits-protocol

Git over TLS
git clone git://git.rr3.xyz/gits-protocol | git clone gits://git.rr3.xyz/gits-protocol
Log | Files | Refs | README

commit ad7bde637339d28f0cd3166b9f47777a25014ab5
Author: Robert Russell <robert@rr3.xyz>
Date:   Wed, 20 May 2026 15:27:56 -0700

Initial commit

Diffstat:
Agit-remote-gits | 34++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+), 0 deletions(-)

diff --git a/git-remote-gits b/git-remote-gits @@ -0,0 +1,34 @@ +#!/bin/sh +set -eu + +fail() { + echo "$0: $1" >&2 + exit 1 +} + +[ $# -eq 2 ] || fail "invalid usage; see gitremote-helpers(7)" +REMOTE="$1" +URL="$2" + +command -v ncat >/dev/null 2>&1 || fail "ncat must be installed" + +# Parse the URL +IFS=',' read -r GITS_HOST GITS_PORT GITS_PATH <<EOF +$(echo "$URL" | sed -En ' + # |proto||addr-----------------------------------------------||port------||path----------| + # | |||IPv6 addr-------------------------| |other addr--||| || | + s@^gits://(\[[a-fA-F0-9:]+(%[a-zA-Z0-9._-]+)?\]|[a-zA-Z0-9.-]+)(:([0-9]+))?(/[[:graph:]]*)?$@\1,\4,\5@; + tp; # Goto p if the s did match + bq; # Goto q if the s did not match + :p; p; + :q; q; +') +EOF + +# GITS_HOST is empty iff the URL didn't match the regex +[ -n "$GITS_HOST" ] || fail "invalid address" +: "${GITS_PORT:=9419}" +: "${GITS_PATH:=/}" + +exec git remote-ext "$REMOTE" "ncat --ssl-verify $GITS_HOST $GITS_PORT %G$GITS_PATH" +