This helper handles gcrypt:: URLs that will access a remote repository
encrypted with GPG, using our custom format.
-Supported locations are `local`, `ssh://`, `sftp://` and
-`gitception://`. `gcrypt::gitception://<giturl>` allows stacking gcrypt
-on top of any other git transport.
+Supported locations are `local`, `ssh://` and `sftp://`, where the
+repository is stored as a set of files. If the location instead is any
+`<giturl>`, gcrypt will store the same representation in a git
+repository, and so it can be bridged over any git transport.
.. NOTE:: Repository format MAY STILL change, incompatibly
git remote add cryptremote gcrypt::ssh://example.com:repo
git push cryptremote HEAD
+How to use a git backend::
+
+ # notice that the target repo must already exist and its
+ # `master` branch will be overwritten!
+ git remote add gitcrypt gcrypt::git@example.com:repo
+ git push gitcrypt HEAD
+
Notes
=====
# Append $2 to $1 with a newline separator
append() { isnull "$1" || xecho "$1" && xecho "$2"; }
isurl() { isnull "${2%%$1://*}"; }
+islocalrepo() { isnull "${1##/*}" && [ ! -e "$1/HEAD" ]; }
xgrep() { command grep "$@" || : ; }
sort_C() { LC_ALL=C command sort "$@"; }
GIT_AUTHOR_DATE="1356994801 -0400" GIT_COMMITTER_NAME="root" \
GIT_COMMITTER_EMAIL="root@localhost" \
GIT_COMMITTER_DATE="1356994801 -0400" \
- git commit-tree -m "Initial commit" "$@"
+ git commit-tree "$@" <<EOF
+Initial commit
+EOF
}
# Get 'tree' from $1, change file $2 to obj id $3
elif isurl sftp "$1"
then
(exec 0>&-; curl -s -S -k "$1/$2")
- elif isurl gitception "$1"
+ elif islocalrepo "$1"
then
- gitception_get "${1#gitception://}" "$2"
- else
cat "$1/$2"
+ else
+ gitception_get "${1#gitception://}" "$2"
fi
}
elif isurl sftp "$1"
then
curl -s -S -k --ftp-create-dirs -T - "$1/$2"
- elif isurl gitception "$1"
+ elif islocalrepo "$1"
then
- gitception_put "${1#gitception://}" "$2"
- else
cat > "$1/$2"
+ else
+ gitception_put "${1#gitception://}" "$2"
fi
}
# Put all PUT changes for repo $1 at once
PUT_FINAL()
{
- if isurl gitception "$1"
+ if isurl ssh "$1" || isurl sftp "$1" || islocalrepo "$1"
then
- git push --quiet -f "${1#gitception://}" "$Gref:$Gref_rbranch"
- else
:
+ else
+ git push --quiet -f "${1#gitception://}" "$Gref:$Gref_rbranch"
fi
}
elif isurl sftp "$1"
then
:
- elif isurl gitception "$1"
+ elif islocalrepo "$1"
then
- gitception_new_repo "${1#gitception://}"
- else
mkdir -p "$1"
+ else
+ gitception_new_repo "${1#gitception://}"
fi
}
CLEAN_FINAL()
{
- isurl gitception "$1" && git update-ref -d "$Gref" || :
+ if isurl ssh "$1" || isurl sftp "$1" || islocalrepo "$1"
+ then
+ :
+ else
+ git update-ref -d "$Gref" || :
+ fi
}
addsignkeyparam()
echo_git
}
-# Main program, check $URL is supported
-NAME=$1
-URL=$2
-( isurl ssh "$URL" || isurl sftp "$URL" ||
- isurl gitception "$URL" || isnull "${URL##/*}" ) ||
- echo_die "Supported URLs: gitception://<giturl>, Absolute path, sftp://, ssh://"
+NAME=$1 # Remote name
+URL=$2 # Remote URL
mkdir -p "$Localdir"
while read Input
do
- #echo_info "Got: $Input ($GITCEPTION)"
case "$Input" in
capabilities)
do_capabilities
args_="${Input##push }"
while read InputX
do
- #echo_info "Got: (for push) $InputX"
case "$InputX" in
push\ *)
args_=$(append "$args_" "${InputX#push }")
echo_die "Unknown input!"
;;
*)
- #echo_info "Blank line, we are done"
CLEAN_FINAL "$URL"
exit 0
;;