diff options
author | root <root@localhost> | 2013-02-14 00:00:00 +0000 |
---|---|---|
committer | root <root@localhost> | 2013-02-14 00:00:00 +0000 |
commit | e2de0ce73fcb4d79092995c91bf9d80635217445 (patch) | |
tree | 230117195ca7eb846c24305636cac456f77f0116 | |
parent | 853dae8914f7d74e6cb4bcc155ae565aa1c4d6ba (diff) | |
download | git-remote-gcrypt-e2de0ce73fcb4d79092995c91bf9d80635217445.zip git-remote-gcrypt-e2de0ce73fcb4d79092995c91bf9d80635217445.tar.gz git-remote-gcrypt-e2de0ce73fcb4d79092995c91bf9d80635217445.tar.bz2 |
Simply detect if using git repository backend. gitception:// is unneeded
Simply treat absolute paths that do not lead to a HEAD file as local
directory backends, and all other as git backends.
-rw-r--r-- | README.rst | 14 | ||||
-rwxr-xr-x | git-remote-gcrypt | 47 |
2 files changed, 35 insertions, 26 deletions
@@ -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://<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 @@ -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 "$@" <<EOF +Initial commit +EOF } # Get 'tree' from $1, change file $2 to obj id $3 @@ -128,11 +131,11 @@ GET() 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 } @@ -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://<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 @@ -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 ;; |