summaryrefslogtreecommitdiff
path: root/CmdLine
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-02-10 16:06:53 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-02-10 16:06:53 -0400
commit6a1596bcaaaeea06108fd336ca9633e931d207c1 (patch)
tree1c594181c4031e8f7af7fc1b4758256149456282 /CmdLine
parentebbec7ac550343034a9b0341256ca475082f88e1 (diff)
metadata: When setting metadata, do not recurse into directories by default, since that can be surprising behavior and difficult to recover from. The old behavior is available by using --force.
Diffstat (limited to 'CmdLine')
-rw-r--r--CmdLine/Seek.hs21
1 files changed, 21 insertions, 0 deletions
diff --git a/CmdLine/Seek.hs b/CmdLine/Seek.hs
index 2fe217703..7bfea45d0 100644
--- a/CmdLine/Seek.hs
+++ b/CmdLine/Seek.hs
@@ -32,6 +32,27 @@ withFilesInGit :: (FilePath -> CommandStart) -> CommandSeek
withFilesInGit a params = seekActions $ prepFiltered a $
seekHelper LsFiles.inRepo params
+withFilesInGitNonRecursive :: (FilePath -> CommandStart) -> CommandSeek
+withFilesInGitNonRecursive a params = ifM (Annex.getState Annex.force)
+ ( withFilesInGit a params
+ , if null params
+ then needforce
+ else seekActions $ prepFiltered a (getfiles [] params)
+ )
+ where
+ getfiles c [] = return (reverse c)
+ getfiles c (p:ps) = do
+ (fs, cleanup) <- inRepo $ LsFiles.inRepo [p]
+ case fs of
+ [f] -> do
+ void $ liftIO $ cleanup
+ getfiles (f:c) ps
+ [] -> do
+ void $ liftIO $ cleanup
+ getfiles c ps
+ _ -> needforce
+ needforce = error "Not recursively setting metadata. Use --force to do that."
+
withFilesNotInGit :: Bool -> (FilePath -> CommandStart) -> CommandSeek
withFilesNotInGit skipdotfiles a params
| skipdotfiles = do