aboutsummaryrefslogtreecommitdiff
path: root/Annex.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-10-12 13:02:41 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-10-12 13:02:41 -0400
commitea5d7fe07a5c40349e66848fc9cd06a9f748b724 (patch)
tree5e3ebcaf507b8d29962a57f04bfcf5690222879c /Annex.hs
parent31b24348d25f5aec7ff521b7452fab6833a1d051 (diff)
add uuid
Diffstat (limited to 'Annex.hs')
-rw-r--r--Annex.hs15
1 files changed, 15 insertions, 0 deletions
diff --git a/Annex.hs b/Annex.hs
index 3461a92cd..5adc73996 100644
--- a/Annex.hs
+++ b/Annex.hs
@@ -10,6 +10,8 @@ module Annex (
import System.Posix.Files
import System.Directory
+import System.Cmd.Utils
+import System.IO
import GitRepo
import Utility
import Locations
@@ -84,6 +86,13 @@ unannexFile state file = do
{- Sets up a git repo for git-annex. May be called repeatedly. -}
gitPrep :: GitRepo -> IO ()
gitPrep repo = do
+ -- Make sure that the repo has an annex.uuid setting.
+ if ("" == gitConfig repo "annex.uuid" "")
+ then do
+ uuid <- genUUID
+ gitRun repo ["config", "annex.uuid", uuid]
+ else return ()
+
-- configure git to use union merge driver on state files
let attrLine = stateLoc ++ "/*.log merge=union"
let attributes = gitAttributes repo
@@ -99,3 +108,9 @@ gitPrep repo = do
appendFile attributes $ attrLine ++ "\n"
gitAdd repo attributes
else return ()
+
+{- Generates a UUID. There is a library for this, but it's not packaged,
+ - so use the command line tool. -}
+genUUID :: IO String
+genUUID = do
+ pOpen ReadFromPipe "uuid" ["-m"] $ \h -> hGetLine h