Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Preserve quoted leading and trailing single-line config var whitespace#2036

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

EliahKagan
Copy link
Member

#2035 fixed issue#1923 by removing separate double quotation marks appearing on a single-line configuration variable when parsing a configuration file. However, as noted in#2035 (comment), it also stripped leading and trailing whitespace from the string obtained by removing the quotes.

In this PR:

  1. 5f30320 adds a test case of a plausible--and in my view, decisive--scenario where such whitespace needs to be preserved and where a user would almost certainly expect it to preserve. This test would also have failed before#2035, due to the absence of quote removal. But it is the sort of value that one would expect to parse correctly now that#1923 is fixed, and which#2035almost does parse correctly.
  2. bd2b930 fixes the case by removing thestrip() call while leaving the changes from#2035 otherwise intact. The test added in (1) fails until this change, and then passes.

See the commit message for further details.

gitpython-developers#2035 fixed issuegitpython-developers#1923 by removing separate double quotation marksappearing on a single-line configuration variable when parsing aconfiguration file. However, it also stripped leading and trailingwhitespace from the string obtained by removing the quotes.This adds a test case of a plausible scenario where such whitespaceneeds to be preserved and where a user would almost certainly expectit to preserve: setting a value like `# ` for `core.commentString`,in order to be able to easily create commit messages like this one,that contain a line that begins with a literal `#`, while stillletting `#` in the more common case that it is followed by a spacebe interpreted as a comment.The effect of  `git config --local core.commentString '# '` is toadd a `commentString = "# "` line in the `[core]` section of`.git/config`. The changes ingitpython-developers#2035 allow us to correctly parsemore quoted strings than before, and almost allow us to parse this,but not quite, because of the `strip()` operation that turns `# `into `#`.
At least in a single line, whitespace in a double-quoted value in aconfiguration file, like `name = " abc def "`, would presumably beintended. This removes the `strip()` call that is applied to text`ConfigParser` obtained by removing the double quotes around it.This slightly refines the changes ingitpython-developers#2035 by dropping the `strip()`call while continuing to remove opening and closing double quotes.
@EliahKaganEliahKagan marked this pull request as ready for reviewJune 7, 2025 05:31
@EliahKaganEliahKagan requested a review fromByronJune 7, 2025 05:31
Copy link
Member

@ByronByron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thanks a lot for this, a great catch!

EliahKagan reacted with thumbs up emoji
@ByronByron merged commitcf8029d intogitpython-developers:mainJun 7, 2025
26 checks passed
@EliahKaganEliahKagan deleted the quoted-whitespace branchJune 7, 2025 05:59
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@ByronByronByron approved these changes

Assignees
No one assigned
Labels
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@EliahKagan@Byron

[8]ページ先頭

©2009-2025 Movatter.jp