-
-
Notifications
You must be signed in to change notification settings - Fork 741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
borg diff should have --format option #4634
Comments
I'd like to implement this. Is it ok? |
Great, go ahead. 👍 Just note that it is not as trivial as it sounds, the current output is not generated by the diff function but deeper in the code where the actual changes between items are detected. So based on what I remember from back then, when I did briefly look into the code to see whether I could just fix it quickly instead of opening the bug, I would imagine it to involve these steps:
Further additions, such as some sort of JSON output would then be quite trivial. |
One question: what are the expected list of possible placeholders? |
I would like to work on this. Please assign this issue to me, I'll ask for help when needed on the #borgbackup IRC channel. |
@diivi you have it, thanks for helping! |
Hey @elho, the current |
Also, regarding the placeholders - |
I'd like to get a try for solution of this |
@RF-Tar-Railt maybe @diivi is still working on this? @diivi are you? |
Nope, I couldn't start working on this as it required some more design discussions. |
what would be the default format of
{
"changes": [
{
"added": 1705,
"removed": 1705,
"type": "modified"
},
{
"new_ctime": "2023-03-11T13:34:35.678141+08:00",
"old_ctime": "2023-02-22T00:08:47.979206+08:00",
"type": "ctime"
},
{
"new_mtime": "2023-03-11T13:34:35.678141+08:00",
"old_mtime": "2023-02-22T00:08:47.979206+08:00",
"type": "mtime"
}
],
"path": "dev/Alconna"
} if follows what "{mode}{size}{ctime}{mtime}{path}{NL}"
|
and if don't mind, I'll make some changes to the whole diff instruction handling |
I create a issue in my fork for collect some ideas: #1 |
IMHO, it would be better if you will collect your ideas here. For those who track changes in the main repository this is a better place to track changes and comments. |
I will also move the summary ideas here, thank you for your advice |
Some thoughts now:
|
new idea: class DiffChange:
type: str
@property
def content() -> dict: ...
... and so that it can easily used by DiffFormater |
Can I rewrite part of the BaseFormatter as well? @ThomasWaldmann |
@elho A question need to resolve: |
diff: add --format option also: refactoring/improvements of BaseFormatter
fixed by #7534 |
The
diff
sub-command should have a--format
option like e.g. thelist
sub-command has.Placeholders should include (but not be limited to),
path
,type
(directory entry type, same as withlist
),change
(giving the type of change, ie. whether added, deleted, modified (content change), owner, group, mode, etc. - speaking long or like AME, whatever is deemed preferable) and whatever fields to represent what else diff has at its hands that it can output, e.g.oldsize
,newsize
,deltasize
, etc.If several aspects of a directory entry were changed, multiple lines, each with the according
change
value would be printed. This does not sound nice at first, bit fits the format-string style output (as opposed to more template style with conditionals etc.) and suits working on the output with shell tools likegrep
.This would allow to do stuff like
borg diff --format "{change}{type}:{path}{NUL}" | sed --null-data --quiet --expression='s/(A|M)-://p' | xargs --null dosomethingwithchangedfiles
, thus being able to workaround/solve e.g. #3514 and #4191.The text was updated successfully, but these errors were encountered: