diff --git a/README.rst b/README.rst index 7e48b97..8b84d0e 100644 --- a/README.rst +++ b/README.rst @@ -16,9 +16,10 @@ Remote helper programs are invoked by git to handle network transport. 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://` 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 +``, 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 @@ -91,6 +92,13 @@ Examples 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 ===== diff --git a/git-remote-gcrypt b/git-remote-gcrypt index 2b797cd..e7a435c 100755 --- a/git-remote-gcrypt +++ b/git-remote-gcrypt @@ -44,6 +44,7 @@ isnoteq() { ! iseq "$@"; } # 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 "$@"; } @@ -83,7 +84,9 @@ anon_commit() 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 "$@" <&-; 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 } @@ -146,22 +149,22 @@ PUT() 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 } @@ -175,17 +178,22 @@ PUTREPO() 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() @@ -518,18 +526,13 @@ EOF 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://, 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 @@ -556,7 +559,6 @@ do args_="${Input##push }" while read InputX do - #echo_info "Got: (for push) $InputX" case "$InputX" in push\ *) args_=$(append "$args_" "${InputX#push }") @@ -572,7 +574,6 @@ do echo_die "Unknown input!" ;; *) - #echo_info "Blank line, we are done" CLEAN_FINAL "$URL" exit 0 ;;