Skip to content

Commit

Permalink
get_config_settings: Avoid break with multiline configs
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
ribalda committed Dec 25, 2024
1 parent 0ee22eb commit 1c2e75b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions git-filter-repo
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 1c2e75b

Please sign in to comment.