promote forum request to todo item so it is not lost
This commit is contained in:
parent
7b52315d35
commit
cedca095b9
2 changed files with 32 additions and 10 deletions
|
@ -32,17 +32,28 @@ import Git.Sha
|
||||||
|
|
||||||
import Numeric
|
import Numeric
|
||||||
import System.Posix.Types
|
import System.Posix.Types
|
||||||
|
import Data.Char
|
||||||
|
|
||||||
|
{- Somewhat unexpectedly, git-ls-files does its own wildcard expansion
|
||||||
|
- of files passed to it. To avoid that, and only get back exactly the
|
||||||
|
- files we asked for, slash-escape punctuation in the filename. -}
|
||||||
|
mkFile :: FilePath -> CommandParam
|
||||||
|
mkFile = File . concatMap go
|
||||||
|
where
|
||||||
|
go c
|
||||||
|
| c == '*' = ['\\', c]
|
||||||
|
| otherwise = [c]
|
||||||
|
|
||||||
{- 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 $ Params "ls-files --cached -z --" : map mkFile 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 = [Params "ls-files --others"] ++ exclude ++
|
||||||
[Params "-z --"] ++ map File l
|
[Params "-z --"] ++ map mkFile l
|
||||||
exclude
|
exclude
|
||||||
| include_ignored = []
|
| include_ignored = []
|
||||||
| otherwise = [Param "--exclude-standard"]
|
| otherwise = [Param "--exclude-standard"]
|
||||||
|
@ -50,28 +61,28 @@ 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 $ Params "ls-files --cached --others -z --" : map mkFile 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 = [Params "ls-files --deleted -z --"] ++ map mkFile 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 = [Params "ls-files --modified -z --"] ++ map mkFile 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 = [Params "ls-files --modified --others --exclude-standard -z --"] ++ map mkFile 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)
|
||||||
|
@ -86,7 +97,7 @@ 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 = [Params "diff --cached --name-only -z"]
|
||||||
suffix = Param "--" : map File l
|
suffix = Param "--" : map mkFile l
|
||||||
|
|
||||||
type StagedDetails = (FilePath, Maybe Sha, Maybe FileMode)
|
type StagedDetails = (FilePath, Maybe Sha, Maybe FileMode)
|
||||||
|
|
||||||
|
@ -107,7 +118,7 @@ stagedDetails' ps l repo = do
|
||||||
return (map parse ls, cleanup)
|
return (map parse ls, cleanup)
|
||||||
where
|
where
|
||||||
params = Params "ls-files --stage -z" : ps ++
|
params = Params "ls-files --stage -z" : ps ++
|
||||||
Param "--" : map File l
|
Param "--" : map mkFile l
|
||||||
parse s
|
parse s
|
||||||
| null file = (s, Nothing, Nothing)
|
| null file = (s, Nothing, Nothing)
|
||||||
| otherwise = (file, extractSha $ take shaSize rest, readmode mode)
|
| otherwise = (file, extractSha $ take shaSize rest, readmode mode)
|
||||||
|
@ -136,7 +147,7 @@ typeChanged' ps l repo = do
|
||||||
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 = [Params "diff --name-only --diff-filter=T -z"]
|
||||||
suffix = Param "--" : (if null l then [File "."] else map File l)
|
suffix = Param "--" : (if null l then [File "."] else map mkFile l)
|
||||||
|
|
||||||
{- A item in conflict has two possible values.
|
{- A item in conflict has two possible values.
|
||||||
- Either can be Nothing, when that side deleted the file. -}
|
- Either can be Nothing, when that side deleted the file. -}
|
||||||
|
@ -166,7 +177,7 @@ 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 = Params "ls-files --unmerged -z --" : map mkFile l
|
||||||
|
|
||||||
data InternalUnmerged = InternalUnmerged
|
data InternalUnmerged = InternalUnmerged
|
||||||
{ isus :: Bool
|
{ isus :: Bool
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
Someone in the forum noticed that `git annex wanted`
|
||||||
|
handles preferred content settings, but there is no analagous `git annex
|
||||||
|
required`.
|
||||||
|
|
||||||
|
Probably worth adding that, although required content is not an often
|
||||||
|
used feature, and vicfg can already configure it.
|
||||||
|
|
||||||
|
(I don't much like the `git annex required` name. Nor the `git annex wanted`
|
||||||
|
one when it comes to that. Oh well.)
|
||||||
|
|
||||||
|
--[[Joey]]
|
Loading…
Add table
Add a link
Reference in a new issue