summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Git/LsFiles.hs31
-rw-r--r--doc/todo/command_line_interface_for_required_content_setthings.mdwn11
2 files changed, 32 insertions, 10 deletions
diff --git a/Git/LsFiles.hs b/Git/LsFiles.hs
index c23c282d0..1006be808 100644
--- a/Git/LsFiles.hs
+++ b/Git/LsFiles.hs
@@ -32,17 +32,28 @@ import Git.Sha
import Numeric
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. -}
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. -}
notInRepo :: Bool -> [FilePath] -> Repo -> IO ([FilePath], IO Bool)
notInRepo include_ignored l repo = pipeNullSplit params repo
where
params = [Params "ls-files --others"] ++ exclude ++
- [Params "-z --"] ++ map File l
+ [Params "-z --"] ++ map mkFile l
exclude
| include_ignored = []
| 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
- not. -}
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
- deleted. -}
deleted :: [FilePath] -> Repo -> IO ([FilePath], IO Bool)
deleted l repo = pipeNullSplit params repo
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
- modified. -}
modified :: [FilePath] -> Repo -> IO ([FilePath], IO Bool)
modified l repo = pipeNullSplit params repo
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
- ignored). -}
modifiedOthers :: [FilePath] -> Repo -> IO ([FilePath], IO Bool)
modifiedOthers l repo = pipeNullSplit params repo
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. -}
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
where
prefix = [Params "diff --cached --name-only -z"]
- suffix = Param "--" : map File l
+ suffix = Param "--" : map mkFile l
type StagedDetails = (FilePath, Maybe Sha, Maybe FileMode)
@@ -107,7 +118,7 @@ stagedDetails' ps l repo = do
return (map parse ls, cleanup)
where
params = Params "ls-files --stage -z" : ps ++
- Param "--" : map File l
+ Param "--" : map mkFile l
parse s
| null file = (s, Nothing, Nothing)
| 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)
where
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.
- Either can be Nothing, when that side deleted the file. -}
@@ -166,7 +177,7 @@ unmerged l repo = do
(fs, cleanup) <- pipeNullSplit params repo
return (reduceUnmerged [] $ catMaybes $ map parseUnmerged fs, cleanup)
where
- params = Params "ls-files --unmerged -z --" : map File l
+ params = Params "ls-files --unmerged -z --" : map mkFile l
data InternalUnmerged = InternalUnmerged
{ isus :: Bool
diff --git a/doc/todo/command_line_interface_for_required_content_setthings.mdwn b/doc/todo/command_line_interface_for_required_content_setthings.mdwn
new file mode 100644
index 000000000..1334b151a
--- /dev/null
+++ b/doc/todo/command_line_interface_for_required_content_setthings.mdwn
@@ -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]]