annex.addunlocked expressions
* annex.addunlocked can be set to an expression with the same format used by annex.largefiles, in case you want to default to unlocking some files but not others. * annex.addunlocked can be configured by git-annex config. Added a git-annex-matching-expression man page, broken out from tips/largefiles. A tricky consequence of this is that git-annex add --relaxed honors annex.addunlocked, but an expression might want to know the size or content of an url, which it's not going to download. I decided it was better not to fail, and just dummy up some plausible data in that case. Performance impact should be negligible. The global config is already loaded for annex.largefiles. The expression only has to be parsed once, and in the simple true/false case, it should not do any additional work matching it.
This commit is contained in:
parent
f79bd52132
commit
37467a008f
25 changed files with 305 additions and 179 deletions
|
@ -31,11 +31,25 @@ These settings can be overridden on a per-repository basis using
|
|||
|
||||
Used to configure which files are large enough to be added to the annex.
|
||||
It is an expression that matches the large files, eg
|
||||
"include=*.mp3 or largerthan(500kb)"
|
||||
"include=*.mp3 or largerthan(500kb)".
|
||||
See [[git-annex-matching-expression]](1) for details on the syntax.
|
||||
|
||||
This sets a default, which can be overridden by annex.largefiles
|
||||
attributes in `.gitattributes` files, or by `git config`.
|
||||
|
||||
* `annex.addunlocked`
|
||||
|
||||
Commands like `git-annex add` default to adding files to the repository
|
||||
in locked form. This can make them add the files in unlocked form,
|
||||
the same as if [[git-annex-unlock]](1) were run on the files.
|
||||
|
||||
This can be set to "true" to add everything unlocked, or it can be a more
|
||||
complicated expression that matches files by name, size, or content. See
|
||||
[[git-annex-matching-expression]](1) for details.
|
||||
|
||||
This sets a default, which can be overridden by annex.addunlocked
|
||||
in `git config`.
|
||||
|
||||
* `annex.autocommit`
|
||||
|
||||
Set to false to prevent the `git-annex assistant` and `git-annex sync`
|
||||
|
|
|
@ -59,6 +59,8 @@ For example, this will exit 0:
|
|||
|
||||
[[git-annex-preferred-content]](1)
|
||||
|
||||
[[git-annex-matching-expression]](1)
|
||||
|
||||
# AUTHOR
|
||||
|
||||
Joey Hess <id@joeyh.name>
|
||||
|
|
87
doc/git-annex-matching-expression.mdwn
Normal file
87
doc/git-annex-matching-expression.mdwn
Normal file
|
@ -0,0 +1,87 @@
|
|||
# NAME
|
||||
|
||||
git-annex-matching-expression - specifying a set of files
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
The annex.largefiles and annex.addunlocked configurations both use
|
||||
expressions that match some files in the working tree.
|
||||
|
||||
# SYNTAX
|
||||
|
||||
The format of these expressions is similar to
|
||||
[[git-annex-preferred-content]](1) expressions.
|
||||
|
||||
For example:
|
||||
|
||||
largerthan=100kb and not (include=*.c or include=*.h)
|
||||
|
||||
This matches large files, but excludes C source files.
|
||||
|
||||
The following terms can be used:
|
||||
|
||||
* `include=glob` / `exclude=glob`
|
||||
|
||||
Specify files to include or exclude.
|
||||
|
||||
The glob can contain `*` and `?` to match arbitrary characters.
|
||||
|
||||
* `smallerthan=size` / `largerthan=size`
|
||||
|
||||
Matches only files smaller than, or larger than the specified size.
|
||||
|
||||
The size can be specified with any commonly used units, for example,
|
||||
"0.5 gb" or "100 KiloBytes"
|
||||
|
||||
* `mimetype=glob`
|
||||
|
||||
Looks up the MIME type of a file, and checks if the glob matches it.
|
||||
|
||||
For example, `"mimetype=text/*"` will match many varieties of text files,
|
||||
including "text/plain", but also "text/x-shellscript", "text/x-makefile",
|
||||
etc.
|
||||
|
||||
The MIME types are the same that are displayed by running `file --mime-type`
|
||||
|
||||
This is only available to use when git-annex was built with the
|
||||
MagicMime build flag.
|
||||
|
||||
* `mimeencoding=glob`
|
||||
|
||||
Looks up the MIME encoding of a file, and checks if the glob matches it.
|
||||
|
||||
For example, `"mimeencoding=binary"` will match many kinds of binary
|
||||
files.
|
||||
|
||||
The MIME encodings are the same that are displayed by running `file --mime-encoding`
|
||||
|
||||
This is only available to use when git-annex was built with the
|
||||
MagicMime build flag.
|
||||
|
||||
* `anything`
|
||||
|
||||
Matches any file.
|
||||
|
||||
* `nothing`
|
||||
|
||||
Matches no files. (Same as "not anything")
|
||||
|
||||
* `not expression`
|
||||
|
||||
Inverts what the expression matches.
|
||||
|
||||
* `and` / `or` / `( expression )`
|
||||
|
||||
These can be used to build up more complicated expressions.
|
||||
|
||||
# SEE ALSO
|
||||
|
||||
[[git-annex]](1)
|
||||
|
||||
# AUTHOR
|
||||
|
||||
Joey Hess <id@joeyh.name>
|
||||
|
||||
<http://git-annex.branchable.com/>
|
||||
|
||||
Warning: Automatically converted into a man page by mdwn2man. Edit with care.
|
|
@ -892,6 +892,7 @@ Like other git commands, git-annex is configured via `.git/config`.
|
|||
Used to configure which files are large enough to be added to the annex.
|
||||
It is an expression that matches the large files, eg
|
||||
"include=*.mp3 or largerthan(500kb)"
|
||||
See [[git-annex-matching-expression]](1) for details on the syntax.
|
||||
|
||||
Overrides any annex.largefiles attributes in `.gitattributes` files.
|
||||
|
||||
|
@ -909,9 +910,6 @@ Like other git commands, git-annex is configured via `.git/config`.
|
|||
`git annex import`, `git annex addurl`, `git annex importfeed`
|
||||
and the assistant.
|
||||
|
||||
See <https://git-annex.branchable.com/tips/largefiles> for syntax
|
||||
documentation and more.
|
||||
|
||||
* `annex.gitaddtoannex`
|
||||
|
||||
Setting this to false will prevent `git add` from adding
|
||||
|
@ -925,13 +923,20 @@ Like other git commands, git-annex is configured via `.git/config`.
|
|||
|
||||
* `annex.addunlocked`
|
||||
|
||||
Set to true to make commands like `git-annex add` that add files to the
|
||||
repository add them in unlocked form. The default is for these commands
|
||||
to add files in locked form.
|
||||
Commands like `git-annex add` default to adding files to the repository
|
||||
in locked form. This can make them add the files in unlocked form,
|
||||
the same as if [[git-annex-unlock]](1) were run on the files.
|
||||
|
||||
This can be set to "true" to add everything unlocked, or it can be a more
|
||||
complicated expression that matches files by name, size, or content. See
|
||||
[[git-annex-matching-expression]](1) for details.
|
||||
|
||||
To configure a default annex.addunlocked for all clones of the repository,
|
||||
this can be set in [[git-annex-config]](1).
|
||||
|
||||
(Using `git add` always adds files in unlocked form and it is not
|
||||
affected by this setting.)
|
||||
|
||||
|
||||
When a repository has core.symlinks set to false, or has an adjusted
|
||||
unlocked branch checked out, this setting is ignored, and files are
|
||||
always added to the repository in unlocked form.
|
||||
|
@ -1702,9 +1707,8 @@ There is a annex.largefiles attribute, which is used to configure which
|
|||
files are large enough to be added to the annex. Since attributes cannot
|
||||
contain spaces, it is difficult to use for more complex annex.largefiles
|
||||
settings. Setting annex.largefiles in [[git-annex-config]](1) is an easier
|
||||
way to configure it across all clones of the repository. See
|
||||
<https://git-annex.branchable.com/tips/largefiles> for examples and more
|
||||
documentation.
|
||||
way to configure it across all clones of the repository.
|
||||
See [[git-annex-matching-expression]](1) for details on the syntax.
|
||||
|
||||
The numcopies setting can also be configured on a per-file-type basis via
|
||||
the `annex.numcopies` attribute in `.gitattributes` files. This overrides
|
||||
|
|
|
@ -59,65 +59,9 @@ Or in all clones:
|
|||
|
||||
## syntax
|
||||
|
||||
The value of annex.largefiles is similar to a
|
||||
[[preferred content expression|git-annex-preferred-content]].
|
||||
The following terms can be used in annex.largefiles:
|
||||
See [[git-annex-matching-expression]] for details about the syntax.
|
||||
|
||||
* `include=glob` / `exclude=glob`
|
||||
|
||||
Specify files to include or exclude.
|
||||
|
||||
The glob can contain `*` and `?` to match arbitrary characters.
|
||||
|
||||
* `smallerthan=size` / `largerthan=size`
|
||||
|
||||
Matches only files smaller than, or larger than the specified size.
|
||||
|
||||
The size can be specified with any commonly used units, for example,
|
||||
"0.5 gb" or "100 KiloBytes"
|
||||
|
||||
* `mimetype=glob`
|
||||
|
||||
Looks up the MIME type of a file, and checks if the glob matches it.
|
||||
|
||||
For example, `"mimetype=text/*"` will match many varieties of text files,
|
||||
including "text/plain", but also "text/x-shellscript", "text/x-makefile",
|
||||
etc.
|
||||
|
||||
The MIME types are the same that are displayed by running `file --mime-type`
|
||||
|
||||
This is only available to use when git-annex was built with the
|
||||
MagicMime build flag.
|
||||
|
||||
* `mimeencoding=glob`
|
||||
|
||||
Looks up the MIME encoding of a file, and checks if the glob matches it.
|
||||
|
||||
For example, `"mimeencoding=binary"` will match many kinds of binary
|
||||
files.
|
||||
|
||||
The MIME encodings are the same that are displayed by running `file --mime-encoding`
|
||||
|
||||
This is only available to use when git-annex was built with the
|
||||
MagicMime build flag.
|
||||
|
||||
* `anything`
|
||||
|
||||
Matches any file.
|
||||
|
||||
* `nothing`
|
||||
|
||||
Matches no files. (Same as "not anything")
|
||||
|
||||
* `not expression`
|
||||
|
||||
Inverts what the expression matches.
|
||||
|
||||
* `and` / `or` / `( expression )`
|
||||
|
||||
These can be used to build up more complicated expressions.
|
||||
|
||||
## gitattributes syntax
|
||||
## gitattributes format
|
||||
|
||||
Here's that example `.gitattributes` again:
|
||||
|
||||
|
|
|
@ -3,3 +3,5 @@ Can the `annex.addunlocked` be extended to have the same syntax as `annex.largef
|
|||
Basically, I want a reliable way to prevent inadvertently adding files as annexed unlocked files.
|
||||
|
||||
Related: [[forum/lets_discuss_git_add_behavior]]
|
||||
|
||||
> [[done]] --[[Joey]]
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
[[!comment format=mdwn
|
||||
username="joey"
|
||||
subject="""comment 4"""
|
||||
date="2019-12-20T19:45:21Z"
|
||||
content="""
|
||||
Made annex.addunlocked support expressions like annex.largefiles.
|
||||
|
||||
And both of them can be set globally with `git annex config`. I did not
|
||||
make annex.addunlocked be settable by git attribute, because my sense is
|
||||
that `git annex config` covers that use case, or mostly so.
|
||||
"""]]
|
Loading…
Add table
Add a link
Reference in a new issue