correctness
This commit is contained in:
parent
dc1d5e6831
commit
4fbdb197d5
3 changed files with 9 additions and 7 deletions
9
Annex.hs
9
Annex.hs
|
@ -33,11 +33,12 @@ annexDir repo key = gitDir repo ++ "/annex/" ++ key
|
||||||
startAnnex :: IO State
|
startAnnex :: IO State
|
||||||
startAnnex = do
|
startAnnex = do
|
||||||
r <- gitRepoFromCwd
|
r <- gitRepoFromCwd
|
||||||
gitPrep r
|
r' <- prepUUID r
|
||||||
|
gitPrep r'
|
||||||
|
|
||||||
return State {
|
return State {
|
||||||
repo = r,
|
repo = r',
|
||||||
backends = parseBackendList $ gitConfig r "annex.backends" ""
|
backends = parseBackendList $ gitConfig r' "annex.backends" ""
|
||||||
}
|
}
|
||||||
|
|
||||||
{- Annexes a file, storing it in a backend, and then moving it into
|
{- Annexes a file, storing it in a backend, and then moving it into
|
||||||
|
@ -85,8 +86,6 @@ unannexFile state file = do
|
||||||
{- Sets up a git repo for git-annex. May be called repeatedly. -}
|
{- Sets up a git repo for git-annex. May be called repeatedly. -}
|
||||||
gitPrep :: GitRepo -> IO ()
|
gitPrep :: GitRepo -> IO ()
|
||||||
gitPrep repo = do
|
gitPrep repo = do
|
||||||
prepUUID repo
|
|
||||||
|
|
||||||
-- configure git to use union merge driver on state files
|
-- configure git to use union merge driver on state files
|
||||||
let attrLine = stateLoc ++ "/*.log merge=union"
|
let attrLine = stateLoc ++ "/*.log merge=union"
|
||||||
let attributes = gitAttributes repo
|
let attributes = gitAttributes repo
|
||||||
|
|
|
@ -14,6 +14,7 @@ module GitRepo (
|
||||||
gitDir,
|
gitDir,
|
||||||
gitRelative,
|
gitRelative,
|
||||||
gitConfig,
|
gitConfig,
|
||||||
|
gitConfigRead,
|
||||||
gitAdd,
|
gitAdd,
|
||||||
gitRm,
|
gitRm,
|
||||||
gitRun,
|
gitRun,
|
||||||
|
|
6
UUID.hs
6
UUID.hs
|
@ -23,14 +23,16 @@ genUUID :: IO String
|
||||||
genUUID = do
|
genUUID = do
|
||||||
pOpen ReadFromPipe "uuid" ["-m"] $ \h -> hGetLine h
|
pOpen ReadFromPipe "uuid" ["-m"] $ \h -> hGetLine h
|
||||||
|
|
||||||
|
{- Looks up a repo's UUID -}
|
||||||
getUUID :: GitRepo -> String
|
getUUID :: GitRepo -> String
|
||||||
getUUID repo = gitConfig repo "annex.uuid" ""
|
getUUID repo = gitConfig repo "annex.uuid" ""
|
||||||
|
|
||||||
{- Make sure that the repo has an annex.uuid setting. -}
|
{- Make sure that the repo has an annex.uuid setting. -}
|
||||||
prepUUID :: GitRepo -> IO ()
|
prepUUID :: GitRepo -> IO GitRepo
|
||||||
prepUUID repo =
|
prepUUID repo =
|
||||||
if ("" == getUUID repo)
|
if ("" == getUUID repo)
|
||||||
then do
|
then do
|
||||||
uuid <- genUUID
|
uuid <- genUUID
|
||||||
gitRun repo ["config", configkey, uuid]
|
gitRun repo ["config", configkey, uuid]
|
||||||
else return ()
|
gitConfigRead repo -- return new repo with updated config
|
||||||
|
else return repo
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue