fix: join backslash line continuations when reading config values · gitpython-developers/GitPython@075a664 · GitHub
Skip to content

Commit 075a664

Browse files
author
NK
committed
fix: join backslash line continuations when reading config values
git config joins an unquoted value that ends in a backslash with the next line: the backslash and the newline are removed and the next line is appended verbatim, so 'k = line1\' followed by ' line2' reads back as 'line1 line2'. GitPython only implemented multi-line values for quoted strings; for unquoted values the continuation line was silently dropped, truncating whatever was stored in the config. Read the continuation inside _read and join it, chaining across lines that themselves end in a backslash. An even number of trailing backslashes is an escaped one, so the value ends there; a single backslash right at end-of-file is dropped, matching git. Verified against git itself for every case covered by the new tests.
1 parent 62d1e2f commit 075a664

2 files changed

Lines changed: 40 additions & 1 deletion

File tree

git/config.py

Lines changed: 20 additions & 1 deletion

test/test_config.py

Lines changed: 20 additions & 0 deletions

0 commit comments

Comments
 (0)