You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: Clarify TagFollowing implementation fix in v6
Section 3 was misleading - it said tag defaults didn't change, but missed
the key point: the *implementation* of TagFollowing was fixed in v6.
What actually happened:
- The default (TagFollowing) did not change
- BUT v5 had a bug where TagFollowing fetched ALL tags (including those
pointing to tree/blob objects)
- v6 transport refactor (Dec 2024) fixed TagFollowing to correctly match
git's behavior: only fetch tags pointing to commits being fetched
- PR #1459 fixed a test that relied on the buggy behavior
TagFollowing should use git's include-tag capability to fetch only
annotated tags pointing to commits in the fetched history. The v5
implementation incorrectly fetched all tags.
Impact: Users who relied on TagFollowing fetching all tags (bug) now need
to explicitly set Tags: AllTags.
Changes made:
- Corrected section title to reflect the bug fix
- Explained v5 had buggy TagFollowing implementation
- Clarified v6 fixed it to match git CLI behavior
- Updated migration guidance for users who relied on the bug
- Added clear examples showing the before/after behavior
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Arieh Schneier <15041913+AriehSchneier@users.noreply.github.com>
### 3. Tags are no longer fetched by default on `Fetch` ✅ Merged
112
+
### 3. `TagFollowing` implementation fixed to match git behavior ✅ Merged
114
113
115
-
**What changed:**`git.FetchOptions` previously defaulted to fetching all
116
-
tags (`AllTags`). In v6 the default is **no tags**. This aligns go-git's
117
-
behaviour with the `git fetch` CLI, which only auto-follows tags
118
-
reachable from fetched commits when no explicit tag refspec is given.
114
+
**What changed:** The default tag fetch mode remains `TagFollowing` in both v5 and v6, but v6 fixed a bug in how `TagFollowing` was implemented. In v5, `TagFollowing` incorrectly fetched **all** tags (including those pointing to tree/blob objects). In v6, `TagFollowing` correctly fetches only tags that point to commits in the fetched history, matching git CLI behavior.
119
115
120
-
**Why:** When comparing actual `git fetch` behaviour with the test
121
-
expectations in go-git, it became clear that the tests expected all tags to
122
-
be pulled without the user explicitly requesting them.
116
+
**Defaults (unchanged):**
117
+
-`CloneOptions.Tags` defaults to `AllTags` (fetch all tags)
118
+
-`FetchOptions.Tags` defaults to `TagFollowing` (fetch tags pointing to fetched commits)
123
119
124
-
**Impact:** Code that relied on tags being silently included in every
125
-
`Fetch` call will no longer receive them.
120
+
**What `TagFollowing` should do (and now does correctly):**
121
+
`TagFollowing` uses git's `include-tag` capability to fetch annotated tags that point to commits being fetched. This matches `git fetch` behavior. It should **not** fetch:
122
+
- Tags pointing to tree or blob objects
123
+
- Tags not reachable from the commits being fetched
124
+
- All tags indiscriminately (that's `AllTags`)
126
125
127
-
**How to migrate:** If you need all remote tags, set `Tags: git.AllTags`
128
-
explicitly:
126
+
**Why the change:** The v6 transport layer refactor (Dec 2024) fixed the implementation to correctly use the `include-tag` capability. Previously, `TagFollowing` was fetching all tags, which was incorrect.
127
+
128
+
**Impact:** If your v5 code relied on `TagFollowing` fetching all tags (including those pointing to trees/blobs), you now need to explicitly set `Tags: git.AllTags`.
129
+
130
+
**How to migrate:**
131
+
132
+
If you need all tags (including those pointing to non-commit objects):
129
133
130
134
```go
131
-
// v5 — tags were returned by default
135
+
// v5 — TagFollowing incorrectly fetched all tags (bug)
132
136
err:= r.Fetch(&git.FetchOptions{
133
137
RemoteName: "origin",
138
+
// Tags defaults to TagFollowing, but was fetching all tags
134
139
})
135
140
136
-
// v6 — must opt in to fetching all tags
141
+
// v6 — explicitly request all tags
142
+
err:= r.Fetch(&git.FetchOptions{
143
+
RemoteName: "origin",
144
+
Tags: git.AllTags, // now required for all tags
145
+
})
146
+
```
147
+
148
+
If you only need tags pointing to fetched commits (correct behavior):
149
+
150
+
```go
151
+
// v6 — default behavior now works correctly
137
152
err:= r.Fetch(&git.FetchOptions{
138
153
RemoteName: "origin",
139
-
Tags: git.AllTags,
154
+
//Tags defaults to TagFollowing (now correctly implemented)
0 commit comments