get many more commands building again
about half are building now
This commit is contained in:
parent
6535aea49a
commit
3c7fd09ec8
19 changed files with 100 additions and 92 deletions
|
@ -20,15 +20,12 @@ import Types.Benchmark
|
||||||
|
|
||||||
import qualified Command.Help
|
import qualified Command.Help
|
||||||
import qualified Command.Add
|
import qualified Command.Add
|
||||||
{-
|
|
||||||
import qualified Command.Unannex
|
import qualified Command.Unannex
|
||||||
-}
|
|
||||||
import qualified Command.Drop
|
import qualified Command.Drop
|
||||||
import qualified Command.Move
|
import qualified Command.Move
|
||||||
import qualified Command.Copy
|
import qualified Command.Copy
|
||||||
import qualified Command.Get
|
import qualified Command.Get
|
||||||
import qualified Command.Fsck
|
import qualified Command.Fsck
|
||||||
{-
|
|
||||||
import qualified Command.LookupKey
|
import qualified Command.LookupKey
|
||||||
import qualified Command.CalcKey
|
import qualified Command.CalcKey
|
||||||
import qualified Command.ContentLocation
|
import qualified Command.ContentLocation
|
||||||
|
@ -51,9 +48,7 @@ import qualified Command.VAdd
|
||||||
import qualified Command.VFilter
|
import qualified Command.VFilter
|
||||||
import qualified Command.VPop
|
import qualified Command.VPop
|
||||||
import qualified Command.VCycle
|
import qualified Command.VCycle
|
||||||
-}
|
|
||||||
import qualified Command.Reinject
|
import qualified Command.Reinject
|
||||||
{-
|
|
||||||
import qualified Command.Fix
|
import qualified Command.Fix
|
||||||
import qualified Command.Init
|
import qualified Command.Init
|
||||||
import qualified Command.Describe
|
import qualified Command.Describe
|
||||||
|
@ -70,6 +65,7 @@ import qualified Command.AddUnused
|
||||||
import qualified Command.Unlock
|
import qualified Command.Unlock
|
||||||
import qualified Command.Lock
|
import qualified Command.Lock
|
||||||
import qualified Command.PreCommit
|
import qualified Command.PreCommit
|
||||||
|
{-
|
||||||
import qualified Command.PostReceive
|
import qualified Command.PostReceive
|
||||||
-}
|
-}
|
||||||
import qualified Command.Find
|
import qualified Command.Find
|
||||||
|
@ -120,7 +116,9 @@ import qualified Command.Forget
|
||||||
import qualified Command.P2P
|
import qualified Command.P2P
|
||||||
import qualified Command.Proxy
|
import qualified Command.Proxy
|
||||||
import qualified Command.DiffDriver
|
import qualified Command.DiffDriver
|
||||||
|
-}
|
||||||
import qualified Command.Smudge
|
import qualified Command.Smudge
|
||||||
|
{-
|
||||||
import qualified Command.Undo
|
import qualified Command.Undo
|
||||||
import qualified Command.Version
|
import qualified Command.Version
|
||||||
import qualified Command.RemoteDaemon
|
import qualified Command.RemoteDaemon
|
||||||
|
@ -146,11 +144,9 @@ cmds testoptparser testrunner mkbenchmarkgenerator =
|
||||||
, Command.Move.cmd
|
, Command.Move.cmd
|
||||||
, Command.Copy.cmd
|
, Command.Copy.cmd
|
||||||
, Command.Fsck.cmd
|
, Command.Fsck.cmd
|
||||||
{-
|
|
||||||
, Command.Unlock.cmd
|
, Command.Unlock.cmd
|
||||||
, Command.Unlock.editcmd
|
, Command.Unlock.editcmd
|
||||||
, Command.Lock.cmd
|
, Command.Lock.cmd
|
||||||
-}
|
|
||||||
, Command.Sync.cmd
|
, Command.Sync.cmd
|
||||||
{-
|
{-
|
||||||
, Command.Mirror.cmd
|
, Command.Mirror.cmd
|
||||||
|
@ -160,7 +156,6 @@ cmds testoptparser testrunner mkbenchmarkgenerator =
|
||||||
-}
|
-}
|
||||||
, Command.Import.cmd
|
, Command.Import.cmd
|
||||||
, Command.Export.cmd
|
, Command.Export.cmd
|
||||||
{-
|
|
||||||
, Command.Init.cmd
|
, Command.Init.cmd
|
||||||
, Command.Describe.cmd
|
, Command.Describe.cmd
|
||||||
, Command.InitRemote.cmd
|
, Command.InitRemote.cmd
|
||||||
|
@ -168,13 +163,14 @@ cmds testoptparser testrunner mkbenchmarkgenerator =
|
||||||
, Command.RenameRemote.cmd
|
, Command.RenameRemote.cmd
|
||||||
, Command.EnableTor.cmd
|
, Command.EnableTor.cmd
|
||||||
, Command.Multicast.cmd
|
, Command.Multicast.cmd
|
||||||
-}
|
|
||||||
, Command.Reinject.cmd
|
, Command.Reinject.cmd
|
||||||
{-
|
|
||||||
, Command.Unannex.cmd
|
, Command.Unannex.cmd
|
||||||
|
{-
|
||||||
, Command.Uninit.cmd
|
, Command.Uninit.cmd
|
||||||
, Command.Reinit.cmd
|
, Command.Reinit.cmd
|
||||||
|
-}
|
||||||
, Command.PreCommit.cmd
|
, Command.PreCommit.cmd
|
||||||
|
{-
|
||||||
, Command.PostReceive.cmd
|
, Command.PostReceive.cmd
|
||||||
, Command.NumCopies.cmd
|
, Command.NumCopies.cmd
|
||||||
, Command.Trust.cmd
|
, Command.Trust.cmd
|
||||||
|
@ -189,6 +185,7 @@ cmds testoptparser testrunner mkbenchmarkgenerator =
|
||||||
, Command.Ungroup.cmd
|
, Command.Ungroup.cmd
|
||||||
, Command.Config.cmd
|
, Command.Config.cmd
|
||||||
, Command.Vicfg.cmd
|
, Command.Vicfg.cmd
|
||||||
|
-}
|
||||||
, Command.LookupKey.cmd
|
, Command.LookupKey.cmd
|
||||||
, Command.CalcKey.cmd
|
, Command.CalcKey.cmd
|
||||||
, Command.ContentLocation.cmd
|
, Command.ContentLocation.cmd
|
||||||
|
@ -217,7 +214,6 @@ cmds testoptparser testrunner mkbenchmarkgenerator =
|
||||||
, Command.Unused.cmd
|
, Command.Unused.cmd
|
||||||
, Command.DropUnused.cmd
|
, Command.DropUnused.cmd
|
||||||
, Command.AddUnused.cmd
|
, Command.AddUnused.cmd
|
||||||
-}
|
|
||||||
, Command.Find.cmd
|
, Command.Find.cmd
|
||||||
{-
|
{-
|
||||||
, Command.FindRef.cmd
|
, Command.FindRef.cmd
|
||||||
|
@ -240,7 +236,9 @@ cmds testoptparser testrunner mkbenchmarkgenerator =
|
||||||
, Command.P2P.cmd
|
, Command.P2P.cmd
|
||||||
, Command.Proxy.cmd
|
, Command.Proxy.cmd
|
||||||
, Command.DiffDriver.cmd
|
, Command.DiffDriver.cmd
|
||||||
|
-}
|
||||||
, Command.Smudge.cmd
|
, Command.Smudge.cmd
|
||||||
|
{-
|
||||||
, Command.Undo.cmd
|
, Command.Undo.cmd
|
||||||
, Command.Version.cmd
|
, Command.Version.cmd
|
||||||
, Command.RemoteDaemon.cmd
|
, Command.RemoteDaemon.cmd
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
- Licensed under the GNU AGPL version 3 or higher.
|
- Licensed under the GNU AGPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
|
||||||
module Command.EnableRemote where
|
module Command.EnableRemote where
|
||||||
|
|
||||||
import Command
|
import Command
|
||||||
|
|
|
@ -22,5 +22,5 @@ cmd = noCommit $ noMessages $ dontCheck repoExists $
|
||||||
run :: Maybe Utility.Format.Format -> String -> Annex Bool
|
run :: Maybe Utility.Format.Format -> String -> Annex Bool
|
||||||
run format p = do
|
run format p = do
|
||||||
let k = fromMaybe (giveup "bad key") $ deserializeKey p
|
let k = fromMaybe (giveup "bad key") $ deserializeKey p
|
||||||
showFormatted format (serializeKey k) (keyVars k)
|
showFormatted format (serializeKey' k) (keyVars k)
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -9,6 +9,7 @@ module Command.Find where
|
||||||
|
|
||||||
import Data.Default
|
import Data.Default
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
|
import qualified Data.ByteString as S
|
||||||
import qualified Data.ByteString.Char8 as S8
|
import qualified Data.ByteString.Char8 as S8
|
||||||
|
|
||||||
import Command
|
import Command
|
||||||
|
@ -76,7 +77,7 @@ startKeys o (key, ActionItemBranchFilePath (BranchFilePath _ topf) _) =
|
||||||
start o (toRawFilePath (getTopFilePath topf)) key
|
start o (toRawFilePath (getTopFilePath topf)) key
|
||||||
startKeys _ _ = stop
|
startKeys _ _ = stop
|
||||||
|
|
||||||
showFormatted :: Maybe Utility.Format.Format -> RawFilePath -> [(String, String)] -> Annex ()
|
showFormatted :: Maybe Utility.Format.Format -> S.ByteString -> [(String, String)] -> Annex ()
|
||||||
showFormatted format unformatted vars =
|
showFormatted format unformatted vars =
|
||||||
unlessM (showFullJSON $ JSONChunk vars) $
|
unlessM (showFullJSON $ JSONChunk vars) $
|
||||||
case format of
|
case format of
|
||||||
|
|
|
@ -37,13 +37,14 @@ seek ps = unlessM crippledFileSystem $ do
|
||||||
|
|
||||||
data FixWhat = FixSymlinks | FixAll
|
data FixWhat = FixSymlinks | FixAll
|
||||||
|
|
||||||
start :: FixWhat -> FilePath -> Key -> CommandStart
|
start :: FixWhat -> RawFilePath -> Key -> CommandStart
|
||||||
start fixwhat file key = do
|
start fixwhat file key = do
|
||||||
currlink <- liftIO $ catchMaybeIO $ readSymbolicLink file
|
currlink <- liftIO $ catchMaybeIO $ readSymbolicLink $ fromRawFilePath file
|
||||||
wantlink <- calcRepo $ gitAnnexLink file key
|
wantlink <- calcRepo $ gitAnnexLink (fromRawFilePath file) key
|
||||||
case currlink of
|
case currlink of
|
||||||
Just l
|
Just l
|
||||||
| l /= wantlink -> fixby $ fixSymlink file wantlink
|
| l /= wantlink -> fixby $
|
||||||
|
fixSymlink (fromRawFilePath file) wantlink
|
||||||
| otherwise -> stop
|
| otherwise -> stop
|
||||||
Nothing -> case fixwhat of
|
Nothing -> case fixwhat of
|
||||||
FixAll -> fixthin
|
FixAll -> fixthin
|
||||||
|
@ -52,15 +53,15 @@ start fixwhat file key = do
|
||||||
fixby = starting "fix" (mkActionItem (key, file))
|
fixby = starting "fix" (mkActionItem (key, file))
|
||||||
fixthin = do
|
fixthin = do
|
||||||
obj <- calcRepo $ gitAnnexLocation key
|
obj <- calcRepo $ gitAnnexLocation key
|
||||||
stopUnless (isUnmodified key file <&&> isUnmodified key obj) $ do
|
stopUnless (isUnmodified key (fromRawFilePath file) <&&> isUnmodified key obj) $ do
|
||||||
thin <- annexThin <$> Annex.getGitConfig
|
thin <- annexThin <$> Annex.getGitConfig
|
||||||
fs <- liftIO $ catchMaybeIO $ getFileStatus file
|
fs <- liftIO $ catchMaybeIO $ getFileStatus (fromRawFilePath file)
|
||||||
os <- liftIO $ catchMaybeIO $ getFileStatus obj
|
os <- liftIO $ catchMaybeIO $ getFileStatus obj
|
||||||
case (linkCount <$> fs, linkCount <$> os, thin) of
|
case (linkCount <$> fs, linkCount <$> os, thin) of
|
||||||
(Just 1, Just 1, True) ->
|
(Just 1, Just 1, True) ->
|
||||||
fixby $ makeHardLink file key
|
fixby $ makeHardLink (fromRawFilePath file) key
|
||||||
(Just n, Just n', False) | n > 1 && n == n' ->
|
(Just n, Just n', False) | n > 1 && n == n' ->
|
||||||
fixby $ breakHardLink file key obj
|
fixby $ breakHardLink (fromRawFilePath file) key obj
|
||||||
_ -> stop
|
_ -> stop
|
||||||
|
|
||||||
breakHardLink :: FilePath -> Key -> FilePath -> CommandPerform
|
breakHardLink :: FilePath -> Key -> FilePath -> CommandPerform
|
||||||
|
|
|
@ -51,7 +51,7 @@ seekBatch fmt = batchInput fmt parse commandAction
|
||||||
in if not (null keyname) && not (null file)
|
in if not (null keyname) && not (null file)
|
||||||
then Right $ go file (keyOpt keyname)
|
then Right $ go file (keyOpt keyname)
|
||||||
else Left "Expected pairs of key and filename"
|
else Left "Expected pairs of key and filename"
|
||||||
go file key = starting "fromkey" (mkActionItem (key, file)) $
|
go file key = starting "fromkey" (mkActionItem (key, toRawFilePath file)) $
|
||||||
perform key file
|
perform key file
|
||||||
|
|
||||||
start :: Bool -> (String, FilePath) -> CommandStart
|
start :: Bool -> (String, FilePath) -> CommandStart
|
||||||
|
@ -61,7 +61,7 @@ start force (keyname, file) = do
|
||||||
inbackend <- inAnnex key
|
inbackend <- inAnnex key
|
||||||
unless inbackend $ giveup $
|
unless inbackend $ giveup $
|
||||||
"key ("++ keyname ++") is not present in backend (use --force to override this sanity check)"
|
"key ("++ keyname ++") is not present in backend (use --force to override this sanity check)"
|
||||||
starting "fromkey" (mkActionItem (key, file)) $
|
starting "fromkey" (mkActionItem (key, toRawFilePath file)) $
|
||||||
perform key file
|
perform key file
|
||||||
|
|
||||||
-- From user input to a Key.
|
-- From user input to a Key.
|
||||||
|
@ -80,7 +80,7 @@ keyOpt s = case parseURI s of
|
||||||
Nothing -> giveup $ "bad key/url " ++ s
|
Nothing -> giveup $ "bad key/url " ++ s
|
||||||
|
|
||||||
perform :: Key -> FilePath -> CommandPerform
|
perform :: Key -> FilePath -> CommandPerform
|
||||||
perform key file = lookupFileNotHidden file >>= \case
|
perform key file = lookupFileNotHidden (toRawFilePath file) >>= \case
|
||||||
Nothing -> ifM (liftIO $ doesFileExist file)
|
Nothing -> ifM (liftIO $ doesFileExist file)
|
||||||
( hasothercontent
|
( hasothercontent
|
||||||
, do
|
, do
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
- Licensed under the GNU AGPL version 3 or higher.
|
- Licensed under the GNU AGPL version 3 or higher.
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
|
||||||
module Command.InitRemote where
|
module Command.InitRemote where
|
||||||
|
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
|
|
|
@ -32,7 +32,7 @@ seek ps = do
|
||||||
l <- workTreeItems ps
|
l <- workTreeItems ps
|
||||||
withFilesInGit (commandAction . (whenAnnexed startNew)) l
|
withFilesInGit (commandAction . (whenAnnexed startNew)) l
|
||||||
|
|
||||||
startNew :: FilePath -> Key -> CommandStart
|
startNew :: RawFilePath -> Key -> CommandStart
|
||||||
startNew file key = ifM (isJust <$> isAnnexLink file)
|
startNew file key = ifM (isJust <$> isAnnexLink file)
|
||||||
( stop
|
( stop
|
||||||
, starting "lock" (mkActionItem (key, file)) $
|
, starting "lock" (mkActionItem (key, file)) $
|
||||||
|
@ -43,7 +43,7 @@ startNew file key = ifM (isJust <$> isAnnexLink file)
|
||||||
| key' == key = cont
|
| key' == key = cont
|
||||||
| otherwise = errorModified
|
| otherwise = errorModified
|
||||||
go Nothing =
|
go Nothing =
|
||||||
ifM (isUnmodified key file)
|
ifM (isUnmodified key (fromRawFilePath file))
|
||||||
( cont
|
( cont
|
||||||
, ifM (Annex.getState Annex.force)
|
, ifM (Annex.getState Annex.force)
|
||||||
( cont
|
( cont
|
||||||
|
@ -52,11 +52,11 @@ startNew file key = ifM (isJust <$> isAnnexLink file)
|
||||||
)
|
)
|
||||||
cont = performNew file key
|
cont = performNew file key
|
||||||
|
|
||||||
performNew :: FilePath -> Key -> CommandPerform
|
performNew :: RawFilePath -> Key -> CommandPerform
|
||||||
performNew file key = do
|
performNew file key = do
|
||||||
lockdown =<< calcRepo (gitAnnexLocation key)
|
lockdown =<< calcRepo (gitAnnexLocation key)
|
||||||
addLink file key
|
addLink (fromRawFilePath file) key
|
||||||
=<< withTSDelta (liftIO . genInodeCache file)
|
=<< withTSDelta (liftIO . genInodeCache (fromRawFilePath file))
|
||||||
next $ cleanupNew file key
|
next $ cleanupNew file key
|
||||||
where
|
where
|
||||||
lockdown obj = do
|
lockdown obj = do
|
||||||
|
@ -70,7 +70,7 @@ performNew file key = do
|
||||||
-- It's ok if the file is hard linked to obj, but if some other
|
-- It's ok if the file is hard linked to obj, but if some other
|
||||||
-- associated file is, we need to break that link to lock down obj.
|
-- associated file is, we need to break that link to lock down obj.
|
||||||
breakhardlink obj = whenM (catchBoolIO $ (> 1) . linkCount <$> liftIO (getFileStatus obj)) $ do
|
breakhardlink obj = whenM (catchBoolIO $ (> 1) . linkCount <$> liftIO (getFileStatus obj)) $ do
|
||||||
mfc <- withTSDelta (liftIO . genInodeCache file)
|
mfc <- withTSDelta (liftIO . genInodeCache (fromRawFilePath file))
|
||||||
unlessM (sameInodeCache obj (maybeToList mfc)) $ do
|
unlessM (sameInodeCache obj (maybeToList mfc)) $ do
|
||||||
modifyContent obj $ replaceFile obj $ \tmp -> do
|
modifyContent obj $ replaceFile obj $ \tmp -> do
|
||||||
unlessM (checkedCopyFile key obj tmp Nothing) $
|
unlessM (checkedCopyFile key obj tmp Nothing) $
|
||||||
|
@ -92,21 +92,21 @@ performNew file key = do
|
||||||
|
|
||||||
lostcontent = logStatus key InfoMissing
|
lostcontent = logStatus key InfoMissing
|
||||||
|
|
||||||
cleanupNew :: FilePath -> Key -> CommandCleanup
|
cleanupNew :: RawFilePath -> Key -> CommandCleanup
|
||||||
cleanupNew file key = do
|
cleanupNew file key = do
|
||||||
Database.Keys.removeAssociatedFile key =<< inRepo (toTopFilePath file)
|
Database.Keys.removeAssociatedFile key =<< inRepo (toTopFilePath (fromRawFilePath file))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
startOld :: FilePath -> CommandStart
|
startOld :: RawFilePath -> CommandStart
|
||||||
startOld file = do
|
startOld file = do
|
||||||
unlessM (Annex.getState Annex.force)
|
unlessM (Annex.getState Annex.force)
|
||||||
errorModified
|
errorModified
|
||||||
starting "lock" (ActionItemWorkTreeFile file) $
|
starting "lock" (ActionItemWorkTreeFile file) $
|
||||||
performOld file
|
performOld file
|
||||||
|
|
||||||
performOld :: FilePath -> CommandPerform
|
performOld :: RawFilePath -> CommandPerform
|
||||||
performOld file = do
|
performOld file = do
|
||||||
Annex.Queue.addCommand "checkout" [Param "--"] [file]
|
Annex.Queue.addCommand "checkout" [Param "--"] [fromRawFilePath file]
|
||||||
next $ return True
|
next $ return True
|
||||||
|
|
||||||
errorModified :: a
|
errorModified :: a
|
||||||
|
|
|
@ -29,11 +29,12 @@ run _ file = seekSingleGitFile file >>= \case
|
||||||
|
|
||||||
-- To support absolute filenames, pass through git ls-files.
|
-- To support absolute filenames, pass through git ls-files.
|
||||||
-- But, this plumbing command does not recurse through directories.
|
-- But, this plumbing command does not recurse through directories.
|
||||||
seekSingleGitFile :: FilePath -> Annex (Maybe FilePath)
|
seekSingleGitFile :: FilePath -> Annex (Maybe RawFilePath)
|
||||||
seekSingleGitFile file = do
|
seekSingleGitFile file = do
|
||||||
(l, cleanup) <- inRepo (Git.LsFiles.inRepo [file])
|
(l, cleanup) <- inRepo (Git.LsFiles.inRepo [toRawFilePath file])
|
||||||
r <- case l of
|
r <- case l of
|
||||||
(f:[]) | takeFileName f == takeFileName file -> return (Just f)
|
(f:[]) | takeFileName (fromRawFilePath f) == takeFileName file ->
|
||||||
|
return (Just f)
|
||||||
_ -> return Nothing
|
_ -> return Nothing
|
||||||
void $ liftIO cleanup
|
void $ liftIO cleanup
|
||||||
return r
|
return r
|
||||||
|
|
|
@ -92,7 +92,7 @@ seek o = case batchOption o of
|
||||||
)
|
)
|
||||||
_ -> giveup "--batch is currently only supported in --json mode"
|
_ -> giveup "--batch is currently only supported in --json mode"
|
||||||
|
|
||||||
start :: VectorClock -> MetaDataOptions -> FilePath -> Key -> CommandStart
|
start :: VectorClock -> MetaDataOptions -> RawFilePath -> Key -> CommandStart
|
||||||
start c o file k = startKeys c o (k, mkActionItem (k, afile))
|
start c o file k = startKeys c o (k, mkActionItem (k, afile))
|
||||||
where
|
where
|
||||||
afile = AssociatedFile (Just file)
|
afile = AssociatedFile (Just file)
|
||||||
|
@ -147,7 +147,7 @@ instance FromJSON MetaDataFields where
|
||||||
fieldsField :: T.Text
|
fieldsField :: T.Text
|
||||||
fieldsField = T.pack "fields"
|
fieldsField = T.pack "fields"
|
||||||
|
|
||||||
parseJSONInput :: String -> Either String (Either FilePath Key, MetaData)
|
parseJSONInput :: String -> Either String (Either RawFilePath Key, MetaData)
|
||||||
parseJSONInput i = do
|
parseJSONInput i = do
|
||||||
v <- eitherDecode (BU.fromString i)
|
v <- eitherDecode (BU.fromString i)
|
||||||
let m = case itemAdded v of
|
let m = case itemAdded v of
|
||||||
|
@ -155,16 +155,16 @@ parseJSONInput i = do
|
||||||
Just (MetaDataFields m') -> m'
|
Just (MetaDataFields m') -> m'
|
||||||
case (itemKey v, itemFile v) of
|
case (itemKey v, itemFile v) of
|
||||||
(Just k, _) -> Right (Right k, m)
|
(Just k, _) -> Right (Right k, m)
|
||||||
(Nothing, Just f) -> Right (Left f, m)
|
(Nothing, Just f) -> Right (Left (toRawFilePath f), m)
|
||||||
(Nothing, Nothing) -> Left "JSON input is missing either file or key"
|
(Nothing, Nothing) -> Left "JSON input is missing either file or key"
|
||||||
|
|
||||||
startBatch :: (Either FilePath Key, MetaData) -> CommandStart
|
startBatch :: (Either RawFilePath Key, MetaData) -> CommandStart
|
||||||
startBatch (i, (MetaData m)) = case i of
|
startBatch (i, (MetaData m)) = case i of
|
||||||
Left f -> do
|
Left f -> do
|
||||||
mk <- lookupFile f
|
mk <- lookupFile f
|
||||||
case mk of
|
case mk of
|
||||||
Just k -> go k (mkActionItem (k, AssociatedFile (Just f)))
|
Just k -> go k (mkActionItem (k, AssociatedFile (Just f)))
|
||||||
Nothing -> giveup $ "not an annexed file: " ++ f
|
Nothing -> giveup $ "not an annexed file: " ++ fromRawFilePath f
|
||||||
Right k -> go k (mkActionItem k)
|
Right k -> go k (mkActionItem k)
|
||||||
where
|
where
|
||||||
go k ai = starting "metadata" ai $ do
|
go k ai = starting "metadata" ai $ do
|
||||||
|
|
|
@ -137,7 +137,7 @@ send ups fs = do
|
||||||
mk <- lookupFile f
|
mk <- lookupFile f
|
||||||
case mk of
|
case mk of
|
||||||
Nothing -> noop
|
Nothing -> noop
|
||||||
Just k -> withObjectLoc k (addlist f)
|
Just k -> withObjectLoc k (addlist (fromRawFilePath f))
|
||||||
liftIO $ hClose h
|
liftIO $ hClose h
|
||||||
|
|
||||||
serverkey <- uftpKey
|
serverkey <- uftpKey
|
||||||
|
|
|
@ -53,11 +53,11 @@ seek ps = lockPreCommitHook $ do
|
||||||
(removeViewMetaData v)
|
(removeViewMetaData v)
|
||||||
|
|
||||||
addViewMetaData :: View -> ViewedFile -> Key -> CommandStart
|
addViewMetaData :: View -> ViewedFile -> Key -> CommandStart
|
||||||
addViewMetaData v f k = starting "metadata" (mkActionItem (k, f)) $
|
addViewMetaData v f k = starting "metadata" (mkActionItem (k, toRawFilePath f)) $
|
||||||
next $ changeMetaData k $ fromView v f
|
next $ changeMetaData k $ fromView v f
|
||||||
|
|
||||||
removeViewMetaData :: View -> ViewedFile -> Key -> CommandStart
|
removeViewMetaData :: View -> ViewedFile -> Key -> CommandStart
|
||||||
removeViewMetaData v f k = starting "metadata" (mkActionItem (k, f)) $
|
removeViewMetaData v f k = starting "metadata" (mkActionItem (k, toRawFilePath f)) $
|
||||||
next $ changeMetaData k $ unsetMetaData $ fromView v f
|
next $ changeMetaData k $ unsetMetaData $ fromView v f
|
||||||
|
|
||||||
changeMetaData :: Key -> MetaData -> CommandCleanup
|
changeMetaData :: Key -> MetaData -> CommandCleanup
|
||||||
|
|
|
@ -38,13 +38,13 @@ optParser desc = ReKeyOptions
|
||||||
|
|
||||||
-- Split on the last space, since a FilePath can contain whitespace,
|
-- Split on the last space, since a FilePath can contain whitespace,
|
||||||
-- but a Key very rarely does.
|
-- but a Key very rarely does.
|
||||||
batchParser :: String -> Either String (FilePath, Key)
|
batchParser :: String -> Either String (RawFilePath, Key)
|
||||||
batchParser s = case separate (== ' ') (reverse s) of
|
batchParser s = case separate (== ' ') (reverse s) of
|
||||||
(rk, rf)
|
(rk, rf)
|
||||||
| null rk || null rf -> Left "Expected: \"file key\""
|
| null rk || null rf -> Left "Expected: \"file key\""
|
||||||
| otherwise -> case deserializeKey (reverse rk) of
|
| otherwise -> case deserializeKey (reverse rk) of
|
||||||
Nothing -> Left "bad key"
|
Nothing -> Left "bad key"
|
||||||
Just k -> Right (reverse rf, k)
|
Just k -> Right (toRawFilePath (reverse rf), k)
|
||||||
|
|
||||||
seek :: ReKeyOptions -> CommandSeek
|
seek :: ReKeyOptions -> CommandSeek
|
||||||
seek o = case batchOption o of
|
seek o = case batchOption o of
|
||||||
|
@ -52,9 +52,9 @@ seek o = case batchOption o of
|
||||||
NoBatch -> withPairs (commandAction . start . parsekey) (reKeyThese o)
|
NoBatch -> withPairs (commandAction . start . parsekey) (reKeyThese o)
|
||||||
where
|
where
|
||||||
parsekey (file, skey) =
|
parsekey (file, skey) =
|
||||||
(file, fromMaybe (giveup "bad key") (deserializeKey skey))
|
(toRawFilePath file, fromMaybe (giveup "bad key") (deserializeKey skey))
|
||||||
|
|
||||||
start :: (FilePath, Key) -> CommandStart
|
start :: (RawFilePath, Key) -> CommandStart
|
||||||
start (file, newkey) = ifAnnexed file go stop
|
start (file, newkey) = ifAnnexed file go stop
|
||||||
where
|
where
|
||||||
go oldkey
|
go oldkey
|
||||||
|
@ -62,19 +62,19 @@ start (file, newkey) = ifAnnexed file go stop
|
||||||
| otherwise = starting "rekey" (ActionItemWorkTreeFile file) $
|
| otherwise = starting "rekey" (ActionItemWorkTreeFile file) $
|
||||||
perform file oldkey newkey
|
perform file oldkey newkey
|
||||||
|
|
||||||
perform :: FilePath -> Key -> Key -> CommandPerform
|
perform :: RawFilePath -> Key -> Key -> CommandPerform
|
||||||
perform file oldkey newkey = do
|
perform file oldkey newkey = do
|
||||||
ifM (inAnnex oldkey)
|
ifM (inAnnex oldkey)
|
||||||
( unlessM (linkKey file oldkey newkey) $
|
( unlessM (linkKey file oldkey newkey) $
|
||||||
giveup "failed creating link from old to new key"
|
giveup "failed creating link from old to new key"
|
||||||
, unlessM (Annex.getState Annex.force) $
|
, unlessM (Annex.getState Annex.force) $
|
||||||
giveup $ file ++ " is not available (use --force to override)"
|
giveup $ fromRawFilePath file ++ " is not available (use --force to override)"
|
||||||
)
|
)
|
||||||
next $ cleanup file oldkey newkey
|
next $ cleanup file oldkey newkey
|
||||||
|
|
||||||
{- Make a hard link to the old key content (when supported),
|
{- Make a hard link to the old key content (when supported),
|
||||||
- to avoid wasting disk space. -}
|
- to avoid wasting disk space. -}
|
||||||
linkKey :: FilePath -> Key -> Key -> Annex Bool
|
linkKey :: RawFilePath -> Key -> Key -> Annex Bool
|
||||||
linkKey file oldkey newkey = ifM (isJust <$> isAnnexLink file)
|
linkKey file oldkey newkey = ifM (isJust <$> isAnnexLink file)
|
||||||
{- If the object file is already hardlinked to elsewhere, a hard
|
{- If the object file is already hardlinked to elsewhere, a hard
|
||||||
- link won't be made by getViaTmpFromDisk, but a copy instead.
|
- link won't be made by getViaTmpFromDisk, but a copy instead.
|
||||||
|
@ -89,40 +89,40 @@ linkKey file oldkey newkey = ifM (isJust <$> isAnnexLink file)
|
||||||
- it's hard linked to the old key, that link must be broken. -}
|
- it's hard linked to the old key, that link must be broken. -}
|
||||||
oldobj <- calcRepo (gitAnnexLocation oldkey)
|
oldobj <- calcRepo (gitAnnexLocation oldkey)
|
||||||
v <- tryNonAsync $ do
|
v <- tryNonAsync $ do
|
||||||
st <- liftIO $ getFileStatus file
|
st <- liftIO $ getFileStatus (fromRawFilePath file)
|
||||||
when (linkCount st > 1) $ do
|
when (linkCount st > 1) $ do
|
||||||
freezeContent oldobj
|
freezeContent oldobj
|
||||||
replaceFile file $ \tmp -> do
|
replaceFile (fromRawFilePath file) $ \tmp -> do
|
||||||
unlessM (checkedCopyFile oldkey oldobj tmp Nothing) $
|
unlessM (checkedCopyFile oldkey oldobj tmp Nothing) $
|
||||||
error "can't lock old key"
|
error "can't lock old key"
|
||||||
thawContent tmp
|
thawContent tmp
|
||||||
ic <- withTSDelta (liftIO . genInodeCache file)
|
ic <- withTSDelta (liftIO . genInodeCache (fromRawFilePath file))
|
||||||
case v of
|
case v of
|
||||||
Left e -> do
|
Left e -> do
|
||||||
warning (show e)
|
warning (show e)
|
||||||
return False
|
return False
|
||||||
Right () -> do
|
Right () -> do
|
||||||
r <- linkToAnnex newkey file ic
|
r <- linkToAnnex newkey (fromRawFilePath file) ic
|
||||||
return $ case r of
|
return $ case r of
|
||||||
LinkAnnexFailed -> False
|
LinkAnnexFailed -> False
|
||||||
LinkAnnexOk -> True
|
LinkAnnexOk -> True
|
||||||
LinkAnnexNoop -> True
|
LinkAnnexNoop -> True
|
||||||
)
|
)
|
||||||
|
|
||||||
cleanup :: FilePath -> Key -> Key -> CommandCleanup
|
cleanup :: RawFilePath -> Key -> Key -> CommandCleanup
|
||||||
cleanup file oldkey newkey = do
|
cleanup file oldkey newkey = do
|
||||||
ifM (isJust <$> isAnnexLink file)
|
ifM (isJust <$> isAnnexLink file)
|
||||||
( do
|
( do
|
||||||
-- Update symlink to use the new key.
|
-- Update symlink to use the new key.
|
||||||
liftIO $ removeFile file
|
liftIO $ removeFile (fromRawFilePath file)
|
||||||
addLink file newkey Nothing
|
addLink (fromRawFilePath file) newkey Nothing
|
||||||
, do
|
, do
|
||||||
mode <- liftIO $ catchMaybeIO $ fileMode <$> getFileStatus file
|
mode <- liftIO $ catchMaybeIO $ fileMode <$> getFileStatus (fromRawFilePath file)
|
||||||
liftIO $ whenM (isJust <$> isPointerFile file) $
|
liftIO $ whenM (isJust <$> isPointerFile file) $
|
||||||
writePointerFile file newkey mode
|
writePointerFile file newkey mode
|
||||||
stagePointerFile file mode =<< hashPointerFile newkey
|
stagePointerFile file mode =<< hashPointerFile newkey
|
||||||
Database.Keys.removeAssociatedFile oldkey
|
Database.Keys.removeAssociatedFile oldkey
|
||||||
=<< inRepo (toTopFilePath file)
|
=<< inRepo (toTopFilePath (fromRawFilePath file))
|
||||||
)
|
)
|
||||||
whenM (inAnnex newkey) $
|
whenM (inAnnex newkey) $
|
||||||
logStatus newkey InfoPresent
|
logStatus newkey InfoPresent
|
||||||
|
|
|
@ -86,9 +86,9 @@ clean file = do
|
||||||
( liftIO $ L.hPut stdout b
|
( liftIO $ L.hPut stdout b
|
||||||
, case parseLinkTargetOrPointerLazy b of
|
, case parseLinkTargetOrPointerLazy b of
|
||||||
Just k -> do
|
Just k -> do
|
||||||
getMoveRaceRecovery k file
|
getMoveRaceRecovery k (toRawFilePath file)
|
||||||
liftIO $ L.hPut stdout b
|
liftIO $ L.hPut stdout b
|
||||||
Nothing -> go b =<< catKeyFile file
|
Nothing -> go b =<< catKeyFile (toRawFilePath file)
|
||||||
)
|
)
|
||||||
stop
|
stop
|
||||||
where
|
where
|
||||||
|
@ -187,10 +187,10 @@ emitPointer = S.putStr . formatPointer
|
||||||
-- This also handles the case where a copy of a pointer file is made,
|
-- This also handles the case where a copy of a pointer file is made,
|
||||||
-- then git-annex gets the content, and later git add is run on
|
-- then git-annex gets the content, and later git add is run on
|
||||||
-- the pointer copy. It will then be populated with the content.
|
-- the pointer copy. It will then be populated with the content.
|
||||||
getMoveRaceRecovery :: Key -> FilePath -> Annex ()
|
getMoveRaceRecovery :: Key -> RawFilePath -> Annex ()
|
||||||
getMoveRaceRecovery k file = void $ tryNonAsync $
|
getMoveRaceRecovery k file = void $ tryNonAsync $
|
||||||
whenM (inAnnex k) $ do
|
whenM (inAnnex k) $ do
|
||||||
obj <- calcRepo (gitAnnexLocation k)
|
obj <- toRawFilePath <$> calcRepo (gitAnnexLocation k)
|
||||||
-- Cannot restage because git add is running and has
|
-- Cannot restage because git add is running and has
|
||||||
-- the index locked.
|
-- the index locked.
|
||||||
populatePointerFile (Restage False) k obj file >>= \case
|
populatePointerFile (Restage False) k obj file >>= \case
|
||||||
|
@ -204,11 +204,11 @@ update = do
|
||||||
|
|
||||||
updateSmudged :: Restage -> Annex ()
|
updateSmudged :: Restage -> Annex ()
|
||||||
updateSmudged restage = streamSmudged $ \k topf -> do
|
updateSmudged restage = streamSmudged $ \k topf -> do
|
||||||
f <- fromRepo $ fromTopFilePath topf
|
f <- toRawFilePath <$> fromRepo (fromTopFilePath topf)
|
||||||
whenM (inAnnex k) $ do
|
whenM (inAnnex k) $ do
|
||||||
obj <- calcRepo (gitAnnexLocation k)
|
obj <- toRawFilePath <$> calcRepo (gitAnnexLocation k)
|
||||||
unlessM (isJust <$> populatePointerFile restage k obj f) $
|
unlessM (isJust <$> populatePointerFile restage k obj f) $
|
||||||
liftIO (isPointerFile f) >>= \case
|
liftIO (isPointerFile f) >>= \case
|
||||||
Just k' | k' == k -> toplevelWarning False $
|
Just k' | k' == k -> toplevelWarning False $
|
||||||
"unable to populate worktree file " ++ f
|
"unable to populate worktree file " ++ fromRawFilePath f
|
||||||
_ -> noop
|
_ -> noop
|
||||||
|
|
|
@ -116,10 +116,10 @@ instance TCSerialized Direction where
|
||||||
deserialize _ = Nothing
|
deserialize _ = Nothing
|
||||||
|
|
||||||
instance TCSerialized AssociatedFile where
|
instance TCSerialized AssociatedFile where
|
||||||
serialize (AssociatedFile (Just f)) = f
|
serialize (AssociatedFile (Just f)) = fromRawFilePath f
|
||||||
serialize (AssociatedFile Nothing) = ""
|
serialize (AssociatedFile Nothing) = ""
|
||||||
deserialize "" = Just (AssociatedFile Nothing)
|
deserialize "" = Just (AssociatedFile Nothing)
|
||||||
deserialize f = Just (AssociatedFile (Just f))
|
deserialize f = Just (AssociatedFile (Just (toRawFilePath f)))
|
||||||
|
|
||||||
instance TCSerialized RemoteName where
|
instance TCSerialized RemoteName where
|
||||||
serialize n = n
|
serialize n = n
|
||||||
|
|
|
@ -31,17 +31,18 @@ seek ps = withFilesInGit (commandAction . whenAnnexed start) =<< workTreeItems p
|
||||||
{- Before v6, the unlock subcommand replaces the symlink with a copy of
|
{- Before v6, the unlock subcommand replaces the symlink with a copy of
|
||||||
- the file's content. In v6 and above, it converts the file from a symlink
|
- the file's content. In v6 and above, it converts the file from a symlink
|
||||||
- to a pointer. -}
|
- to a pointer. -}
|
||||||
start :: FilePath -> Key -> CommandStart
|
start :: RawFilePath -> Key -> CommandStart
|
||||||
start file key = ifM (isJust <$> isAnnexLink file)
|
start file key = ifM (isJust <$> isAnnexLink file)
|
||||||
( starting "unlock" (mkActionItem (key, AssociatedFile (Just file))) $
|
( starting "unlock" (mkActionItem (key, AssociatedFile (Just file))) $
|
||||||
perform file key
|
perform file key
|
||||||
, stop
|
, stop
|
||||||
)
|
)
|
||||||
|
|
||||||
perform :: FilePath -> Key -> CommandPerform
|
perform :: RawFilePath -> Key -> CommandPerform
|
||||||
perform dest key = do
|
perform dest key = do
|
||||||
destmode <- liftIO $ catchMaybeIO $ fileMode <$> getFileStatus dest
|
destmode <- liftIO $ catchMaybeIO $ fileMode
|
||||||
replaceFile dest $ \tmp ->
|
<$> getFileStatus (fromRawFilePath dest)
|
||||||
|
replaceFile (fromRawFilePath dest) $ \tmp ->
|
||||||
ifM (inAnnex key)
|
ifM (inAnnex key)
|
||||||
( do
|
( do
|
||||||
r <- linkFromAnnex key tmp destmode
|
r <- linkFromAnnex key tmp destmode
|
||||||
|
@ -49,12 +50,12 @@ perform dest key = do
|
||||||
LinkAnnexOk -> return ()
|
LinkAnnexOk -> return ()
|
||||||
LinkAnnexNoop -> return ()
|
LinkAnnexNoop -> return ()
|
||||||
LinkAnnexFailed -> error "unlock failed"
|
LinkAnnexFailed -> error "unlock failed"
|
||||||
, liftIO $ writePointerFile tmp key destmode
|
, liftIO $ writePointerFile (toRawFilePath tmp) key destmode
|
||||||
)
|
)
|
||||||
next $ cleanup dest key destmode
|
next $ cleanup dest key destmode
|
||||||
|
|
||||||
cleanup :: FilePath -> Key -> Maybe FileMode -> CommandCleanup
|
cleanup :: RawFilePath -> Key -> Maybe FileMode -> CommandCleanup
|
||||||
cleanup dest key destmode = do
|
cleanup dest key destmode = do
|
||||||
stagePointerFile dest destmode =<< hashPointerFile key
|
stagePointerFile dest destmode =<< hashPointerFile key
|
||||||
Database.Keys.addAssociatedFile key =<< inRepo (toTopFilePath dest)
|
Database.Keys.addAssociatedFile key =<< inRepo (toTopFilePath (fromRawFilePath dest))
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -192,10 +192,10 @@ withKeysReferencedM a = withKeysReferenced' Nothing () calla
|
||||||
calla k _ _ = a k
|
calla k _ _ = a k
|
||||||
|
|
||||||
{- Folds an action over keys and files referenced in a particular directory. -}
|
{- Folds an action over keys and files referenced in a particular directory. -}
|
||||||
withKeysFilesReferencedIn :: FilePath -> v -> (Key -> FilePath -> v -> Annex v) -> Annex v
|
withKeysFilesReferencedIn :: FilePath -> v -> (Key -> RawFilePath -> v -> Annex v) -> Annex v
|
||||||
withKeysFilesReferencedIn = withKeysReferenced' . Just
|
withKeysFilesReferencedIn = withKeysReferenced' . Just
|
||||||
|
|
||||||
withKeysReferenced' :: Maybe FilePath -> v -> (Key -> FilePath -> v -> Annex v) -> Annex v
|
withKeysReferenced' :: Maybe FilePath -> v -> (Key -> RawFilePath -> v -> Annex v) -> Annex v
|
||||||
withKeysReferenced' mdir initial a = do
|
withKeysReferenced' mdir initial a = do
|
||||||
(files, clean) <- getfiles
|
(files, clean) <- getfiles
|
||||||
r <- go initial files
|
r <- go initial files
|
||||||
|
@ -207,9 +207,9 @@ withKeysReferenced' mdir initial a = do
|
||||||
( return ([], return True)
|
( return ([], return True)
|
||||||
, do
|
, do
|
||||||
top <- fromRepo Git.repoPath
|
top <- fromRepo Git.repoPath
|
||||||
inRepo $ LsFiles.allFiles [top]
|
inRepo $ LsFiles.allFiles [toRawFilePath top]
|
||||||
)
|
)
|
||||||
Just dir -> inRepo $ LsFiles.inRepo [dir]
|
Just dir -> inRepo $ LsFiles.inRepo [toRawFilePath dir]
|
||||||
go v [] = return v
|
go v [] = return v
|
||||||
go v (f:fs) = do
|
go v (f:fs) = do
|
||||||
mk <- lookupFile f
|
mk <- lookupFile f
|
||||||
|
@ -221,7 +221,8 @@ withKeysReferenced' mdir initial a = do
|
||||||
|
|
||||||
withKeysReferencedDiffGitRefs :: RefSpec -> (Key -> Annex ()) -> Annex ()
|
withKeysReferencedDiffGitRefs :: RefSpec -> (Key -> Annex ()) -> Annex ()
|
||||||
withKeysReferencedDiffGitRefs refspec a = do
|
withKeysReferencedDiffGitRefs refspec a = do
|
||||||
rs <- relevantrefs <$> inRepo (Git.Command.pipeReadStrict [Param "show-ref"])
|
rs <- relevantrefs . decodeBS'
|
||||||
|
<$> inRepo (Git.Command.pipeReadStrict [Param "show-ref"])
|
||||||
shaHead <- maybe (return Nothing) (inRepo . Git.Ref.sha)
|
shaHead <- maybe (return Nothing) (inRepo . Git.Ref.sha)
|
||||||
=<< inRepo Git.Branch.currentUnsafe
|
=<< inRepo Git.Branch.currentUnsafe
|
||||||
let haveHead = any (\(shaRef, _) -> Just shaRef == shaHead) rs
|
let haveHead = any (\(shaRef, _) -> Just shaRef == shaHead) rs
|
||||||
|
|
|
@ -101,7 +101,8 @@ checkoutViewBranch view mkbranch = do
|
||||||
- removed.) -}
|
- removed.) -}
|
||||||
top <- liftIO . absPath =<< fromRepo Git.repoPath
|
top <- liftIO . absPath =<< fromRepo Git.repoPath
|
||||||
(l, cleanup) <- inRepo $
|
(l, cleanup) <- inRepo $
|
||||||
LsFiles.notInRepoIncludingEmptyDirectories False [top]
|
LsFiles.notInRepoIncludingEmptyDirectories False
|
||||||
|
[toRawFilePath top]
|
||||||
forM_ l (removeemptydir top)
|
forM_ l (removeemptydir top)
|
||||||
liftIO $ void cleanup
|
liftIO $ void cleanup
|
||||||
unlessM (liftIO $ doesDirectoryExist here) $ do
|
unlessM (liftIO $ doesDirectoryExist here) $ do
|
||||||
|
@ -109,7 +110,7 @@ checkoutViewBranch view mkbranch = do
|
||||||
return ok
|
return ok
|
||||||
where
|
where
|
||||||
removeemptydir top d = do
|
removeemptydir top d = do
|
||||||
p <- inRepo $ toTopFilePath d
|
p <- inRepo $ toTopFilePath $ fromRawFilePath d
|
||||||
liftIO $ tryIO $ removeDirectory (top </> getTopFilePath p)
|
liftIO $ tryIO $ removeDirectory (top </> getTopFilePath p)
|
||||||
cwdmissing top = unlines
|
cwdmissing top = unlines
|
||||||
[ "This view does not include the subdirectory you are currently in."
|
[ "This view does not include the subdirectory you are currently in."
|
||||||
|
|
|
@ -284,7 +284,7 @@ findUncorruptedCommit missing goodcommits branch r = do
|
||||||
, Param "--format=%H"
|
, Param "--format=%H"
|
||||||
, Param (fromRef branch)
|
, Param (fromRef branch)
|
||||||
] r
|
] r
|
||||||
let branchshas = catMaybes $ map (extractSha . decodeBS) ls
|
let branchshas = catMaybes $ map (extractSha . decodeBL) ls
|
||||||
reflogshas <- RefLog.get branch r
|
reflogshas <- RefLog.get branch r
|
||||||
-- XXX Could try a bit harder here, and look
|
-- XXX Could try a bit harder here, and look
|
||||||
-- for uncorrupted old commits in branches in the
|
-- for uncorrupted old commits in branches in the
|
||||||
|
@ -313,7 +313,7 @@ verifyCommit missing goodcommits commit r
|
||||||
, Param "--format=%H %T"
|
, Param "--format=%H %T"
|
||||||
, Param (fromRef commit)
|
, Param (fromRef commit)
|
||||||
] r
|
] r
|
||||||
let committrees = map (parse . decodeBS) ls
|
let committrees = map (parse . decodeBL) ls
|
||||||
if any isNothing committrees || null committrees
|
if any isNothing committrees || null committrees
|
||||||
then do
|
then do
|
||||||
void cleanup
|
void cleanup
|
||||||
|
@ -342,7 +342,7 @@ verifyTree missing treesha r
|
||||||
| S.member treesha missing = return False
|
| S.member treesha missing = return False
|
||||||
| otherwise = do
|
| otherwise = do
|
||||||
(ls, cleanup) <- pipeNullSplit (LsTree.lsTreeParams LsTree.LsTreeRecursive treesha []) r
|
(ls, cleanup) <- pipeNullSplit (LsTree.lsTreeParams LsTree.LsTreeRecursive treesha []) r
|
||||||
let objshas = map (LsTree.sha . LsTree.parseLsTree) ls
|
let objshas = mapMaybe (LsTree.sha <$$> eitherToMaybe . LsTree.parseLsTree) ls
|
||||||
if any (`S.member` missing) objshas
|
if any (`S.member` missing) objshas
|
||||||
then do
|
then do
|
||||||
void cleanup
|
void cleanup
|
||||||
|
@ -366,7 +366,7 @@ checkIndex r = do
|
||||||
- itself is not corrupt. -}
|
- itself is not corrupt. -}
|
||||||
checkIndexFast :: Repo -> IO Bool
|
checkIndexFast :: Repo -> IO Bool
|
||||||
checkIndexFast r = do
|
checkIndexFast r = do
|
||||||
(indexcontents, cleanup) <- LsFiles.stagedDetails [repoPath r] r
|
(indexcontents, cleanup) <- LsFiles.stagedDetails [toRawFilePath (repoPath r)] r
|
||||||
length indexcontents `seq` cleanup
|
length indexcontents `seq` cleanup
|
||||||
|
|
||||||
missingIndex :: Repo -> IO Bool
|
missingIndex :: Repo -> IO Bool
|
||||||
|
@ -375,7 +375,7 @@ missingIndex r = not <$> doesFileExist (localGitDir r </> "index")
|
||||||
{- Finds missing and ok files staged in the index. -}
|
{- Finds missing and ok files staged in the index. -}
|
||||||
partitionIndex :: Repo -> IO ([LsFiles.StagedDetails], [LsFiles.StagedDetails], IO Bool)
|
partitionIndex :: Repo -> IO ([LsFiles.StagedDetails], [LsFiles.StagedDetails], IO Bool)
|
||||||
partitionIndex r = do
|
partitionIndex r = do
|
||||||
(indexcontents, cleanup) <- LsFiles.stagedDetails [repoPath r] r
|
(indexcontents, cleanup) <- LsFiles.stagedDetails [toRawFilePath (repoPath r)] r
|
||||||
l <- forM indexcontents $ \i -> case i of
|
l <- forM indexcontents $ \i -> case i of
|
||||||
(_file, Just sha, Just _mode) -> (,) <$> isMissing sha r <*> pure i
|
(_file, Just sha, Just _mode) -> (,) <$> isMissing sha r <*> pure i
|
||||||
_ -> pure (False, i)
|
_ -> pure (False, i)
|
||||||
|
@ -394,12 +394,12 @@ rewriteIndex r
|
||||||
UpdateIndex.streamUpdateIndex r
|
UpdateIndex.streamUpdateIndex r
|
||||||
=<< (catMaybes <$> mapM reinject good)
|
=<< (catMaybes <$> mapM reinject good)
|
||||||
void cleanup
|
void cleanup
|
||||||
return $ map fst3 bad
|
return $ map (fromRawFilePath . fst3) bad
|
||||||
where
|
where
|
||||||
reinject (file, Just sha, Just mode) = case toTreeItemType mode of
|
reinject (file, Just sha, Just mode) = case toTreeItemType mode of
|
||||||
Nothing -> return Nothing
|
Nothing -> return Nothing
|
||||||
Just treeitemtype -> Just <$>
|
Just treeitemtype -> Just <$>
|
||||||
UpdateIndex.stageFile sha treeitemtype file r
|
UpdateIndex.stageFile sha treeitemtype (fromRawFilePath file) r
|
||||||
reinject _ = return Nothing
|
reinject _ = return Nothing
|
||||||
|
|
||||||
newtype GoodCommits = GoodCommits (S.Set Sha)
|
newtype GoodCommits = GoodCommits (S.Set Sha)
|
||||||
|
|
Loading…
Reference in a new issue