summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2010-11-01 21:21:13 -0400
committerGravatar Joey Hess <joey@kitenet.net>2010-11-01 21:21:13 -0400
commit13514b6afc6cb043dfa742dd0e69efca7a4374df (patch)
tree8f4f6b66d4db1fbc5d81d12ad44c3d301a57c3d3
parente379307900ba571a5104f3bb2e7ad6c6900d3062 (diff)
fix checkAttr to not deadlock and not need strictness
Yeah, "will never deadlock" is never a good sign in code comments. ;)
-rw-r--r--GitRepo.hs15
1 files changed, 5 insertions, 10 deletions
diff --git a/GitRepo.hs b/GitRepo.hs
index e8dd0a5dc..bc6d45066 100644
--- a/GitRepo.hs
+++ b/GitRepo.hs
@@ -149,17 +149,12 @@ attributes repo
{- Looks up a gitattributes value for each file in a list. -}
checkAttr :: Repo -> String -> [FilePath] -> IO [(FilePath, String)]
checkAttr repo attr files = do
- (pid, fromh, toh) <- hPipeBoth "git" $
- gitCommandLine repo ["check-attr", attr, "-z", "--stdin"]
- -- git-check-attr reads all its stdin before outputting anything,
- -- so we don't need to worry about deadlock
- hPutStr toh files0
- hClose toh
- c <- hGetContentsStrict fromh
- hClose fromh
- forceSuccess pid
- return $ map topair $ lines c
+ (handle, s) <- pipeBoth "git" params files0
+ return $ map topair $ lines s
+ -- XXX handle is left open, this is ok for git-annex, but may need
+ -- to be cleaned up for other uses.
where
+ params = gitCommandLine repo ["check-attr", attr, "-z", "--stdin"]
files0 = join "\0" files
topair l = (bits !! 0, join sep $ drop 1 $ bits)
where