From ed1fcab6d70e8507efa9662c364c227f34339ad1 Mon Sep 17 00:00:00 2001
From: Joey Hess <joey@kitenet.net>
Date: Tue, 31 Dec 2013 13:50:18 -0400
Subject: [PATCH] external special remote protocol: Added GETUUID.

---
 Remote/External.hs                               | 2 ++
 Remote/External/Types.hs                         | 2 ++
 debian/changelog                                 | 6 ++++++
 doc/design/external_special_remote_protocol.mdwn | 5 +++--
 4 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/Remote/External.hs b/Remote/External.hs
index e444a729de..3a567d834a 100644
--- a/Remote/External.hs
+++ b/Remote/External.hs
@@ -226,6 +226,8 @@ handleRequest' lck external req mp responsehandler
 		creds <- fromMaybe ("", "") <$> 
 			getRemoteCredPair c (credstorage setting)
 		sendMessage lck external $ CREDS (fst creds) (snd creds)
+	handleRemoteRequest GETUUID = sendMessage lck external $
+		VALUE $ fromUUID $ externalUUID external
 	handleRemoteRequest (VERSION _) =
 		sendMessage lck external $ ERROR "too late to send VERSION"
 
diff --git a/Remote/External/Types.hs b/Remote/External/Types.hs
index 0525cdfee3..40bd8d52e8 100644
--- a/Remote/External/Types.hs
+++ b/Remote/External/Types.hs
@@ -166,6 +166,7 @@ data RemoteRequest
 	| GETCONFIG Setting
 	| SETCREDS Setting String String
 	| GETCREDS Setting
+	| GETUUID
 	deriving (Show)
 
 instance Receivable RemoteRequest where
@@ -176,6 +177,7 @@ instance Receivable RemoteRequest where
 	parseCommand "GETCONFIG" = parse1 GETCONFIG
 	parseCommand "SETCREDS" = parse3 SETCREDS
 	parseCommand "GETCREDS" = parse1 GETCREDS
+	parseCommand "GETUUID" = parse0 GETUUID
 	parseCommand _ = parseFail
 
 -- Responses to RemoteRequest.
diff --git a/debian/changelog b/debian/changelog
index 4689f05591..b767d86b07 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+git-annex (5.20131231) UNRELEASED; urgency=medium
+
+  * external special remote protocol: Added GETUUID.
+
+ -- Joey Hess <joeyh@debian.org>  Tue, 31 Dec 2013 13:41:18 -0400
+
 git-annex (5.20131230) unstable; urgency=medium
 
   * Added new external special remote interface.
diff --git a/doc/design/external_special_remote_protocol.mdwn b/doc/design/external_special_remote_protocol.mdwn
index 550a0ff14d..8214a48a80 100644
--- a/doc/design/external_special_remote_protocol.mdwn
+++ b/doc/design/external_special_remote_protocol.mdwn
@@ -209,6 +209,9 @@ in control.
   or a file.
   (git-annex replies with "CREDS User Password". If no creds are found,
   User and Password are both empty.)
+* `GETUUID`  
+  Queries for the UUID of the special remote being used.  
+  (git-annex replies with VALUE followed by the UUID.)
 
 ## general messages
 
@@ -232,8 +235,6 @@ remote.
   the remote. However, \n and probably \0 need to be escaped somehow in the
   file data, which adds complication.
 * uuid discovery during INITREMOTE.
-* uuid verification during PREPARE (so, for example, it can check if a
-  removable drive repo has the expected uuid)
 * Support for splitting files into chunks.
 * Support for getting and setting the list of urls that can be associated
   with a key.