[diffoscope] 01/01: Drop libarchive check; prevent directories from being byte-compared instead.

Maria Glukhova siamezzze-guest at moszumanska.debian.org
Fri Jan 20 15:29:09 CET 2017


This is an automated email from the git hooks/post-receive script.

siamezzze-guest pushed a commit to branch siamezzze/containers
in repository diffoscope.

commit 29458c44f3174a96212e3c20d31344c494b15f49
Author: Maria Glukhova <siamezzze at gmail.com>
Date:   Fri Jan 20 08:07:42 2017 +0200

    Drop libarchive check; prevent directories from being byte-compared instead.
    
    In case of cross-container comparison, it might happen that Directory
    subclass objects (ZipDirectory, SquashfsDirectory, ...) will be compared
    using compare_files. We don't want this comparison to be handled by compare_bytes.
---
 diffoscope/comparators/utils/compare.py | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/diffoscope/comparators/utils/compare.py b/diffoscope/comparators/utils/compare.py
index e74fe2d..86a0f65 100644
--- a/diffoscope/comparators/utils/compare.py
+++ b/diffoscope/comparators/utils/compare.py
@@ -83,14 +83,9 @@ def compare_containers(file1, file2, source=None):
         source="file list"
     )])
 
-    if isinstance(container1, LibarchiveContainer) == \
-            isinstance(container2, LibarchiveContainer):
-        logger.debug("Comparing content.")
-        details.extend(container1.compare(container2))
-    else:
-        logger.debug("Can't compare libarchive with regular container, "
-                     "falling back to binary diff.")
-        details.extend([file1.compare_bytes(file2, source)])
+    logger.debug("Comparing content.")
+    details.extend(container1.compare(container2, source))
+
     details = [d for d in details if d is not None]
     difference.add_details(details)
     return difference
@@ -110,6 +105,9 @@ def compare_files(file1, file2, source=None):
     elif file1.__class__.__name__ != file2.__class__.__name__:
         if file1.as_container and file2.as_container:
             return compare_containers(file1, file2, source)
+        if file1.is_directory() and file2.is_directory():
+            # ZipDirectory, LibarchiveDirectory etc.
+            return None
         return file1.compare_bytes(file2, source)
     with profile('compare_files (cumulative)', file1):
         return file1.compare(file2, source)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list