Don't remove quotes if \
or "
are present inside
#2048
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
#2035 fixed issue #1923, where the ConfigParser would not remove the quotes around single-line values. As discussed in comments there:
Let's take the best of both worlds (so far)
This PR keeps the changes from #2035 in the case that they work because the text contained strictly between the beginning and ending
"
characters contains neither any\
nor any other"
. This both:\
is meant to be preserved rather than treated as an escape character. This is presumably rare--if it ever happens--since that's not the syntax of double-quoted values in Git config files.)Changes
But it can get better than this
This is not intended as a long-term alternative to parsing escape sequences. The idea in #2035 (comment) of handling them is good, and this is not meant to discourage or interfere with that. The new test fixture and test can be modified accordingly. See the docstring and comments in
test_config_with_quotes_containing_escapes
.For review
It seems to me that the idea here is sound, since it restores the main branch to a state where no changes are expected to produce problems for programs and libraries that use GitPython, if a patch release were to be made.
But even if I am right to think that, there are a few reasons it may be useful to have a review here before merging:
(This follows #2046 and #2047, which followed #2035 and #2036.)