aboutsummaryrefslogtreecommitdiff
path: root/Git.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Git.hs')
-rw-r--r--Git.hs19
1 files changed, 3 insertions, 16 deletions
diff --git a/Git.hs b/Git.hs
index b87f2a265..173deba6e 100644
--- a/Git.hs
+++ b/Git.hs
@@ -547,36 +547,23 @@ configMap = config
{- Efficiently looks up a gitattributes value for each file in a list. -}
checkAttr :: Repo -> String -> [FilePath] -> IO [(FilePath, String)]
checkAttr repo attr files = do
- -- git check-attr wants files that are absolute (or relative to the
- -- top of the repo). But we're passed files relative to the current
- -- directory. Convert to absolute, and then convert the filenames
- -- in its output back to relative.
- cwd <- getCurrentDirectory
- let top = workTree repo
- let absfiles = map (absPathFrom cwd) files
(_, fromh, toh) <- hPipeBoth "git" (toCommand params)
_ <- forkProcess $ do
hClose fromh
- hPutStr toh $ join "\0" absfiles
+ hPutStr toh $ join "\0" files
hClose toh
exitSuccess
hClose toh
- s <- hGetContents fromh
- return $ map (topair cwd top) $ lines s
+ (map topair . lines) <$> hGetContents fromh
where
params = gitCommandLine repo [Param "check-attr", Param attr, Params "-z --stdin"]
- topair cwd top l = (relfile, value)
+ topair l = (file, value)
where
- relfile
- | startswith cwd' file = drop (length cwd') file
- | otherwise = relPathDirToFile top' file
file = decodeGitFile $ join sep $ take end bits
value = bits !! end
end = length bits - 1
bits = split sep l
sep = ": " ++ attr ++ ": "
- cwd' = cwd ++ "/"
- top' = top ++ "/"
{- Some git commands output encoded filenames. Decode that (annoyingly
- complex) encoding. -}