This commit is contained in:
aurelien@f0d0a0c7da69eff6badf0464898f0a859f69114d 2023-11-06 01:48:43 +00:00 committed by admin
parent 184ebb8802
commit eb846403c9

View file

@ -0,0 +1,76 @@
### Please describe the problem.
As I understand the manual:
- Options `--json --json-error-messages` are provided so that another program can parse the `git annex fsck` results.
- Option `--quiet` is provided to list only problems (not print anything for OK files).
However, when options are combined, only plain text error messages are provided, no json output is provided.
I understand this may be "as designed", quiet is quiet... But then how to log only errors in json? I have +300k files in the annex, and no need to log when everything is fine.
### What steps will reproduce the problem?
Create a repo with files b and c
Corrupt file b
`git annex fsck --json --json-error-messages --quiet`
I expected to have a json output with only files that fail the fsck, instead I get only normal stderr, just like with
`git annex fsck --quiet`
### What version of git-annex are you using? On what operating system?
10.20230926-12 on arch
### Please provide any additional information below.
[[!format sh """
# Expected plain result
> git annex fsck
fsck b
** No known copies exist of b
failed
fsck c (checksum...) ok
(recording state in git...)
fsck: 1 failed
# Expected json result (error message to stderr, both logs)
> git annex fsck --json
** No known copies exist of b
{"command":"fsck","dead":[],"error-messages":[],"file":"b","input":["b"],"key":"SHA256E-s5--f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2","success":false,"untrusted":[]}
{"command":"fsck","error-messages":[],"file":"c","input":["c"],"key":"SHA256E-s4--530a0b93b8c1ea618546d3aaa6ec71f888d2a6095322bfdb1b04c9225e26481e","note":"checksum...","success":true}
fsck: 1 failed
# Expected json output with error message embedded
> git annex fsck --json --json-error-messages
{"command":"fsck","dead":[],"error-messages":["** No known copies exist of b"],"file":"b","input":["b"],"key":"SHA256E-s5--f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2","success":false,"untrusted":[]}
{"command":"fsck","error-messages":[],"file":"c","input":["c"],"key":"SHA256E-s4--530a0b93b8c1ea618546d3aaa6ec71f888d2a6095322bfdb1b04c9225e26481e","note":"checksum...","success":true}
fsck: 1 failed
# Expected only error message
> git annex fsck --quiet
** No known copies exist of b
fsck: 1 failed
# UnExpected result: I expected a json output with the error message embedded "--json --json-error-messages" seem ignored here
> git annex fsck --json --json-error-messages --quiet
** No known copies exist of b
fsck: 1 failed
# End of transcript or log.
"""]]
### Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders)
Yes, great tool ! Thanks !