container-diff icon indicating copy to clipboard operation
container-diff copied to clipboard

Don't exit with 0 if images are different

Open bodgit opened this issue 7 years ago • 5 comments
trafficstars

This tool seems to always exit 0 when I run container-diff diff ... on two images that are different. A common convention in diff tools is to exit 0 when there are no differences, 1 when there are differences and 2 when an error occurred.

This would make it simple to use in shell scripts or build pipelines; I don't want to parse the output to discern if there are differences, in fact I probably don't even care about the output at all, I just want to be able to do something like container-diff diff <img1> <img2> || ....

See also the --exit-code option for git diff so having something implied by setting --quiet in #175 could work.

bodgit avatar Feb 19 '18 14:02 bodgit

We are working on a common CLI Lib for all our tools and this will be a good feature to add in there.

tejal29 avatar Feb 20 '18 19:02 tejal29

Any news on this?

moschlar avatar May 09 '19 10:05 moschlar

Using this tool for what I wanted is a lot harder due to this issue still not being fixed. A good diff-tool allows one to quickly identify if the compared objects are identical, and container-diff makes it a lot more convoluted to evaluate this.

This will provide almost what I want:

[ $(container-diff diff --type file image1 image2 --format='{{if not .Diff.Adds}}0{{else}}1{{end}}{{if not .Diff.Dels}}0{{else}}1{{end}}{{if not .Diff.Mods}}0{{else}}1{{end}}' 2> /dev/null) == "000" ] && echo true

If container-diff exited with 0 when there was no diff and 1 if there was a diff it would be:

container-diff diff --type file image1 image2 && echo true

denisbr avatar Oct 04 '19 20:10 denisbr

Why did you close the issue? Is there a solution? If not, can you reopen this issue?

Reamer avatar Mar 21 '22 12:03 Reamer

This issue has been open for four years and nothing has apparently changed so I think it's unlikely this will ever be fixed, plus I'm not even using this tool these days.

I'll reopen for the benefit of anyone else.

bodgit avatar Mar 21 '22 13:03 bodgit