Preserve multiline config values when writing

fix: preserve multiline config values when writing
Preserve multiline config values when writing4b4e47-fix-preserve-multiline-config-values-when-writing-cve-2026-78676fixpreserve multiline config values writing

Committed by Byron

commit message
fix: preserve multiline config values when writing

<!-- agent -->
GitConfigParser decoded valid multiline values into embedded newlines, but
_write() serialized those newlines as indented physical lines. Rewriting an
otherwise unchanged config could therefore change its meaning to Git.
 
Serialize resident multiline values with Git-compatible escapes inside a
quoted continuation, preserving GitPython read compatibility while keeping
each option structurally intact. This addresses GHSA-284h-m62q-gf8w.
 
The regression starts with an inert multiline value, performs an unrelated
write, and verifies with both GitPython and git config that it remains one
value and does not create another option.
 
Git baseline: config.c parse_value() and write_pair() at cf5497b14c5a escape
embedded LF as \\n rather than emitting it as a physical config line.
 
Assisted-by: GPT 5.6
Co-authored-by: GPT 5.6 <[email protected]>

Editor assessment

This commit patches CVE-2026-78676. The subject 'fix: preserve multiline config values when writing' is clear and imperative, and the body does the work a good commit should: it explains that decoded multiline values were re-serialized as indented physical lines, so an unrelated write could silently change a config's meaning for Git. It names the remedy—Git-compatible escapes inside a quoted continuation—states the compatibility goal, cites GHSA-284h-m62q-gf8w, and grounds the fix in Git's own parse_value and write_pair behavior. A regression test is described and both GitPython and git config verify the result. The stray agent HTML comment and the missing config scope are the only blemishes; otherwise this is publishable work.

Browse categories

More fix examples · Back to search