--metadata lexicographical comparisons
Change --metadata comparisons < > <= and >= to fall back to lexicographical comparisons when one or both values being compared are not numbers. Sponsored-by: Erik Bjäreholt on Patreon
This commit is contained in:
parent
69499b4452
commit
aa6919737c
4 changed files with 27 additions and 11 deletions
|
@ -104,15 +104,17 @@ parseMetaDataMatcher p = (,)
|
||||||
(f, op_v) = break (`elem` "=<>") p
|
(f, op_v) = break (`elem` "=<>") p
|
||||||
matcher = case op_v of
|
matcher = case op_v of
|
||||||
('=':v) -> checkglob v
|
('=':v) -> checkglob v
|
||||||
('<':'=':v) -> checkcmp (<=) v
|
('<':'=':v) -> checkcmp (<=) (<=) v
|
||||||
('<':v) -> checkcmp (<) v
|
('<':v) -> checkcmp (<) (<) v
|
||||||
('>':'=':v) -> checkcmp (>=) v
|
('>':'=':v) -> checkcmp (>=) (>=) v
|
||||||
('>':v) -> checkcmp (>) v
|
('>':v) -> checkcmp (>) (>) v
|
||||||
_ -> checkglob ""
|
_ -> checkglob ""
|
||||||
checkglob v =
|
checkglob v =
|
||||||
let cglob = compileGlob v CaseInsensative (GlobFilePath False)
|
let cglob = compileGlob v CaseInsensative (GlobFilePath False)
|
||||||
in matchGlob cglob . decodeBS . fromMetaValue
|
in matchGlob cglob . decodeBS . fromMetaValue
|
||||||
checkcmp cmp v v' = case (doubleval v, doubleval (decodeBS (fromMetaValue v'))) of
|
checkcmp cmp cmp' v mv' =
|
||||||
|
let v' = decodeBS (fromMetaValue mv')
|
||||||
|
in case (doubleval v, doubleval v') of
|
||||||
(Just d, Just d') -> d' `cmp` d
|
(Just d, Just d') -> d' `cmp` d
|
||||||
_ -> False
|
_ -> v' `cmp'` v
|
||||||
doubleval v = readish v :: Maybe Double
|
doubleval v = readish v :: Maybe Double
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
git-annex (10.20221213) UNRELEASED; urgency=medium
|
||||||
|
|
||||||
|
* Change --metadata comparisons < > <= and >= to fall back to
|
||||||
|
lexicographical comparisons when one or both values being compared
|
||||||
|
are not numbers.
|
||||||
|
|
||||||
|
-- Joey Hess <id@joeyh.name> Mon, 12 Dec 2022 13:04:54 -0400
|
||||||
|
|
||||||
git-annex (10.20221212) upstream; urgency=medium
|
git-annex (10.20221212) upstream; urgency=medium
|
||||||
|
|
||||||
* Fix a hang that occasionally occurred during commands such as move,
|
* Fix a hang that occasionally occurred during commands such as move,
|
||||||
|
|
|
@ -142,11 +142,15 @@ in either of two repositories.
|
||||||
matches the glob. The values of metadata fields are matched case
|
matches the glob. The values of metadata fields are matched case
|
||||||
insensitively.
|
insensitively.
|
||||||
|
|
||||||
* `--metadata field<number` / `--metadata field>number`
|
* `--metadata field<value` / `--metadata field>value`
|
||||||
* `--metadata field<=number` / `--metadata field>=number`
|
* `--metadata field<=value` / `--metadata field>=value`
|
||||||
|
|
||||||
Matches only when there is a metadata field attached with a value that
|
Matches only when there is a metadata field attached with a value
|
||||||
is a number and is less than or greater than the specified number.
|
that is less then or greater than the specified value, respectively.
|
||||||
|
|
||||||
|
When both values are numbers, the comparison is done numerically.
|
||||||
|
When one value is not a number, the values are instead compared
|
||||||
|
lexicographically.
|
||||||
|
|
||||||
(Note that you will need to quote the second parameter to avoid
|
(Note that you will need to quote the second parameter to avoid
|
||||||
the shell doing redirection.)
|
the shell doing redirection.)
|
||||||
|
|
|
@ -91,3 +91,5 @@ file9
|
||||||
```
|
```
|
||||||
|
|
||||||
Yann / @nobodyinperson
|
Yann / @nobodyinperson
|
||||||
|
|
||||||
|
> [[fixed|done]] --[[Joey]]
|
||||||
|
|
Loading…
Reference in a new issue