]> Nutra Git (v2) - gamesguru/git-remote-gcrypt.git/commitdiff
Only encrypt to keys with encrypt capability
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)
git-remote-gcrypt

index 6c380daf5702e01985ec4f23b66bcbaaf38aeb1e..49fed5fbd90c81192e46c264ea368c8265c1eb6f 100755 (executable)
@@ -257,10 +257,14 @@ safe_git_rev_parse()
 
 check_recipients()
 {
-       Recipients="$(gpg --no-default-keyring --keyring "$Conf_keyring" \
-               --with-colons -k | xgrep ^pub | cut -f 5 -d ':' | tr '\n' ' ')"
-       # Split recipients by space, example "a b c" =>  -R a -R b -R c
-       Recipients=$(xecho_n "$Recipients" | sed -e 's/\([^ ]\+\)/-R &/g')
+       # Find which keys in the keyring we can encrypt to
+       Recipients=$(gpg --no-default-keyring --keyring "$Conf_keyring" \
+               --with-colons --fast-list -k | xgrep ^pub | \
+               while read rc_line; do
+                       cap_=$(xecho "$rc_line" | cut -f 12 -d :)
+                       keyid_=$(xecho "$rc_line" | cut -f 5 -d :)
+                       iseq "${cap_#*E}" "$cap_" || xecho_n "-R $keyid_ "
+               done)
        if isnull "$Recipients"
        then
                echo_info "You must configure a keyring for the repository."