[diffoscope] 02/04: Add a --exclude-directory-metadata option. (Closes: #866241)

Ximin Luo infinity0 at debian.org
Fri Jun 30 19:12:28 CEST 2017


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

infinity0 pushed a commit to branch master
in repository diffoscope.

commit 7f2fa5fa137675e116fdbfc38c2ef6fbe17d5dc9
Author: Ximin Luo <infinity0 at debian.org>
Date:   Fri Jun 30 18:27:12 2017 +0200

    Add a --exclude-directory-metadata option. (Closes: #866241)
---
 debian/changelog                    |  6 ++++++
 diffoscope/comparators/directory.py |  5 +++++
 diffoscope/config.py                |  1 +
 diffoscope/main.py                  | 12 ++++++++++++
 4 files changed, 24 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 6da6168..6e1d3a4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+diffoscope (84) UNRELEASED; urgency=medium
+
+  * Add a --exclude-directory-metadata option. (Closes: #866241)
+
+ -- Ximin Luo <infinity0 at debian.org>  Fri, 30 Jun 2017 18:25:03 +0200
+
 diffoscope (83) unstable; urgency=medium
 
   [ Chris Lamb ]
diff --git a/diffoscope/comparators/directory.py b/diffoscope/comparators/directory.py
index 5235709..2f6289d 100644
--- a/diffoscope/comparators/directory.py
+++ b/diffoscope/comparators/directory.py
@@ -24,6 +24,7 @@ import logging
 import subprocess
 from collections import OrderedDict
 
+from diffoscope.config import Config
 from diffoscope.exc import RequiredToolNotFound
 from diffoscope.tools import tool_required
 from diffoscope.progress import Progress
@@ -100,6 +101,10 @@ class Getfacl(Command):
 
 
 def compare_meta(path1, path2):
+    if Config().exclude_directory_metadata:
+        logger.debug("Excluding directory metadata for paths (%s, %s)", path1, path2)
+        return []
+
     logger.debug('compare_meta(%s, %s)', path1, path2)
     differences = []
     try:
diff --git a/diffoscope/config.py b/diffoscope/config.py
index ccc744c..d5f6007 100644
--- a/diffoscope/config.py
+++ b/diffoscope/config.py
@@ -35,6 +35,7 @@ class Config(object):
     enforce_constraints = True
     excludes = ()
     exclude_commands = ()
+    exclude_directory_metadata = False
     compute_visual_diffs = False
     max_container_depth = 50
 
diff --git a/diffoscope/main.py b/diffoscope/main.py
index 8ce6e1c..13606ab 100644
--- a/diffoscope/main.py
+++ b/diffoscope/main.py
@@ -169,6 +169,17 @@ def create_parser():
                         'the longest time, and differences here are probably '
                         'only secondary differences caused by something that '
                         'is already represented elsewhere in the diff.')
+    group3.add_argument('--exclude-directory-metadata', action='store_true',
+                        help='Exclude directory metadata. Useful if comparing '
+                        'files whose filesystem-level metadata is not intended '
+                        'to be distributed to other systems. For example, this '
+                        'is true for most distros\' package builders, but not '
+                        'true for the output of commands like `make install`. '
+                        'Metadata of archive members remain un-excluded.')
+    group3.add_argument('--no-exclude-directory-metadata', action='store_const',
+                        const=False, dest='exclude_directory_metadata',
+                        help='Don\'t exclude directory metadata, useful to '
+                        'cancel an earlier --exclude-directory-metadata flag.')
     group3.add_argument('--fuzzy-threshold', type=int,
                         help='Threshold for fuzzy-matching '
                         '(0 to disable, %(default)s is default, 400 is high fuzziness)',
@@ -299,6 +310,7 @@ def run_diffoscope(parsed_args):
     Config().new_file = parsed_args.new_file
     Config().excludes = parsed_args.excludes
     Config().exclude_commands = parsed_args.exclude_commands
+    Config().exclude_directory_metadata = parsed_args.exclude_directory_metadata
     Config().compute_visual_diffs = PresenterManager().compute_visual_diffs()
     set_path()
     set_locale()

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


More information about the diffoscope mailing list