summaryrefslogtreecommitdiff
path: root/Git.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-07-10 13:52:53 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-07-10 13:52:53 -0400
commit7919de73af81d1788867ecbcbcc17e25b348ad1d (patch)
tree9041aaa9c3bfcf083e86b0e77de3ab8da9a8ec1e /Git.hs
parent562fd41d6c7a522d5aa8e8eb65f1c8e12d830df4 (diff)
Bugfix: Make add ../ work.
The complication of check-attr returning absolute paths that have to be converted back to relative paths..
Diffstat (limited to 'Git.hs')
-rw-r--r--Git.hs13
1 files changed, 8 insertions, 5 deletions
diff --git a/Git.hs b/Git.hs
index 7005f24f5..7827f8051 100644
--- a/Git.hs
+++ b/Git.hs
@@ -530,6 +530,7 @@ checkAttr repo attr files = do
-- 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
@@ -539,19 +540,21 @@ checkAttr repo attr files = do
exitSuccess
hClose toh
s <- hGetContents fromh
- return $ map (topair $ cwd++"/") $ lines s
+ return $ map (topair cwd top) $ lines s
where
params = gitCommandLine repo [Param "check-attr", Param attr, Params "-z --stdin"]
- topair cwd l = (relfile, value)
+ topair cwd top l = (relfile, value)
where
- relfile
- | startswith cwd file = drop (length cwd) file
- | otherwise = file
+ 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. -}