summaryrefslogtreecommitdiff
path: root/Annex
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-04-15 20:13:35 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-04-15 20:13:35 -0400
commitdc748c7336aea9cbf04c0311098a44c2b329633d (patch)
tree1a993dd9662ff046b74a427232b8e301500a97b8 /Annex
parent60c4bcefd4d3001e7025fc59c1f7ab927a3a5c34 (diff)
reinit: New command that can initialize a new reposotory using the configuration of a previously known repository. Useful if a repository got deleted and you want to clone it back the way it was.
Diffstat (limited to 'Annex')
-rw-r--r--Annex/Init.hs18
-rw-r--r--Annex/UUID.hs12
2 files changed, 20 insertions, 10 deletions
diff --git a/Annex/Init.hs b/Annex/Init.hs
index 0cb41872c..637b130ee 100644
--- a/Annex/Init.hs
+++ b/Annex/Init.hs
@@ -11,6 +11,7 @@ module Annex.Init (
ensureInitialized,
isInitialized,
initialize,
+ initialize',
uninitialize,
probeCrippledFileSystem,
) where
@@ -60,6 +61,17 @@ genDescription Nothing = do
initialize :: Maybe String -> Annex ()
initialize mdescription = do
prepUUID
+ initialize'
+
+ u <- getUUID
+ {- This will make the first commit to git, so ensure git is set up
+ - properly to allow commits when running it. -}
+ ensureCommit $ do
+ Annex.Branch.create
+ describeUUID u =<< genDescription mdescription
+
+initialize' :: Annex ()
+initialize' = do
checkFifoSupport
checkCrippledFileSystem
unlessM isBare $
@@ -75,12 +87,6 @@ initialize mdescription = do
switchHEADBack
)
createInodeSentinalFile
- u <- getUUID
- {- This will make the first commit to git, so ensure git is set up
- - properly to allow commits when running it. -}
- ensureCommit $ do
- Annex.Branch.create
- describeUUID u =<< genDescription mdescription
uninitialize :: Annex ()
uninitialize = do
diff --git a/Annex/UUID.hs b/Annex/UUID.hs
index 4e274503b..5ed887689 100644
--- a/Annex/UUID.hs
+++ b/Annex/UUID.hs
@@ -21,6 +21,7 @@ module Annex.UUID (
gCryptNameSpace,
removeRepoUUID,
storeUUID,
+ storeUUIDIn,
setUUID,
) where
@@ -70,7 +71,7 @@ getRepoUUID r = do
where
updatecache u = do
g <- gitRepo
- when (g /= r) $ storeUUID cachekey u
+ when (g /= r) $ storeUUIDIn cachekey u
cachekey = remoteConfig r "uuid"
removeRepoUUID :: Annex ()
@@ -84,10 +85,13 @@ getUncachedUUID = toUUID . Git.Config.get key ""
{- Make sure that the repo has an annex.uuid setting. -}
prepUUID :: Annex ()
prepUUID = whenM ((==) NoUUID <$> getUUID) $
- storeUUID configkey =<< liftIO genUUID
+ storeUUID =<< liftIO genUUID
-storeUUID :: ConfigKey -> UUID -> Annex ()
-storeUUID configfield = setConfig configfield . fromUUID
+storeUUID :: UUID -> Annex ()
+storeUUID = storeUUIDIn configkey
+
+storeUUIDIn :: ConfigKey -> UUID -> Annex ()
+storeUUIDIn configfield = setConfig configfield . fromUUID
{- Only sets the configkey in the Repo; does not change .git/config -}
setUUID :: Git.Repo -> UUID -> IO Git.Repo