securehash matching

Added --securehash option to match files using a secure hash function, and
corresponding securehash preferred content expression.

This commit was sponsored by Ethan Aubin.
This commit is contained in:
Joey Hess 2017-02-27 15:02:38 -04:00
parent 31275754f5
commit 49114cf4ea
No known key found for this signature in database
GPG key ID: C910D9222512E3C7
7 changed files with 27 additions and 1 deletions

View file

@ -117,6 +117,7 @@ preferredContentParser matchstandard matchgroupwanted getgroupmap configmap mu e
, SimpleToken "groupwanted" (call matchgroupwanted)
, SimpleToken "present" (simply $ limitPresent mu)
, SimpleToken "inpreferreddir" (simply $ limitInDir preferreddir)
, SimpleToken "securehash" (simply limitSecureHash)
, ValueToken "copies" (usev limitCopies)
, ValueToken "lackingcopies" (usev $ limitLackingCopies False)
, ValueToken "approxlackingcopies" (usev $ limitLackingCopies True)

View file

@ -7,6 +7,8 @@ git-annex (6.20170215) UNRELEASED; urgency=medium
from being added to .git/annex/objects by any method.
* fsck: Warn about any files whose content is present, that don't
use secure hashes, when annex.securehashesonly is set.
* Added --securehash option to match files using a secure hash function,
and corresponding securehash preferred content expression.
* sync, merge: Fail when the current branch has no commits yet, instead
of not merging in anything from remotes and appearing to succeed.
* Run ssh with -n whenever input is not being piped into it,

View file

@ -224,6 +224,11 @@ nonWorkTreeMatchingOptions' =
<> hidden
<> completeBackends
)
, globalFlag Limit.addSecureHash
( long "securehash"
<> help "match files using a cryptographically secure hash"
<> hidden
)
, globalSetter Limit.addInAllGroup $ strOption
( long "inallgroup" <> metavar paramGroup
<> help "match files present in all remotes in a group"

View file

@ -1,6 +1,6 @@
{- user-specified limits on files to act on
-
- Copyright 2011-2016 Joey Hess <id@joeyh.name>
- Copyright 2011-2017 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU GPL version 3 or higher.
-}
@ -255,6 +255,13 @@ limitInBackend name = Right $ const $ checkKey check
check key = pure $ keyVariety key == variety
variety = parseKeyVariety name
{- Adds a limit to skip files not using a secure hash. -}
addSecureHash :: Annex ()
addSecureHash = addLimit $ Right limitSecureHash
limitSecureHash :: MatchFiles Annex
limitSecureHash _ = checkKey $ pure . cryptographicallySecure . keyVariety
{- Adds a limit to skip files that are too large or too small -}
addLargerThan :: String -> Annex ()
addLargerThan = addLimit . limitSize (>)

View file

@ -95,6 +95,11 @@ in either of two repositories.
Matches only files whose content is stored using the specified key-value
backend.
* `--securehash`
Matches only files whose content is hashed using a cryptographically
secure function.
* `--inallgroup=groupname`
Matches only files that git-annex believes are present in all repositories

View file

@ -96,6 +96,11 @@ elsewhere to allow removing it).
Matches only files whose content is stored using the specified key-value
backend.
* `securehash`
Matches only files whose content is hashed using a cryptographically
secure function.
* `inallgroup=groupname`
Matches only files that git-annex believes are present in all repositories

View file

@ -58,6 +58,7 @@ it assumes all files that are currently present are preferred content.
Here are recent changes to preferred content expressions, and the version
they were added in.
* "securehash" 6.20170228
* "nothing" 6.201600202
* "anything" 5.20150616
* "standard" 5.20140314