aboutsummaryrefslogtreecommitdiff
path: root/CmdLine
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2017-03-02 13:06:20 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2017-03-02 13:06:20 -0400
commit13e1c107e862233b2d01a01fe9e3951f44e13819 (patch)
tree4945a91616368759c3c9c4afb8164fad1646b406 /CmdLine
parentf886a58b056fba4277bb84d81118bb616e9eb580 (diff)
Bugfix: Passing a command a filename that does not exist sometimes did not display an error, when a path to a directory was also passed.
It was relying on segmentPaths to work correctly, so when it didn't, sometimes the file that did not exist got matched up with a non-null list of results. Fixed by always checking if each parameter exists. There are two reason segmentPaths might not work correctly. For one, it assumes that when the original list of paths has more than 100 paths, it's not worth paying the CPU cost to preserve input orders. And then, it fails when a directory such as "." or ".." or /path/to/repo is in the input list, and the list of found paths does not start with that same thing. It should probably not be using dirContains, but something else. But, it's not clear how to handle this fully. Consider when [".", "subdir"] has been expanded by git ls-files to ["subdir/1", "subdir/2"] -- Both of the inputs contained those results, so there's no one right answer for segmentPaths. All these would be equally valid: [["subdir/1", "subdir/2"], []] [[], ["subdir/1", "subdir/2"]] [["subdir/1"], [""subdir/2"]] So I've not tried to improve segmentPaths.
Diffstat (limited to 'CmdLine')
-rw-r--r--CmdLine/Seek.hs7
1 files changed, 3 insertions, 4 deletions
diff --git a/CmdLine/Seek.hs b/CmdLine/Seek.hs
index 7fc64c528..0afb0e66a 100644
--- a/CmdLine/Seek.hs
+++ b/CmdLine/Seek.hs
@@ -243,13 +243,12 @@ seekActions gen = mapM_ commandAction =<< gen
seekHelper :: ([FilePath] -> Git.Repo -> IO ([FilePath], IO Bool)) -> [FilePath] -> Annex [FilePath]
seekHelper a params = do
- ll <- inRepo $ \g -> concat <$> forM (segmentXargsOrdered params)
- (runSegmentPaths (\fs -> Git.Command.leaveZombie <$> a fs g))
- forM_ (map fst $ filter (null . snd) $ zip params ll) $ \p ->
+ forM_ params $ \p ->
unlessM (isJust <$> liftIO (catchMaybeIO $ getSymbolicLinkStatus p)) $ do
toplevelWarning False (p ++ " not found")
Annex.incError
- return $ concat ll
+ inRepo $ \g -> concat . concat <$> forM (segmentXargsOrdered params)
+ (runSegmentPaths (\fs -> Git.Command.leaveZombie <$> a fs g))
notSymlink :: FilePath -> IO Bool
notSymlink f = liftIO $ not . isSymbolicLink <$> getSymbolicLinkStatus f