--anything and --nothing
authorJoey Hess <joeyh@joeyh.name>
Tue, 20 Dec 2022 19:42:34 +0000 (15:42 -0400)
committerJoey Hess <joeyh@joeyh.name>
Tue, 20 Dec 2022 19:44:09 +0000 (15:44 -0400)
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
CHANGELOG
CmdLine/GitAnnex/Options.hs
Limit.hs
doc/git-annex-find.mdwn
doc/git-annex-matching-options.mdwn
doc/todo/add_--all___40__or_alike__41___to_find_and_findref.mdwn
doc/todo/add_--all___40__or_alike__41___to_find_and_findref/comment_1_8407146882e97ee8510f28df2ba5129c._comment [new file with mode: 0644]

index 75d1b6eaa44ee74a6d3bbfce9acac2c2a22d1de8..7a423117d9c307fb8cee51fccb6cd095db717516 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -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
 
index df24b7f1f9fa1972703eff6351e6227d7a82582e..de481d25e58da2b4f94c6415d1ea5403d2b4d195 100644 (file)
@@ -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]
index 79d7e47942f65904755526d9c9a4e12cd5a434de..b105c9fb888c60b3d9b03e533f17bca451667505 100644 (file)
--- a/Limit.hs
+++ b/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 
index 2decd932b8dfd68d7b446f114646941b203b6a25..9f578092a9863f210719f6578145789822906cff 100644 (file)
@@ -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`
 
index 510aeb1c7674fdba579e1390c28b29de7c2732ca..41de0d77b27c75ccba164f46d9bf28749d681775 100644 (file)
@@ -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
index aa02cd747a4fce9f1fe19dd610e48f5a8fdf7fa8..c6a57de89b4d80012cfc258864143fac0ca9f8ee 100644 (file)
@@ -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]]
diff --git a/doc/todo/add_--all___40__or_alike__41___to_find_and_findref/comment_1_8407146882e97ee8510f28df2ba5129c._comment b/doc/todo/add_--all___40__or_alike__41___to_find_and_findref/comment_1_8407146882e97ee8510f28df2ba5129c._comment
new file mode 100644 (file)
index 0000000..b3b6857
--- /dev/null
@@ -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..)
+"""]]