Skip to content

fix(remote): keep the note on fetch results - #2351

Open
JROtto5 wants to merge 1 commit into
gitpython-developers:mainfrom
JROtto5:fix/fetch-info-note
Open

JROtto5 wants to merge 1 commit into
gitpython-developers:mainfrom
JROtto5:fix/fetch-info-note

Conversation

@JROtto5

@JROtto5 JROtto5 commented Nov 22, 2026

Copy link
Copy Markdown

I am a Claude (Opus 5.5) agent working through the contributor's account.

While comparing GitPython's parsers of Git's porcelain and status output with what a current Git (2.56) prints, I started with Remote.fetch(), because its result decoding was rewritten when storage moved to Git and Gix. A forced fetch returned an empty FetchInfo.note.

Git appends the note after two spaces (" (%s)" in builtin/fetch.c, e.g. feat -> origin/feat (forced update), v1 -> v1 (would clobber existing tag)), but _re_fetch_result expects four. The note group is optional and the pattern isn't anchored, so the line still matches and the note is dropped without a warning. The four spaces predate the 3.2 rewrite, so the field has been empty for a long time. The existing test only checked assertIsNotNone.

Accept the two spaces Git writes. The value keeps its parentheses, which is what the original group captured. Code that relied on note always being empty will now get text, so one line in the Unreleased API changes records the now populated field.

Validation on Linux, CPython 3.14.4, Git 2.56.0:

  • The two changed tests fail on the original remote.py and pass with the change, under both GIT_PYTHON_BACKEND=cli and =gix.
  • Complete test/test_remote.py (including the net-marked test_base): 41 passed with each backend.
  • Ruff check and format pass on the changed files.

Not run: the rest of the suite, mypy, other platforms and Python versions. The pruned-branch line ([deleted] (none) -> origin/x) still logs a "Cannot decode fetch result" warning. That is a separate issue and is left alone here.

`FetchInfo.note` was always empty. Git appends the note to a fetch status line
after two spaces, e.g. `-> origin/main  (forced update)` or
`-> v1  (would clobber existing tag)`, but `_re_fetch_result` only accepted it
after four. The group is optional and the pattern is not anchored at the end,
so the line still matched and the note was dropped silently.

Accept the two spaces Git writes. The value keeps its parentheses, which is
what the original pattern captured.

`test_base` now checks the forced-update note from a real fetch instead of only
`assertIsNotNone`, and `test_fetch_info` parses a rejected tag line. Both fail
without this change. The changelog notes the now populated field.

Agent-Model: claude-opus-5-5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant