Visitar URL original
Comparing main...v4-breaking · gitpython-developers/GitPython · GitHub
Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: gitpython-developers/GitPython
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: gitpython-developers/GitPython
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v4-breaking
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
  • 2 commits
  • 21 files changed
  • 2 contributors

Commits on Aug 10, 2026

  1. feat: rewrite config parser to be consistent with Git

    Previously it was based on an ini-parser, which depends on the
    Python version and also isn't actually dealing with the Git's
    specific grammar and rules.
    
    Now it's much more consistent, albeit probably also slower.
    
    --- agent
    
    Replace the line-oriented INI parsing logic in GitConfigParser with a
    character-stream parser modeled on Git's config.c implementation.
    
    The inherited configparser section matcher treats everything between the
    first opening bracket and the last closing bracket as one section name.
    Consequently, GitPython interpreted a header such as:
    
        [user] [other]
    
    as one section named "user] [other", while Git interpreted it as two
    successive section headers and assigned following values to "other".
    Writing opaque section names through the INI serializer could therefore
    change the configuration's meaning when Git subsequently read it.
    
    Implement Git's configuration grammar directly, following the behavior of
    git_parse_source(), get_base_var(), get_value(), and parse_value(). The new
    parser handles:
    
    - basic and quoted-subsection section headers
    - multiple section headers in the same character stream
    - comments introduced by '#' or ';'
    - quoted and unquoted values
    - supported backslash escapes
    - backslash-newline continuations
    - leading and trailing whitespace rules
    - CRLF input and UTF-8 byte-order marks
    - entries without values, represented semantically as boolean true
    - duplicate options while preserving their order
    
    Reject syntax that Git itself rejects, including colon delimiters,
    underscore-containing option names, malformed section headers, unknown
    value escapes, and unterminated quoted values.
    
    Replace the raw value writer with a canonical Git-config serializer.
    Values are always quoted, with backslashes, quotes, newlines, tabs, and
    backspaces escaped. Quoted subsection names are parsed and re-escaped
    canonically before being written. Comments and original whitespace remain
    intentionally unpreserved when a dirty configuration is flushed.
    
    Validate section names by parsing them as complete Git section headers.
    This ensures each supplied name identifies exactly one section and
    prevents unquoted closing brackets from injecting another section.
    Validate option names against Git's ASCII letter, digit, and hyphen
    grammar as well.
    
    Update fixtures that previously depended on INI syntax rejected by Git,
    and adjust expectations for decoded value escapes and valueless boolean
    entries.
    
    Add coverage for:
    
    - the differing interpretation of adjacent section headers
    - BOM, CRLF, comments, continuations, and valueless entries
    - malformed syntax rejected by Git
    - canonical value serialization and reparsing
    - real `git config` interoperability
    - closing brackets inside quoted subsection names
    - quotes and backslashes inside subsection names
    - invalid section and option names
    - duplicate-value behavior with Git-compatible option names
    
    Co-authored-by: Sebastian Thiel <sebastian.thiel@icloud.com>
    codex and Byron committed Aug 10, 2026
    Configuration menu
    Copy the full SHA
    4c260e4 View commit details
    Browse the repository at this point in the history

Commits on Sep 10, 2026

  1. feat!: return None for detached refs and add HEAD.hexsha (#2230)

    A detached HEAD currently turns a branch lookup into a TypeError. Return
    None from SymbolicReference.reference (and its ref alias) and
    Repo.active_branch. An unborn branch still exposes its reference.
    
    Add repo.head.hexsha to read the hexadecimal object ID directly without
    loading commit objects. Resolve loose and packed references in attached,
    detached, bare, and linked-worktree repositories. Return None for an
    unborn target, and raise for a missing HEAD, malformed or cyclic refs,
    and failures to read reference data.
    
    Distinguish missing references from other I/O errors so an unreadable
    loose ref cannot silently fall back to a stale packed value. Replace the
    empty-ref assertion with ValueError and detect symbolic-reference cycles.
    Preserve revision lookup for branch names that overlap Git metadata paths.
    
    Update conditional configuration includes, reflog and upstream lookups,
    commit creation, checkout, and submodule tracking to handle optional
    references. Relative submodule URLs use origin when HEAD is detached.
    
    Update the tutorial and regression tests for the new API. Make writable
    test clones usable from detached checkouts, give remote tests an explicit
    master branch, and compare reflog results with Git instead of assuming
    successive entries always name different commits.
    
    Validation:
    - 311 targeted tests passed using disposable clones and isolated Git
      configuration, with additional detached-HEAD and feature-branch checks.
    - Ruff lint and formatting checks passed; mypy passed for 45 source files.
    - The pre-existing test_writer_rejects_invalid_option_names failure
      remains: it expects an underscore-containing option name to be accepted,
      while the config parser correctly rejects that Git-incompatible name.
    codex authored and Byron committed Sep 10, 2026
    Configuration menu
    Copy the full SHA
    dd6f1c8 View commit details
    Browse the repository at this point in the history
Loading