]> Nutra Git (v1) - gamesguru/git-remote-gcrypt.git/commitdiff
--check option to see if a repo exists and can be decrypted
authorJoey Hess <joey@kitenet.net>
Thu, 19 Sep 2013 16:03:33 +0000 (12:03 -0400)
committerJoey Hess <joey@kitenet.net>
Thu, 19 Sep 2013 16:03:33 +0000 (12:03 -0400)
This is to allow programs to determine if a repo uses gcrypt, per #6.

Since this program already knows the name of the manifest file and how to
download it and decrypt it, it makes sense to do the check here rather than
in, eg, git-annex.

README.rst
git-remote-gcrypt

index 6fc46368ca57b60abfc3a5046b1b487b1ebfd1ac..3922376ce3a1d16654feb8a2869ebf15c4c02309 100644 (file)
@@ -173,6 +173,17 @@ Each item extends until newline, and matches one of the following:
 ``extn <name> ...``
     Extension field, preserved but unused.
 
+Detecting gcrypt repos
+======================
+
+To detect if a git url is a gcrypt repo, use: git-remote-gcrypt --check url
+Exit status if 0 if the repo exists and can be decrypted, 1 if the repo
+uses gcrypt but could not be decrypted, and 100 if the repo does not 
+exist or could not be accessed.
+
+Note that this has to fetch the repo contents into the local git
+repository, the same as is done when using a gcrypt repo.
+
 See Also
 ========
 
index bf757777b480e742d4bc0fd4bd0780ecbe5a659a..67b0f67c9eb214d1ee2bb78324b3de5fb68b8763 100755 (executable)
@@ -779,14 +779,8 @@ cleanup_tmpfiles()
        rm -r -f -- "${Tempdir}" >&2
 }
 
-# handle git-remote-helpers protocol
-gcrypt_main_loop()
+setup()
 {
-       local input_= input_inner= r_args= temp_key=
-
-       NAME=$1  # Remote name
-       URL=$2   # Remote URL
-
        mkdir -p "$Localdir"
 
        # Set up a subdirectory in /tmp
@@ -798,6 +792,17 @@ gcrypt_main_loop()
        trap 'exit 1' 1 2 3 15
 
        echo_info "Development version -- Repository format MAY CHANGE"
+}
+
+# handle git-remote-helpers protocol
+gcrypt_main_loop()
+{
+       local input_= input_inner= r_args= temp_key=
+
+       NAME=$1  # Remote name
+       URL=$2   # Remote URL
+
+       setup
 
        while read input_
        do
@@ -849,4 +854,16 @@ gcrypt_main_loop()
        done
 }
 
-gcrypt_main_loop "$@"
+if [ "x$1" = x--check ]
+then
+       NAME=dummy-gcrypt-check
+       URL=$2
+       setup
+       ensure_connected
+       if iseq "$Did_find_repo" "no"
+       then
+               exit 100
+       fi
+else
+       gcrypt_main_loop "$@"
+fi