add, import: Fix a reversion in 7.20191009 that broke handling of --largerthan and...
authorJoey Hess <joeyh@joeyh.name>
Mon, 19 Oct 2020 19:36:18 +0000 (15:36 -0400)
committerJoey Hess <joeyh@joeyh.name>
Mon, 19 Oct 2020 19:36:18 +0000 (15:36 -0400)
This commit was sponsored by Jochen Bartl on Patreon.

Annex/FileMatcher.hs
CHANGELOG
CmdLine/GitAnnex/Options.hs
Command/Add.hs
Command/Import.hs
Limit.hs
doc/bugs/add_--largerthan_reversion.mdwn

index e46b75da6a4a07a6b05e469c41f21b84d2690fee..9aa3ca18cf755def4a185c2290da1971206cd2b1 100644 (file)
@@ -25,6 +25,7 @@ module Annex.FileMatcher (
        AddUnlockedMatcher,
        addUnlockedMatcher,
        checkAddUnlockedMatcher,
+       LimitBy(..),
        module Types.FileMatcher
 ) where
 
index cdffcba3bfb4c1a88fec86b2ca384817c31ce851..70c4c406b46ca2dba3db30df83362d6c1bf9363a 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,8 @@ git-annex (8.20201008) UNRELEASED; urgency=medium
 
   * Fix build on Windows with network-3.
   * Fix a memory leak introduced in the last release.
+  * add, import: Fix a reversion in 7.20191009 that broke handling
+    of --largerthan and --smallerthan.
 
  -- Joey Hess <id@joeyh.name>  Thu, 08 Oct 2020 10:48:17 -0400
 
index 22f07045cecbbd155e47876478fb9a52dc6666aa..87660e50b635a080693c113097a6aec9791e98c0 100644 (file)
@@ -223,7 +223,7 @@ parseKey = maybe (Fail.fail "invalid key") return . deserializeKey
 annexedMatchingOptions :: [GlobalOption]
 annexedMatchingOptions = concat
        [ keyMatchingOptions'
-       , fileMatchingOptions'
+       , fileMatchingOptions' Limit.LimitAnnexFiles
        , combiningOptions
        , timeLimitOption
        ]
@@ -315,11 +315,11 @@ keyMatchingOptions' =
        ]
 
 -- Options to match files which may not yet be annexed.
-fileMatchingOptions :: [GlobalOption]
-fileMatchingOptions = fileMatchingOptions' ++ combiningOptions ++ timeLimitOption
+fileMatchingOptions :: Limit.LimitBy -> [GlobalOption]
+fileMatchingOptions lb = fileMatchingOptions' lb ++ combiningOptions ++ timeLimitOption
 
-fileMatchingOptions' :: [GlobalOption]
-fileMatchingOptions' =
+fileMatchingOptions' :: Limit.LimitBy -> [GlobalOption]
+fileMatchingOptions' lb =
        [ globalSetter Limit.addExclude $ strOption
                ( long "exclude" <> short 'x' <> metavar paramGlob
                <> help "skip files matching the glob pattern"
@@ -330,12 +330,12 @@ fileMatchingOptions' =
                <> help "limit to files matching the glob pattern"
                <> hidden
                )
-       , globalSetter Limit.addLargerThan $ strOption
+       , globalSetter (Limit.addLargerThan lb) $ strOption
                ( long "largerthan" <> metavar paramSize
                <> help "match files larger than a size"
                <> hidden
                )
-       , globalSetter Limit.addSmallerThan $ strOption
+       , globalSetter (Limit.addSmallerThan lb) $ strOption
                ( long "smallerthan" <> metavar paramSize
                <> help "match files smaller than a size"
                <> hidden
index b19aaea54a233f6d032b01e72cb34d879a56d1ad..6aecce8d0c40210fa38521b3d180a361da40b79b 100644 (file)
@@ -29,9 +29,16 @@ import qualified Utility.RawFilePath as R
 
 cmd :: Command
 cmd = notBareRepo $ 
-       withGlobalOptions [jobsOption, jsonOptions, jsonProgressOption, fileMatchingOptions] $
+       withGlobalOptions opts $
                command "add" SectionCommon "add files to annex"
                        paramPaths (seek <$$> optParser)
+  where
+       opts =
+               [ jobsOption
+               , jsonOptions
+               , jsonProgressOption
+               , fileMatchingOptions LimitDiskFiles
+               ]
 
 data AddOptions = AddOptions
        { addThese :: CmdParams
index 98bc94cf2ce032157372d0891b55b46b927e5dc9..18f75432e7cfbb7639b8ea7781b90be2ed93c1e0 100644 (file)
@@ -39,11 +39,21 @@ import Control.Concurrent.STM
 
 cmd :: Command
 cmd = notBareRepo $
-       withGlobalOptions [jobsOption, jsonOptions, jsonProgressOption, fileMatchingOptions] $
+       withGlobalOptions opts $
                command "import" SectionCommon 
                        "add a tree of files to the repository"
                        (paramPaths ++ "|BRANCH[:SUBDIR]")
                        (seek <$$> optParser)
+  where
+       opts =
+               [ jobsOption
+               , jsonOptions
+               , jsonProgressOption
+               -- These options are only used when importing from a
+               -- directory, not from a special remote. So it's ok
+               -- to use LimitDiskFiles.
+               , fileMatchingOptions LimitDiskFiles
+               ]
 
 data ImportOptions 
        = LocalImportOptions
index 8f958efd66f0b4c4c4da84d8354af93fdf2b5577..9caeb44e02135932eb6bf4649c2e7984609bd09c 100644 (file)
--- a/Limit.hs
+++ b/Limit.hs
@@ -441,11 +441,11 @@ limitSecureHash = MatchFiles
        }
 
 {- Adds a limit to skip files that are too large or too small -}
-addLargerThan :: String -> Annex ()
-addLargerThan = addLimit . limitSize LimitAnnexFiles (>)
+addLargerThan :: LimitBy -> String -> Annex ()
+addLargerThan lb = addLimit . limitSize lb (>)
 
-addSmallerThan :: String -> Annex ()
-addSmallerThan = addLimit . limitSize LimitAnnexFiles (<)
+addSmallerThan :: LimitBy -> String -> Annex ()
+addSmallerThan lb = addLimit . limitSize lb (<)
 
 limitSize :: LimitBy -> (Maybe Integer -> Maybe Integer -> Bool) -> MkLimit Annex
 limitSize lb vs s = case readSize dataUnits s of
index 850efdfbe179e5ca37d78b116feb25c3651772e4..c94205688fcf782cc2515776e0fbb2ad195409a0 100644 (file)
@@ -14,7 +14,4 @@ That commit was otherwise right, eg `git-annex get --largerthan` should
 look at the size of the annexed file, not of the file on disk, which could
 be a small pointer file.
 
-Rather than being global options, --largerthan and --smallerthan, 
-could added by each command, so the command can specify how the size
-should be determined. Finding a way to do that w/o needing to add
-boilerplate to many commands would be best.
+> [[fixed|done]] --[[Joey]]