git annex find --unlocked
reports also not just files which are known to git-annex
as unlocked, but also files which were regular "locked" (symlinks) but are modified in the tree:
here is a reproducer script
#!/bin/bash
cd "$(mktemp -d ${TMPDIR:-/tmp}/dl-XXXXXXX)"
set -eu
git init
git annex init
echo 123 > 123
git annex add 123
git commit -m 'commit 123 locked'
git annex unlock 123
git commit -m 'commit 123 unlocked' 123
set -x
git annex find --unlocked # should show 123
git status # should show all clean
# let's create another file which we just modify
echo 124 > 124
git annex add 124
git commit -m 'committing 124 locked' 124
rm 124
touch 124
git annex find --unlocked # will report both 123 and 124
git status
which with git-annex 8.20211231+git140-gc3817495f-1~ndall+1
would produce at the end
+ git commit -m 'committing 124 locked' 124
[master b58274c] committing 124 locked
1 file changed, 1 insertion(+)
create mode 120000 124
+ rm 124
+ touch 124
+ git annex find --unlocked
123
124
+ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
typechange: 124
no changes added to commit (use "git add" and/or "git commit -a")
and I do not think it should report 124
as unlocked. Or is there some find
way to search only for "truly unlocked" files?
The only difference between those two is that git-annex unlock stages the unlocking, while replacing the file with unlocked content does not stage it yet.
Both files are unlocked in the working tree though. One is unlocked in the index, and the other one is not yet. But git-annex find examines the working tree.
What you are looking for is a a way to have
git-annex find
ignore the working tree and find files that are unlocked in the index. That is doable:--branch
should be the one to remember indeed and would fulfill my desires (I think ). thank you Joey!