summaryrefslogtreecommitdiff
path: root/Assistant/XMPP
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-11-10 00:08:15 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-11-10 00:09:03 -0400
commit68c6dcca0b61416db2ffe7a9818fb3b3640da283 (patch)
treeef841f450fe6f814eafee82296125aeaceca526a /Assistant/XMPP
parent9f0eba77e889ceeaeb2711ffcd18b1f73ec1b97e (diff)
refactor
Diffstat (limited to 'Assistant/XMPP')
-rw-r--r--Assistant/XMPP/Git.hs27
1 files changed, 15 insertions, 12 deletions
diff --git a/Assistant/XMPP/Git.hs b/Assistant/XMPP/Git.hs
index fcdb5dc2d..d177db8ad 100644
--- a/Assistant/XMPP/Git.hs
+++ b/Assistant/XMPP/Git.hs
@@ -66,11 +66,9 @@ makeXMPPGitRemote buddyname jid u = do
- git receive-pack <--> xmppReceivePack <---------------> xmpp
-
- The pipe between git-annex xmppgit and us is set up and communicated
- - using two file descriptors, GIT_ANNEX_XMPPGIT_IN and
- - GIT_ANNEX_XMPPGIT_OUT. It simply connects those up to its stdin
- - and stdout, respectively, which are in turn connected to "git-push".
- - There is also a GIT_ANNEX_XMPPGIT_CONTROL descriptor, to which an
- - exit status is sent for xmppgit to propigate.
+ - using two environment variables, relayIn and relayOut, that are set
+ - to the file descriptors to use. Another, relayControl, is used to
+ - propigate the exit status of git receive-pack.
-
- We listen at the other end of the pipe and relay to and from XMPP.
-}
@@ -141,16 +139,21 @@ xmppPush cid remote refs = runPush (SendPushRunning cid) handleDeferred $ do
]
modifyFileMode wrapper $ addModes executeModes
-relayIn :: String
-relayIn = "GIT_ANNEX_XMPPGIT_IN"
+type EnvVar = String
-relayOut :: String
-relayOut = "GIT_ANNEX_XMPPGIT_OUT"
+envVar :: String -> EnvVar
+envVar s = "GIT_ANNEX_XMPPGIT_" ++ s
-relayControl :: String
-relayControl = "GIT_ANNEX_XMPPGIT_CONTROL"
+relayIn :: EnvVar
+relayIn = envVar "IN"
-relayHandle :: String -> IO Handle
+relayOut :: EnvVar
+relayOut = envVar "OUT"
+
+relayControl :: EnvVar
+relayControl = envVar "CONTROL"
+
+relayHandle :: EnvVar -> IO Handle
relayHandle var = do
v <- getEnv var
case readish =<< v of