clone: Add --defuse-gitattributes
authorAndrej Shadura <andrew.shadura@collabora.co.uk>
Sun, 7 Feb 2021 18:31:00 +0000 (19:31 +0100)
committerGuido Günther <agx@sigxcpu.org>
Thu, 11 Mar 2021 11:48:47 +0000 (12:48 +0100)
On clone, disable Git attributes that may interfere with building
packages shipping .gitattributes *iff* they ship those files.
Set to auto by default, can also be turned off completely or
can be performed unconditionally.

Signed-off-by: Andrej Shadura <andrew.shadura@collabora.co.uk>
gbp/config.py
gbp/scripts/clone.py

index 1ca8defd9e697d33e504cf8c7f3e29d60af5f127..c2e8ec13a9e0c4c67fe773e0cbff6b090fb16b28 100644 (file)
@@ -121,6 +121,7 @@ class GbpOptionParser(OptionParser):
                 'debian-branch': 'master',
                 'debian-tag': 'debian/%(version)s',
                 'debian-tag-msg': '%(pkg)s Debian release %(version)s',
+                'defuse-gitattributes': 'auto',
                 'dist': 'sid',
                 'drop': 'False',
                 'export': 'HEAD',
index 7894b618dd8dde26a2375bfe896c11696d6739fc..d538cdfebd81067544cedb1cef16bbd917454f80 100755 (executable)
@@ -138,6 +138,8 @@ def build_parser(name):
                                   choices=['DEBIAN', 'GIT'])
     parser.add_config_file_option(option_name="repo-email", dest="repo_email",
                                   choices=['DEBIAN', 'GIT'])
+    parser.add_config_file_option(option_name="defuse-gitattributes", dest="defuse_gitattributes",
+                                  type="tristate", help="disable harmful Git attributes")
     return parser
 
 
@@ -208,6 +210,9 @@ def main(argv):
             repo.set_branch(options.debian_branch)
 
         repo_setup.set_user_name_and_email(options.repo_user, options.repo_email, repo)
+        if not options.defuse_gitattributes.is_off():
+            if options.defuse_gitattributes.is_on() or not repo_setup.check_gitattributes(repo, 'HEAD'):
+                repo_setup.setup_gitattributes(repo)
 
         if postclone:
             Hook('Postclone', options.postclone,