From 1c2e75be118ad5b24e440c9009482a0e211f4afa Mon Sep 17 00:00:00 2001 From: Ricardo Ribalda Date: Wed, 25 Dec 2024 22:22:15 +0000 Subject: [PATCH] get_config_settings: Avoid break with multiline configs If a user has a multiline config like: ``` git config test.test = "Hello world" ``` git-filter-repo breaks: ``` > return dict(line.split(b'=', maxsplit=1) for line in output.strip().split(b"\n")) E ValueError: dictionary update sequence element #12 has length 1; 2 is required ``` Multiline configs are required by b4 in branch-description strategy: https://b4.docs.kernel.org/en/latest/contributor/prep.html#prep-cover-strategies Signed-off-by: Ricardo Ribalda --- git-filter-repo | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/git-filter-repo b/git-filter-repo index a40bce54..7ff048b5 100755 --- a/git-filter-repo +++ b/git-filter-repo @@ -1688,9 +1688,11 @@ class GitUtils(object): except subprocess.CalledProcessError as e: # pragma: no cover raise SystemExit('fatal: {}'.format(e)) + configs = map(lambda x: x.strip().split(b'=', maxsplit=1), output.splitlines()) + # FIXME: Ignores multi-line values, just take the first line for now + configs = filter(lambda x: len(x) == 2, configs) # 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(configs) @staticmethod def get_blob_sizes(quiet = False):