remove Params constructor from Utility.SafeCommand
This removes a bit of complexity, and should make things faster (avoids tokenizing Params string), and probably involve less garbage collection. In a few places, it was useful to use Params to avoid needing a list, but that is easily avoided. Problems noticed while doing this conversion: * Some uses of Params "oneword" which was entirely unnecessary overhead. * A few places that built up a list of parameters with ++ and then used Params to split it! Test suite passes.
This commit is contained in:
parent
8f4860df13
commit
eb33569f9d
26 changed files with 221 additions and 118 deletions
|
@ -89,7 +89,9 @@ resolveMerge us them = do
|
||||||
unlessM isDirect $ do
|
unlessM isDirect $ do
|
||||||
(deleted, cleanup2) <- inRepo (LsFiles.deleted [top])
|
(deleted, cleanup2) <- inRepo (LsFiles.deleted [top])
|
||||||
unless (null deleted) $
|
unless (null deleted) $
|
||||||
Annex.Queue.addCommand "rm" [Params "--quiet -f --"] deleted
|
Annex.Queue.addCommand "rm"
|
||||||
|
[Param "--quiet", Param "-f", Param "--"]
|
||||||
|
deleted
|
||||||
void $ liftIO cleanup2
|
void $ liftIO cleanup2
|
||||||
|
|
||||||
when merged $ do
|
when merged $ do
|
||||||
|
@ -173,7 +175,8 @@ resolveMerge' (Just us) them u = do
|
||||||
|
|
||||||
resolveby a = do
|
resolveby a = do
|
||||||
{- Remove conflicted file from index so merge can be resolved. -}
|
{- Remove conflicted file from index so merge can be resolved. -}
|
||||||
Annex.Queue.addCommand "rm" [Params "--quiet -f --cached --"] [file]
|
Annex.Queue.addCommand "rm"
|
||||||
|
[Param "--quiet", Param "-f", Param "--cached", Param "--"] [file]
|
||||||
void a
|
void a
|
||||||
return (Just file)
|
return (Just file)
|
||||||
|
|
||||||
|
|
|
@ -315,7 +315,10 @@ files = do
|
||||||
- and without updating the branch. -}
|
- and without updating the branch. -}
|
||||||
branchFiles :: Annex [FilePath]
|
branchFiles :: Annex [FilePath]
|
||||||
branchFiles = withIndex $ inRepo $ Git.Command.pipeNullSplitZombie
|
branchFiles = withIndex $ inRepo $ Git.Command.pipeNullSplitZombie
|
||||||
[ Params "ls-tree --name-only -r -z"
|
[ Param "ls-tree"
|
||||||
|
, Param "--name-only"
|
||||||
|
, Param "-r"
|
||||||
|
, Param "-z"
|
||||||
, Param $ fromRef fullname
|
, Param $ fromRef fullname
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -14,11 +14,11 @@ import qualified Annex
|
||||||
import Utility.Quvi
|
import Utility.Quvi
|
||||||
import Utility.Url
|
import Utility.Url
|
||||||
|
|
||||||
withQuviOptions :: forall a. Query a -> [QuviParam] -> URLString -> Annex a
|
withQuviOptions :: forall a. Query a -> [QuviParams] -> URLString -> Annex a
|
||||||
withQuviOptions a ps url = do
|
withQuviOptions a ps url = do
|
||||||
v <- quviVersion
|
v <- quviVersion
|
||||||
opts <- map Param . annexQuviOptions <$> Annex.getGitConfig
|
opts <- map Param . annexQuviOptions <$> Annex.getGitConfig
|
||||||
liftIO $ a v (map (\mkp -> mkp v) ps++opts) url
|
liftIO $ a v (concatMap (\mkp -> mkp v) ps ++ opts) url
|
||||||
|
|
||||||
quviSupported :: URLString -> Annex Bool
|
quviSupported :: URLString -> Annex Bool
|
||||||
quviSupported u = liftIO . flip supported u =<< quviVersion
|
quviSupported u = liftIO . flip supported u =<< quviVersion
|
||||||
|
|
|
@ -92,7 +92,8 @@ bestSocketPath abssocketfile = do
|
||||||
sshConnectionCachingParams :: FilePath -> [CommandParam]
|
sshConnectionCachingParams :: FilePath -> [CommandParam]
|
||||||
sshConnectionCachingParams socketfile =
|
sshConnectionCachingParams socketfile =
|
||||||
[ Param "-S", Param socketfile
|
[ Param "-S", Param socketfile
|
||||||
, Params "-o ControlMaster=auto -o ControlPersist=yes"
|
, Param "-o", Param "ControlMaster=auto"
|
||||||
|
, Param "-o", Param "ControlPersist=yes"
|
||||||
]
|
]
|
||||||
|
|
||||||
{- ssh connection caching creates sockets, so will not work on a
|
{- ssh connection caching creates sockets, so will not work on a
|
||||||
|
@ -180,8 +181,8 @@ forceStopSsh socketfile = do
|
||||||
void $ liftIO $ catchMaybeIO $
|
void $ liftIO $ catchMaybeIO $
|
||||||
withQuietOutput createProcessSuccess $
|
withQuietOutput createProcessSuccess $
|
||||||
(proc "ssh" $ toCommand $
|
(proc "ssh" $ toCommand $
|
||||||
[ Params "-O stop"
|
[ Param "-O", Param "stop" ] ++
|
||||||
] ++ params ++ [Param "localhost"])
|
params ++ [Param "localhost"])
|
||||||
{ cwd = Just dir }
|
{ cwd = Just dir }
|
||||||
liftIO $ nukeFile socketfile
|
liftIO $ nukeFile socketfile
|
||||||
|
|
||||||
|
|
|
@ -202,7 +202,7 @@ add bigfilematcher file = ifM (liftAnnex $ checkFileMatcher bigfilematcher file)
|
||||||
( pendingAddChange file
|
( pendingAddChange file
|
||||||
, do
|
, do
|
||||||
liftAnnex $ Annex.Queue.addCommand "add"
|
liftAnnex $ Annex.Queue.addCommand "add"
|
||||||
[Params "--force --"] [file]
|
[Param "--force", Param "--"] [file]
|
||||||
madeChange file AddFileChange
|
madeChange file AddFileChange
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,11 @@ getGCryptRemoteName :: UUID -> String -> Annex RemoteName
|
||||||
getGCryptRemoteName u repoloc = do
|
getGCryptRemoteName u repoloc = do
|
||||||
tmpremote <- uniqueRemoteName "tmpgcryptremote" 0 <$> gitRepo
|
tmpremote <- uniqueRemoteName "tmpgcryptremote" 0 <$> gitRepo
|
||||||
void $ inRepo $ Git.Command.runBool
|
void $ inRepo $ Git.Command.runBool
|
||||||
[Params "remote add", Param tmpremote, Param $ Git.GCrypt.urlPrefix ++ repoloc]
|
[ Param "remote"
|
||||||
|
, Param "add"
|
||||||
|
, Param tmpremote
|
||||||
|
, Param $ Git.GCrypt.urlPrefix ++ repoloc
|
||||||
|
]
|
||||||
mname <- ifM (inRepo $ Git.Command.runBool [Param "fetch", Param tmpremote])
|
mname <- ifM (inRepo $ Git.Command.runBool [Param "fetch", Param tmpremote])
|
||||||
( do
|
( do
|
||||||
void Annex.Branch.forceUpdate
|
void Annex.Branch.forceUpdate
|
||||||
|
|
|
@ -130,11 +130,13 @@ makeinfos updated version = do
|
||||||
]
|
]
|
||||||
void $ inRepo $ runBool
|
void $ inRepo $ runBool
|
||||||
[ Param "annex"
|
[ Param "annex"
|
||||||
, Params "move --to website"
|
, Param "move"
|
||||||
|
, Param "--to"
|
||||||
|
, Param "website"
|
||||||
]
|
]
|
||||||
void $ inRepo $ runBool
|
void $ inRepo $ runBool
|
||||||
[ Param "annex"
|
[ Param "annex"
|
||||||
, Params "sync"
|
, Param "sync"
|
||||||
]
|
]
|
||||||
|
|
||||||
-- Check for out of date info files.
|
-- Check for out of date info files.
|
||||||
|
|
|
@ -148,7 +148,11 @@ getLog key os = do
|
||||||
config <- Annex.getGitConfig
|
config <- Annex.getGitConfig
|
||||||
let logfile = p </> locationLogFile config key
|
let logfile = p </> locationLogFile config key
|
||||||
inRepo $ pipeNullSplitZombie $
|
inRepo $ pipeNullSplitZombie $
|
||||||
[ Params "log -z --pretty=format:%ct --raw --abbrev=40"
|
[ Param "log"
|
||||||
|
, Param "-z"
|
||||||
|
, Param "--pretty=format:%ct"
|
||||||
|
, Param "-raw"
|
||||||
|
, Param "--abbrev=40"
|
||||||
, Param "--remove-empty"
|
, Param "--remove-empty"
|
||||||
] ++ os ++
|
] ++ os ++
|
||||||
[ Param $ Git.fromRef Annex.Branch.fullname
|
[ Param $ Git.fromRef Annex.Branch.fullname
|
||||||
|
|
|
@ -72,7 +72,14 @@ start file key = stopUnless (inAnnex key) $ do
|
||||||
performIndirect :: FilePath -> Key -> CommandPerform
|
performIndirect :: FilePath -> Key -> CommandPerform
|
||||||
performIndirect file key = do
|
performIndirect file key = do
|
||||||
liftIO $ removeFile file
|
liftIO $ removeFile file
|
||||||
inRepo $ Git.Command.run [Params "rm --cached --force --quiet --", File file]
|
inRepo $ Git.Command.run
|
||||||
|
[ Param "rm"
|
||||||
|
, Param "--cached"
|
||||||
|
, Param "--force"
|
||||||
|
, Param "--quiet"
|
||||||
|
, Param "--"
|
||||||
|
, File file
|
||||||
|
]
|
||||||
next $ cleanupIndirect file key
|
next $ cleanupIndirect file key
|
||||||
|
|
||||||
cleanupIndirect :: FilePath -> Key -> CommandCleanup
|
cleanupIndirect :: FilePath -> Key -> CommandCleanup
|
||||||
|
@ -108,7 +115,14 @@ cleanupIndirect file key = do
|
||||||
performDirect :: FilePath -> Key -> CommandPerform
|
performDirect :: FilePath -> Key -> CommandPerform
|
||||||
performDirect file key = do
|
performDirect file key = do
|
||||||
-- --force is needed when the file is not committed
|
-- --force is needed when the file is not committed
|
||||||
inRepo $ Git.Command.run [Params "rm --cached --force --quiet --", File file]
|
inRepo $ Git.Command.run
|
||||||
|
[ Param "rm"
|
||||||
|
, Param "--cached"
|
||||||
|
, Param "--force"
|
||||||
|
, Param "--quiet"
|
||||||
|
, Param "--"
|
||||||
|
, File file
|
||||||
|
]
|
||||||
next $ cleanupDirect file key
|
next $ cleanupDirect file key
|
||||||
|
|
||||||
{- The direct mode file is not touched during unannex, so the content
|
{- The direct mode file is not touched during unannex, so the content
|
||||||
|
|
|
@ -37,7 +37,7 @@ check = do
|
||||||
where
|
where
|
||||||
current_branch = Git.Ref . Prelude.head . lines <$> revhead
|
current_branch = Git.Ref . Prelude.head . lines <$> revhead
|
||||||
revhead = inRepo $ Git.Command.pipeReadStrict
|
revhead = inRepo $ Git.Command.pipeReadStrict
|
||||||
[Params "rev-parse --abbrev-ref HEAD"]
|
[Param "rev-parse", Param "--abbrev-ref", Param "HEAD"]
|
||||||
|
|
||||||
seek :: CommandSeek
|
seek :: CommandSeek
|
||||||
seek ps = do
|
seek ps = do
|
||||||
|
|
|
@ -30,7 +30,8 @@ checkAttrStart attrs repo = do
|
||||||
where
|
where
|
||||||
params =
|
params =
|
||||||
[ Param "check-attr"
|
[ Param "check-attr"
|
||||||
, Params "-z --stdin"
|
, Param "-z"
|
||||||
|
, Param "--stdin"
|
||||||
] ++ map Param attrs ++
|
] ++ map Param attrs ++
|
||||||
[ Param "--" ]
|
[ Param "--" ]
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,10 @@ checkIgnoreStart repo = ifM supportedGitVersion
|
||||||
where
|
where
|
||||||
params =
|
params =
|
||||||
[ Param "check-ignore"
|
[ Param "check-ignore"
|
||||||
, Params "-z --stdin --verbose --non-matching"
|
, Param "-z"
|
||||||
|
, Param "--stdin"
|
||||||
|
, Param "--verbose"
|
||||||
|
, Param "--non-matching"
|
||||||
]
|
]
|
||||||
repo' = repo { gitGlobalOpts = filter (not . pathspecs) (gitGlobalOpts repo) }
|
repo' = repo { gitGlobalOpts = filter (not . pathspecs) (gitGlobalOpts repo) }
|
||||||
pathspecs (Param "--literal-pathspecs") = True
|
pathspecs (Param "--literal-pathspecs") = True
|
||||||
|
|
|
@ -78,7 +78,13 @@ getdiff command params repo = do
|
||||||
(diff, cleanup) <- pipeNullSplit ps repo
|
(diff, cleanup) <- pipeNullSplit ps repo
|
||||||
return (parseDiffRaw diff, cleanup)
|
return (parseDiffRaw diff, cleanup)
|
||||||
where
|
where
|
||||||
ps = command : Params "-z --raw --no-renames -l0" : params
|
ps =
|
||||||
|
command :
|
||||||
|
Param "-z" :
|
||||||
|
Param "--raw" :
|
||||||
|
Param "--no-renames" :
|
||||||
|
Param "-l0" :
|
||||||
|
params
|
||||||
|
|
||||||
{- Parses --raw output used by diff-tree and git-log. -}
|
{- Parses --raw output used by diff-tree and git-log. -}
|
||||||
parseDiffRaw :: [String] -> [DiffTreeItem]
|
parseDiffRaw :: [String] -> [DiffTreeItem]
|
||||||
|
|
|
@ -35,14 +35,23 @@ import System.Posix.Types
|
||||||
|
|
||||||
{- Scans for files that are checked into git at the specified locations. -}
|
{- Scans for files that are checked into git at the specified locations. -}
|
||||||
inRepo :: [FilePath] -> Repo -> IO ([FilePath], IO Bool)
|
inRepo :: [FilePath] -> Repo -> IO ([FilePath], IO Bool)
|
||||||
inRepo l = pipeNullSplit $ Params "ls-files --cached -z --" : map File l
|
inRepo l = pipeNullSplit $
|
||||||
|
Param "ls-files" :
|
||||||
|
Param "--cached" :
|
||||||
|
Param "-z" :
|
||||||
|
Param "--" :
|
||||||
|
map File l
|
||||||
|
|
||||||
{- Scans for files at the specified locations that are not checked into git. -}
|
{- Scans for files at the specified locations that are not checked into git. -}
|
||||||
notInRepo :: Bool -> [FilePath] -> Repo -> IO ([FilePath], IO Bool)
|
notInRepo :: Bool -> [FilePath] -> Repo -> IO ([FilePath], IO Bool)
|
||||||
notInRepo include_ignored l repo = pipeNullSplit params repo
|
notInRepo include_ignored l repo = pipeNullSplit params repo
|
||||||
where
|
where
|
||||||
params = [Params "ls-files --others"] ++ exclude ++
|
params = concat
|
||||||
[Params "-z --"] ++ map File l
|
[ [ Param "ls-files", Param "--others"]
|
||||||
|
, exclude
|
||||||
|
, [ Param "-z", Param "--" ]
|
||||||
|
, map File l
|
||||||
|
]
|
||||||
exclude
|
exclude
|
||||||
| include_ignored = []
|
| include_ignored = []
|
||||||
| otherwise = [Param "--exclude-standard"]
|
| otherwise = [Param "--exclude-standard"]
|
||||||
|
@ -50,28 +59,51 @@ notInRepo include_ignored l repo = pipeNullSplit params repo
|
||||||
{- Finds all files in the specified locations, whether checked into git or
|
{- Finds all files in the specified locations, whether checked into git or
|
||||||
- not. -}
|
- not. -}
|
||||||
allFiles :: [FilePath] -> Repo -> IO ([FilePath], IO Bool)
|
allFiles :: [FilePath] -> Repo -> IO ([FilePath], IO Bool)
|
||||||
allFiles l = pipeNullSplit $ Params "ls-files --cached --others -z --" : map File l
|
allFiles l = pipeNullSplit $
|
||||||
|
Param "ls-files" :
|
||||||
|
Param "--cached" :
|
||||||
|
Param "--others" :
|
||||||
|
Param "-z" :
|
||||||
|
Param "--" :
|
||||||
|
map File l
|
||||||
|
|
||||||
{- Returns a list of files in the specified locations that have been
|
{- Returns a list of files in the specified locations that have been
|
||||||
- deleted. -}
|
- deleted. -}
|
||||||
deleted :: [FilePath] -> Repo -> IO ([FilePath], IO Bool)
|
deleted :: [FilePath] -> Repo -> IO ([FilePath], IO Bool)
|
||||||
deleted l repo = pipeNullSplit params repo
|
deleted l repo = pipeNullSplit params repo
|
||||||
where
|
where
|
||||||
params = [Params "ls-files --deleted -z --"] ++ map File l
|
params =
|
||||||
|
Param "ls-files" :
|
||||||
|
Param "--deleted" :
|
||||||
|
Param "-z" :
|
||||||
|
Param "--" :
|
||||||
|
map File l
|
||||||
|
|
||||||
{- Returns a list of files in the specified locations that have been
|
{- Returns a list of files in the specified locations that have been
|
||||||
- modified. -}
|
- modified. -}
|
||||||
modified :: [FilePath] -> Repo -> IO ([FilePath], IO Bool)
|
modified :: [FilePath] -> Repo -> IO ([FilePath], IO Bool)
|
||||||
modified l repo = pipeNullSplit params repo
|
modified l repo = pipeNullSplit params repo
|
||||||
where
|
where
|
||||||
params = [Params "ls-files --modified -z --"] ++ map File l
|
params =
|
||||||
|
Param "ls-files" :
|
||||||
|
Param "--modified" :
|
||||||
|
Param "-z" :
|
||||||
|
Param "--" :
|
||||||
|
map File l
|
||||||
|
|
||||||
{- Files that have been modified or are not checked into git (and are not
|
{- Files that have been modified or are not checked into git (and are not
|
||||||
- ignored). -}
|
- ignored). -}
|
||||||
modifiedOthers :: [FilePath] -> Repo -> IO ([FilePath], IO Bool)
|
modifiedOthers :: [FilePath] -> Repo -> IO ([FilePath], IO Bool)
|
||||||
modifiedOthers l repo = pipeNullSplit params repo
|
modifiedOthers l repo = pipeNullSplit params repo
|
||||||
where
|
where
|
||||||
params = [Params "ls-files --modified --others --exclude-standard -z --"] ++ map File l
|
params =
|
||||||
|
Param "ls-files" :
|
||||||
|
Param "--modified" :
|
||||||
|
Param "--others" :
|
||||||
|
Param "--exclude-standard" :
|
||||||
|
Param "-z" :
|
||||||
|
Param "--" :
|
||||||
|
map File l
|
||||||
|
|
||||||
{- Returns a list of all files that are staged for commit. -}
|
{- Returns a list of all files that are staged for commit. -}
|
||||||
staged :: [FilePath] -> Repo -> IO ([FilePath], IO Bool)
|
staged :: [FilePath] -> Repo -> IO ([FilePath], IO Bool)
|
||||||
|
@ -85,7 +117,7 @@ stagedNotDeleted = staged' [Param "--diff-filter=ACMRT"]
|
||||||
staged' :: [CommandParam] -> [FilePath] -> Repo -> IO ([FilePath], IO Bool)
|
staged' :: [CommandParam] -> [FilePath] -> Repo -> IO ([FilePath], IO Bool)
|
||||||
staged' ps l = pipeNullSplit $ prefix ++ ps ++ suffix
|
staged' ps l = pipeNullSplit $ prefix ++ ps ++ suffix
|
||||||
where
|
where
|
||||||
prefix = [Params "diff --cached --name-only -z"]
|
prefix = [Param "diff", Param "--cached", Param "--name-only", Param "-z"]
|
||||||
suffix = Param "--" : map File l
|
suffix = Param "--" : map File l
|
||||||
|
|
||||||
type StagedDetails = (FilePath, Maybe Sha, Maybe FileMode)
|
type StagedDetails = (FilePath, Maybe Sha, Maybe FileMode)
|
||||||
|
@ -93,7 +125,7 @@ type StagedDetails = (FilePath, Maybe Sha, Maybe FileMode)
|
||||||
{- Returns details about files that are staged in the index,
|
{- Returns details about files that are staged in the index,
|
||||||
- as well as files not yet in git. Skips ignored files. -}
|
- as well as files not yet in git. Skips ignored files. -}
|
||||||
stagedOthersDetails :: [FilePath] -> Repo -> IO ([StagedDetails], IO Bool)
|
stagedOthersDetails :: [FilePath] -> Repo -> IO ([StagedDetails], IO Bool)
|
||||||
stagedOthersDetails = stagedDetails' [Params "--others --exclude-standard"]
|
stagedOthersDetails = stagedDetails' [Param "--others", Param "--exclude-standard"]
|
||||||
|
|
||||||
{- Returns details about all files that are staged in the index. -}
|
{- Returns details about all files that are staged in the index. -}
|
||||||
stagedDetails :: [FilePath] -> Repo -> IO ([StagedDetails], IO Bool)
|
stagedDetails :: [FilePath] -> Repo -> IO ([StagedDetails], IO Bool)
|
||||||
|
@ -106,7 +138,7 @@ stagedDetails' ps l repo = do
|
||||||
(ls, cleanup) <- pipeNullSplit params repo
|
(ls, cleanup) <- pipeNullSplit params repo
|
||||||
return (map parse ls, cleanup)
|
return (map parse ls, cleanup)
|
||||||
where
|
where
|
||||||
params = Params "ls-files --stage -z" : ps ++
|
params = Param "ls-files" : Param "--stage" : Param "-z" : ps ++
|
||||||
Param "--" : map File l
|
Param "--" : map File l
|
||||||
parse s
|
parse s
|
||||||
| null file = (s, Nothing, Nothing)
|
| null file = (s, Nothing, Nothing)
|
||||||
|
@ -135,7 +167,12 @@ typeChanged' ps l repo = do
|
||||||
currdir <- getCurrentDirectory
|
currdir <- getCurrentDirectory
|
||||||
return (map (\f -> relPathDirToFileAbs currdir $ top </> f) fs, cleanup)
|
return (map (\f -> relPathDirToFileAbs currdir $ top </> f) fs, cleanup)
|
||||||
where
|
where
|
||||||
prefix = [Params "diff --name-only --diff-filter=T -z"]
|
prefix =
|
||||||
|
[ Param "diff"
|
||||||
|
, Param "--name-only"
|
||||||
|
, Param "--diff-filter=T"
|
||||||
|
, Param "-z"
|
||||||
|
]
|
||||||
suffix = Param "--" : (if null l then [File "."] else map File l)
|
suffix = Param "--" : (if null l then [File "."] else map File l)
|
||||||
|
|
||||||
{- A item in conflict has two possible values.
|
{- A item in conflict has two possible values.
|
||||||
|
@ -166,7 +203,12 @@ unmerged l repo = do
|
||||||
(fs, cleanup) <- pipeNullSplit params repo
|
(fs, cleanup) <- pipeNullSplit params repo
|
||||||
return (reduceUnmerged [] $ catMaybes $ map parseUnmerged fs, cleanup)
|
return (reduceUnmerged [] $ catMaybes $ map parseUnmerged fs, cleanup)
|
||||||
where
|
where
|
||||||
params = Params "ls-files --unmerged -z --" : map File l
|
params =
|
||||||
|
Param "ls-files" :
|
||||||
|
Param "--unmerged" :
|
||||||
|
Param "-z" :
|
||||||
|
Param "--" :
|
||||||
|
map File l
|
||||||
|
|
||||||
data InternalUnmerged = InternalUnmerged
|
data InternalUnmerged = InternalUnmerged
|
||||||
{ isus :: Bool
|
{ isus :: Bool
|
||||||
|
|
|
@ -37,13 +37,26 @@ lsTree t repo = map parseLsTree
|
||||||
<$> pipeNullSplitZombie (lsTreeParams t) repo
|
<$> pipeNullSplitZombie (lsTreeParams t) repo
|
||||||
|
|
||||||
lsTreeParams :: Ref -> [CommandParam]
|
lsTreeParams :: Ref -> [CommandParam]
|
||||||
lsTreeParams t = [ Params "ls-tree --full-tree -z -r --", File $ fromRef t ]
|
lsTreeParams t =
|
||||||
|
[ Param "ls-tree"
|
||||||
|
, Param "--full-tree"
|
||||||
|
, Param "-z"
|
||||||
|
, Param "-r"
|
||||||
|
, Param "--"
|
||||||
|
, File $ fromRef t
|
||||||
|
]
|
||||||
|
|
||||||
{- Lists specified files in a tree. -}
|
{- Lists specified files in a tree. -}
|
||||||
lsTreeFiles :: Ref -> [FilePath] -> Repo -> IO [TreeItem]
|
lsTreeFiles :: Ref -> [FilePath] -> Repo -> IO [TreeItem]
|
||||||
lsTreeFiles t fs repo = map parseLsTree <$> pipeNullSplitStrict ps repo
|
lsTreeFiles t fs repo = map parseLsTree <$> pipeNullSplitStrict ps repo
|
||||||
where
|
where
|
||||||
ps = [Params "ls-tree --full-tree -z --", File $ fromRef t] ++ map File fs
|
ps =
|
||||||
|
[ Param "ls-tree"
|
||||||
|
, Param "--full-tree"
|
||||||
|
, Param "-z"
|
||||||
|
, Param "--"
|
||||||
|
, File $ fromRef t
|
||||||
|
] ++ map File fs
|
||||||
|
|
||||||
{- Parses a line of ls-tree output.
|
{- Parses a line of ls-tree output.
|
||||||
- (The --long format is not currently supported.) -}
|
- (The --long format is not currently supported.) -}
|
||||||
|
|
|
@ -99,7 +99,7 @@ retrieveMissingObjects :: FsckResults -> Maybe FilePath -> Repo -> IO FsckResult
|
||||||
retrieveMissingObjects missing referencerepo r
|
retrieveMissingObjects missing referencerepo r
|
||||||
| not (foundBroken missing) = return missing
|
| not (foundBroken missing) = return missing
|
||||||
| otherwise = withTmpDir "tmprepo" $ \tmpdir -> do
|
| otherwise = withTmpDir "tmprepo" $ \tmpdir -> do
|
||||||
unlessM (boolSystem "git" [Params "init", File tmpdir]) $
|
unlessM (boolSystem "git" [Param "init", File tmpdir]) $
|
||||||
error $ "failed to create temp repository in " ++ tmpdir
|
error $ "failed to create temp repository in " ++ tmpdir
|
||||||
tmpr <- Config.read =<< Construct.fromAbsPath tmpdir
|
tmpr <- Config.read =<< Construct.fromAbsPath tmpdir
|
||||||
stillmissing <- pullremotes tmpr (remotes r) fetchrefstags missing
|
stillmissing <- pullremotes tmpr (remotes r) fetchrefstags missing
|
||||||
|
@ -140,7 +140,9 @@ retrieveMissingObjects missing referencerepo r
|
||||||
ps' =
|
ps' =
|
||||||
[ Param "fetch"
|
[ Param "fetch"
|
||||||
, Param fetchurl
|
, Param fetchurl
|
||||||
, Params "--force --update-head-ok --quiet"
|
, Param "--force"
|
||||||
|
, Param "--update-head-ok"
|
||||||
|
, Param "--quiet"
|
||||||
] ++ ps
|
] ++ ps
|
||||||
fetchr' = fetchr { gitGlobalOpts = gitGlobalOpts fetchr ++ nogc }
|
fetchr' = fetchr { gitGlobalOpts = gitGlobalOpts fetchr ++ nogc }
|
||||||
nogc = [ Param "-c", Param "gc.auto=0" ]
|
nogc = [ Param "-c", Param "gc.auto=0" ]
|
||||||
|
|
|
@ -167,7 +167,7 @@ remove buprepo k = do
|
||||||
| otherwise = void $ liftIO $ catchMaybeIO $ do
|
| otherwise = void $ liftIO $ catchMaybeIO $ do
|
||||||
r' <- Git.Config.read r
|
r' <- Git.Config.read r
|
||||||
boolSystem "git" $ Git.Command.gitCommandLine params r'
|
boolSystem "git" $ Git.Command.gitCommandLine params r'
|
||||||
params = [ Params "branch -q -D", Param (bupRef k) ]
|
params = [ Param "branch", Param "-q", Param "-D", Param (bupRef k) ]
|
||||||
|
|
||||||
{- Bup does not provide a way to tell if a given dataset is present
|
{- Bup does not provide a way to tell if a given dataset is present
|
||||||
- in a bup repository. One way it to check if the git repository has
|
- in a bup repository. One way it to check if the git repository has
|
||||||
|
@ -182,7 +182,9 @@ checkKey r bupr k
|
||||||
Git.Command.gitCommandLine params bupr
|
Git.Command.gitCommandLine params bupr
|
||||||
where
|
where
|
||||||
params =
|
params =
|
||||||
[ Params "show-ref --quiet --verify"
|
[ Param "show-ref"
|
||||||
|
, Param "--quiet"
|
||||||
|
, Param "--verify"
|
||||||
, Param $ "refs/heads/" ++ bupRef k
|
, Param $ "refs/heads/" ++ bupRef k
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -194,7 +196,7 @@ storeBupUUID u buprepo = do
|
||||||
then do
|
then do
|
||||||
showAction "storing uuid"
|
showAction "storing uuid"
|
||||||
unlessM (onBupRemote r boolSystem "git"
|
unlessM (onBupRemote r boolSystem "git"
|
||||||
[Params $ "config annex.uuid " ++ v]) $
|
[Param "config", Param "annex.uuid", Param v]) $
|
||||||
error "ssh failed"
|
error "ssh failed"
|
||||||
else liftIO $ do
|
else liftIO $ do
|
||||||
r' <- Git.Config.read r
|
r' <- Git.Config.read r
|
||||||
|
|
|
@ -175,7 +175,7 @@ gCryptSetup mu _ c = go $ M.lookup "gitrepo" c
|
||||||
go (Just gitrepo) = do
|
go (Just gitrepo) = do
|
||||||
(c', _encsetup) <- encryptionSetup c
|
(c', _encsetup) <- encryptionSetup c
|
||||||
inRepo $ Git.Command.run
|
inRepo $ Git.Command.run
|
||||||
[ Params "remote add"
|
[ Param "remote", Param "add"
|
||||||
, Param remotename
|
, Param remotename
|
||||||
, Param $ Git.GCrypt.urlPrefix ++ gitrepo
|
, Param $ Git.GCrypt.urlPrefix ++ gitrepo
|
||||||
]
|
]
|
||||||
|
@ -251,7 +251,7 @@ setupRepo gcryptid r
|
||||||
void $ Git.Config.changeFile tmpconfig coreGCryptId gcryptid
|
void $ Git.Config.changeFile tmpconfig coreGCryptId gcryptid
|
||||||
void $ Git.Config.changeFile tmpconfig denyNonFastForwards (Git.Config.boolConfig False)
|
void $ Git.Config.changeFile tmpconfig denyNonFastForwards (Git.Config.boolConfig False)
|
||||||
ok <- liftIO $ rsync $ rsynctransport ++
|
ok <- liftIO $ rsync $ rsynctransport ++
|
||||||
[ Params "--recursive"
|
[ Param "--recursive"
|
||||||
, Param $ tmp ++ "/"
|
, Param $ tmp ++ "/"
|
||||||
, Param rsyncurl
|
, Param rsyncurl
|
||||||
]
|
]
|
||||||
|
|
|
@ -95,7 +95,7 @@ inAnnex r k = do
|
||||||
{- Removes a key from a remote. -}
|
{- Removes a key from a remote. -}
|
||||||
dropKey :: Git.Repo -> Key -> Annex Bool
|
dropKey :: Git.Repo -> Key -> Annex Bool
|
||||||
dropKey r key = onRemote r (boolSystem, return False) "dropkey"
|
dropKey r key = onRemote r (boolSystem, return False) "dropkey"
|
||||||
[ Params "--quiet --force"
|
[ Param "--quiet", Param "--force"
|
||||||
, Param $ key2file key
|
, Param $ key2file key
|
||||||
]
|
]
|
||||||
[]
|
[]
|
||||||
|
|
|
@ -172,10 +172,9 @@ store o k src meterupdate = withRsyncScratchDir $ \tmp -> do
|
||||||
ps <- sendParams
|
ps <- sendParams
|
||||||
if ok
|
if ok
|
||||||
then showResumable $ rsyncRemote Upload o (Just meterupdate) $ ps ++
|
then showResumable $ rsyncRemote Upload o (Just meterupdate) $ ps ++
|
||||||
[ Param "--recursive"
|
Param "--recursive" : partialParams ++
|
||||||
, partialParams
|
|
||||||
-- tmp/ to send contents of tmp dir
|
-- tmp/ to send contents of tmp dir
|
||||||
, File $ addTrailingPathSeparator tmp
|
[ File $ addTrailingPathSeparator tmp
|
||||||
, Param $ rsyncUrl o
|
, Param $ rsyncUrl o
|
||||||
]
|
]
|
||||||
else return False
|
else return False
|
||||||
|
@ -204,9 +203,9 @@ remove o k = do
|
||||||
rsync $ rsyncOptions o ++ ps ++
|
rsync $ rsyncOptions o ++ ps ++
|
||||||
map (\s -> Param $ "--include=" ++ s) includes ++
|
map (\s -> Param $ "--include=" ++ s) includes ++
|
||||||
[ Param "--exclude=*" -- exclude everything else
|
[ Param "--exclude=*" -- exclude everything else
|
||||||
, Params "--quiet --delete --recursive"
|
, Param "--quiet", Param "--delete", Param "--recursive"
|
||||||
, partialParams
|
] ++ partialParams ++
|
||||||
, Param $ addTrailingPathSeparator dummy
|
[ Param $ addTrailingPathSeparator dummy
|
||||||
, Param $ rsyncUrl o
|
, Param $ rsyncUrl o
|
||||||
]
|
]
|
||||||
where
|
where
|
||||||
|
@ -237,8 +236,8 @@ checkKey r o k = do
|
||||||
{- Rsync params to enable resumes of sending files safely,
|
{- Rsync params to enable resumes of sending files safely,
|
||||||
- ensure that files are only moved into place once complete
|
- ensure that files are only moved into place once complete
|
||||||
-}
|
-}
|
||||||
partialParams :: CommandParam
|
partialParams :: [CommandParam]
|
||||||
partialParams = Params "--partial --partial-dir=.rsync-partial"
|
partialParams = [Param "--partial", Param "--partial-dir=.rsync-partial"]
|
||||||
|
|
||||||
{- When sending files from crippled filesystems, the permissions can be all
|
{- When sending files from crippled filesystems, the permissions can be all
|
||||||
- messed up, and it's better to use the default permissions on the
|
- messed up, and it's better to use the default permissions on the
|
||||||
|
@ -290,7 +289,7 @@ rsyncRemote direction o m params = do
|
||||||
oh <- mkOutputHandler
|
oh <- mkOutputHandler
|
||||||
liftIO $ rsyncProgress oh meter ps
|
liftIO $ rsyncProgress oh meter ps
|
||||||
where
|
where
|
||||||
ps = opts ++ [Params "--progress"] ++ params
|
ps = opts ++ Param "--progress" : params
|
||||||
opts
|
opts
|
||||||
| direction == Download = rsyncDownloadOptions o
|
| direction == Download = rsyncDownloadOptions o
|
||||||
| otherwise = rsyncUploadOptions o
|
| otherwise = rsyncUploadOptions o
|
||||||
|
|
52
Test.hs
52
Test.hs
|
@ -261,7 +261,7 @@ test_add = inmainrepo $ do
|
||||||
, do
|
, do
|
||||||
writeFile ingitfile $ content ingitfile
|
writeFile ingitfile $ content ingitfile
|
||||||
boolSystem "git" [Param "add", File ingitfile] @? "git add failed"
|
boolSystem "git" [Param "add", File ingitfile] @? "git add failed"
|
||||||
boolSystem "git" [Params "commit -q -m commit"] @? "git commit failed"
|
boolSystem "git" [Param "commit", Param "-q", Param "-m", Param "commit"] @? "git commit failed"
|
||||||
git_annex "add" [ingitfile] @? "add ingitfile should be no-op"
|
git_annex "add" [ingitfile] @? "add ingitfile should be no-op"
|
||||||
unannexed ingitfile
|
unannexed ingitfile
|
||||||
)
|
)
|
||||||
|
@ -314,7 +314,7 @@ test_unannex_withcopy = intmpclonerepo $ do
|
||||||
test_drop_noremote :: Assertion
|
test_drop_noremote :: Assertion
|
||||||
test_drop_noremote = intmpclonerepo $ do
|
test_drop_noremote = intmpclonerepo $ do
|
||||||
git_annex "get" [annexedfile] @? "get failed"
|
git_annex "get" [annexedfile] @? "get failed"
|
||||||
boolSystem "git" [Params "remote rm origin"]
|
boolSystem "git" [Param "remote", Param "rm", Param "origin"]
|
||||||
@? "git remote rm origin failed"
|
@? "git remote rm origin failed"
|
||||||
not <$> git_annex "drop" [annexedfile] @? "drop wrongly succeeded with no known copy of file"
|
not <$> git_annex "drop" [annexedfile] @? "drop wrongly succeeded with no known copy of file"
|
||||||
annexed_present annexedfile
|
annexed_present annexedfile
|
||||||
|
@ -503,7 +503,7 @@ test_edit' precommit = intmpclonerepoInDirect $ do
|
||||||
if precommit
|
if precommit
|
||||||
then git_annex "pre-commit" []
|
then git_annex "pre-commit" []
|
||||||
@? "pre-commit failed"
|
@? "pre-commit failed"
|
||||||
else boolSystem "git" [Params "commit -q -m contentchanged"]
|
else boolSystem "git" [Param "commit", Param "-q", Param "-m", Param "contentchanged"]
|
||||||
@? "git commit of edited file failed"
|
@? "git commit of edited file failed"
|
||||||
runchecks [checklink, checkunwritable] annexedfile
|
runchecks [checklink, checkunwritable] annexedfile
|
||||||
c <- readFile annexedfile
|
c <- readFile annexedfile
|
||||||
|
@ -515,7 +515,7 @@ test_partial_commit = intmpclonerepoInDirect $ do
|
||||||
git_annex "get" [annexedfile] @? "get of file failed"
|
git_annex "get" [annexedfile] @? "get of file failed"
|
||||||
annexed_present annexedfile
|
annexed_present annexedfile
|
||||||
git_annex "unlock" [annexedfile] @? "unlock failed"
|
git_annex "unlock" [annexedfile] @? "unlock failed"
|
||||||
not <$> boolSystem "git" [Params "commit -q -m test", File annexedfile]
|
not <$> boolSystem "git" [Param "commit", Param "-q", Param "-m", Param "test", File annexedfile]
|
||||||
@? "partial commit of unlocked file not blocked by pre-commit hook"
|
@? "partial commit of unlocked file not blocked by pre-commit hook"
|
||||||
|
|
||||||
test_fix :: Assertion
|
test_fix :: Assertion
|
||||||
|
@ -675,15 +675,15 @@ test_unused = intmpclonerepoInDirect $ do
|
||||||
git_annex "get" [annexedfile] @? "get of file failed"
|
git_annex "get" [annexedfile] @? "get of file failed"
|
||||||
git_annex "get" [sha1annexedfile] @? "get of file failed"
|
git_annex "get" [sha1annexedfile] @? "get of file failed"
|
||||||
checkunused [] "after get"
|
checkunused [] "after get"
|
||||||
boolSystem "git" [Params "rm -fq", File annexedfile] @? "git rm failed"
|
boolSystem "git" [Param "rm", Param "-fq", File annexedfile] @? "git rm failed"
|
||||||
checkunused [] "after rm"
|
checkunused [] "after rm"
|
||||||
boolSystem "git" [Params "commit -q -m foo"] @? "git commit failed"
|
boolSystem "git" [Param "commit", Param "-q", Param "-m", Param "foo"] @? "git commit failed"
|
||||||
checkunused [] "after commit"
|
checkunused [] "after commit"
|
||||||
-- unused checks origin/master; once it's gone it is really unused
|
-- unused checks origin/master; once it's gone it is really unused
|
||||||
boolSystem "git" [Params "remote rm origin"] @? "git remote rm origin failed"
|
boolSystem "git" [Param "remote", Param "rm", Param "origin"] @? "git remote rm origin failed"
|
||||||
checkunused [annexedfilekey] "after origin branches are gone"
|
checkunused [annexedfilekey] "after origin branches are gone"
|
||||||
boolSystem "git" [Params "rm -fq", File sha1annexedfile] @? "git rm failed"
|
boolSystem "git" [Param "rm", Param "-fq", File sha1annexedfile] @? "git rm failed"
|
||||||
boolSystem "git" [Params "commit -q -m foo"] @? "git commit failed"
|
boolSystem "git" [Param "commit", Param "-q", Param "-m", Param "foo"] @? "git commit failed"
|
||||||
checkunused [annexedfilekey, sha1annexedfilekey] "after rm sha1annexedfile"
|
checkunused [annexedfilekey, sha1annexedfilekey] "after rm sha1annexedfile"
|
||||||
|
|
||||||
-- good opportunity to test dropkey also
|
-- good opportunity to test dropkey also
|
||||||
|
@ -702,7 +702,7 @@ test_unused = intmpclonerepoInDirect $ do
|
||||||
git_annex "add" ["unusedfile"] @? "add of unusedfile failed"
|
git_annex "add" ["unusedfile"] @? "add of unusedfile failed"
|
||||||
unusedfilekey <- annexeval $ findkey "unusedfile"
|
unusedfilekey <- annexeval $ findkey "unusedfile"
|
||||||
renameFile "unusedfile" "unusedunstagedfile"
|
renameFile "unusedfile" "unusedunstagedfile"
|
||||||
boolSystem "git" [Params "rm -qf", File "unusedfile"] @? "git rm failed"
|
boolSystem "git" [Param "rm", Param "-qf", File "unusedfile"] @? "git rm failed"
|
||||||
checkunused [] "with unstaged link"
|
checkunused [] "with unstaged link"
|
||||||
removeFile "unusedunstagedfile"
|
removeFile "unusedunstagedfile"
|
||||||
checkunused [unusedfilekey] "with unstaged link deleted"
|
checkunused [unusedfilekey] "with unstaged link deleted"
|
||||||
|
@ -714,7 +714,7 @@ test_unused = intmpclonerepoInDirect $ do
|
||||||
boolSystem "git" [Param "add", File "unusedfile"] @? "git add failed"
|
boolSystem "git" [Param "add", File "unusedfile"] @? "git add failed"
|
||||||
unusedfilekey' <- annexeval $ findkey "unusedfile"
|
unusedfilekey' <- annexeval $ findkey "unusedfile"
|
||||||
checkunused [] "with staged deleted link"
|
checkunused [] "with staged deleted link"
|
||||||
boolSystem "git" [Params "rm -qf", File "unusedfile"] @? "git rm failed"
|
boolSystem "git" [Param "rm", Param "-qf", File "unusedfile"] @? "git rm failed"
|
||||||
checkunused [unusedfilekey'] "with staged link deleted"
|
checkunused [unusedfilekey'] "with staged link deleted"
|
||||||
|
|
||||||
-- unused used to miss symlinks that were deleted or modified
|
-- unused used to miss symlinks that were deleted or modified
|
||||||
|
@ -799,13 +799,13 @@ test_union_merge_regression =
|
||||||
withtmpclonerepo False $ \r3 -> do
|
withtmpclonerepo False $ \r3 -> do
|
||||||
forM_ [r1, r2, r3] $ \r -> indir r $ do
|
forM_ [r1, r2, r3] $ \r -> indir r $ do
|
||||||
when (r /= r1) $
|
when (r /= r1) $
|
||||||
boolSystem "git" [Params "remote add r1", File ("../../" ++ r1)] @? "remote add"
|
boolSystem "git" [Param "remote", Param "add", Param "r1", File ("../../" ++ r1)] @? "remote add"
|
||||||
when (r /= r2) $
|
when (r /= r2) $
|
||||||
boolSystem "git" [Params "remote add r2", File ("../../" ++ r2)] @? "remote add"
|
boolSystem "git" [Param "remote", Param "add", Param "r2", File ("../../" ++ r2)] @? "remote add"
|
||||||
when (r /= r3) $
|
when (r /= r3) $
|
||||||
boolSystem "git" [Params "remote add r3", File ("../../" ++ r3)] @? "remote add"
|
boolSystem "git" [Param "remote", Param "add", Param "r3", File ("../../" ++ r3)] @? "remote add"
|
||||||
git_annex "get" [annexedfile] @? "get failed"
|
git_annex "get" [annexedfile] @? "get failed"
|
||||||
boolSystem "git" [Params "remote rm origin"] @? "remote rm"
|
boolSystem "git" [Param "remote", Param "rm", Param "origin"] @? "remote rm"
|
||||||
forM_ [r3, r2, r1] $ \r -> indir r $
|
forM_ [r3, r2, r1] $ \r -> indir r $
|
||||||
git_annex "sync" [] @? "sync failed"
|
git_annex "sync" [] @? "sync failed"
|
||||||
forM_ [r3, r2] $ \r -> indir r $
|
forM_ [r3, r2] $ \r -> indir r $
|
||||||
|
@ -995,7 +995,7 @@ test_nonannexed_file_conflict_resolution = do
|
||||||
indir r2 $ do
|
indir r2 $ do
|
||||||
disconnectOrigin
|
disconnectOrigin
|
||||||
writeFile conflictor nonannexed_content
|
writeFile conflictor nonannexed_content
|
||||||
boolSystem "git" [Params "add", File conflictor] @? "git add conflictor failed"
|
boolSystem "git" [Param "add", File conflictor] @? "git add conflictor failed"
|
||||||
git_annex "sync" [] @? "sync failed in r2"
|
git_annex "sync" [] @? "sync failed in r2"
|
||||||
pair r1 r2
|
pair r1 r2
|
||||||
let l = if inr1 then [r1, r2] else [r2, r1]
|
let l = if inr1 then [r1, r2] else [r2, r1]
|
||||||
|
@ -1046,7 +1046,7 @@ test_nonannexed_symlink_conflict_resolution = do
|
||||||
indir r2 $ do
|
indir r2 $ do
|
||||||
disconnectOrigin
|
disconnectOrigin
|
||||||
createSymbolicLink symlinktarget "conflictor"
|
createSymbolicLink symlinktarget "conflictor"
|
||||||
boolSystem "git" [Params "add", File conflictor] @? "git add conflictor failed"
|
boolSystem "git" [Param "add", File conflictor] @? "git add conflictor failed"
|
||||||
git_annex "sync" [] @? "sync failed in r2"
|
git_annex "sync" [] @? "sync failed in r2"
|
||||||
pair r1 r2
|
pair r1 r2
|
||||||
let l = if inr1 then [r1, r2] else [r2, r1]
|
let l = if inr1 then [r1, r2] else [r2, r1]
|
||||||
|
@ -1154,9 +1154,9 @@ test_conflict_resolution_symlink_bit =
|
||||||
pair :: FilePath -> FilePath -> Assertion
|
pair :: FilePath -> FilePath -> Assertion
|
||||||
pair r1 r2 = forM_ [r1, r2] $ \r -> indir r $ do
|
pair r1 r2 = forM_ [r1, r2] $ \r -> indir r $ do
|
||||||
when (r /= r1) $
|
when (r /= r1) $
|
||||||
boolSystem "git" [Params "remote add r1", File ("../../" ++ r1)] @? "remote add"
|
boolSystem "git" [Param "remote", Param "add", Param "r1", File ("../../" ++ r1)] @? "remote add"
|
||||||
when (r /= r2) $
|
when (r /= r2) $
|
||||||
boolSystem "git" [Params "remote add r2", File ("../../" ++ r2)] @? "remote add"
|
boolSystem "git" [Param "remote", Param "add", Param "r2", File ("../../" ++ r2)] @? "remote add"
|
||||||
|
|
||||||
test_map :: Assertion
|
test_map :: Assertion
|
||||||
test_map = intmpclonerepo $ do
|
test_map = intmpclonerepo $ do
|
||||||
|
@ -1176,7 +1176,7 @@ test_uninit = intmpclonerepo $ do
|
||||||
|
|
||||||
test_uninit_inbranch :: Assertion
|
test_uninit_inbranch :: Assertion
|
||||||
test_uninit_inbranch = intmpclonerepoInDirect $ do
|
test_uninit_inbranch = intmpclonerepoInDirect $ do
|
||||||
boolSystem "git" [Params "checkout git-annex"] @? "git checkout git-annex"
|
boolSystem "git" [Param "checkout", Param "git-annex"] @? "git checkout git-annex"
|
||||||
not <$> git_annex "uninit" [] @? "uninit failed to fail when git-annex branch was checked out"
|
not <$> git_annex "uninit" [] @? "uninit failed to fail when git-annex branch was checked out"
|
||||||
|
|
||||||
test_upgrade :: Assertion
|
test_upgrade :: Assertion
|
||||||
|
@ -1448,7 +1448,7 @@ withtmpclonerepo bare a = do
|
||||||
bracket (clonerepo mainrepodir dir bare) cleanup a
|
bracket (clonerepo mainrepodir dir bare) cleanup a
|
||||||
|
|
||||||
disconnectOrigin :: Assertion
|
disconnectOrigin :: Assertion
|
||||||
disconnectOrigin = boolSystem "git" [Params "remote rm origin"] @? "remote rm"
|
disconnectOrigin = boolSystem "git" [Param "remote", Param "rm", Param "origin"] @? "remote rm"
|
||||||
|
|
||||||
withgitrepo :: (FilePath -> Assertion) -> Assertion
|
withgitrepo :: (FilePath -> Assertion) -> Assertion
|
||||||
withgitrepo = bracket (setuprepo mainrepodir) return
|
withgitrepo = bracket (setuprepo mainrepodir) return
|
||||||
|
@ -1469,7 +1469,7 @@ setuprepo :: FilePath -> IO FilePath
|
||||||
setuprepo dir = do
|
setuprepo dir = do
|
||||||
cleanup dir
|
cleanup dir
|
||||||
ensuretmpdir
|
ensuretmpdir
|
||||||
boolSystem "git" [Params "init -q", File dir] @? "git init failed"
|
boolSystem "git" [Param "init", Param "-q", File dir] @? "git init failed"
|
||||||
configrepo dir
|
configrepo dir
|
||||||
return dir
|
return dir
|
||||||
|
|
||||||
|
@ -1479,7 +1479,7 @@ clonerepo old new bare = do
|
||||||
cleanup new
|
cleanup new
|
||||||
ensuretmpdir
|
ensuretmpdir
|
||||||
let b = if bare then " --bare" else ""
|
let b = if bare then " --bare" else ""
|
||||||
boolSystem "git" [Params ("clone -q" ++ b), File old, File new] @? "git clone failed"
|
boolSystem "git" [Param "clone", Param "-q", Param b, File old, File new] @? "git clone failed"
|
||||||
configrepo new
|
configrepo new
|
||||||
indir new $
|
indir new $
|
||||||
git_annex "init" ["-q", new] @? "git annex init failed"
|
git_annex "init" ["-q", new] @? "git annex init failed"
|
||||||
|
@ -1491,10 +1491,10 @@ clonerepo old new bare = do
|
||||||
configrepo :: FilePath -> IO ()
|
configrepo :: FilePath -> IO ()
|
||||||
configrepo dir = indir dir $ do
|
configrepo dir = indir dir $ do
|
||||||
-- ensure git is set up to let commits happen
|
-- ensure git is set up to let commits happen
|
||||||
boolSystem "git" [Params "config user.name", Param "Test User"] @? "git config failed"
|
boolSystem "git" [Param "config", Param "user.name", Param "Test User"] @? "git config failed"
|
||||||
boolSystem "git" [Params "config user.email test@example.com"] @? "git config failed"
|
boolSystem "git" [Param "config", Param "user.email", Param "test@example.com"] @? "git config failed"
|
||||||
-- avoid signed commits by test suite
|
-- avoid signed commits by test suite
|
||||||
boolSystem "git" [Params "config commit.gpgsign false"] @? "git config failed"
|
boolSystem "git" [Param "config", Param "commit.gpgsign", Param "false"] @? "git config failed"
|
||||||
|
|
||||||
handleforcedirect :: IO ()
|
handleforcedirect :: IO ()
|
||||||
handleforcedirect = whenM ((==) "1" <$> Utility.Env.getEnvDefault "FORCEDIRECT" "") $
|
handleforcedirect = whenM ((==) "1" <$> Utility.Env.getEnvDefault "FORCEDIRECT" "") $
|
||||||
|
|
|
@ -60,17 +60,20 @@ stdParams params = do
|
||||||
|
|
||||||
{- Usual options for symmetric / public-key encryption. -}
|
{- Usual options for symmetric / public-key encryption. -}
|
||||||
stdEncryptionParams :: Bool -> [CommandParam]
|
stdEncryptionParams :: Bool -> [CommandParam]
|
||||||
stdEncryptionParams symmetric =
|
stdEncryptionParams symmetric = enc symmetric ++
|
||||||
[ enc symmetric
|
[ Param "--force-mdc"
|
||||||
, Param "--force-mdc"
|
|
||||||
, Param "--no-textmode"
|
, Param "--no-textmode"
|
||||||
]
|
]
|
||||||
where
|
where
|
||||||
enc True = Param "--symmetric"
|
enc True = [ Param "--symmetric" ]
|
||||||
-- Force gpg to only encrypt to the specified recipients, not
|
-- Force gpg to only encrypt to the specified recipients, not
|
||||||
-- configured defaults. Recipients are assumed to be specified in
|
-- configured defaults. Recipients are assumed to be specified in
|
||||||
-- elsewhere.
|
-- elsewhere.
|
||||||
enc False = Params "--encrypt --no-encrypt-to --no-default-recipient"
|
enc False =
|
||||||
|
[ Param "--encrypt"
|
||||||
|
, Param "--no-encrypt-to"
|
||||||
|
, Param "--no-default-recipient"
|
||||||
|
]
|
||||||
|
|
||||||
{- Runs gpg with some params and returns its stdout, strictly. -}
|
{- Runs gpg with some params and returns its stdout, strictly. -}
|
||||||
readStrict :: [CommandParam] -> IO String
|
readStrict :: [CommandParam] -> IO String
|
||||||
|
@ -152,7 +155,7 @@ pipeLazy params feeder reader = do
|
||||||
findPubKeys :: String -> IO KeyIds
|
findPubKeys :: String -> IO KeyIds
|
||||||
findPubKeys for = KeyIds . parse . lines <$> readStrict params
|
findPubKeys for = KeyIds . parse . lines <$> readStrict params
|
||||||
where
|
where
|
||||||
params = [Params "--with-colons --list-public-keys", Param for]
|
params = [Param "--with-colons", Param "--list-public-keys", Param for]
|
||||||
parse = mapMaybe (keyIdField . split ":")
|
parse = mapMaybe (keyIdField . split ":")
|
||||||
keyIdField ("pub":_:_:_:f:_) = Just f
|
keyIdField ("pub":_:_:_:f:_) = Just f
|
||||||
keyIdField _ = Nothing
|
keyIdField _ = Nothing
|
||||||
|
@ -165,7 +168,7 @@ secretKeys :: IO (M.Map KeyId UserId)
|
||||||
secretKeys = catchDefaultIO M.empty makemap
|
secretKeys = catchDefaultIO M.empty makemap
|
||||||
where
|
where
|
||||||
makemap = M.fromList . parse . lines <$> readStrict params
|
makemap = M.fromList . parse . lines <$> readStrict params
|
||||||
params = [Params "--with-colons --list-secret-keys --fixed-list-mode"]
|
params = [Param "--with-colons", Param "--list-secret-keys", Param "--fixed-list-mode"]
|
||||||
parse = extract [] Nothing . map (split ":")
|
parse = extract [] Nothing . map (split ":")
|
||||||
extract c (Just keyid) (("uid":_:_:_:_:_:_:_:_:userid:_):rest) =
|
extract c (Just keyid) (("uid":_:_:_:_:_:_:_:_:userid:_):rest) =
|
||||||
extract ((keyid, decode_c userid):c) Nothing rest
|
extract ((keyid, decode_c userid):c) Nothing rest
|
||||||
|
@ -215,13 +218,14 @@ genSecretKey keytype passphrase userid keysize =
|
||||||
- It is armored, to avoid newlines, since gpg only reads ciphers up to the
|
- It is armored, to avoid newlines, since gpg only reads ciphers up to the
|
||||||
- first newline. -}
|
- first newline. -}
|
||||||
genRandom :: Bool -> Size -> IO String
|
genRandom :: Bool -> Size -> IO String
|
||||||
genRandom highQuality size = checksize <$> readStrict
|
genRandom highQuality size = checksize <$> readStrict params
|
||||||
[ Params params
|
|
||||||
, Param $ show randomquality
|
|
||||||
, Param $ show size
|
|
||||||
]
|
|
||||||
where
|
where
|
||||||
params = "--gen-random --armor"
|
params =
|
||||||
|
[ Param "--gen-random"
|
||||||
|
, Param "--armor"
|
||||||
|
, Param $ show randomquality
|
||||||
|
, Param $ show size
|
||||||
|
]
|
||||||
|
|
||||||
-- See http://www.gnupg.org/documentation/manuals/gcrypt/Quality-of-random-numbers.html
|
-- See http://www.gnupg.org/documentation/manuals/gcrypt/Quality-of-random-numbers.html
|
||||||
-- for the meaning of random quality levels.
|
-- for the meaning of random quality levels.
|
||||||
|
@ -242,7 +246,7 @@ genRandom highQuality size = checksize <$> readStrict
|
||||||
else shortread len
|
else shortread len
|
||||||
|
|
||||||
shortread got = error $ unwords
|
shortread got = error $ unwords
|
||||||
[ "Not enough bytes returned from gpg", params
|
[ "Not enough bytes returned from gpg", show params
|
||||||
, "(got", show got, "; expected", show expectedlength, ")"
|
, "(got", show got, "; expected", show expectedlength, ")"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -335,8 +339,8 @@ testHarness a = do
|
||||||
dir <- mktmpdir $ base </> "gpgtmpXXXXXX"
|
dir <- mktmpdir $ base </> "gpgtmpXXXXXX"
|
||||||
setEnv var dir True
|
setEnv var dir True
|
||||||
-- For some reason, recent gpg needs a trustdb to be set up.
|
-- For some reason, recent gpg needs a trustdb to be set up.
|
||||||
_ <- pipeStrict [Params "--trust-model auto --update-trustdb"] []
|
_ <- pipeStrict [Param "--trust-model auto", Param "--update-trustdb"] []
|
||||||
_ <- pipeStrict [Params "--import -q"] $ unlines
|
_ <- pipeStrict [Param "--import", Param "-q"] $ unlines
|
||||||
[testSecretKey, testKey]
|
[testSecretKey, testKey]
|
||||||
return dir
|
return dir
|
||||||
|
|
||||||
|
@ -356,13 +360,13 @@ checkEncryptionFile :: FilePath -> Maybe KeyIds -> IO Bool
|
||||||
checkEncryptionFile filename keys =
|
checkEncryptionFile filename keys =
|
||||||
checkGpgPackets keys =<< readStrict params
|
checkGpgPackets keys =<< readStrict params
|
||||||
where
|
where
|
||||||
params = [Params "--list-packets --list-only", File filename]
|
params = [Param "--list-packets", Param "--list-only", File filename]
|
||||||
|
|
||||||
checkEncryptionStream :: String -> Maybe KeyIds -> IO Bool
|
checkEncryptionStream :: String -> Maybe KeyIds -> IO Bool
|
||||||
checkEncryptionStream stream keys =
|
checkEncryptionStream stream keys =
|
||||||
checkGpgPackets keys =<< pipeStrict params stream
|
checkGpgPackets keys =<< pipeStrict params stream
|
||||||
where
|
where
|
||||||
params = [Params "--list-packets --list-only"]
|
params = [Param "--list-packets", Param "--list-only"]
|
||||||
|
|
||||||
{- Parses an OpenPGP packet list, and checks whether data is
|
{- Parses an OpenPGP packet list, and checks whether data is
|
||||||
- symmetrically encrypted (keys is Nothing), or encrypted to some
|
- symmetrically encrypted (keys is Nothing), or encrypted to some
|
||||||
|
|
|
@ -108,7 +108,8 @@ check v ps url = maybe False (not . null . pageLinks) <$> query v ps url
|
||||||
supported :: QuviVersion -> URLString -> IO Bool
|
supported :: QuviVersion -> URLString -> IO Bool
|
||||||
supported NoQuvi _ = return False
|
supported NoQuvi _ = return False
|
||||||
supported Quvi04 url = boolSystem "quvi"
|
supported Quvi04 url = boolSystem "quvi"
|
||||||
[ Params "--verbosity mute --support"
|
[ Param "--verbosity mute"
|
||||||
|
, Param "--support"
|
||||||
, Param url
|
, Param url
|
||||||
]
|
]
|
||||||
{- Use quvi-info to see if the url's domain is supported.
|
{- Use quvi-info to see if the url's domain is supported.
|
||||||
|
@ -134,18 +135,18 @@ listdomains Quvi09 = concatMap (split ",")
|
||||||
(toCommand [Param "info", Param "-p", Param "domains"])
|
(toCommand [Param "info", Param "-p", Param "domains"])
|
||||||
listdomains _ = return []
|
listdomains _ = return []
|
||||||
|
|
||||||
type QuviParam = QuviVersion -> CommandParam
|
type QuviParams = QuviVersion -> [CommandParam]
|
||||||
|
|
||||||
{- Disables progress, but not information output. -}
|
{- Disables progress, but not information output. -}
|
||||||
quiet :: QuviParam
|
quiet :: QuviParams
|
||||||
-- Cannot use quiet as it now disables informational output.
|
-- Cannot use quiet as it now disables informational output.
|
||||||
-- No way to disable progress.
|
-- No way to disable progress.
|
||||||
quiet Quvi09 = Params "--verbosity verbose"
|
quiet Quvi09 = [Param "--verbosity", Param "verbose"]
|
||||||
quiet Quvi04 = Params "--verbosity quiet"
|
quiet Quvi04 = [Param "--verbosity", Param "quiet"]
|
||||||
quiet NoQuvi = Params ""
|
quiet NoQuvi = []
|
||||||
|
|
||||||
{- Only return http results, not streaming protocols. -}
|
{- Only return http results, not streaming protocols. -}
|
||||||
httponly :: QuviParam
|
httponly :: QuviParams
|
||||||
-- No way to do it with 0.9?
|
-- No way to do it with 0.9?
|
||||||
httponly Quvi04 = Params "-c http"
|
httponly Quvi04 = [Param "-c", Param "http"]
|
||||||
httponly _ = Params "" -- No way to do it with 0.9?
|
httponly _ = [] -- No way to do it with 0.9?
|
||||||
|
|
|
@ -44,7 +44,8 @@ rsyncServerParams =
|
||||||
-- allow resuming of transfers of big files
|
-- allow resuming of transfers of big files
|
||||||
, Param "--inplace"
|
, Param "--inplace"
|
||||||
-- other options rsync normally uses in server mode
|
-- other options rsync normally uses in server mode
|
||||||
, Params "-e.Lsf ."
|
, Param "-e.Lsf"
|
||||||
|
, Param "."
|
||||||
]
|
]
|
||||||
|
|
||||||
rsyncUseDestinationPermissions :: CommandParam
|
rsyncUseDestinationPermissions :: CommandParam
|
||||||
|
|
|
@ -19,25 +19,23 @@ import Prelude
|
||||||
|
|
||||||
-- | Parameters that can be passed to a shell command.
|
-- | Parameters that can be passed to a shell command.
|
||||||
data CommandParam
|
data CommandParam
|
||||||
= Params String -- ^ Contains multiple parameters, separated by whitespace
|
= Param String -- ^ A parameter
|
||||||
| Param String -- ^ A single parameter
|
|
||||||
| File FilePath -- ^ The name of a file
|
| File FilePath -- ^ The name of a file
|
||||||
deriving (Eq, Show, Ord)
|
deriving (Eq, Show, Ord)
|
||||||
|
|
||||||
-- | Used to pass a list of CommandParams to a function that runs
|
-- | Used to pass a list of CommandParams to a function that runs
|
||||||
-- a command and expects Strings. -}
|
-- a command and expects Strings. -}
|
||||||
toCommand :: [CommandParam] -> [String]
|
toCommand :: [CommandParam] -> [String]
|
||||||
toCommand = concatMap unwrap
|
toCommand = map unwrap
|
||||||
where
|
where
|
||||||
unwrap (Param s) = [s]
|
unwrap (Param s) = s
|
||||||
unwrap (Params s) = filter (not . null) (split " " s)
|
|
||||||
-- Files that start with a non-alphanumeric that is not a path
|
-- Files that start with a non-alphanumeric that is not a path
|
||||||
-- separator are modified to avoid the command interpreting them as
|
-- separator are modified to avoid the command interpreting them as
|
||||||
-- options or other special constructs.
|
-- options or other special constructs.
|
||||||
unwrap (File s@(h:_))
|
unwrap (File s@(h:_))
|
||||||
| isAlphaNum h || h `elem` pathseps = [s]
|
| isAlphaNum h || h `elem` pathseps = s
|
||||||
| otherwise = ["./" ++ s]
|
| otherwise = "./" ++ s
|
||||||
unwrap (File s) = [s]
|
unwrap (File s) = s
|
||||||
-- '/' is explicitly included because it's an alternative
|
-- '/' is explicitly included because it's an alternative
|
||||||
-- path separator on Windows.
|
-- path separator on Windows.
|
||||||
pathseps = pathSeparator:"./"
|
pathseps = pathSeparator:"./"
|
||||||
|
|
|
@ -228,14 +228,14 @@ download' quiet url file uo = do
|
||||||
- a less cluttered download display.
|
- a less cluttered download display.
|
||||||
-}
|
-}
|
||||||
#ifndef __ANDROID__
|
#ifndef __ANDROID__
|
||||||
wgetparams = catMaybes
|
wgetparams = concat
|
||||||
[ if Build.SysConfig.wgetquietprogress && not quiet
|
[ if Build.SysConfig.wgetquietprogress && not quiet
|
||||||
then Just $ Params "-q --show-progress"
|
then [Param "-q", Param "--show-progress"]
|
||||||
else Nothing
|
else []
|
||||||
, Just $ Params "--clobber -c -O"
|
, [ Param "--clobber", Param "-c", Param "-O"]
|
||||||
]
|
]
|
||||||
#else
|
#else
|
||||||
wgetparams = [Params "-c -O"]
|
wgetparams = [Param "-c", Param "-O"]
|
||||||
#endif
|
#endif
|
||||||
{- Uses the -# progress display, because the normal
|
{- Uses the -# progress display, because the normal
|
||||||
- one is very confusing when resuming, showing
|
- one is very confusing when resuming, showing
|
||||||
|
@ -247,7 +247,7 @@ download' quiet url file uo = do
|
||||||
-- if the url happens to be empty, so pre-create.
|
-- if the url happens to be empty, so pre-create.
|
||||||
writeFile file ""
|
writeFile file ""
|
||||||
go "curl" $ headerparams ++ quietopt "-s" ++
|
go "curl" $ headerparams ++ quietopt "-s" ++
|
||||||
[Params "-f -L -C - -# -o"]
|
[Param "-f", Param "-L", Param "-C", Param "-", Param "-#", Param "-o"]
|
||||||
|
|
||||||
{- Run wget in a temp directory because it has been buggy
|
{- Run wget in a temp directory because it has been buggy
|
||||||
- and overwritten files in the current directory, even though
|
- and overwritten files in the current directory, even though
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue