git-annex config annex.largefiles
annex.largefiles can be configured by git-annex config, to more easily set a default that will also be used by clones, without needing to shoehorn the expression into the gitattributes file. The git config and gitattributes override that. Whenever something is added to git-annex config, we have to consider what happens if a user puts a purposfully bad value in there. Or, if a new git-annex adds some new value that an old git-annex can't parse. In this case, a global annex.largefiles that can't be parsed currently makes an error be thrown. That might not be ideal, but the gitattribute behaves the same, and is almost equally repo-global. Performance notes: git-annex add and addurl construct a matcher once and uses it for every file, so the added time penalty for reading the global config log is minor. If the gitattributes annex.largefiles were deprecated, git-annex add would get around 2% faster (excluding hashing), because looking that up for each file is not fast. So this new way of setting it is progress toward speeding up add. git-annex smudge does need to load the log every time. As well as checking the git attribute. Not ideal. Setting annex.gitaddtoannex=false avoids both overheads.
This commit is contained in:
parent
ce3fb0b2e5
commit
4acbb40112
9 changed files with 119 additions and 63 deletions
|
@ -26,28 +26,37 @@ the assistant.
|
|||
For example, let's make only files larger than 100 kb be added to the annex,
|
||||
and never `*.c` and `*.h` source code files.
|
||||
|
||||
Write this to the `.gitattributes` file:
|
||||
git config annex.largefiles 'largerthan=100kb and not (include=*.c or include=*.h)'
|
||||
|
||||
* annex.largefiles=(largerthan=100kb)
|
||||
That is a local configuration, so will only apply to your clone of the
|
||||
repository. To set a default that will apply to all clones, unless
|
||||
overridden, do this instead:
|
||||
|
||||
git annex config --set annex.largefiles 'largerthan=100kb and not (include=*.c or include=*.h)'
|
||||
|
||||
There's one other way to configure the same thing, you can put this in
|
||||
the `.gitattributes` file:
|
||||
|
||||
* annex.largefiles=largerthan=100kb
|
||||
*.c annex.largefiles=nothing
|
||||
*.h annex.largefiles=nothing
|
||||
|
||||
Or, set the git configuration instead:
|
||||
|
||||
git config annex.largefiles 'largerthan=100kb and not (include=*.c or include=*.h)'
|
||||
The syntax in .gitattributes is a bit different, because the .gitattributes
|
||||
matches files itself, and the values of attributes cannot contain spaces.
|
||||
So using .gitattributes for this is not recommended (but it does work for
|
||||
older versions of git-annex, where the `git annex config` setting does
|
||||
not). Any .gitattributes setting overrides the `git annex config` setting,
|
||||
but will be overridden by the `git config` setting.
|
||||
|
||||
Both of these settings do the same thing. Setting it in the
|
||||
`.gitattributes` file makes any checkout of the repository share that
|
||||
configuration, so is often a good choice. Setting the annex.largefiles git
|
||||
configuration lets different checkouts behave differently. The git
|
||||
configuration overrides the `.gitattributes` configuration.
|
||||
|
||||
Or, perhaps you just want all files to be added to the annex, no matter
|
||||
what. Just write "* annex.largefiles=anything" to the `.gitattributes`
|
||||
file, or run:
|
||||
Another example. If you wanted `git add` to put all files the annex
|
||||
in your local repository:
|
||||
|
||||
git config annex.largefiles anything
|
||||
|
||||
Or in all clones:
|
||||
|
||||
git annex config --set annex.largefiles anything
|
||||
|
||||
## syntax
|
||||
|
||||
The value of annex.largefiles is similar to a
|
||||
|
@ -108,19 +117,28 @@ The following terms can be used in annex.largefiles:
|
|||
|
||||
These can be used to build up more complicated expressions.
|
||||
|
||||
The way the `.gitattributes` example above works is, `*.c` and `*.h` files
|
||||
have the annex.largefiles attribute set to "nothing",
|
||||
and so those files are never treated as large files. All other files use
|
||||
the other value, which checks the file size.
|
||||
## gitattributes syntax
|
||||
|
||||
Note that, since git attribute values cannot contain whitespace,
|
||||
it's useful to instead parenthesize the terms of the annex.largefiles
|
||||
attribute. This trick allows for more complicated expressions.
|
||||
Here's that example `.gitattributes` again:
|
||||
|
||||
* annex.largefiles=largerthan=100kb
|
||||
*.c annex.largefiles=nothing
|
||||
*.h annex.largefiles=nothing
|
||||
|
||||
The way that works is, `*.c` and `*.h` files have the annex.largefiles
|
||||
attribute set to "nothing", and so those files are never treated as large
|
||||
files. All other files use the other value, which checks the file size.
|
||||
|
||||
Since git attribute values cannot contain whitespace, when you need
|
||||
a more complicated annex.largefiles expression, you can instead
|
||||
parenthesize the terms of the annex.largefiles attribute.
|
||||
For example, this is the same as the git config shown earlier, shoehorned
|
||||
into a git attribute:
|
||||
into a single git attribute:
|
||||
|
||||
* annex.largefiles=(largerthan=100kb)and(not((include=*.c)or(include=*.h)))
|
||||
|
||||
It's generally a better idea to use `git annex config` instead.
|
||||
|
||||
## temporarily override
|
||||
|
||||
If you've set up an annex.largefiles configuration but want to force a file to
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue