Please describe the problem.
Recent git-annex release triggered a number of datalad test fails.
One of them is attempted to workaround in datalad/pull/6510 is due to the fact that annex find
did not only change its output (which seems to ignore having --json --json-error-messages
and not providing json records with errors) but also not even exiting no longer with non-0 exit code:
(git-annex)lena:/tmp/testds[master]
$> git annex find --copies 0 --json --json-error-messages qwdqwd csdc
error: pathspec 'qwdqwd' did not match any file(s) known to git
error: pathspec 'csdc' did not match any file(s) known to git
Did you forget to 'git add'?
$> echo $?
0
$> git annex version
git-annex version: 10.20220222+git23-g51c528980-1~ndall+1
This is the annex.skipunknown transition so you can set that to true to get back the previous behavior. (See NEWS)
However, I do not think that was intended to result in this behavior when the specified files do not exist at all, it was only supposed to make it skip files that exist but are not checked into git. So this does seem like a bug.
Also, the docs for annex.skipunknown say that a command should exit nonzero if all files in a directory are not checked into git, but it does not behave that way either. It seems that it needs to propagate a nonzero exit status of git-ls-files at least for that, if not for also the handling of files that do not exist.
I've fixed it to propagate the non-zero exit status from git ls-files.
The git ls-files message still goes to stderr, not to --json-error-messages, the same as any stderr output by a git command that git-annex runs. And this is actually not a behavior change; the old git-annex output of "not found" did not get included in --json-error-messages either:
Bear in mind that --json-error-messages is about errors encountered while processing a particular file that it outputs a json record for. This error comes before it starts processing any particular file. Also, of course, error messages output by git commands are never included in --json-error-messages.
I think it might be a good idea to add an actual API for detecting when there is this kind of problem, so datalad does not have to parse error messages (which could easily change). But that would need to be a separate discussion. I've opened api for telling when nonexistant or non git files passed for that.