17
0

4 Commits

5 changed files with 86 additions and 5 deletions

View File

@@ -0,0 +1,69 @@
From: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= <toke@toke.dk>
Date: Sat, 14 Dec 2024 19:13:06 +0100
Subject: Don't crash on multi-line config values
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
References: https://github.com/newren/git-filter-repo/issues/659
Git-repo: https://github.com/newren/git-filter-repo
Git-commit: 4697eeb37b7c3c30b0492e344f6b89f7139cef26
Patch-mainline: yes
The parsing of the output of `git config --list` fails if any of the
config values contain newlines. Fix this by using the --null parameter
to `git config`, which is designed for this purpose.
Add a simple test that causes the crash pre-patch.
Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
---
git-filter-repo | 6 +++---
t/t9390-filter-repo-basics.sh | 11 +++++++++++
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/git-filter-repo b/git-filter-repo
index a40bce548d..3b75eadd81 100755
--- a/git-filter-repo
+++ b/git-filter-repo
@@ -1683,14 +1683,14 @@ class GitUtils(object):
def get_config_settings(repo_working_dir):
output = ''
try:
- output = subproc.check_output('git config --list'.split(),
+ output = subproc.check_output('git config --list --null'.split(),
cwd=repo_working_dir)
except subprocess.CalledProcessError as e: # pragma: no cover
raise SystemExit('fatal: {}'.format(e))
# FIXME: Ignores multi-valued keys, just let them overwrite for now
- return dict(line.split(b'=', maxsplit=1)
- for line in output.strip().split(b"\n"))
+ return dict(item.split(b'\n', maxsplit=1)
+ for item in output.strip().split(b"\0") if item)
@staticmethod
def get_blob_sizes(quiet = False):
diff --git a/t/t9390-filter-repo-basics.sh b/t/t9390-filter-repo-basics.sh
index c129799fb6..1dc2dca789 100755
--- a/t/t9390-filter-repo-basics.sh
+++ b/t/t9390-filter-repo-basics.sh
@@ -895,4 +895,15 @@ test_expect_success 'origin refs without origin remote does not die' '
)
'
+test_expect_success 'multi-line config value' '
+ test_create_repo multiline_config &&
+ (
+ cd multiline_config &&
+
+ git config set test.test "test
+test" &&
+ git filter-repo --force
+ )
+'
+
test_done
--
2.49.0

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:db954f4cae9e47c6be3bd3161bc80540d44f5379cb9cf9df498f4e019f0a41a9
size 153772

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4662cbe5918196a9f1b5b3e1211a32e61cff1812419c21df4f47c5439f09e902
size 186836

View File

@@ -1,3 +1,14 @@
-------------------------------------------------------------------
Thu Apr 24 06:14:02 UTC 2025 - Jiri Slaby <jslaby@suse.cz>
- add Don-t-crash-on-multi-line-config-values.patch (#659)
-------------------------------------------------------------------
Sat Apr 19 08:50:17 UTC 2025 - Nathan Cutler <ncutler@suse.com>
- update to 2.47.0:
https://github.com/newren/git-filter-repo/compare/v2.38.0...v2.47.0
-------------------------------------------------------------------
Sun Dec 4 15:52:06 UTC 2022 - Dirk Müller <dmueller@suse.com>

View File

@@ -1,7 +1,7 @@
#
# spec file for package git-filter-repo
#
# Copyright (c) 2022 SUSE LLC
# Copyright (c) 2025 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -22,13 +22,14 @@
%global gitexecdir %{_libexecdir}/git
Name: git-filter-repo
Version: 2.38.0
Version: 2.47.0
Release: 0
Summary: Quickly rewrite git repository history (git-filter-branch replacement)
License: GPL-2.0-only OR MIT
Group: Development/Tools/Version Control
URL: https://github.com/newren/git-filter-repo
Source0: https://github.com/newren/git-filter-repo/releases/download/v%{version}/%{name}-%{version}.tar.xz
Patch0: Don-t-crash-on-multi-line-config-values.patch
BuildArch: noarch
BuildRequires: %{python_module devel}
BuildRequires: git-core