GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitConfigParser misparses quotes in options · Issue #1923 · gitpython-developers/GitPython

GitConfigParser misparses quotes in options #1923

New issue
Copy link
New issue
Copy link
Closed
#2035
Closed
GitConfigParser misparses quotes in options#1923
#2035
Copy link
Labels
acknowledgedhelp wanted

Description

@cjwatson
cjwatson
opened on May 31, 2024
Issue body actions

My ~/.gitconfig starts like this:

[user]
        name = "Colin Watson"
        email = "[email protected]"

It's been like that for a long time, so I don't remember whether an old version of git config wrote it like that, or whether I put it there by hand. Anyway, git itself has always been fine with this. The relevant part of git-config(1) says:

A line that defines a value can be continued to the next line by ending it with a ; the backslash and the end-of-line are stripped. Leading whitespaces after name =, the remainder of the line after the first comment character # or ;, and trailing whitespaces of the line are discarded unless they are enclosed in double quotes. Internal whitespaces within the value are retained verbatim.

Inside double quotes, double quote " and backslash \ characters must be escaped: use " for " and \ for .

The following escape sequences (beside " and \) are recognized: \n for newline character (NL), \t for horizontal tabulation (HT, TAB) and \b for backspace (BS). Other char escape sequences (including octal escape sequences) are invalid.

But when I create a commit using IndexFile.commit(), I get this in the commit metadata, which I'm pretty sure is malformed:

Author: "Colin Watson" <"[email protected]">

I think GitConfigParser should match the parsing rules that git config follows.

Reacted by Paul Meyer and betaboon

Activity

  1. Byron
    added
    acknowledged
    help wanted
    on Jun 1, 2024
  2. Byron commented on Jun 1, 2024

    @Byron
    Byron
    on Jun 1, 2024
    Member
    More actions

    Thanks a lot for reporting!

    The config parser here is based on the INI config parser, which makes it very much non-conforming to the Git specification.
    Fixes on top of that can certainly be done though, hoping they won't introduce more problems than they solve.

  3. katexochen commented on Nov 2, 2024

    @katexochen
    katexochen
    on Nov 2, 2024
    More actions

    This is a problem as GitHub won't recognize the quoted version, so commits aren't liked to the authors profile.

  4. betaboon commented on Jun 6, 2025

    @betaboon
    betaboon
    on Jun 6, 2025
    Contributor
    More actions

    i just stumbled upon the same problem and tried my hand at a fix in #2035.

  5. Byron
    closed this as completedin #2035on Jun 7, 2025
  6. EliahKagan
    added 7 commits that reference this issue on Jun 7, 2025

    Test a quoted config var with meaningful edge whitespace

    de71ec3

    Test a quoted config var with meaningful edge whitespace

    5f30320

    Don't remove quotes if `\` or `"` are present inside

    dacd198

    Don't remove quotes if `\` or `"` are present inside

    531dc34

    Don't remove quotes if `\` or `"` are present inside

    f2b8041

    Don't remove quotes if `\` or `"` are present inside

    8eb30e7

    Don't remove quotes if `\` or `"` are present inside

    4dcd0b5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    acknowledgedhelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.