aboutsummaryrefslogtreecommitdiffhomepage
path: root/git-remote-gcrypt
diff options
context:
space:
mode:
authorroot <root@localhost>2013-02-14 00:00:00 +0000
committerroot <root@localhost>2013-02-14 00:00:00 +0000
commit12cd4c92d66b9a3502385caf7156196afec72381 (patch)
treeb19c70e9e8a73513a3d4b601bf5de018f1ab057a /git-remote-gcrypt
parentf74bd695d275d0138a04e1800ad814c058df6b9c (diff)
downloadgit-remote-gcrypt-12cd4c92d66b9a3502385caf7156196afec72381.tar.gz
Move getting master key and manifest into ensure_connected
Diffstat (limited to 'git-remote-gcrypt')
-rwxr-xr-xgit-remote-gcrypt19
1 files changed, 17 insertions, 2 deletions
diff --git a/git-remote-gcrypt b/git-remote-gcrypt
index 824fae2..96fda22 100755
--- a/git-remote-gcrypt
+++ b/git-remote-gcrypt
@@ -24,6 +24,7 @@ sha1()
LOCALDIR="${GIT_DIR:-.git}/remote-gcrypt"
DUMMYKEY="00000000000000000000"
+DID_CONNECT=
isurl() { test -z "${2%%$1://*}" ; }
@@ -122,6 +123,17 @@ make_new_repo()
printf "%s" "$MASTERKEY" | gpg -e $RECIPIENTS | PUT "$URL" masterkey
}
+ensure_connected()
+{
+ if [ ! -z "$DID_CONNECT" ]
+ then
+ return
+ fi
+ DID_CONNECT=1
+ MASTERKEY="$(get_masterkey)"
+ MANIFESTDATA="$(GET_OR_EMPTY "$URL" manifest | DECRYPT)"
+}
+
get_masterkey()
{
(GET "$URL" masterkey 2>/dev/null || : ) | \
@@ -139,6 +151,8 @@ do_list()
{
local OBJID
local REFNAME
+ ensure_connected
+
printf "%s\n" "$MANIFESTDATA" | while read LINE
do
OBJID=${LINE%% *}
@@ -164,6 +178,8 @@ do_fetch()
local PREMOTE
local PBOTH
local PHAVE
+ ensure_connected
+
touch "$LOCALDIR/packfest"
PREMOTE="$(GET_OR_EMPTY "$URL" packfest | DECRYPT)"
if [ -z "$PREMOTE" ]
@@ -211,6 +227,7 @@ do_push()
local PACKFEST
local prefix_
local suffix_
+ ensure_connected
if [ "$MASTERKEY" = "$DUMMYKEY" ]
then
@@ -292,8 +309,6 @@ URL=$2
{ echo_info "Supported URLs: Absolute path, sftp://, ssh://" ; exit 1 ; }
mkdir -p "$LOCALDIR"
-MASTERKEY="$(get_masterkey)"
-MANIFESTDATA="$(GET_OR_EMPTY "$URL" manifest | DECRYPT)"
while read INPUT
do