]> Nutra Git (v2) - gamesguru/git-remote-gcrypt.git/commitdiff
Use a shorter repository id in the URL, to simplify a tiny bit
authorroot <root@localhost>
Thu, 14 Feb 2013 00:00:00 +0000 (00:00 +0000)
committerroot <root@localhost>
Thu, 14 Feb 2013 00:00:00 +0000 (00:00 +0000)
README.rst
git-remote-gcrypt

index 6add2bdd8d85c64d5aa6b8b420375e261c0a1c29..b975ef60c45b0313c3a5e1f3759d9acc701c75e9 100644 (file)
@@ -23,8 +23,8 @@ Example use::
     git remote add cryptremote  gcrypt::ssh://example.com:repo
     git push cryptremote master
     > gcrypt: Setting up new repository at ssh://example.com:repo
-    > gcrypt: Repository ID is 99b45a84a13168fc5efe
-    > gcrypt: Repository URL is gcrypt::ssh://example.com:repo/G/99b45a84a13168fc5efe
+    > gcrypt: Repository ID  is KNBr0wKzct52
+    > gcrypt: Repository URL is gcrypt::ssh://example.com:repo/G/KNBr0wKzct52
     > gcrypt: (configuration for cryptremote updated)
     > [ more lines .. ]
     > To gcrypt::[...]
index e758173b561454ff6d6bc01b36035dd07ed8023c..b0a4fdf9085c761d713be0833627625c2b3aa50c 100755 (executable)
@@ -217,9 +217,10 @@ PRIVDECRYPT()
        })
 }
 
+# Generate $1 random bytes
 genkey()
 {
-       gpg --armor --gen-rand 1 128 | tr -d \\n
+       gpg --armor --gen-rand 1 "$1"
 }
 
 pack_hash()
@@ -260,15 +261,15 @@ make_new_repo()
        local urlid_= fix_config=
        echo_info "Setting up new repository at $URL"
        PUTREPO "$URL"
-       Masterkey="$(genkey)"
+       Masterkey="$(genkey 128)"
 
        # We need a relatively short ID for URL+REPO
        # The manifest will be stored at SHA224(urlid_)
        # Needed assumption: the same user should have no duplicate urlid_
-       # For now, we use 20 random hex digits (80 bits), can be increased
-       urlid_=$(genkey | pack_hash | cut -c 1-20)
+       # For now, we arbitrarily use 9 random bytes (72 bits)
+       urlid_=$(genkey 9 | tr '/+' 'Zz')
        Repoid=$(xecho_n "$urlid_" | pack_hash)
-       echo_info "Repository ID is" "$urlid_"
+       echo_info "Repository ID  is" "$urlid_"
        isnoteq "${NAME#gcrypt::}" "$URL" && {
                git config "remote.$NAME.url" "gcrypt::$URL/G/$urlid_"
                fix_config=1