From 7386a157c5e2d078465a78da31c38e3015388743 Mon Sep 17 00:00:00 2001 From: JROtto5 <222316562+JROtto5@users.noreply.github.com> Date: Sun, 22 Nov 2026 01:07:36 -0500 Subject: [PATCH 1/2] fix(remote): keep the note on fetch results `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 --- doc/source/changes.rst | 2 ++ git/remote.py | 2 +- test/test_remote.py | 10 +++++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/doc/source/changes.rst b/doc/source/changes.rst index f9e8a13b2..6e18e1e95 100644 --- a/doc/source/changes.rst +++ b/doc/source/changes.rst @@ -232,6 +232,8 @@ API changes collection. Close files and repositories you opened yourself before removing a repository on Windows; call ``gc.collect()`` only if your own objects are reachable solely through reference cycles. +* ``FetchInfo.note`` carries Git's note for the reference, such as + ``(forced update)`` or ``(would clobber existing tag)``. It was always empty. 3.2.1 ===== diff --git a/git/remote.py b/git/remote.py index a122b1a5a..ba887c2cb 100644 --- a/git/remote.py +++ b/git/remote.py @@ -315,7 +315,7 @@ class FetchInfo(IterableObj): ERROR, ) = [1 << x for x in range(8)] - _re_fetch_result = re.compile(r"^ *(?:.{0,3})(.) (\[[\w \.$@]+\]|[\w\.$@]+) +(.+) -> ([^ ]+)( \(.*\)?$)?") + _re_fetch_result = re.compile(r"^ *(?:.{0,3})(.) (\[[\w \.$@]+\]|[\w\.$@]+) +(.+) -> ([^ ]+)( \(.*\)?$)?") _flag_map: Dict[flagKeyLiteral, int] = { "!": ERROR, diff --git a/test/test_remote.py b/test/test_remote.py index aba4ddce7..d3ecbb33a 100644 --- a/test/test_remote.py +++ b/test/test_remote.py @@ -229,7 +229,7 @@ def get_info(res, remote, name): mkey = "%s/%s" % (remote, "master") master_info = res[mkey] self.assertTrue(master_info.flags & FetchInfo.FORCED_UPDATE) - self.assertIsNotNone(master_info.note) + self.assertEqual(master_info.note, "(forced update)") # Normal fast forward - set head back to previous one. rhead.commit = remote_commit @@ -573,6 +573,14 @@ def test_fetch_info(self): self.assertIsInstance(info.ref, ref_type) self.assertEqual(info.remote_ref_path, source) self.assertTrue(info.flags & FetchInfo.NEW_HEAD) + self.assertEqual(info.note, "") + info = FetchInfo._from_line( + self.rorepo, + "! [rejected] tag -> subdir/tag (would clobber existing tag)", + ["refs/tags/tag:refs/tags/subdir/tag"], + ) + self.assertTrue(info.flags & FetchInfo.REJECTED) + self.assertEqual(info.note, "(would clobber existing tag)") with self.assertRaises(ValueError): FetchInfo._from_line(self.rorepo, "= [up to date] master -> ambiguous") From 7d9a2f01f7491b3d83073d67bf7eb5bbe8ae784d Mon Sep 17 00:00:00 2001 From: Byron Date: Sun, 22 Nov 2026 21:46:24 +0100 Subject: [PATCH 2/2] review --- doc/source/changes.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/doc/source/changes.rst b/doc/source/changes.rst index 6e18e1e95..f9e8a13b2 100644 --- a/doc/source/changes.rst +++ b/doc/source/changes.rst @@ -232,8 +232,6 @@ API changes collection. Close files and repositories you opened yourself before removing a repository on Windows; call ``gc.collect()`` only if your own objects are reachable solely through reference cycles. -* ``FetchInfo.note`` carries Git's note for the reference, such as - ``(forced update)`` or ``(would clobber existing tag)``. It was always empty. 3.2.1 =====