From 9026d4ec9279cbe452867fcb78fe689902a9617f Mon Sep 17 00:00:00 2001 From: Otto Liljalaakso Date: Mar 17 2025 22:41:29 +0000 Subject: Restrict Git index version to what GitPython supports The Git index version used by a repository is set when the repository is cloned. If the user has a non-default Git config like `feature.manyFiles=true`, index versions above the default of 2 may be used. On the other hand, GitPython, and consequently rpkg, do not support anything above 2. Create repositories that can be manipulated by rpkg by forcing index version 2 when cloning. Upstream issue: https://github.com/gitpython-developers/GitPython/issues/1960 Original report at Fedora Package Maintainer Docs: https://pagure.io/fedora-docs/package-maintainer-docs/pull-request/173 Signed-off-by: Otto Liljalaakso --- diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py index e14a63e..32ad4ff 100644 --- a/pyrpkg/__init__.py +++ b/pyrpkg/__init__.py @@ -1601,6 +1601,9 @@ class Commands(object): # Create the command cmd = ['git', 'clone'] + # Restrict index version to what GitPython supports + # https://github.com/gitpython-developers/GitPython/issues/1960 + cmd.extend(['-c', 'index.version=2']) if self.quiet: cmd.append('-q') if depth: diff --git a/tests/test_cli.py b/tests/test_cli.py index 662a471..dd1a2be 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -629,8 +629,9 @@ class TestClone(CliTestCase): cli = self.new_cli() cli.clone() - expected_cmd = ['git', 'clone', 'ssh://dude@localhost/repository_name', - '--origin', 'origin', '--progress'] + expected_cmd = ['git', 'clone', '-c', 'index.version=2', + 'ssh://dude@localhost/repository_name', '--origin', + 'origin', '--progress'] _run_command.assert_called_once_with(expected_cmd, cwd=self.cloned_repo_path) output = sys.stderr.getvalue().strip() @@ -675,8 +676,9 @@ class TestClone(CliTestCase): cli = self.new_cli() cli.clone() - expected_cmd = ['git', 'clone', 'ssh://dude@localhost/repository_name', - '--origin', 'origin', '--progress'] + expected_cmd = ['git', 'clone', '-c', 'index.version=2', + 'ssh://dude@localhost/repository_name', '--origin', + 'origin', '--progress'] _run_command.assert_called_once_with(expected_cmd, cwd=self.cloned_repo_path) output = sys.stderr.getvalue().strip()