diff: Add -j option to enable JSON-formatted output
This commit introduces a new command-line option -j (and --json) to the diff utility. When specified, file and directory information is printed in JSON format.
The output is a JSON array of objects, where each object represents an entry and includes fields such as:
- name, path, type, inode, size, blocks, link count
- UID, GID, user/group names
- permission string, octal mode
- timestamps (atime, mtime, ctime, birthtime)
- symbolic link target, file flags (with
-o) - MAC label (with
-Z)
This format is particularly useful for scripts and tools requiring structured output.
Key changes:
- Added
f_jsonflag and parsing of-j/--jsonoptions. - Implemented JSON serialization with proper string escaping.
- Disabled color, human-readable sizes, and other formatting when
-jis used. - Updated the manual page with documentation and JSON structure details.
- Added regression tests using
jqto validate JSON output correctness.
Signed-off-by: Recep Karahan [email protected]
Thank you for taking the time to contribute to FreeBSD! There are a few issues that need to be fixed:
- Missing Signed-off-by lines9640a474a4d4d648af854f78f5361dbf9c618c95, e8d53c05a2462d4bf9f4a534ab37e5bffe402f2f
- Real email address is needed9640a474a4d4d648af854f78f5361dbf9c618c95, e8d53c05a2462d4bf9f4a534ab37e5bffe402f2f
So the code looks good. But normally use use libxo for things like this. On the other hand, it is simple enough... So I'm unsure.
And please add 'ls: ' to the start of that commit's subject. Similarly reword the second one to start with 'ldconfig:'
my deleted comment was PEBKAC
Wow, this is cool. What are you doing with json diffs? I've never heard of that. Layman's +1 for libxo, seems like consistency might be easier to maintain, understand, or improve.
Please don't spam our repository with AI-generated slop. It serves only to waste our time and yours. After reviewing some of your PRs, I have concluded that the rest do not warrant even a cursory review. Therefore I will close them all. If you wish to contribute again in the future, you must take more care with your submissions. You must build and test them all, at least! And you need to consider what the PR does. Is it even useful? Furthermore, the copyright status of AI-generated code is currently unclear, so the project is not accepting any such submissions at this time. But AI can of course be used as an aid, such as for debugging. Finally, I encourage you to read these documents to familiarize yourself with our project and its practices.
https://docs.freebsd.org/en/books/developers-handbook/ https://docs.freebsd.org/en/articles/problem-reports/