Hi joey,
How about making annex.addunlocked
configurable similar to annex.largefiles
so different file types can be configured to be added unlocked and others locked?
The following illustrates a use case:
#!/bin/sh -x
# make a repo
export LC_ALL=C.UTF-8
chmod -R +w addunlocked;rm -rf addunlocked
git init addunlocked
cd addunlocked
git annex init
# configure *.txt files to be added unlocked so they stay editable
echo '*.txt annex.addunlocked=true' > .gitattributes
git add .gitattributes
git commit -m "Add .gitattributes"
# make a note
echo bla > notes.txt
git annex add
git annex sync -m "add notes.txt"
# However editing doesn't work as it was added locked
echo blubb >> notes.txt # fails as it was not added unlocked
Probably not all matching options (like copies
for example) make sense or work at all in this context, but at least include=
would be useful („all files in that dir should be added unlocked always”). For example, in a synced folder for collaboration, PDFs could stay locked to save space, but Spreadsheets and ODT documents for example make sense to be added unlocked by default to stay editable. This could be achieved with something like this:
# repo-wide stored in git-annex branch
git annex config --set annex.addunlocked 'include=*.odt or include=**.pdf'
# folder-specific via .gitattributes
echo '*.pdf annex.addunlocked=true' >> .gitattributes # (or 'anything')
echo '*.odt annex.addunlocked=true' >> .gitattributes # (or 'anything')
# repo-specific
git config annex.addunlocked 'include=**/*.odt or include=**/*.pdf'
What do you think?
Cheers, Yann
git annex matching options that make sense for
annex.addunlocked
:All the others won't work AFAICS because location tracking hasn't yet happened at adding time.
annex.addunlocked can already be set to a git-annex-matching-expression and this allows configuring it differently for different filenames, etc. This has been supported since 7.20191230.
You can already configure annex.addunlocked with
git-annex config
.Adding gitattributes for configs is problimatic because querying for them is not fast. They have to be queried for every file. Also the gitattributes format is not well suited to complex expressions since the value cannot contain spaces.
The only benefit to supporting it in gitattributes would be to configure it differently in different branches of the repository.
There was a todo already suggesting this, annex.addunlocked in gitattributes and I decided to close it.
Heh, didn't check that as I assumed when gitattributes does't work, git annex config won't either. Different branch config is a point but I guess not a huge one, right.
Maybe a note about addunlocked would fit into the docs: https://git-annex.branchable.com/git-annex-add/