--anything and --nothing
Added --anything (and --nothing). Eg, git-annex find --anything will list all annexed files whether or not the content is present. This is slightly faster and clearer than --include=* or --exclude=* While I can't imagine how --nothing will be used, preferred content expressions already had anything and nothing, so might as well support both as matching options as well. Sponsored-by: Dartmouth College's Datalad project
This commit is contained in:
parent
9d60385001
commit
0b2dd374d8
7 changed files with 60 additions and 2 deletions
|
@ -6,6 +6,9 @@ git-annex (10.20221213) UNRELEASED; urgency=medium
|
|||
* Improve handling of some .git/annex/ subdirectories being on other
|
||||
filesystems, in the bittorrent special remote, and youtube-dl
|
||||
integration, and git-annex addurl.
|
||||
* Added --anything (and --nothing). Eg, git-annex find --anything
|
||||
will list all annexed files whether or not the content is present.
|
||||
This is slightly faster and clearer than --include=* or --exclude=*
|
||||
|
||||
-- Joey Hess <id@joeyh.name> Mon, 12 Dec 2022 13:04:54 -0400
|
||||
|
||||
|
|
|
@ -378,6 +378,16 @@ fileMatchingOptions' lb =
|
|||
<> help "match files smaller than a size"
|
||||
<> hidden
|
||||
)
|
||||
, annexFlag (setAnnexState Limit.addAnything)
|
||||
( long "anything"
|
||||
<> help "match all files"
|
||||
<> hidden
|
||||
)
|
||||
, annexFlag (setAnnexState Limit.addNothing)
|
||||
( long "nothing"
|
||||
<> help "don't match any files"
|
||||
<> hidden
|
||||
)
|
||||
]
|
||||
|
||||
combiningOptions :: [AnnexOption]
|
||||
|
|
10
Limit.hs
10
Limit.hs
|
@ -1,6 +1,6 @@
|
|||
{- user-specified limits on files to act on
|
||||
-
|
||||
- Copyright 2011-2021 Joey Hess <id@joeyh.name>
|
||||
- Copyright 2011-2022 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- Licensed under the GNU AGPL version 3 or higher.
|
||||
-}
|
||||
|
@ -431,6 +431,10 @@ limitUnused = MatchFiles
|
|||
|
||||
isunused k = S.member k <$> unusedKeys
|
||||
|
||||
{- Adds a limit that matches anything. -}
|
||||
addAnything :: Annex ()
|
||||
addAnything = addLimit (Right limitAnything)
|
||||
|
||||
{- Limit that matches any version of any file or key. -}
|
||||
limitAnything :: MatchFiles Annex
|
||||
limitAnything = MatchFiles
|
||||
|
@ -441,6 +445,10 @@ limitAnything = MatchFiles
|
|||
, matchNeedsLocationLog = False
|
||||
}
|
||||
|
||||
{- Adds a limit that never matches. -}
|
||||
addNothing :: Annex ()
|
||||
addNothing = addLimit (Right limitNothing)
|
||||
|
||||
{- Limit that never matches. -}
|
||||
limitNothing :: MatchFiles Annex
|
||||
limitNothing = MatchFiles
|
||||
|
|
|
@ -22,7 +22,7 @@ finds files in the current directory and its subdirectories.
|
|||
currently present. Specifying any of the matching options will override
|
||||
this default behavior.
|
||||
|
||||
To list all annexed files, present or not, specify `--include "*"`.
|
||||
To list all annexed files, present or not, specify `--anything`.
|
||||
|
||||
To list annexed files whose content is not present, specify `--not --in=here`
|
||||
|
||||
|
|
|
@ -245,6 +245,15 @@ in either of two repositories.
|
|||
This is only available to use when git-annex was built with the
|
||||
MagicMime build flag.
|
||||
|
||||
* `--anything`
|
||||
|
||||
Always matches. One way this can be useful is `git-annex find --anything`
|
||||
will list all annexed files, whether their content is present or not.
|
||||
|
||||
* `--nothing`
|
||||
|
||||
Never matches. (Same as `--not --anything`)
|
||||
|
||||
* `--not`
|
||||
|
||||
Inverts the next matching option. For example, to match
|
||||
|
|
|
@ -6,3 +6,5 @@ I found no other way to make `find` (or `findref`) to do what is needed. So I fe
|
|||
|
||||
[[!meta author=yoh]]
|
||||
[[!tag projects/datalad]]
|
||||
|
||||
> [[done]]; added --anything (and --nothing). --[[Joey]]
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
[[!comment format=mdwn
|
||||
username="joey"
|
||||
subject="""comment 1"""
|
||||
date="2022-12-20T19:21:34Z"
|
||||
content="""
|
||||
Using --copies necessarily loads up the location tracking log for
|
||||
each file, which does add overhead.
|
||||
|
||||
Any other matching option that matches everything will work just as well
|
||||
for you. I think that `git-annex find --include='*'` is the best thing
|
||||
currently available. Indeed, the git-annex-find man page suggests to use
|
||||
that. The only overhead is an unncessary glob match, which
|
||||
should be almost unmeasurable.
|
||||
|
||||
It does seem like it might be worth adding --anything that simply matches
|
||||
anything. Preferred content expressions already support "anything". And
|
||||
`git-annex find --anything` makes sense and is easier to type.
|
||||
|
||||
But, you'll probably be better off using `--include='*'` since it works
|
||||
with older versions of git-annex.
|
||||
|
||||
(--all is the wrong name for such an option since it already has another
|
||||
meaning, although I don't think it makes sense for `git-annex find` to
|
||||
support --all, it has certianly been requested before by people who want to
|
||||
generalize that existing meaning..)
|
||||
"""]]
|
Loading…
Reference in a new issue