Skip to content
This repository was archived by the owner on Mar 27, 2024. It is now read-only.

File diff reports diff as single-line #271

Closed
briandealwis opened this issue Nov 2, 2018 · 1 comment
Closed

File diff reports diff as single-line #271

briandealwis opened this issue Nov 2, 2018 · 1 comment

Comments

@briandealwis
Copy link
Member

Doing a container-diff --type=file --filename=... reports a unified diff but treats the file contents as a single line.

Expected behavior

Output as per diff -u. In the below, I copied the content reported by container-diff to files /tmp/f1 and /tmp/f2.

$ diff -u /tmp/f1 /tmp/f2
--- /tmp/f1	2018-11-02 09:35:03.000000000 -0400
+++ /tmp/f2	2018-11-02 09:35:12.000000000 -0400
@@ -1,9 +1,9 @@
 Package: openjdk-8-jre-headless
 Source: openjdk-8
-Version: 8u171-b11-1~deb9u1
+Version: 8u181-b13-1~deb9u1
 Architecture: amd64
 Maintainer: OpenJDK Team <[email protected]>
-Installed-Size: 97311
+Installed-Size: 97352
 Depends: ca-certificates-java, java-common (>= 0.28), libcups2, liblcms2-2 (>= 2.2+git20110628), libjpeg62-turbo (>= 1.3.1), libfontconfig1, libnss3 (>= 2:3.17.1), util-linux (>= 2.26.2-4), libc6 (>= 2.14), libfreetype6 (>= 2.2.1), libgcc1 (>= 1:3.0), libpcsclite1 (>= 1.3.0), libstdc++6 (>= 4.1.1), libx11-6, libxext6, libxi6, libxrender1, libxtst6, zlib1g (>= 1:1.1.4)
 Suggests: libnss-mdns, fonts-dejavu-extra, fonts-ipafont-gothic, fonts-ipafont-mincho, fonts-wqy-microhei, fonts-wqy-zenhei, fonts-indic
 Breaks: ca-certificates-java (<< 20160321~), oracle-java8-installer (<< 8u77+8u77arm-1), tzdata-java

Actual behavior

The actual behaviour just reports the diff as if the file content was retrieved as a single line.

$ container-diff diff --type=file --filename=/var/lib/dpkg/status.d/openjdk remote://gcr.io/distroless/java@sha256:b430543bea1d8326e767058bdab3a2482ea45f59d7af5c5c61334cd29ede88a1 remote://gcr.io/distroless/java@sha256:bb1c9179c2263733f235291998cb849d52fb730743125420cf4f97a362d6a6dd
[...]
-----Diff of /var/lib/dpkg/status.d/openjdk-----


--- gcr.io/distroless/java@sha256:b430543bea1d8326e767058bdab3a2482ea45f59d7af5c5c61334cd29ede88a1
+++ gcr.io/distroless/java@sha256:bb1c9179c2263733f235291998cb849d52fb730743125420cf4f97a362d6a6dd
@@ -1 +1 @@
-Package: openjdk-8-jre-headless
Source: openjdk-8
Version: 8u171-b11-1~deb9u1
Architecture: amd64
Maintainer: OpenJDK Team <[email protected]>
Installed-Size: 97311
Depends: ca-certificates-java, java-common (>= 0.28), libcups2, liblcms2-2 (>= 2.2+git20110628), libjpeg62-turbo (>= 1.3.1), libfontconfig1, libnss3 (>= 2:3.17.1), util-linux (>= 2.26.2-4), libc6 (>= 2.14), libfreetype6 (>= 2.2.1), libgcc1 (>= 1:3.0), libpcsclite1 (>= 1.3.0), libstdc++6 (>= 4.1.1), libx11-6, libxext6, libxi6, libxrender1, libxtst6, zlib1g (>= 1:1.1.4)
Suggests: libnss-mdns, fonts-dejavu-extra, fonts-ipafont-gothic, fonts-ipafont-mincho, fonts-wqy-microhei, fonts-wqy-zenhei, fonts-indic
Breaks: ca-certificates-java (<< 20160321~), oracle-java8-installer (<< 8u77+8u77arm-1), tzdata-java
Provides: java2-runtime-headless, java5-runtime-headless, java6-runtime-headless, java7-runtime-headless, java8-runtime-headless
Section: java
Priority: optional
Multi-Arch: same
Homepage: http://openjdk.java.net/
Description: OpenJDK Java runtime, using Hotspot JIT (headless)
 Minimal Java runtime - needed for executing non GUI Java programs,
 using Hotspot JIT.
 .
 The packages are built using the IcedTea build support and patches
 from the IcedTea project.
+Package: openjdk-8-jre-headless
Source: openjdk-8
Version: 8u181-b13-1~deb9u1
Architecture: amd64
Maintainer: OpenJDK Team <[email protected]>
Installed-Size: 97352
Depends: ca-certificates-java, java-common (>= 0.28), libcups2, liblcms2-2 (>= 2.2+git20110628), libjpeg62-turbo (>= 1.3.1), libfontconfig1, libnss3 (>= 2:3.17.1), util-linux (>= 2.26.2-4), libc6 (>= 2.14), libfreetype6 (>= 2.2.1), libgcc1 (>= 1:3.0), libpcsclite1 (>= 1.3.0), libstdc++6 (>= 4.1.1), libx11-6, libxext6, libxi6, libxrender1, libxtst6, zlib1g (>= 1:1.1.4)
Suggests: libnss-mdns, fonts-dejavu-extra, fonts-ipafont-gothic, fonts-ipafont-mincho, fonts-wqy-microhei, fonts-wqy-zenhei, fonts-indic
Breaks: ca-certificates-java (<< 20160321~), oracle-java8-installer (<< 8u77+8u77arm-1), tzdata-java
Provides: java2-runtime-headless, java5-runtime-headless, java6-runtime-headless, java7-runtime-headless, java8-runtime-headless
Section: java
Priority: optional
Multi-Arch: same
Homepage: http://openjdk.java.net/
Description: OpenJDK Java runtime, using Hotspot JIT (headless)
 Minimal Java runtime - needed for executing non GUI Java programs,
 using Hotspot JIT.
 .
 The packages are built using the IcedTea build support and patches
 from the IcedTea project.

Information

  • container-diff version: from HEAD (commit 392203e)
  • Operating system: macOS 10.13.6

Steps to reproduce the behavior

container-diff diff --type=file --filename=/var/lib/dpkg/status.d/openjdk remote://gcr.io/distroless/java@sha256:b430543bea1d8326e767058bdab3a2482ea45f59d7af5c5c61334cd29ede88a1

@briandealwis
Copy link
Member Author

briandealwis commented Nov 2, 2018

I think the file contents need to be split with difflib.SplitLines()

//Carry on with diffing, make string array for difflib requirements
image1Contents := []string{string(*image1FileContents)}
image2Contents := []string{string(*image2FileContents)}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant