#!/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'") }"`"/.git" echo $path >&2 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(){ echo -n $* | awk '{ printf("%04x%s\0", length($0)+1+4, $0) }' } #CPU=$host AUTH=$host tlsclient -p 17021 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 git-upload-pack') # lie that the connection works echo { packinitfmt git-upload-pack $path cat } | tee /proc/self/fd/2 | CPU=$host AUTH='p9auth.'$host tlsclient -p 17021 | tee /proc/self/fd/2 exit ;; esac done