-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgit-remote-hjgit
More file actions
executable file
·41 lines (33 loc) · 856 Bytes
/
git-remote-hjgit
File metadata and controls
executable file
·41 lines (33 loc) · 856 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/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"
refspec="refs/heads/*:$prefix/heads/*"
test $GIT_REMOTE_HJGIT_REFSPEC && refspec=$GIT_REMOTE_HJGIT_REFSPEC
test -z "$refspec" && prefix="refs"
mkdir -p "$dir"
packinitfmt(){
printf "%s %s\0host=%s\0" $1 $2 $3 | awk '{ printf("%04x%s", length($0)+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